diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-11-14 12:30:09 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-11-14 12:30:09 +0000 |
commit | 5e43cfa5e7f6d344f4b0a6a9f7a4b2811d5b8bab (patch) | |
tree | b55a1011537d337efbdd3ff7472d6969f9752854 | |
parent | 8c6e4855ac47415f1f2863690860f24213638cb5 (diff) | |
download | compiler-rt-5e43cfa5e7f6d344f4b0a6a9f7a4b2811d5b8bab.tar.gz |
[UBSan] Make sure ASan and UBSan interact properly by running each test from UBSan test suite with and without ASan
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194698 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/ubsan/lit_tests/AsanConfig/lit.cfg | 25 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/AsanConfig/lit.site.cfg.in | 9 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/CMakeLists.txt | 24 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Float/cast-overflow.cpp (renamed from lib/ubsan/lit_tests/Float/cast-overflow.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Integer/add-overflow.cpp (renamed from lib/ubsan/lit_tests/Integer/add-overflow.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Integer/div-overflow.cpp (renamed from lib/ubsan/lit_tests/Integer/div-overflow.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Integer/div-zero.cpp (renamed from lib/ubsan/lit_tests/Integer/div-zero.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Integer/incdec-overflow.cpp (renamed from lib/ubsan/lit_tests/Integer/incdec-overflow.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Integer/mul-overflow.cpp (renamed from lib/ubsan/lit_tests/Integer/mul-overflow.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Integer/negate-overflow.cpp (renamed from lib/ubsan/lit_tests/Integer/negate-overflow.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Integer/no-recover.cpp (renamed from lib/ubsan/lit_tests/Integer/no-recover.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Integer/shift.cpp (renamed from lib/ubsan/lit_tests/Integer/shift.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Integer/sub-overflow.cpp (renamed from lib/ubsan/lit_tests/Integer/sub-overflow.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Integer/uadd-overflow.cpp (renamed from lib/ubsan/lit_tests/Integer/uadd-overflow.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Integer/uincdec-overflow.cpp (renamed from lib/ubsan/lit_tests/Integer/uincdec-overflow.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Integer/umul-overflow.cpp (renamed from lib/ubsan/lit_tests/Integer/umul-overflow.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Integer/usub-overflow.cpp (renamed from lib/ubsan/lit_tests/Integer/usub-overflow.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Misc/bool.cpp (renamed from lib/ubsan/lit_tests/Misc/bool.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Misc/bounds.cpp (renamed from lib/ubsan/lit_tests/Misc/bounds.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Misc/deduplication.cpp (renamed from lib/ubsan/lit_tests/Misc/deduplication.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Misc/enum.cpp (renamed from lib/ubsan/lit_tests/Misc/enum.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Misc/missing_return.cpp (renamed from lib/ubsan/lit_tests/Misc/missing_return.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Misc/unreachable.cpp (renamed from lib/ubsan/lit_tests/Misc/unreachable.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/Misc/vla.c (renamed from lib/ubsan/lit_tests/Misc/vla.c) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/TypeCheck/Function/function.cpp (renamed from lib/ubsan/lit_tests/TypeCheck/Function/function.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/TypeCheck/Function/lit.local.cfg (renamed from lib/ubsan/lit_tests/TypeCheck/Function/lit.local.cfg) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/TypeCheck/misaligned.cpp (renamed from lib/ubsan/lit_tests/TypeCheck/misaligned.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/TypeCheck/null.cpp (renamed from lib/ubsan/lit_tests/TypeCheck/null.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/TestCases/TypeCheck/vptr.cpp (renamed from lib/ubsan/lit_tests/TypeCheck/vptr.cpp) | 0 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/UbsanConfig/lit.cfg | 23 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/UbsanConfig/lit.site.cfg.in (renamed from lib/ubsan/lit_tests/lit.site.cfg.in) | 8 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/lit.cfg | 65 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/lit.common.cfg | 31 |
33 files changed, 105 insertions, 80 deletions
diff --git a/lib/ubsan/lit_tests/AsanConfig/lit.cfg b/lib/ubsan/lit_tests/AsanConfig/lit.cfg new file mode 100644 index 000000000..407e5ec32 --- /dev/null +++ b/lib/ubsan/lit_tests/AsanConfig/lit.cfg @@ -0,0 +1,25 @@ +# -*- 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 + +ubsan_lit_tests_dir = get_required_attr(config, "ubsan_lit_tests_dir") +ubsan_lit_cfg = os.path.join(ubsan_lit_tests_dir, "lit.common.cfg") +lit_config.load_config(config, ubsan_lit_cfg) + +config.name = 'UndefinedBehaviorSanitizer-AddressSanitizer' + +# Define %clang and %clangxx substitutions to use in test RUN lines. +config.substitutions.append( ("%clang ", (" " + config.clang + + " -fsanitize=address ")) ) +config.substitutions.append( ("%clangxx ", (" " + config.clang + + " -fsanitize=address" + + " --driver-mode=g++ ")) ) diff --git a/lib/ubsan/lit_tests/AsanConfig/lit.site.cfg.in b/lib/ubsan/lit_tests/AsanConfig/lit.site.cfg.in new file mode 100644 index 000000000..f75741838 --- /dev/null +++ b/lib/ubsan/lit_tests/AsanConfig/lit.site.cfg.in @@ -0,0 +1,9 @@ +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured") + +# Tool-specific config options. +config.ubsan_lit_tests_dir = "@UBSAN_LIT_TESTS_DIR@" + +# Load tool-specific config that would do the real work. +print config.ubsan_lit_tests_dir +lit_config.load_config(config, "@UBSAN_LIT_TESTS_DIR@/AsanConfig/lit.cfg") diff --git a/lib/ubsan/lit_tests/CMakeLists.txt b/lib/ubsan/lit_tests/CMakeLists.txt index 7e1a13c78..36d8dc1f9 100644 --- a/lib/ubsan/lit_tests/CMakeLists.txt +++ b/lib/ubsan/lit_tests/CMakeLists.txt @@ -1,21 +1,23 @@ +set(UBSAN_LIT_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/UbsanConfig/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/UbsanConfig/lit.site.cfg) + configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - ) + ${CMAKE_CURRENT_SOURCE_DIR}/AsanConfig/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/AsanConfig/lit.site.cfg) if(COMPILER_RT_CAN_EXECUTE_TESTS) # Run UBSan output tests only if we're sure that clang would produce # working binaries. set(UBSAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS} - ${UBSAN_RUNTIME_LIBRARIES}) - set(UBSAN_TEST_PARAMS - ubsan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - ) + ${UBSAN_RUNTIME_LIBRARIES} + asan_runtime_libraries) add_lit_testsuite(check-ubsan "Running UndefinedBehaviorSanitizer tests" - ${CMAKE_CURRENT_BINARY_DIR} - PARAMS ${UBSAN_TEST_PARAMS} - DEPENDS ${UBSAN_TEST_DEPS} - ) + ${CMAKE_CURRENT_BINARY_DIR}/UbsanConfig + ${CMAKE_CURRENT_BINARY_DIR}/AsanConfig + DEPENDS ${UBSAN_TEST_DEPS}) set_target_properties(check-ubsan PROPERTIES FOLDER "UBSan unittests") endif() diff --git a/lib/ubsan/lit_tests/Float/cast-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Float/cast-overflow.cpp index 35f9336c9..35f9336c9 100644 --- a/lib/ubsan/lit_tests/Float/cast-overflow.cpp +++ b/lib/ubsan/lit_tests/TestCases/Float/cast-overflow.cpp diff --git a/lib/ubsan/lit_tests/Integer/add-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/add-overflow.cpp index 412eb7621..412eb7621 100644 --- a/lib/ubsan/lit_tests/Integer/add-overflow.cpp +++ b/lib/ubsan/lit_tests/TestCases/Integer/add-overflow.cpp diff --git a/lib/ubsan/lit_tests/Integer/div-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/div-overflow.cpp index 83aa85448..83aa85448 100644 --- a/lib/ubsan/lit_tests/Integer/div-overflow.cpp +++ b/lib/ubsan/lit_tests/TestCases/Integer/div-overflow.cpp diff --git a/lib/ubsan/lit_tests/Integer/div-zero.cpp b/lib/ubsan/lit_tests/TestCases/Integer/div-zero.cpp index 6b8aadfe1..6b8aadfe1 100644 --- a/lib/ubsan/lit_tests/Integer/div-zero.cpp +++ b/lib/ubsan/lit_tests/TestCases/Integer/div-zero.cpp diff --git a/lib/ubsan/lit_tests/Integer/incdec-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/incdec-overflow.cpp index 904250a76..904250a76 100644 --- a/lib/ubsan/lit_tests/Integer/incdec-overflow.cpp +++ b/lib/ubsan/lit_tests/TestCases/Integer/incdec-overflow.cpp diff --git a/lib/ubsan/lit_tests/Integer/mul-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/mul-overflow.cpp index 1cfe23f57..1cfe23f57 100644 --- a/lib/ubsan/lit_tests/Integer/mul-overflow.cpp +++ b/lib/ubsan/lit_tests/TestCases/Integer/mul-overflow.cpp diff --git a/lib/ubsan/lit_tests/Integer/negate-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/negate-overflow.cpp index 6bee3eea2..6bee3eea2 100644 --- a/lib/ubsan/lit_tests/Integer/negate-overflow.cpp +++ b/lib/ubsan/lit_tests/TestCases/Integer/negate-overflow.cpp diff --git a/lib/ubsan/lit_tests/Integer/no-recover.cpp b/lib/ubsan/lit_tests/TestCases/Integer/no-recover.cpp index 269b464ab..269b464ab 100644 --- a/lib/ubsan/lit_tests/Integer/no-recover.cpp +++ b/lib/ubsan/lit_tests/TestCases/Integer/no-recover.cpp diff --git a/lib/ubsan/lit_tests/Integer/shift.cpp b/lib/ubsan/lit_tests/TestCases/Integer/shift.cpp index f35fa1f95..f35fa1f95 100644 --- a/lib/ubsan/lit_tests/Integer/shift.cpp +++ b/lib/ubsan/lit_tests/TestCases/Integer/shift.cpp diff --git a/lib/ubsan/lit_tests/Integer/sub-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/sub-overflow.cpp index bf33d2937..bf33d2937 100644 --- a/lib/ubsan/lit_tests/Integer/sub-overflow.cpp +++ b/lib/ubsan/lit_tests/TestCases/Integer/sub-overflow.cpp diff --git a/lib/ubsan/lit_tests/Integer/uadd-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/uadd-overflow.cpp index d97a642a9..d97a642a9 100644 --- a/lib/ubsan/lit_tests/Integer/uadd-overflow.cpp +++ b/lib/ubsan/lit_tests/TestCases/Integer/uadd-overflow.cpp diff --git a/lib/ubsan/lit_tests/Integer/uincdec-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/uincdec-overflow.cpp index a14bd6a77..a14bd6a77 100644 --- a/lib/ubsan/lit_tests/Integer/uincdec-overflow.cpp +++ b/lib/ubsan/lit_tests/TestCases/Integer/uincdec-overflow.cpp diff --git a/lib/ubsan/lit_tests/Integer/umul-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/umul-overflow.cpp index c84bb39ef..c84bb39ef 100644 --- a/lib/ubsan/lit_tests/Integer/umul-overflow.cpp +++ b/lib/ubsan/lit_tests/TestCases/Integer/umul-overflow.cpp diff --git a/lib/ubsan/lit_tests/Integer/usub-overflow.cpp b/lib/ubsan/lit_tests/TestCases/Integer/usub-overflow.cpp index 44621fd80..44621fd80 100644 --- a/lib/ubsan/lit_tests/Integer/usub-overflow.cpp +++ b/lib/ubsan/lit_tests/TestCases/Integer/usub-overflow.cpp diff --git a/lib/ubsan/lit_tests/Misc/bool.cpp b/lib/ubsan/lit_tests/TestCases/Misc/bool.cpp index e916e7fb3..e916e7fb3 100644 --- a/lib/ubsan/lit_tests/Misc/bool.cpp +++ b/lib/ubsan/lit_tests/TestCases/Misc/bool.cpp diff --git a/lib/ubsan/lit_tests/Misc/bounds.cpp b/lib/ubsan/lit_tests/TestCases/Misc/bounds.cpp index dc4c4a513..dc4c4a513 100644 --- a/lib/ubsan/lit_tests/Misc/bounds.cpp +++ b/lib/ubsan/lit_tests/TestCases/Misc/bounds.cpp diff --git a/lib/ubsan/lit_tests/Misc/deduplication.cpp b/lib/ubsan/lit_tests/TestCases/Misc/deduplication.cpp index d325bf6dd..d325bf6dd 100644 --- a/lib/ubsan/lit_tests/Misc/deduplication.cpp +++ b/lib/ubsan/lit_tests/TestCases/Misc/deduplication.cpp diff --git a/lib/ubsan/lit_tests/Misc/enum.cpp b/lib/ubsan/lit_tests/TestCases/Misc/enum.cpp index c5642507a..c5642507a 100644 --- a/lib/ubsan/lit_tests/Misc/enum.cpp +++ b/lib/ubsan/lit_tests/TestCases/Misc/enum.cpp diff --git a/lib/ubsan/lit_tests/Misc/missing_return.cpp b/lib/ubsan/lit_tests/TestCases/Misc/missing_return.cpp index 7da238e25..7da238e25 100644 --- a/lib/ubsan/lit_tests/Misc/missing_return.cpp +++ b/lib/ubsan/lit_tests/TestCases/Misc/missing_return.cpp diff --git a/lib/ubsan/lit_tests/Misc/unreachable.cpp b/lib/ubsan/lit_tests/TestCases/Misc/unreachable.cpp index 75fc3e5bd..75fc3e5bd 100644 --- a/lib/ubsan/lit_tests/Misc/unreachable.cpp +++ b/lib/ubsan/lit_tests/TestCases/Misc/unreachable.cpp diff --git a/lib/ubsan/lit_tests/Misc/vla.c b/lib/ubsan/lit_tests/TestCases/Misc/vla.c index 2fa88addc..2fa88addc 100644 --- a/lib/ubsan/lit_tests/Misc/vla.c +++ b/lib/ubsan/lit_tests/TestCases/Misc/vla.c diff --git a/lib/ubsan/lit_tests/TypeCheck/Function/function.cpp b/lib/ubsan/lit_tests/TestCases/TypeCheck/Function/function.cpp index 8106ae47e..8106ae47e 100644 --- a/lib/ubsan/lit_tests/TypeCheck/Function/function.cpp +++ b/lib/ubsan/lit_tests/TestCases/TypeCheck/Function/function.cpp diff --git a/lib/ubsan/lit_tests/TypeCheck/Function/lit.local.cfg b/lib/ubsan/lit_tests/TestCases/TypeCheck/Function/lit.local.cfg index 27c61a343..27c61a343 100644 --- a/lib/ubsan/lit_tests/TypeCheck/Function/lit.local.cfg +++ b/lib/ubsan/lit_tests/TestCases/TypeCheck/Function/lit.local.cfg diff --git a/lib/ubsan/lit_tests/TypeCheck/misaligned.cpp b/lib/ubsan/lit_tests/TestCases/TypeCheck/misaligned.cpp index 9b0b9a119..9b0b9a119 100644 --- a/lib/ubsan/lit_tests/TypeCheck/misaligned.cpp +++ b/lib/ubsan/lit_tests/TestCases/TypeCheck/misaligned.cpp diff --git a/lib/ubsan/lit_tests/TypeCheck/null.cpp b/lib/ubsan/lit_tests/TestCases/TypeCheck/null.cpp index 79726924d..79726924d 100644 --- a/lib/ubsan/lit_tests/TypeCheck/null.cpp +++ b/lib/ubsan/lit_tests/TestCases/TypeCheck/null.cpp diff --git a/lib/ubsan/lit_tests/TypeCheck/vptr.cpp b/lib/ubsan/lit_tests/TestCases/TypeCheck/vptr.cpp index bd7970a95..bd7970a95 100644 --- a/lib/ubsan/lit_tests/TypeCheck/vptr.cpp +++ b/lib/ubsan/lit_tests/TestCases/TypeCheck/vptr.cpp diff --git a/lib/ubsan/lit_tests/UbsanConfig/lit.cfg b/lib/ubsan/lit_tests/UbsanConfig/lit.cfg new file mode 100644 index 000000000..fcc93035c --- /dev/null +++ b/lib/ubsan/lit_tests/UbsanConfig/lit.cfg @@ -0,0 +1,23 @@ +# -*- 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 + +ubsan_lit_tests_dir = get_required_attr(config, "ubsan_lit_tests_dir") +ubsan_lit_cfg = os.path.join(ubsan_lit_tests_dir, "lit.common.cfg") +lit_config.load_config(config, ubsan_lit_cfg) + +config.name = 'UndefinedBehaviorSanitizer-Standalone' + +# Define %clang and %clangxx substitutions to use in test RUN lines. +config.substitutions.append( ("%clang ", (" " + config.clang + " ")) ) +config.substitutions.append( ("%clangxx ", (" " + config.clang + + " --driver-mode=g++ ")) ) diff --git a/lib/ubsan/lit_tests/lit.site.cfg.in b/lib/ubsan/lit_tests/UbsanConfig/lit.site.cfg.in index b0e427446..c08fc30d0 100644 --- a/lib/ubsan/lit_tests/lit.site.cfg.in +++ b/lib/ubsan/lit_tests/UbsanConfig/lit.site.cfg.in @@ -1,8 +1,8 @@ -## Autogenerated by LLVM/Clang configuration. -# Do not edit! - # Load common config for all compiler-rt lit tests. lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured") +# Tool-specific config options. +config.ubsan_lit_tests_dir = "@UBSAN_LIT_TESTS_DIR@" + # Load tool-specific config that would do the real work. -lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg") +lit_config.load_config(config, "@UBSAN_LIT_TESTS_DIR@/UbsanConfig/lit.cfg") diff --git a/lib/ubsan/lit_tests/lit.cfg b/lib/ubsan/lit_tests/lit.cfg deleted file mode 100644 index 4a5bc237b..000000000 --- a/lib/ubsan/lit_tests/lit.cfg +++ /dev/null @@ -1,65 +0,0 @@ -# -*- 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 config name. -config.name = 'UndefinedBehaviorSanitizer' - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -def DisplayNoConfigMessage(): - lit_config.fatal("No site specific configuration available! " + - "Try running your test from the build tree or running " + - "make check-ubsan") - -# Figure out LLVM source root. -llvm_src_root = getattr(config, 'llvm_src_root', None) -if llvm_src_root is None: - # We probably haven't loaded the site-specific configuration: the user - # is likely trying to run a test file directly, and the site configuration - # wasn't created by the build system or we're performing an out-of-tree build. - ubsan_site_cfg = lit_config.params.get('ubsan_site_config', None) - if ubsan_site_cfg and os.path.exists(ubsan_site_cfg): - lit_config.load_config(config, ubsan_site_cfg) - raise SystemExit - - # Try to guess the location of site-specific configuration using llvm-config - # util that can point where the build tree is. - llvm_config = lit.util.which("llvm-config", config.environment["PATH"]) - if not llvm_config: - DisplayNoConfigMessage() - - # Find out the presumed location of generated site config. - llvm_obj_root = lit.util.capture(["llvm-config", "--obj-root"]).strip() - ubsan_site_cfg = os.path.join(llvm_obj_root, "projects", "compiler-rt", - "lib", "ubsan", "lit_tests", "lit.site.cfg") - if not ubsan_site_cfg or not os.path.exists(ubsan_site_cfg): - DisplayNoConfigMessage() - - lit_config.load_config(config, ubsan_site_cfg) - raise SystemExit - -# Define %clang and %clangxx substitutions to use in test RUN lines. -config.substitutions.append( ("%clang ", (" " + config.clang + " ")) ) -config.substitutions.append( ("%clangxx ", (" " + config.clang + - " --driver-mode=g++ ")) ) - -# 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 diff --git a/lib/ubsan/lit_tests/lit.common.cfg b/lib/ubsan/lit_tests/lit.common.cfg new file mode 100644 index 000000000..23c85e9fa --- /dev/null +++ b/lib/ubsan/lit_tests/lit.common.cfg @@ -0,0 +1,31 @@ +# -*- 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. +ubsan_lit_tests_dir = get_required_attr(config, 'ubsan_lit_tests_dir') +config.test_source_root = os.path.join(ubsan_lit_tests_dir, 'TestCases') + +def DisplayNoConfigMessage(): + lit_config.fatal("No site specific configuration available! " + + "Try running your test from the build tree or running " + + "make check-ubsan") + +# 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 |