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