Home | History | Annotate | Download | only in sanitizer_common
      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 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.target_arch not in ['arm', 'armhf', 'aarch64']:
     27   config.available_features.add('stable-runtime')
     28 
     29 if 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']
     33 default_tool_options_str = ':'.join(default_tool_options)
     34 if default_tool_options_str:
     35   config.environment[tool_options] = default_tool_options_str
     36   default_tool_options_str += ':'
     37 
     38 clang_cflags = config.debug_info_flags + tool_cflags + [config.target_cflags]
     39 clang_cxxflags = config.cxx_mode_flags + clang_cflags
     40 
     41 def build_invocation(compile_flags):
     42   return " " + " ".join([config.clang] + compile_flags) + " "
     43 
     44 config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
     45 config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) )
     46 config.substitutions.append( ("%tool_name", config.tool_name) )
     47 config.substitutions.append( ("%tool_options", tool_options) )
     48 config.substitutions.append( ('%env_tool_opts=',
     49                               'env ' + tool_options + '=' + default_tool_options_str))
     50 
     51 config.suffixes = ['.c', '.cc', '.cpp']
     52 
     53 if config.host_os not in ['Linux', 'Darwin']:
     54   config.unsupported = True
     55