diff options
author | Alexey Samsonov <samsonov@google.com> | 2012-12-27 13:19:23 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2012-12-27 13:19:23 +0000 |
commit | d7d7b5f39cf5bbc36403afb0a94d473519c7ab78 (patch) | |
tree | 09cc13f0ae2e396c276b0b8fd19866e1be100100 | |
parent | 4b8fb65802eb47564fbbd4dee1d3e40d892837fe (diff) | |
download | compiler-rt-d7d7b5f39cf5bbc36403afb0a94d473519c7ab78.tar.gz compiler-rt-d7d7b5f39cf5bbc36403afb0a94d473519c7ab78.tar.bz2 compiler-rt-d7d7b5f39cf5bbc36403afb0a94d473519c7ab78.tar.xz |
Define COMPILER_RT_CAN_EXECUTE_TESTS variable on platforms where we can produce working binaries and use it in build rules for sanitizers tests
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@171160 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | CMakeLists.txt | 9 | ||||
-rw-r--r-- | lib/asan/CMakeLists.txt | 3 | ||||
-rw-r--r-- | lib/asan/lit_tests/CMakeLists.txt | 12 | ||||
-rw-r--r-- | lib/asan/tests/CMakeLists.txt | 6 | ||||
-rw-r--r-- | lib/msan/tests/CMakeLists.txt | 27 | ||||
-rw-r--r-- | lib/sanitizer_common/tests/CMakeLists.txt | 26 | ||||
-rw-r--r-- | lib/tsan/lit_tests/CMakeLists.txt | 8 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/CMakeLists.txt | 6 |
8 files changed, 46 insertions, 51 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8574cdc2..0c9f2a62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,15 @@ try_compile(CAN_TARGET_I386 ${CMAKE_BINARY_DIR} ${SIMPLE_SOURCE32} COMPILE_DEFINITIONS "${TARGET_I386_CFLAGS}" CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${TARGET_I386_CFLAGS}") +# We only support running instrumented tests when we're not cross compiling +# and target a unix-like system. On Android we define the rules for building +# unit tests, but don't execute them. +if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND UNIX AND NOT ANDROID) + set(COMPILER_RT_CAN_EXECUTE_TESTS TRUE) +else() + set(COMPILER_RT_CAN_EXECUTE_TESTS FALSE) +endif() + function(filter_available_targets out_var) set(archs) foreach(arch ${ARGN}) diff --git a/lib/asan/CMakeLists.txt b/lib/asan/CMakeLists.txt index 0f561e6c..2a27da9d 100644 --- a/lib/asan/CMakeLists.txt +++ b/lib/asan/CMakeLists.txt @@ -129,7 +129,4 @@ if(LLVM_INCLUDE_TESTS) add_subdirectory(tests) endif() -# ASan output tests. -# FIXME: move all output tests from output_tests/ to lit_tests/ and get rid -# of the first directory. add_subdirectory(lit_tests) diff --git a/lib/asan/lit_tests/CMakeLists.txt b/lib/asan/lit_tests/CMakeLists.txt index afe76a98..1609032d 100644 --- a/lib/asan/lit_tests/CMakeLists.txt +++ b/lib/asan/lit_tests/CMakeLists.txt @@ -11,9 +11,8 @@ configure_lit_site_cfg( ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg ) -if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}") - # Run ASan output tests only if we're not cross-compiling, - # and can be sure that clang would produce working binaries. +if(COMPILER_RT_CAN_EXECUTE_TESTS) + # Run ASan tests only if we're sure we may produce working binaries. set(ASAN_TEST_DEPS clang clang-headers FileCheck count not llvm-nm llvm-symbolizer ${ASAN_RUNTIME_LIBRARIES} @@ -30,11 +29,4 @@ if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}") DEPENDS ${ASAN_TEST_DEPS} ) set_target_properties(check-asan PROPERTIES FOLDER "ASan tests") -elseif(LLVM_INCLUDE_TESTS) - # Otherwise run only ASan unit tests. - add_lit_testsuite(check-asan "Running the AddressSanitizer unit tests" - ${CMAKE_CURRENT_BINARY_DIR}/Unit - DEPENDS AsanUnitTests - ) - set_target_properties(check-asan PROPERTIES FOLDER "ASan unit tests") endif() diff --git a/lib/asan/tests/CMakeLists.txt b/lib/asan/tests/CMakeLists.txt index 33b3c584..0cfb767f 100644 --- a/lib/asan/tests/CMakeLists.txt +++ b/lib/asan/tests/CMakeLists.txt @@ -153,11 +153,7 @@ macro(add_asan_tests_for_arch arch) ${ASAN_BENCHMARKS_OBJECTS} ${ASAN_INST_GTEST}) endmacro() -# We only support building instrumented tests when we're not cross compiling -# and targeting a unix-like system where we can predict viable compilation and -# linking strategies. -# We use a different approach to build these tests for Android. See below. -if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND UNIX AND NOT ANDROID) +if(COMPILER_RT_CAN_EXECUTE_TESTS) if(CAN_TARGET_X86_64) add_asan_tests_for_arch(x86_64) endif() diff --git a/lib/msan/tests/CMakeLists.txt b/lib/msan/tests/CMakeLists.txt index 1c8e2c9e..d6df41c0 100644 --- a/lib/msan/tests/CMakeLists.txt +++ b/lib/msan/tests/CMakeLists.txt @@ -147,21 +147,20 @@ macro(add_msan_tests_for_arch arch) ${MSAN_INST_LIBCXX} ${MSANDR_TEST_SO}) endmacro() -if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND UNIX AND NOT ANDROID - AND EXISTS ${MSAN_LIBCXX_PATH}/) +if(COMPILER_RT_CAN_EXECUTE_TESTS AND EXISTS ${MSAN_LIBCXX_PATH}/) if(CAN_TARGET_X86_64) add_msan_tests_for_arch(x86_64) endif() -endif() -# Run unittests as a part of lit testsuite. -configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - ) - -add_lit_testsuite(check-msan "Running MemorySanitizer unittests" - ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS MsanUnitTests - ) -set_target_properties(check-msan PROPERTIES FOLDER "MemorySanitizer unittests") + # Run unittests as a part of lit testsuite. + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + ) + + add_lit_testsuite(check-msan "Running MemorySanitizer unittests" + ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS MsanUnitTests + ) + set_target_properties(check-msan PROPERTIES FOLDER "MemorySanitizer unittests") +endif() diff --git a/lib/sanitizer_common/tests/CMakeLists.txt b/lib/sanitizer_common/tests/CMakeLists.txt index fa1d7ca0..0cedeb58 100644 --- a/lib/sanitizer_common/tests/CMakeLists.txt +++ b/lib/sanitizer_common/tests/CMakeLists.txt @@ -75,7 +75,9 @@ macro(add_sanitizer_tests_for_arch arch) LINK_FLAGS ${SANITIZER_TEST_LINK_FLAGS}) endmacro() -if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND UNIX AND NOT ANDROID) +if(COMPILER_RT_CAN_EXECUTE_TESTS) + # We use just-built clang to build sanitizer_common unittests, so we must + # be sure that produced binaries would work. if(APPLE) add_sanitizer_common_lib("RTSanitizerCommon.test.osx" $<TARGET_OBJECTS:RTSanitizerCommon.osx>) @@ -95,16 +97,16 @@ if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND UNIX AND NOT ANDROID) if(CAN_TARGET_I386) add_sanitizer_tests_for_arch(i386) endif() -endif() -# Run unittests as a part of lit testsuite. -configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - ) + # Run unittests as a part of lit testsuite. + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + ) -add_lit_testsuite(check-sanitizer "Running sanitizer library unittests" - ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS SanitizerUnitTests - ) -set_target_properties(check-sanitizer PROPERTIES FOLDER "Sanitizer unittests") + add_lit_testsuite(check-sanitizer "Running sanitizer library unittests" + ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS SanitizerUnitTests + ) + set_target_properties(check-sanitizer PROPERTIES FOLDER "Sanitizer unittests") +endif() diff --git a/lib/tsan/lit_tests/CMakeLists.txt b/lib/tsan/lit_tests/CMakeLists.txt index 6dc90e23..ff2508dd 100644 --- a/lib/tsan/lit_tests/CMakeLists.txt +++ b/lib/tsan/lit_tests/CMakeLists.txt @@ -8,9 +8,8 @@ configure_lit_site_cfg( ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg ) -if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}") - # Run TSan output tests only if we're not cross-compiling, - # and can be sure that clang would produce working binaries. +if(COMPILER_RT_CAN_EXECUTE_TESTS) + # Run TSan output tests only if we're sure we can produce working binaries. set(TSAN_TEST_DEPS clang clang-headers FileCheck count not llvm-symbolizer ${TSAN_RUNTIME_LIBRARIES} @@ -28,7 +27,8 @@ if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}") ) set_target_properties(check-tsan PROPERTIES FOLDER "TSan unittests") elseif(LLVM_INCLUDE_TESTS) - # Otherwise run only TSan unit tests. + # Otherwise run only TSan unit tests (they are linked using the + # host compiler). add_lit_testsuite(check-tsan "Running ThreadSanitizer tests" ${CMAKE_CURRENT_BINARY_DIR}/Unit DEPENDS TsanUnitTests llvm-symbolizer) diff --git a/lib/ubsan/lit_tests/CMakeLists.txt b/lib/ubsan/lit_tests/CMakeLists.txt index 67d786dd..565c523c 100644 --- a/lib/ubsan/lit_tests/CMakeLists.txt +++ b/lib/ubsan/lit_tests/CMakeLists.txt @@ -3,9 +3,9 @@ configure_lit_site_cfg( ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg ) -if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}") - # Run UBSan output tests only if we're not cross-compiling, - # and can be sure that clang would produce working binaries. +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 clang clang-headers FileCheck count not ${UBSAN_RUNTIME_LIBRARIES} |