]> git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/sanitizer_common/lit.common.cfg
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / test / sanitizer_common / lit.common.cfg
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 default_tool_options = []
9 if config.tool_name == "asan":
10 tool_cflags = ["-fsanitize=address"]
11 tool_options = "ASAN_OPTIONS"
12 elif config.tool_name == "tsan":
13 tool_cflags = ["-fsanitize=thread"]
14 tool_options = "TSAN_OPTIONS"
15 elif config.tool_name == "msan":
16 tool_cflags = ["-fsanitize=memory"]
17 tool_options = "MSAN_OPTIONS"
18 elif config.tool_name == "lsan":
19 tool_cflags = ["-fsanitize=leak"]
20 tool_options = "LSAN_OPTIONS"
21 else:
22 lit_config.fatal("Unknown tool for sanitizer_common tests: %r" % config.tool_name)
23
24 config.available_features.add(config.tool_name)
25
26 if config.host_os == 'Darwin':
27 # On Darwin, we default to `abort_on_error=1`, which would make tests run
28 # much slower. Let's override this and run lit tests with 'abort_on_error=0'.
29 default_tool_options += ['abort_on_error=0']
30 default_tool_options_str = ':'.join(default_tool_options)
31 if default_tool_options_str:
32 config.environment[tool_options] = default_tool_options_str
33 default_tool_options_str += ':'
34
35 clang_cflags = config.debug_info_flags + tool_cflags + [config.target_cflags]
36 clang_cxxflags = config.cxx_mode_flags + clang_cflags
37
38 def build_invocation(compile_flags):
39 return " " + " ".join([config.clang] + compile_flags) + " "
40
41 config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
42 config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) )
43 config.substitutions.append( ("%tool_name", config.tool_name) )
44 config.substitutions.append( ("%tool_options", tool_options) )
45 config.substitutions.append( ('%env_tool_opts=',
46 'env ' + tool_options + '=' + default_tool_options_str))
47
48 config.suffixes = ['.c', '.cc', '.cpp']
49
50 if config.host_os not in ['Linux', 'Darwin']:
51 config.unsupported = True