diff options
author | Alexey Samsonov <samsonov@google.com> | 2014-05-09 00:28:18 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2014-05-09 00:28:18 +0000 |
commit | 0bef819f9f2bf02baa05b1f8d698f25ab63c6012 (patch) | |
tree | 66ee6c82cc7b439e639de500c6ea764be423808a /compiler-rt | |
parent | 14048090026bbb098a1913a44cb0573dbdad27ee (diff) | |
download | bcm5719-llvm-0bef819f9f2bf02baa05b1f8d698f25ab63c6012.tar.gz bcm5719-llvm-0bef819f9f2bf02baa05b1f8d698f25ab63c6012.zip |
[Sanitizer] Add the machinery to run the same test under several sanitizers
llvm-svn: 208378
Diffstat (limited to 'compiler-rt')
-rw-r--r-- | compiler-rt/test/sanitizer_common/CMakeLists.txt | 35 | ||||
-rw-r--r-- | compiler-rt/test/sanitizer_common/TestCases/ptrace.cc (renamed from compiler-rt/test/msan/ptrace.cc) | 2 | ||||
-rw-r--r-- | compiler-rt/test/sanitizer_common/lit.common.cfg | 30 | ||||
-rw-r--r-- | compiler-rt/test/sanitizer_common/lit.site.cfg.in | 9 |
4 files changed, 71 insertions, 5 deletions
diff --git a/compiler-rt/test/sanitizer_common/CMakeLists.txt b/compiler-rt/test/sanitizer_common/CMakeLists.txt index 2e5a0239351..b34dfc1008e 100644 --- a/compiler-rt/test/sanitizer_common/CMakeLists.txt +++ b/compiler-rt/test/sanitizer_common/CMakeLists.txt @@ -1,9 +1,36 @@ +set(SANITIZER_COMMON_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + +set(SANITIZER_COMMON_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS}) +set(SANITIZER_COMMON_TESTSUITES) + +# Create a separate config for each tool we support. +foreach(tool asan tsan msan) + string(TOUPPER ${tool} tool_toupper) + if(${tool_toupper}_SUPPORTED_ARCH) + set(SANITIZER_COMMON_LIT_TEST_MODE ${tool}) + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/${tool}/lit.site.cfg) + list(APPEND SANITIZER_COMMON_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${tool}) + if(NOT COMPILER_RT_STANDALONE_BUILD) + list(APPEND SANITIZER_COMMON_TEST_DEPS ${tool}) + endif() + endif() +endforeach() + +# Unit tests. if(COMPILER_RT_INCLUDE_TESTS) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg) - add_lit_testsuite(check-sanitizer "Running sanitizer library unittests" - ${CMAKE_CURRENT_BINARY_DIR}/Unit - DEPENDS SanitizerUnitTests) - set_target_properties(check-sanitizer PROPERTIES FOLDER "Sanitizer unittests") + list(APPEND SANITIZER_COMMON_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit) + list(APPEND SANITIZER_COMMON_TEST_DEPS SanitizerUnitTests) +endif() + +if(SANITIZER_COMMON_TESTSUITES) + add_lit_testsuite(check-sanitizer "Running sanitizer_common tests" + ${SANITIZER_COMMON_TESTSUITES} + DEPENDS ${SANITIZER_COMMON_TEST_DEPS}) + set_target_properties(check-sanitizer PROPERTIES FOLDER + "sanitizer_common tests") endif() diff --git a/compiler-rt/test/msan/ptrace.cc b/compiler-rt/test/sanitizer_common/TestCases/ptrace.cc index 36cd03f7bb1..2c7517551af 100644 --- a/compiler-rt/test/msan/ptrace.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/ptrace.cc @@ -1,4 +1,4 @@ -// RUN: %clangxx_msan -m64 -O0 %s -o %t && %run %t +// RUN: %clangxx -O0 %s -o %t && %run %t #include <assert.h> #include <signal.h> diff --git a/compiler-rt/test/sanitizer_common/lit.common.cfg b/compiler-rt/test/sanitizer_common/lit.common.cfg new file mode 100644 index 00000000000..86c9d33d90d --- /dev/null +++ b/compiler-rt/test/sanitizer_common/lit.common.cfg @@ -0,0 +1,30 @@ +# -*- Python -*- + +# Setup source root. +config.test_source_root = os.path.join(os.path.dirname(__file__), "TestCases") + +config.name = "SanitizerCommon-" + config.tool_name + +if config.tool_name == "asan": + tool_cflags = ["-fsanitize=address"] +elif config.tool_name == "tsan": + tool_cflags = ["-fsanitize=thread"] +elif config.tool_name == "msan": + tool_cflags = ["-fsanitize=memory"] +else: + lit_config.fatal("Unknown tool for sanitizer_common tests: %r" % config.tool_name) + +clang_cflags = ["-g"] + tool_cflags +clang_cxxflags = config.cxx_mode_flags + clang_cflags + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + +config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) ) +config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) ) + +config.suffixes = ['.c', '.cc', '.cpp'] + +if config.host_os not in ['Linux', 'Darwin']: + config.unsupported = True + diff --git a/compiler-rt/test/sanitizer_common/lit.site.cfg.in b/compiler-rt/test/sanitizer_common/lit.site.cfg.in new file mode 100644 index 00000000000..1e94aa56763 --- /dev/null +++ b/compiler-rt/test/sanitizer_common/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@/test/lit.common.configured") + +# Tool-specific config options. +config.tool_name = "@SANITIZER_COMMON_LIT_TEST_MODE@" + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@SANITIZER_COMMON_LIT_SOURCE_DIR@/lit.common.cfg") + |