blob: 7abbfc2d3c3a1054118f0d5651e1d7d48a685993 [file] [log] [blame]
Stephen Hines2d1fdb22014-05-28 23:58:16 -07001# -*- Python -*-
2
3# Setup source root.
4config.test_source_root = os.path.join(os.path.dirname(__file__), "TestCases")
5
6config.name = "SanitizerCommon-" + config.tool_name
7
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08008default_tool_options = []
Stephen Hines2d1fdb22014-05-28 23:58:16 -07009if config.tool_name == "asan":
10 tool_cflags = ["-fsanitize=address"]
Stephen Hines6d186232014-11-26 17:56:19 -080011 tool_options = "ASAN_OPTIONS"
Stephen Hines2d1fdb22014-05-28 23:58:16 -070012elif config.tool_name == "tsan":
13 tool_cflags = ["-fsanitize=thread"]
Stephen Hines6d186232014-11-26 17:56:19 -080014 tool_options = "TSAN_OPTIONS"
Stephen Hines2d1fdb22014-05-28 23:58:16 -070015elif config.tool_name == "msan":
16 tool_cflags = ["-fsanitize=memory"]
Stephen Hines6d186232014-11-26 17:56:19 -080017 tool_options = "MSAN_OPTIONS"
Stephen Hines6a211c52014-07-21 00:49:56 -070018elif config.tool_name == "lsan":
19 tool_cflags = ["-fsanitize=leak"]
Stephen Hines6d186232014-11-26 17:56:19 -080020 tool_options = "LSAN_OPTIONS"
Stephen Hines2d1fdb22014-05-28 23:58:16 -070021else:
22 lit_config.fatal("Unknown tool for sanitizer_common tests: %r" % config.tool_name)
23
24config.available_features.add(config.tool_name)
25
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080026if 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']
30default_tool_options_str = ':'.join(default_tool_options)
31if default_tool_options_str:
32 config.environment[tool_options] = default_tool_options_str
33 default_tool_options_str += ':'
34
Stephen Hines6d186232014-11-26 17:56:19 -080035clang_cflags = config.debug_info_flags + tool_cflags + [config.target_cflags]
Stephen Hines2d1fdb22014-05-28 23:58:16 -070036clang_cxxflags = config.cxx_mode_flags + clang_cflags
37
38def build_invocation(compile_flags):
39 return " " + " ".join([config.clang] + compile_flags) + " "
40
41config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
42config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) )
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -070043config.substitutions.append( ("%tool_name", config.tool_name) )
Stephen Hines6d186232014-11-26 17:56:19 -080044config.substitutions.append( ("%tool_options", tool_options) )
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080045config.substitutions.append( ('%env_tool_opts=',
46 'env ' + tool_options + '=' + default_tool_options_str))
Stephen Hines2d1fdb22014-05-28 23:58:16 -070047
48config.suffixes = ['.c', '.cc', '.cpp']
49
50if config.host_os not in ['Linux', 'Darwin']:
51 config.unsupported = True