]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/sanitizer_common/lit.common.cfg
Vendor import of compiler-rt trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / 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.name_suffix
7
8 default_tool_options = []
9 collect_stack_traces = ""
10 if config.tool_name == "asan":
11   tool_cflags = ["-fsanitize=address"]
12   tool_options = "ASAN_OPTIONS"
13 elif config.tool_name == "tsan":
14   tool_cflags = ["-fsanitize=thread"]
15   tool_options = "TSAN_OPTIONS"
16 elif config.tool_name == "msan":
17   tool_cflags = ["-fsanitize=memory"]
18   tool_options = "MSAN_OPTIONS"
19   collect_stack_traces = "-fsanitize-memory-track-origins"
20 elif config.tool_name == "lsan":
21   tool_cflags = ["-fsanitize=leak"]
22   tool_options = "LSAN_OPTIONS"
23 elif config.tool_name == "ubsan":
24   tool_cflags = ["-fsanitize=undefined"]
25   tool_options = "UBSAN_OPTIONS"
26 else:
27   lit_config.fatal("Unknown tool for sanitizer_common tests: %r" % config.tool_name)
28
29 config.available_features.add(config.tool_name)
30
31 if config.host_os == 'Linux' and config.tool_name == "lsan" and config.target_arch == 'i386':
32   config.available_features.add("lsan-x86")
33
34 if config.host_os == 'Darwin':
35   # On Darwin, we default to `abort_on_error=1`, which would make tests run
36   # much slower. Let's override this and run lit tests with 'abort_on_error=0'.
37   default_tool_options += ['abort_on_error=0']
38 elif config.android:
39   # The same as on Darwin, we default to "abort_on_error=1" which slows down
40   # testing. Also, all existing tests are using "not" instead of "not --crash"
41   # which does not work for abort()-terminated programs.
42   default_tool_options += ['abort_on_error=0']
43
44 default_tool_options_str = ':'.join(default_tool_options)
45 if default_tool_options_str:
46   config.environment[tool_options] = default_tool_options_str
47   default_tool_options_str += ':'
48
49 if config.host_os in ['Linux']:
50   extra_link_flags = ["-ldl"]
51 else:
52   extra_link_flags = []
53
54 clang_cflags = config.debug_info_flags + tool_cflags + [config.target_cflags]
55 clang_cflags += extra_link_flags
56 clang_cxxflags = config.cxx_mode_flags + clang_cflags
57
58 def build_invocation(compile_flags):
59   return " " + " ".join([config.clang] + compile_flags) + " "
60
61 config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
62 config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) )
63 config.substitutions.append( ("%collect_stack_traces", collect_stack_traces) )
64 config.substitutions.append( ("%tool_name", config.tool_name) )
65 config.substitutions.append( ("%tool_options", tool_options) )
66 config.substitutions.append( ('%env_tool_opts=',
67                               'env ' + tool_options + '=' + default_tool_options_str))
68
69 config.suffixes = ['.c', '.cc', '.cpp']
70
71 if config.host_os not in ['Linux', 'Darwin', 'NetBSD', 'FreeBSD']:
72   config.unsupported = True