2013-11-14 20:30:09 +08:00
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
def get_required_attr(config, attr_name):
|
|
|
|
attr_value = getattr(config, attr_name, None)
|
|
|
|
if not attr_value:
|
|
|
|
lit_config.fatal(
|
|
|
|
"No attribute %r in test configuration! You may need to run "
|
|
|
|
"tests from your build directory or add this attribute "
|
|
|
|
"to lit.site.cfg " % attr_name)
|
|
|
|
return attr_value
|
|
|
|
|
|
|
|
# Setup source root.
|
2014-02-18 16:56:49 +08:00
|
|
|
config.test_source_root = os.path.dirname(__file__)
|
|
|
|
|
|
|
|
# Choose between standalone and UBSan+ASan modes.
|
|
|
|
ubsan_lit_test_mode = get_required_attr(config, 'ubsan_lit_test_mode')
|
|
|
|
if ubsan_lit_test_mode == "Standalone":
|
|
|
|
config.name = 'UndefinedBehaviorSanitizer-Standalone'
|
|
|
|
clang_ubsan_cflags = []
|
|
|
|
elif ubsan_lit_test_mode == "AddressSanitizer":
|
|
|
|
config.name = 'UndefinedBehaviorSanitizer-AddressSanitizer'
|
|
|
|
clang_ubsan_cflags = ["-fsanitize=address"]
|
|
|
|
else:
|
|
|
|
lit_config.fatal("Unknown UBSan test mode: %r" % ubsan_lit_test_mode)
|
|
|
|
|
|
|
|
def build_invocation(compile_flags):
|
|
|
|
return " " + " ".join([config.clang] + compile_flags) + " "
|
|
|
|
|
2014-02-19 23:13:14 +08:00
|
|
|
clang_ubsan_cxxflags = config.cxx_mode_flags + clang_ubsan_cflags
|
2014-02-18 16:56:49 +08:00
|
|
|
|
|
|
|
# Define %clang and %clangxx substitutions to use in test RUN lines.
|
|
|
|
config.substitutions.append( ("%clang ", build_invocation(clang_ubsan_cflags)) )
|
|
|
|
config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags)) )
|
2013-11-14 20:30:09 +08:00
|
|
|
|
|
|
|
# Default test suffixes.
|
|
|
|
config.suffixes = ['.c', '.cc', '.cpp']
|
|
|
|
|
|
|
|
# UndefinedBehaviorSanitizer tests are currently supported on
|
|
|
|
# Linux and Darwin only.
|
|
|
|
if config.host_os not in ['Linux', 'Darwin']:
|
|
|
|
config.unsupported = True
|
|
|
|
|
|
|
|
config.pipefail = False
|