2014-02-14 22:06:10 +08:00
|
|
|
set(ASAN_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
|
|
|
set(ASAN_TESTSUITES)
|
2014-12-18 07:14:01 +08:00
|
|
|
set(ASAN_DYNAMIC_TESTSUITES)
|
2014-02-14 22:06:10 +08:00
|
|
|
|
2016-05-28 05:29:31 +08:00
|
|
|
# TODO(wwchrome): Re-enable Win64 asan tests when ready.
|
|
|
|
# Disable tests for asan Win64 temporarily.
|
2016-06-07 00:24:47 +08:00
|
|
|
if(OS_NAME MATCHES "Windows" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
2016-05-28 05:29:31 +08:00
|
|
|
set(EXCLUDE_FROM_ALL TRUE)
|
|
|
|
endif()
|
|
|
|
|
2014-09-29 21:18:55 +08:00
|
|
|
macro(get_bits_for_arch arch bits)
|
2015-01-29 10:28:53 +08:00
|
|
|
if (${arch} MATCHES "i386|i686|arm|mips|mipsel")
|
2015-03-05 08:33:11 +08:00
|
|
|
set(${bits} 32)
|
2016-04-30 18:02:12 +08:00
|
|
|
elseif (${arch} MATCHES "x86_64|powerpc64|powerpc64le|aarch64|mips64|mips64el|s390x")
|
2015-03-05 08:33:11 +08:00
|
|
|
set(${bits} 64)
|
2014-09-29 21:18:55 +08:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unknown target architecture: ${arch}")
|
|
|
|
endif()
|
|
|
|
endmacro()
|
2014-02-14 22:06:10 +08:00
|
|
|
|
2015-08-11 23:51:40 +08:00
|
|
|
set(ASAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
|
|
|
|
if(NOT COMPILER_RT_STANDALONE_BUILD)
|
|
|
|
list(APPEND ASAN_TEST_DEPS asan)
|
|
|
|
if(WIN32 AND COMPILER_RT_HAS_LLD_SOURCES)
|
|
|
|
list(APPEND ASAN_TEST_DEPS
|
|
|
|
lld
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
set(ASAN_DYNAMIC_TEST_DEPS ${ASAN_TEST_DEPS})
|
|
|
|
|
2015-08-21 01:32:06 +08:00
|
|
|
set(ASAN_TEST_ARCH ${ASAN_SUPPORTED_ARCH})
|
|
|
|
if(APPLE)
|
|
|
|
darwin_filter_host_archs(ASAN_SUPPORTED_ARCH ASAN_TEST_ARCH)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(arch ${ASAN_TEST_ARCH})
|
2015-01-29 10:28:53 +08:00
|
|
|
if(ANDROID)
|
|
|
|
set(ASAN_TEST_TARGET_ARCH ${arch}-android)
|
|
|
|
else()
|
|
|
|
set(ASAN_TEST_TARGET_ARCH ${arch})
|
2014-04-01 21:16:30 +08:00
|
|
|
endif()
|
2015-01-29 10:28:53 +08:00
|
|
|
string(TOLOWER "-${arch}-${OS_NAME}" ASAN_TEST_CONFIG_SUFFIX)
|
|
|
|
get_bits_for_arch(${arch} ASAN_TEST_BITS)
|
|
|
|
if(ANDROID OR ${arch} MATCHES "arm|aarch64")
|
2014-09-29 21:18:55 +08:00
|
|
|
# This is only true if we are cross-compiling.
|
|
|
|
# Build all tests with host compiler and use host tools.
|
|
|
|
set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
|
|
|
|
set(ASAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS})
|
2015-08-21 01:46:58 +08:00
|
|
|
else()
|
2015-01-29 10:28:53 +08:00
|
|
|
get_target_flags_for_arch(${arch} ASAN_TEST_TARGET_CFLAGS)
|
2015-05-19 17:07:37 +08:00
|
|
|
string(REPLACE ";" " " ASAN_TEST_TARGET_CFLAGS "${ASAN_TEST_TARGET_CFLAGS}")
|
2014-04-01 21:16:30 +08:00
|
|
|
endif()
|
2015-01-29 10:28:53 +08:00
|
|
|
if(ANDROID)
|
|
|
|
set(ASAN_TEST_DYNAMIC True)
|
|
|
|
else()
|
2014-09-29 21:18:55 +08:00
|
|
|
set(ASAN_TEST_DYNAMIC False)
|
|
|
|
endif()
|
2015-01-29 10:28:53 +08:00
|
|
|
string(TOUPPER ${arch} ARCH_UPPER_CASE)
|
|
|
|
set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
|
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg
|
|
|
|
)
|
|
|
|
list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
|
2014-09-29 21:18:55 +08:00
|
|
|
|
2015-01-29 10:28:53 +08:00
|
|
|
if(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME)
|
|
|
|
string(TOLOWER "-${arch}-${OS_NAME}-dynamic" ASAN_TEST_CONFIG_SUFFIX)
|
|
|
|
set(ASAN_TEST_DYNAMIC True)
|
|
|
|
set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}DynamicConfig)
|
2014-09-29 21:18:55 +08:00
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
2015-01-29 10:28:53 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg)
|
|
|
|
list(APPEND ASAN_DYNAMIC_TESTSUITES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
|
2014-09-29 21:18:55 +08:00
|
|
|
endif()
|
2015-01-29 10:28:53 +08:00
|
|
|
endforeach()
|
2014-02-14 22:06:10 +08:00
|
|
|
|
2014-12-18 07:14:01 +08:00
|
|
|
# Add unit tests.
|
|
|
|
if(COMPILER_RT_INCLUDE_TESTS)
|
|
|
|
set(ASAN_TEST_DYNAMIC False)
|
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
|
|
|
|
if(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME)
|
|
|
|
set(ASAN_TEST_DYNAMIC True)
|
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/Unit/dynamic/lit.site.cfg)
|
|
|
|
endif()
|
|
|
|
# FIXME: support unit test in the android test runner
|
|
|
|
if (NOT ANDROID)
|
|
|
|
list(APPEND ASAN_TEST_DEPS AsanUnitTests)
|
|
|
|
list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit)
|
|
|
|
if(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME)
|
|
|
|
list(APPEND ASAN_DYNAMIC_TEST_DEPS AsanDynamicUnitTests)
|
|
|
|
list(APPEND ASAN_DYNAMIC_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit/dynamic)
|
|
|
|
endif()
|
|
|
|
endif()
|
2014-02-14 22:06:10 +08:00
|
|
|
endif()
|
2014-12-18 07:14:01 +08:00
|
|
|
|
2014-02-14 22:06:10 +08:00
|
|
|
add_lit_testsuite(check-asan "Running the AddressSanitizer tests"
|
|
|
|
${ASAN_TESTSUITES}
|
2016-09-14 06:25:41 +08:00
|
|
|
DEPENDS ${ASAN_TEST_DEPS})
|
2016-07-12 05:51:56 +08:00
|
|
|
set_target_properties(check-asan PROPERTIES FOLDER "Compiler-RT Misc")
|
2014-12-18 07:14:01 +08:00
|
|
|
|
|
|
|
if(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME)
|
2015-02-04 02:40:34 +08:00
|
|
|
# Add check-dynamic-asan target. It is a part of check-all only on Windows,
|
|
|
|
# where we want to always test both dynamic and static runtime.
|
2016-05-28 05:29:31 +08:00
|
|
|
|
2015-02-04 02:40:34 +08:00
|
|
|
if(NOT OS_NAME MATCHES "Windows")
|
|
|
|
set(EXCLUDE_FROM_ALL TRUE)
|
|
|
|
endif()
|
2014-12-18 07:14:01 +08:00
|
|
|
add_lit_testsuite(check-asan-dynamic
|
|
|
|
"Running the AddressSanitizer tests with dynamic runtime"
|
|
|
|
${ASAN_DYNAMIC_TESTSUITES}
|
|
|
|
DEPENDS ${ASAN_DYNAMIC_TEST_DEPS})
|
|
|
|
set_target_properties(check-asan-dynamic
|
2016-07-12 05:51:56 +08:00
|
|
|
PROPERTIES FOLDER "Compiler-RT Misc")
|
2015-02-04 02:40:34 +08:00
|
|
|
if(NOT OS_NAME MATCHES "Windows")
|
|
|
|
set(EXCLUDE_FROM_ALL FALSE)
|
|
|
|
endif()
|
2014-12-18 07:14:01 +08:00
|
|
|
endif()
|
2016-05-28 05:29:31 +08:00
|
|
|
|
|
|
|
# TODO(wwchrome): Re-enable the tests for asan Win64 when ready.
|
2016-06-07 00:24:47 +08:00
|
|
|
if(OS_NAME MATCHES "Windows" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
2016-05-28 05:29:31 +08:00
|
|
|
set(EXCLUDE_FROM_ALL FALSE)
|
|
|
|
endif()
|