mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-28 16:11:29 +00:00
Define COMPILER_RT_CAN_EXECUTE_TESTS variable on platforms where we can produce working binaries and use it in build rules for sanitizers tests
llvm-svn: 171160
This commit is contained in:
parent
3edd52c1d0
commit
c20f5d2246
@ -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})
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
||||
# 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()
|
||||
|
||||
# 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")
|
||||
|
@ -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()
|
||||
|
||||
# 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")
|
||||
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-sanitizer "Running sanitizer library unittests"
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS SanitizerUnitTests
|
||||
)
|
||||
set_target_properties(check-sanitizer PROPERTIES FOLDER "Sanitizer unittests")
|
||||
|
@ -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)
|
||||
|
@ -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}
|
||||
|
Loading…
Reference in New Issue
Block a user