1# -*- Python -*- 2 3import os 4 5def get_required_attr(config, attr_name): 6 attr_value = getattr(config, attr_name, None) 7 if not attr_value: 8 lit.fatal("No attribute %r in test configuration! You may need to run " 9 "tests from your build directory or add this attribute " 10 "to lit.site.cfg " % attr_name) 11 return attr_value 12 13# Setup attributes common for all compiler-rt projects. 14llvm_src_root = get_required_attr(config, 'llvm_src_root') 15compiler_rt_lit_unit_cfg = os.path.join(llvm_src_root, "projects", 16 "compiler-rt", "lib", 17 "lit.common.unit.cfg") 18lit.load_config(config, compiler_rt_lit_unit_cfg) 19 20# Setup config name. 21config.name = 'AddressSanitizer-Unit' 22 23# Setup test source and exec root. For unit tests, we define 24# it as build directory with ASan unit tests. 25asan_binary_dir = get_required_attr(config, "asan_binary_dir") 26config.test_exec_root = os.path.join(asan_binary_dir, "tests") 27config.test_source_root = config.test_exec_root 28