Sergey Matveev | e850b87 | 2013-05-23 12:58:56 +0000 | [diff] [blame] | 1 | # -*- Python -*- |
| 2 | |
Sergey Matveev | 895659d | 2013-05-31 13:13:55 +0000 | [diff] [blame] | 3 | # Common configuration for running leak detection tests under LSan/ASan. |
| 4 | |
Sergey Matveev | e850b87 | 2013-05-23 12:58:56 +0000 | [diff] [blame] | 5 | import os |
| 6 | |
| 7 | def get_required_attr(config, attr_name): |
| 8 | attr_value = getattr(config, attr_name, None) |
| 9 | if not attr_value: |
| 10 | lit.fatal("No attribute %r in test configuration! You may need to run " |
| 11 | "tests from your build directory or add this attribute " |
| 12 | "to lit.site.cfg " % attr_name) |
| 13 | return attr_value |
| 14 | |
Sergey Matveev | 895659d | 2013-05-31 13:13:55 +0000 | [diff] [blame] | 15 | # Setup source root. |
| 16 | lsan_lit_src_root = get_required_attr(config, 'lsan_lit_src_root') |
| 17 | config.test_source_root = os.path.join(lsan_lit_src_root, 'TestCases') |
| 18 | |
Sergey Matveev | ebe3a36 | 2013-05-27 11:41:46 +0000 | [diff] [blame] | 19 | clang_cxxflags = ("-ccc-cxx " |
| 20 | + "-g " |
| 21 | + "-O0 " |
| 22 | + "-m64 ") |
| 23 | |
Sergey Matveev | 895659d | 2013-05-31 13:13:55 +0000 | [diff] [blame] | 24 | config.clang_cxxflags = clang_cxxflags |
Sergey Matveev | ebe3a36 | 2013-05-27 11:41:46 +0000 | [diff] [blame] | 25 | |
| 26 | config.substitutions.append( ("%clangxx ", (" " + config.clang + " " + |
| 27 | clang_cxxflags + " ")) ) |
Sergey Matveev | e850b87 | 2013-05-23 12:58:56 +0000 | [diff] [blame] | 28 | |
| 29 | # LeakSanitizer tests are currently supported on x86-64 Linux only. |
| 30 | if config.host_os not in ['Linux'] or config.host_arch not in ['x86_64']: |
| 31 | config.unsupported = True |
Sergey Matveev | 895659d | 2013-05-31 13:13:55 +0000 | [diff] [blame] | 32 | |
| 33 | config.suffixes = ['.c', '.cc', '.cpp'] |