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