brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 33473e2 Raw
58 lines · python
1# -*- Python -*-2 3import os4 5 6def get_required_attr(config, attr_name):7    attr_value = getattr(config, attr_name, None)8    if attr_value is None:9        lit_config.fatal(10            "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.py " % attr_name13        )14    return attr_value15 16 17# Setup source root.18config.test_source_root = os.path.dirname(__file__)19config.name = "UBSan-Minimal" + config.name_suffix20 21 22def build_invocation(compile_flags):23    return " " + " ".join([config.clang] + compile_flags) + " "24 25 26target_cflags = [get_required_attr(config, "target_cflags")]27clang_ubsan_cflags = ["-fsanitize-minimal-runtime"] + target_cflags28clang_ubsan_cxxflags = config.cxx_mode_flags + clang_ubsan_cflags29 30# Define %clang_min_runtime and %clangxx_min_runtime substitutions to use in test RUN lines.31config.substitutions.append(32    ("%clang_min_runtime ", build_invocation(clang_ubsan_cflags))33)34config.substitutions.append(35    ("%clangxx_min_runtime ", build_invocation(clang_ubsan_cxxflags))36)37 38# Default test suffixes.39config.suffixes = [".c", ".cpp"]40 41# Check that the host supports UndefinedBehaviorSanitizerMinimal tests42if config.target_os not in [43    "Linux",44    "FreeBSD",45    "NetBSD",46    "Darwin",47    "OpenBSD",48    "SunOS",49]:  # TODO: Windows50    config.unsupported = True51 52if config.test_cfi:53    config.available_features.add("cfi")54 55# Don't target x86_64h if the test machine can't execute x86_64h binaries.56if "-arch x86_64h" in target_cflags and "x86_64h" not in config.available_features:57    config.unsupported = True58