xref: /aosp_15_r20/external/compiler-rt/test/sanitizer_common/lit.common.cfg (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot# -*- Python -*-
2*7c3d14c8STreehugger Robot
3*7c3d14c8STreehugger Robot# Setup source root.
4*7c3d14c8STreehugger Robotconfig.test_source_root = os.path.join(os.path.dirname(__file__), "TestCases")
5*7c3d14c8STreehugger Robot
6*7c3d14c8STreehugger Robotconfig.name = "SanitizerCommon-" + config.name_suffix
7*7c3d14c8STreehugger Robot
8*7c3d14c8STreehugger Robotdefault_tool_options = []
9*7c3d14c8STreehugger Robotif config.tool_name == "asan":
10*7c3d14c8STreehugger Robot  tool_cflags = ["-fsanitize=address"]
11*7c3d14c8STreehugger Robot  tool_options = "ASAN_OPTIONS"
12*7c3d14c8STreehugger Robotelif config.tool_name == "tsan":
13*7c3d14c8STreehugger Robot  tool_cflags = ["-fsanitize=thread"]
14*7c3d14c8STreehugger Robot  tool_options = "TSAN_OPTIONS"
15*7c3d14c8STreehugger Robotelif config.tool_name == "msan":
16*7c3d14c8STreehugger Robot  tool_cflags = ["-fsanitize=memory"]
17*7c3d14c8STreehugger Robot  tool_options = "MSAN_OPTIONS"
18*7c3d14c8STreehugger Robotelif config.tool_name == "lsan":
19*7c3d14c8STreehugger Robot  tool_cflags = ["-fsanitize=leak"]
20*7c3d14c8STreehugger Robot  tool_options = "LSAN_OPTIONS"
21*7c3d14c8STreehugger Robotelse:
22*7c3d14c8STreehugger Robot  lit_config.fatal("Unknown tool for sanitizer_common tests: %r" % config.tool_name)
23*7c3d14c8STreehugger Robot
24*7c3d14c8STreehugger Robotconfig.available_features.add(config.tool_name)
25*7c3d14c8STreehugger Robot
26*7c3d14c8STreehugger Robotif config.target_arch not in ['arm', 'armhf', 'aarch64']:
27*7c3d14c8STreehugger Robot  config.available_features.add('stable-runtime')
28*7c3d14c8STreehugger Robot
29*7c3d14c8STreehugger Robotif config.host_os == 'Darwin':
30*7c3d14c8STreehugger Robot  # On Darwin, we default to `abort_on_error=1`, which would make tests run
31*7c3d14c8STreehugger Robot  # much slower. Let's override this and run lit tests with 'abort_on_error=0'.
32*7c3d14c8STreehugger Robot  default_tool_options += ['abort_on_error=0']
33*7c3d14c8STreehugger Robotdefault_tool_options_str = ':'.join(default_tool_options)
34*7c3d14c8STreehugger Robotif default_tool_options_str:
35*7c3d14c8STreehugger Robot  config.environment[tool_options] = default_tool_options_str
36*7c3d14c8STreehugger Robot  default_tool_options_str += ':'
37*7c3d14c8STreehugger Robot
38*7c3d14c8STreehugger Robotclang_cflags = config.debug_info_flags + tool_cflags + [config.target_cflags]
39*7c3d14c8STreehugger Robotclang_cxxflags = config.cxx_mode_flags + clang_cflags
40*7c3d14c8STreehugger Robot
41*7c3d14c8STreehugger Robotdef build_invocation(compile_flags):
42*7c3d14c8STreehugger Robot  return " " + " ".join([config.clang] + compile_flags) + " "
43*7c3d14c8STreehugger Robot
44*7c3d14c8STreehugger Robotconfig.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
45*7c3d14c8STreehugger Robotconfig.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) )
46*7c3d14c8STreehugger Robotconfig.substitutions.append( ("%tool_name", config.tool_name) )
47*7c3d14c8STreehugger Robotconfig.substitutions.append( ("%tool_options", tool_options) )
48*7c3d14c8STreehugger Robotconfig.substitutions.append( ('%env_tool_opts=',
49*7c3d14c8STreehugger Robot                              'env ' + tool_options + '=' + default_tool_options_str))
50*7c3d14c8STreehugger Robot
51*7c3d14c8STreehugger Robotconfig.suffixes = ['.c', '.cc', '.cpp']
52*7c3d14c8STreehugger Robot
53*7c3d14c8STreehugger Robotif config.host_os not in ['Linux', 'Darwin']:
54*7c3d14c8STreehugger Robot  config.unsupported = True
55