2014-02-14 19:42:22 +08:00
|
|
|
set(UBSAN_LIT_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
2015-02-27 03:19:44 +08:00
|
|
|
set(UBSAN_TESTSUITES)
|
2015-04-28 08:56:48 +08:00
|
|
|
set(UBSAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
|
|
|
|
|
|
|
|
macro(add_ubsan_testsuite test_mode sanitizer arch)
|
|
|
|
set(UBSAN_LIT_TEST_MODE "${test_mode}")
|
|
|
|
set(CONFIG_NAME ${UBSAN_LIT_TEST_MODE}-${arch})
|
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg)
|
|
|
|
list(APPEND UBSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
|
|
|
|
if(NOT COMPILER_RT_STANDALONE_BUILD)
|
|
|
|
list(APPEND UBSAN_TEST_DEPS ${sanitizer})
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2015-08-22 02:06:00 +08:00
|
|
|
set(UBSAN_TEST_ARCH ${UBSAN_SUPPORTED_ARCH})
|
|
|
|
if(APPLE)
|
|
|
|
darwin_filter_host_archs(UBSAN_SUPPORTED_ARCH UBSAN_TEST_ARCH)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(arch ${UBSAN_TEST_ARCH})
|
2015-02-27 03:19:44 +08:00
|
|
|
set(UBSAN_TEST_TARGET_ARCH ${arch})
|
|
|
|
if(${arch} MATCHES "arm|aarch64")
|
|
|
|
# This is only true if we're cross-compiling.
|
|
|
|
set(UBSAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS})
|
|
|
|
else()
|
|
|
|
get_target_flags_for_arch(${arch} UBSAN_TEST_TARGET_CFLAGS)
|
2015-05-19 17:07:37 +08:00
|
|
|
string(REPLACE ";" " " UBSAN_TEST_TARGET_CFLAGS "${UBSAN_TEST_TARGET_CFLAGS}")
|
2015-02-27 03:19:44 +08:00
|
|
|
endif()
|
2015-04-28 08:56:48 +08:00
|
|
|
add_ubsan_testsuite("Standalone" ubsan ${arch})
|
2015-02-27 03:19:44 +08:00
|
|
|
|
2015-12-10 08:40:58 +08:00
|
|
|
if(COMPILER_RT_HAS_ASAN AND ";${ASAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
|
2015-04-28 08:56:48 +08:00
|
|
|
add_ubsan_testsuite("AddressSanitizer" asan ${arch})
|
|
|
|
endif()
|
2015-12-10 08:40:58 +08:00
|
|
|
if(COMPILER_RT_HAS_MSAN AND ";${MSAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
|
2015-04-28 08:56:48 +08:00
|
|
|
add_ubsan_testsuite("MemorySanitizer" msan ${arch})
|
|
|
|
endif()
|
2015-12-10 08:40:58 +08:00
|
|
|
if(COMPILER_RT_HAS_TSAN AND ";${TSAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
|
2015-04-28 08:56:48 +08:00
|
|
|
add_ubsan_testsuite("ThreadSanitizer" tsan ${arch})
|
2015-02-27 03:19:44 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2014-02-14 19:42:22 +08:00
|
|
|
|
|
|
|
add_lit_testsuite(check-ubsan "Running UndefinedBehaviorSanitizer tests"
|
2014-05-30 06:38:13 +08:00
|
|
|
${UBSAN_TESTSUITES}
|
2014-02-14 19:42:22 +08:00
|
|
|
DEPENDS ${UBSAN_TEST_DEPS})
|
2015-02-27 03:19:44 +08:00
|
|
|
set_target_properties(check-ubsan PROPERTIES FOLDER "UBSan tests")
|