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