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 | |
Sergey Matveev | ebe3a36 | 2013-05-27 11:41:46 +0000 | [diff] [blame^] | 33 | clang_cxxflags = ("-ccc-cxx " |
| 34 | + "-g " |
| 35 | + "-O0 " |
| 36 | + "-m64 ") |
| 37 | |
| 38 | clang_lsan_cxxflags = clang_cxxflags + "-fsanitize=leak " |
| 39 | |
| 40 | config.substitutions.append( ("%clangxx ", (" " + config.clang + " " + |
| 41 | clang_cxxflags + " ")) ) |
Sergey Matveev | e850b87 | 2013-05-23 12:58:56 +0000 | [diff] [blame] | 42 | config.substitutions.append( ("%clangxx_lsan ", (" " + config.clang + " " + |
| 43 | clang_lsan_cxxflags + " ")) ) |
| 44 | |
| 45 | # Default test suffixes. |
| 46 | config.suffixes = ['.c', '.cc', '.cpp'] |
| 47 | |
| 48 | # LeakSanitizer tests are currently supported on x86-64 Linux only. |
| 49 | if config.host_os not in ['Linux'] or config.host_arch not in ['x86_64']: |
| 50 | config.unsupported = True |