Home | History | Annotate | Download | only in esan
      1 # -*- Python -*-
      2 
      3 import os
      4 
      5 # Setup config name.
      6 config.name = 'EfficiencySanitizer' + config.name_suffix
      7 
      8 # Setup source root.
      9 config.test_source_root = os.path.dirname(__file__)
     10 
     11 # Setup default compiler flags used with -fsanitize=efficiency option.
     12 base_cflags = ([config.target_cflags] + config.debug_info_flags)
     13 base_cxxflags = config.cxx_mode_flags + base_cflags
     14 
     15 frag_cflags = (["-fsanitize=efficiency-cache-frag"] + base_cflags)
     16 wset_cflags = (["-fsanitize=efficiency-working-set"] + base_cflags)
     17 esan_incdir = config.test_source_root + "/../../lib"
     18 unit_cxxflags = (["-I%s" % esan_incdir, "-std=c++11",
     19                   # We need to link with the esan runtime.
     20                   # Tests should pass %env_esan_opts="record_snapshots=0".
     21                   "-fsanitize=efficiency-working-set"] + base_cxxflags)
     22 
     23 def build_invocation(compile_flags):
     24   return " " + " ".join([config.clang] + compile_flags) + " "
     25 
     26 config.substitutions.append( ("%clang ",
     27                               build_invocation(base_cflags)) )
     28 config.substitutions.append( ("%clang_esan_frag ",
     29                               build_invocation(frag_cflags)) )
     30 config.substitutions.append( ("%clang_esan_wset ",
     31                               build_invocation(wset_cflags)) )
     32 config.substitutions.append( ("%clangxx_unit",
     33                               build_invocation(unit_cxxflags)) )
     34 
     35 default_esan_opts = ''
     36 config.substitutions.append(('%env_esan_opts=',
     37                              'env ESAN_OPTIONS=' + default_esan_opts))
     38 
     39 # Default test suffixes.
     40 config.suffixes = ['.c', '.cpp']
     41 
     42 # EfficiencySanitizer tests are currently supported on Linux x86-64 only.
     43 if config.host_os not in ['Linux'] or config.target_arch != 'x86_64':
     44   config.unsupported = True
     45