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. |
| 14 | llvm_src_root = get_required_attr(config, 'llvm_src_root') |
| 15 | compiler_rt_lit_unit_cfg = os.path.join(llvm_src_root, "projects", |
| 16 | "compiler-rt", "lib", |
| 17 | "lit.common.unit.cfg") |
| 18 | lit.load_config(config, compiler_rt_lit_unit_cfg) |
| 19 | |
| 20 | # Setup config name. |
| 21 | config.name = 'LeakSanitizer' |
| 22 | |
| 23 | # Setup source root. |
| 24 | config.test_source_root = os.path.dirname(__file__) |
| 25 | |
| 26 | # Setup attributes common for all compiler-rt projects. |
| 27 | compiler_rt_lit_cfg = os.path.join(llvm_src_root, "projects", "compiler-rt", |
| 28 | "lib", "lit.common.cfg") |
| 29 | if (not compiler_rt_lit_cfg) or (not os.path.exists(compiler_rt_lit_cfg)): |
| 30 | lit.fatal("Can't find common compiler-rt lit config at: %r" |
| 31 | % compiler_rt_lit_cfg) |
| 32 | lit.load_config(config, compiler_rt_lit_cfg) |
| 33 | |
| 34 | # Setup default compiler flags used with -fsanitize=leak option. |
| 35 | clang_lsan_cxxflags = ("-ccc-cxx " |
| 36 | + "-fsanitize=leak " |
| 37 | + "-g") |
| 38 | config.substitutions.append( ("%clangxx_lsan ", (" " + config.clang + " " + |
| 39 | clang_lsan_cxxflags + " ")) ) |
| 40 | |
| 41 | # Default test suffixes. |
| 42 | config.suffixes = ['.c', '.cc', '.cpp'] |
| 43 | |
| 44 | # LeakSanitizer tests are currently supported on x86-64 Linux only. |
| 45 | if config.host_os not in ['Linux'] or config.host_arch not in ['x86_64']: |
| 46 | config.unsupported = True |