Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 1 | # -*- Python -*- |
| 2 | |
| 3 | # Setup source root. |
| 4 | config.test_source_root = os.path.join(os.path.dirname(__file__), "TestCases") |
| 5 | |
| 6 | config.name = "SanitizerCommon-" + config.tool_name |
| 7 | |
| 8 | if config.tool_name == "asan": |
| 9 | tool_cflags = ["-fsanitize=address"] |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 10 | tool_options = "ASAN_OPTIONS" |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 11 | elif config.tool_name == "tsan": |
| 12 | tool_cflags = ["-fsanitize=thread"] |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 13 | tool_options = "TSAN_OPTIONS" |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 14 | elif config.tool_name == "msan": |
| 15 | tool_cflags = ["-fsanitize=memory"] |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 16 | tool_options = "MSAN_OPTIONS" |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 17 | elif config.tool_name == "lsan": |
| 18 | tool_cflags = ["-fsanitize=leak"] |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 19 | tool_options = "LSAN_OPTIONS" |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 20 | else: |
| 21 | lit_config.fatal("Unknown tool for sanitizer_common tests: %r" % config.tool_name) |
| 22 | |
| 23 | config.available_features.add(config.tool_name) |
| 24 | |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 25 | clang_cflags = config.debug_info_flags + tool_cflags + [config.target_cflags] |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 26 | clang_cxxflags = config.cxx_mode_flags + clang_cflags |
| 27 | |
| 28 | def build_invocation(compile_flags): |
| 29 | return " " + " ".join([config.clang] + compile_flags) + " " |
| 30 | |
| 31 | config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) ) |
| 32 | config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) ) |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 33 | config.substitutions.append( ("%tool_name", config.tool_name) ) |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 34 | config.substitutions.append( ("%tool_options", tool_options) ) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 35 | |
| 36 | config.suffixes = ['.c', '.cc', '.cpp'] |
| 37 | |
| 38 | if config.host_os not in ['Linux', 'Darwin']: |
| 39 | config.unsupported = True |