1 # -*- Python -*- 2 3 # Common configuration for running leak detection tests under LSan/ASan. 4 5 import os 6 7 def get_required_attr(config, attr_name): 8 attr_value = getattr(config, attr_name, None) 9 if not attr_value: 10 lit.fatal("No attribute %r in test configuration! You may need to run " 11 "tests from your build directory or add this attribute " 12 "to lit.site.cfg " % attr_name) 13 return attr_value 14 15 # Setup source root. 16 lsan_lit_src_root = get_required_attr(config, 'lsan_lit_src_root') 17 config.test_source_root = os.path.join(lsan_lit_src_root, 'TestCases') 18 19 clang_cxxflags = ("--driver-mode=g++ " 20 + "-g " 21 + "-O0 " 22 + "-m64 ") 23 24 config.clang_cxxflags = clang_cxxflags 25 26 config.substitutions.append( ("%clangxx ", (" " + config.clang + " " + 27 clang_cxxflags + " ")) ) 28 29 # LeakSanitizer tests are currently supported on x86-64 Linux only. 30 if config.host_os not in ['Linux'] or config.host_arch not in ['x86_64']: 31 config.unsupported = True 32 33 config.suffixes = ['.c', '.cc', '.cpp'] 34