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.py " % attr_name) 12 return attr_value 13 14# Setup source root. 15config.test_source_root = os.path.dirname(__file__) 16config.name = 'UBSan-Minimal-' + config.target_arch 17 18def build_invocation(compile_flags): 19 return " " + " ".join([config.clang] + compile_flags) + " " 20 21target_cflags = [get_required_attr(config, "target_cflags")] 22clang_ubsan_cflags = ["-fsanitize-minimal-runtime"] + target_cflags 23clang_ubsan_cxxflags = config.cxx_mode_flags + clang_ubsan_cflags 24 25# Define %clang and %clangxx substitutions to use in test RUN lines. 26config.substitutions.append( ("%clang ", build_invocation(clang_ubsan_cflags)) ) 27config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags)) ) 28 29# Default test suffixes. 30config.suffixes = ['.c', '.cpp'] 31 32# Check that the host supports UndefinedBehaviorSanitizerMinimal tests 33if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD', 'Darwin', 'OpenBSD', 'SunOS']: # TODO: Windows 34 config.unsupported = True 35 36# Don't target x86_64h if the test machine can't execute x86_64h binaries. 37if '-arch x86_64h' in target_cflags and 'x86_64h' not in config.available_features: 38 config.unsupported = True 39 40config.available_features.add('arch=' + config.target_arch) 41