2014-05-09 08:28:18 +08:00
|
|
|
set(SANITIZER_COMMON_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
|
|
|
set(SANITIZER_COMMON_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
|
|
|
|
set(SANITIZER_COMMON_TESTSUITES)
|
|
|
|
|
2014-05-13 06:48:29 +08:00
|
|
|
set(SUPPORTED_TOOLS)
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID)
|
|
|
|
list(APPEND SUPPORTED_TOOLS asan)
|
|
|
|
endif()
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID)
|
|
|
|
list(APPEND SUPPORTED_TOOLS tsan)
|
|
|
|
list(APPEND SUPPORTED_TOOLS msan)
|
2014-07-04 15:30:34 +08:00
|
|
|
list(APPEND SUPPORTED_TOOLS lsan)
|
2014-05-13 06:48:29 +08:00
|
|
|
endif()
|
|
|
|
|
2014-05-09 08:28:18 +08:00
|
|
|
# Create a separate config for each tool we support.
|
2014-05-13 06:48:29 +08:00
|
|
|
foreach(tool ${SUPPORTED_TOOLS})
|
2014-05-09 08:28:18 +08:00
|
|
|
string(TOUPPER ${tool} tool_toupper)
|
2015-03-03 06:03:52 +08:00
|
|
|
if(${tool_toupper}_SUPPORTED_ARCH AND NOT COMPILER_RT_STANDALONE_BUILD)
|
|
|
|
list(APPEND SANITIZER_COMMON_TEST_DEPS ${tool})
|
|
|
|
endif()
|
2015-08-21 01:32:06 +08:00
|
|
|
set(TEST_ARCH ${${tool_toupper}_SUPPORTED_ARCH})
|
|
|
|
if(APPLE)
|
|
|
|
darwin_filter_host_archs(${tool_toupper}_SUPPORTED_ARCH TEST_ARCH)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(arch ${TEST_ARCH})
|
2014-05-09 08:28:18 +08:00
|
|
|
set(SANITIZER_COMMON_LIT_TEST_MODE ${tool})
|
2015-03-03 06:03:52 +08:00
|
|
|
set(SANITIZER_COMMON_TEST_TARGET_ARCH ${arch})
|
|
|
|
if(${arch} MATCHES "arm|aarch64")
|
|
|
|
# This is only true if we're cross-compiling.
|
|
|
|
set(SANITIZER_COMMON_TEST_TARGET_CFLAGS
|
|
|
|
${COMPILER_RT_TEST_COMPILER_CFLAGS})
|
2015-08-21 01:46:58 +08:00
|
|
|
else()
|
2015-03-03 06:03:52 +08:00
|
|
|
get_target_flags_for_arch(${arch} SANITIZER_COMMON_TEST_TARGET_CFLAGS)
|
2015-05-19 17:07:37 +08:00
|
|
|
string(REPLACE ";" " " SANITIZER_COMMON_TEST_TARGET_CFLAGS "${SANITIZER_COMMON_TEST_TARGET_CFLAGS}")
|
2015-03-03 06:03:52 +08:00
|
|
|
endif()
|
|
|
|
set(CONFIG_NAME ${tool}-${arch}-${OS_NAME})
|
2014-05-09 08:28:18 +08:00
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
2015-03-03 06:03:52 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg)
|
|
|
|
list(APPEND SANITIZER_COMMON_TESTSUITES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
|
|
|
|
endforeach()
|
2014-05-09 08:28:18 +08:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# Unit tests.
|
2014-02-20 20:18:08 +08:00
|
|
|
if(COMPILER_RT_INCLUDE_TESTS)
|
|
|
|
configure_lit_site_cfg(
|
2014-05-09 07:53:02 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
|
2014-05-09 08:28:18 +08:00
|
|
|
list(APPEND SANITIZER_COMMON_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit)
|
|
|
|
list(APPEND SANITIZER_COMMON_TEST_DEPS SanitizerUnitTests)
|
|
|
|
endif()
|
|
|
|
|
2016-07-23 01:14:31 +08:00
|
|
|
if(SANITIZER_COMMON_TESTSUITES)
|
2014-05-09 08:28:18 +08:00
|
|
|
add_lit_testsuite(check-sanitizer "Running sanitizer_common tests"
|
|
|
|
${SANITIZER_COMMON_TESTSUITES}
|
|
|
|
DEPENDS ${SANITIZER_COMMON_TEST_DEPS})
|
|
|
|
set_target_properties(check-sanitizer PROPERTIES FOLDER
|
2016-07-12 05:51:56 +08:00
|
|
|
"Compiler-RT Misc")
|
2014-02-20 20:18:08 +08:00
|
|
|
endif()
|