Sergey Matveev | e850b87 | 2013-05-23 12:58:56 +0000 | [diff] [blame] | 1 | # -*- Python -*- |
| 2 | |
| 3 | import os |
| 4 | |
| 5 | def get_required_attr(config, attr_name): |
| 6 | attr_value = getattr(config, attr_name, None) |
| 7 | if not attr_value: |
| 8 | lit.fatal("No attribute %r in test configuration! You may need to run " |
| 9 | "tests from your build directory or add this attribute " |
| 10 | "to lit.site.cfg " % attr_name) |
| 11 | return attr_value |
| 12 | |
| 13 | # Setup attributes common for all compiler-rt projects. |
Alexey Samsonov | 57434a3 | 2013-05-27 09:35:24 +0000 | [diff] [blame] | 14 | compiler_rt_src_root = get_required_attr(config, 'compiler_rt_src_root') |
| 15 | compiler_rt_lit_unit_cfg = os.path.join(compiler_rt_src_root, "lib", |
Sergey Matveev | e850b87 | 2013-05-23 12:58:56 +0000 | [diff] [blame] | 16 | "lit.common.unit.cfg") |
| 17 | lit.load_config(config, compiler_rt_lit_unit_cfg) |
| 18 | |
| 19 | # Setup config name. |
| 20 | config.name = 'LeakSanitizer' |
| 21 | |
| 22 | # Setup source root. |
| 23 | config.test_source_root = os.path.dirname(__file__) |
| 24 | |
| 25 | # Setup attributes common for all compiler-rt projects. |
Alexey Samsonov | 57434a3 | 2013-05-27 09:35:24 +0000 | [diff] [blame] | 26 | compiler_rt_lit_cfg = os.path.join(compiler_rt_src_root, "lib", |
| 27 | "lit.common.cfg") |
Sergey Matveev | e850b87 | 2013-05-23 12:58:56 +0000 | [diff] [blame] | 28 | if (not compiler_rt_lit_cfg) or (not os.path.exists(compiler_rt_lit_cfg)): |
| 29 | lit.fatal("Can't find common compiler-rt lit config at: %r" |
| 30 | % compiler_rt_lit_cfg) |
| 31 | lit.load_config(config, compiler_rt_lit_cfg) |
| 32 | |
| 33 | # Setup default compiler flags used with -fsanitize=leak option. |
| 34 | clang_lsan_cxxflags = ("-ccc-cxx " |
| 35 | + "-fsanitize=leak " |
| 36 | + "-g") |
| 37 | config.substitutions.append( ("%clangxx_lsan ", (" " + config.clang + " " + |
| 38 | clang_lsan_cxxflags + " ")) ) |
| 39 | |
| 40 | # Default test suffixes. |
| 41 | config.suffixes = ['.c', '.cc', '.cpp'] |
| 42 | |
| 43 | # LeakSanitizer tests are currently supported on x86-64 Linux only. |
| 44 | if config.host_os not in ['Linux'] or config.host_arch not in ['x86_64']: |
| 45 | config.unsupported = True |