[docs] Fix build-docs.sh
[llvm-project.git] / compiler-rt / test / ubsan_minimal / lit.common.cfg.py
blob39800c968dbf2800079947dfcdb0aa40f30598dc
1 # -*- Python -*-
3 import os
5 def 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
14 # Setup source root.
15 config.test_source_root = os.path.dirname(__file__)
16 config.name = 'UBSan-Minimal-' + config.target_arch
18 def build_invocation(compile_flags):
19 return " " + " ".join([config.clang] + compile_flags) + " "
21 target_cflags = [get_required_attr(config, "target_cflags")]
22 clang_ubsan_cflags = ["-fsanitize-minimal-runtime"] + target_cflags
23 clang_ubsan_cxxflags = config.cxx_mode_flags + clang_ubsan_cflags
25 # Define %clang and %clangxx substitutions to use in test RUN lines.
26 config.substitutions.append( ("%clang ", build_invocation(clang_ubsan_cflags)) )
27 config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags)) )
29 # Default test suffixes.
30 config.suffixes = ['.c', '.cpp']
32 # Check that the host supports UndefinedBehaviorSanitizerMinimal tests
33 if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD', 'Darwin', 'OpenBSD', 'SunOS']: # TODO: Windows
34 config.unsupported = True
36 # Don't target x86_64h if the test machine can't execute x86_64h binaries.
37 if '-arch x86_64h' in target_cflags and 'x86_64h' not in config.available_features:
38 config.unsupported = True
40 config.available_features.add('arch=' + config.target_arch)