lit.common.cfg revision 2d1fdb26e458c4ddc04155c1d421bced3ba90cd0
1# -*- Python -*- 2 3import os 4 5def get_required_attr(config, attr_name): 6 attr_value = getattr(config, attr_name, None) 7 if attr_value == None: 8 lit_config.fatal( 9 "No attribute %r in test configuration! You may need to run " 10 "tests from your build directory or add this attribute " 11 "to lit.site.cfg " % attr_name) 12 return attr_value 13 14# Setup source root. 15config.test_source_root = os.path.dirname(__file__) 16 17# Choose between standalone and UBSan+ASan modes. 18ubsan_lit_test_mode = get_required_attr(config, 'ubsan_lit_test_mode') 19if ubsan_lit_test_mode == "Standalone": 20 config.name = 'UndefinedBehaviorSanitizer-Standalone' 21 clang_ubsan_cflags = [] 22elif ubsan_lit_test_mode == "AddressSanitizer": 23 config.name = 'UndefinedBehaviorSanitizer-AddressSanitizer' 24 clang_ubsan_cflags = ["-fsanitize=address"] 25else: 26 lit_config.fatal("Unknown UBSan test mode: %r" % ubsan_lit_test_mode) 27 28def build_invocation(compile_flags): 29 return " " + " ".join([config.clang] + compile_flags) + " " 30 31target_cflags = [get_required_attr(config, "target_cflags")] 32clang_ubsan_cflags += target_cflags 33clang_ubsan_cxxflags = config.cxx_mode_flags + clang_ubsan_cflags 34 35# Define %clang and %clangxx substitutions to use in test RUN lines. 36config.substitutions.append( ("%clang ", build_invocation(clang_ubsan_cflags)) ) 37config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags)) ) 38 39# Default test suffixes. 40config.suffixes = ['.c', '.cc', '.cpp'] 41 42# UndefinedBehaviorSanitizer tests are currently supported on 43# Linux and Darwin only. 44if config.host_os not in ['Linux', 'Darwin']: 45 config.unsupported = True 46 47config.pipefail = False 48