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
|
|
|
|
2014-09-29 21:18:55 +08:00
|
|
|
macro(get_bits_for_arch arch bits)
|
|
|
|
if (${arch} STREQUAL "arm" OR
|
|
|
|
${arch} STREQUAL "i386" OR
|
2014-10-01 20:55:06 +08:00
|
|
|
${arch} STREQUAL "i686" OR
|
2014-09-29 21:18:55 +08:00
|
|
|
${arch} STREQUAL "mips")
|
|
|
|
set(bits 32)
|
|
|
|
elseif (${arch} STREQUAL "aarch64" OR
|
|
|
|
${arch} STREQUAL "x86_64" OR
|
|
|
|
${arch} STREQUAL "mips64")
|
|
|
|
set(bits 64)
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unknown target architecture: ${arch}")
|
|
|
|
endif()
|
|
|
|
endmacro()
|
2014-02-14 22:06:10 +08:00
|
|
|
|
2014-09-29 21:18:55 +08:00
|
|
|
# TODO: merge with non-ANDROID case
|
|
|
|
if(ANDROID)
|
|
|
|
foreach(arch ${ASAN_SUPPORTED_ARCH})
|
2014-09-30 19:12:41 +08:00
|
|
|
set(ASAN_TEST_TARGET_CC ${CMAKE_CXX_COMPILER})
|
2014-09-29 21:18:55 +08:00
|
|
|
set(ASAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS})
|
|
|
|
set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-android")
|
|
|
|
get_bits_for_arch(${arch} ASAN_TEST_BITS)
|
|
|
|
set(ASAN_TEST_DYNAMIC True)
|
|
|
|
set(ASAN_TEST_TARGET_ARCH "${arch}-android")
|
|
|
|
string(TOUPPER ${arch} ARCH_UPPER_CASE)
|
|
|
|
set(CONFIG ${ARCH_UPPER_CASE}AndroidConfig)
|
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG}/lit.site.cfg
|
|
|
|
)
|
|
|
|
list(APPEND ASAN_TESTSUITES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG})
|
|
|
|
endforeach()
|
2014-05-01 05:32:30 +08:00
|
|
|
|
2014-09-29 21:18:55 +08:00
|
|
|
else() # Not Android
|
2014-05-30 06:38:13 +08:00
|
|
|
|
2014-09-29 21:18:55 +08:00
|
|
|
if(CAN_TARGET_arm)
|
|
|
|
# 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})
|
|
|
|
set(ASAN_TEST_CONFIG_SUFFIX "-arm-linux")
|
|
|
|
set(ASAN_TEST_BITS "32")
|
|
|
|
set(ASAN_TEST_DYNAMIC False)
|
2014-04-01 21:16:30 +08:00
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
2014-09-29 21:18:55 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/ARMLinuxConfig/lit.site.cfg
|
|
|
|
)
|
|
|
|
list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/ARMLinuxConfig)
|
2014-04-01 21:16:30 +08:00
|
|
|
endif()
|
2014-02-14 22:06:10 +08:00
|
|
|
|
2014-09-29 21:18:55 +08:00
|
|
|
if(CAN_TARGET_aarch64)
|
|
|
|
# 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})
|
|
|
|
set(ASAN_TEST_CONFIG_SUFFIX "-aarch64-linux")
|
|
|
|
set(ASAN_TEST_BITS "64")
|
|
|
|
set(ASAN_TEST_DYNAMIC False)
|
2014-06-24 20:08:18 +08:00
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
2014-09-29 21:18:55 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/AArch64LinuxConfig/lit.site.cfg
|
|
|
|
)
|
|
|
|
list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/AArch64LinuxConfig)
|
2014-06-24 20:08:18 +08:00
|
|
|
endif()
|
|
|
|
|
2014-11-13 02:23:16 +08:00
|
|
|
if(CAN_TARGET_x86_64 OR CAN_TARGET_powerpc64 OR CAN_TARGET_mips64 OR CAN_TARGET_mips64el)
|
2014-09-29 21:18:55 +08:00
|
|
|
set(ASAN_TEST_CONFIG_SUFFIX "64")
|
|
|
|
set(ASAN_TEST_BITS "64")
|
|
|
|
set(ASAN_TEST_TARGET_CFLAGS ${TARGET_64_BIT_CFLAGS})
|
|
|
|
set(ASAN_TEST_DYNAMIC False)
|
2014-04-01 21:16:30 +08:00
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
2014-09-29 21:18:55 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/64bitConfig/lit.site.cfg
|
|
|
|
)
|
|
|
|
list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig)
|
2014-12-18 07:14:01 +08:00
|
|
|
if(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME)
|
2014-09-29 21:18:55 +08:00
|
|
|
set(ASAN_TEST_CONFIG_SUFFIX "64-Dynamic")
|
|
|
|
set(ASAN_TEST_DYNAMIC True)
|
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/64bitConfig-dynamic/lit.site.cfg)
|
2014-12-18 07:14:01 +08:00
|
|
|
list(APPEND ASAN_DYNAMIC_TESTSUITES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/64bitConfig-dynamic)
|
2014-09-29 21:18:55 +08:00
|
|
|
endif()
|
2014-04-01 21:16:30 +08:00
|
|
|
endif()
|
2014-09-29 21:18:55 +08:00
|
|
|
|
|
|
|
if(CAN_TARGET_i386)
|
|
|
|
set(ASAN_TEST_CONFIG_SUFFIX "32")
|
|
|
|
set(ASAN_TEST_BITS "32")
|
|
|
|
set(ASAN_TEST_TARGET_CFLAGS ${TARGET_32_BIT_CFLAGS})
|
|
|
|
set(ASAN_TEST_DYNAMIC False)
|
|
|
|
set(ASAN_TEST_TARGET_ARCH "i386")
|
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/32bitConfig/lit.site.cfg
|
|
|
|
)
|
|
|
|
list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig)
|
2014-12-18 07:14:01 +08:00
|
|
|
if(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME)
|
2014-09-29 21:18:55 +08:00
|
|
|
set(ASAN_TEST_CONFIG_SUFFIX "32-Dynamic")
|
|
|
|
set(ASAN_TEST_DYNAMIC True)
|
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic/lit.site.cfg)
|
2014-12-18 07:14:01 +08:00
|
|
|
list(APPEND ASAN_DYNAMIC_TESTSUITES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic)
|
2014-09-29 21:18:55 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2014-10-10 21:46:55 +08:00
|
|
|
if(CAN_TARGET_mips OR CAN_TARGET_mipsel)
|
2014-09-29 21:18:55 +08:00
|
|
|
set(ASAN_TEST_CONFIG_SUFFIX "32")
|
|
|
|
set(ASAN_TEST_BITS "32")
|
|
|
|
set(ASAN_TEST_TARGET_CFLAGS ${TARGET_32_BIT_CFLAGS})
|
|
|
|
set(ASAN_TEST_DYNAMIC False)
|
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/32bitConfig/lit.site.cfg
|
|
|
|
)
|
|
|
|
list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig)
|
2014-12-18 07:14:01 +08:00
|
|
|
if(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME)
|
2014-09-29 21:18:55 +08:00
|
|
|
set(ASAN_TEST_CONFIG_SUFFIX "32-Dynamic")
|
|
|
|
set(ASAN_TEST_DYNAMIC True)
|
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic/lit.site.cfg)
|
2014-12-18 07:14:01 +08:00
|
|
|
list(APPEND ASAN_DYNAMIC_TESTSUITES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic)
|
2014-09-29 21:18:55 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif() # Not Android
|
2014-02-14 22:06:10 +08:00
|
|
|
|
2014-06-09 19:17:37 +08:00
|
|
|
set(ASAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
|
|
|
|
if(COMPILER_RT_STANDALONE_BUILD)
|
2014-11-18 22:04:12 +08:00
|
|
|
add_executable(FileCheck IMPORTED GLOBAL)
|
|
|
|
set_property(TARGET FileCheck PROPERTY IMPORTED_LOCATION ${LLVM_TOOLS_BINARY_DIR}/FileCheck)
|
|
|
|
list(APPEND ASAN_TEST_DEPS FileCheck)
|
2014-06-09 19:17:37 +08:00
|
|
|
else()
|
2014-02-20 17:47:18 +08:00
|
|
|
list(APPEND ASAN_TEST_DEPS asan)
|
|
|
|
endif()
|
2014-12-18 07:14:01 +08:00
|
|
|
set(ASAN_DYNAMIC_TEST_DEPS ${ASAN_TEST_DEPS})
|
2014-02-20 17:47:18 +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}
|
|
|
|
DEPENDS ${ASAN_TEST_DEPS})
|
|
|
|
set_target_properties(check-asan PROPERTIES FOLDER "ASan tests")
|
2014-12-18 07:14:01 +08:00
|
|
|
|
|
|
|
if(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME)
|
|
|
|
# Add check-dynamic-asan target (not included in check-all)
|
|
|
|
set(EXCLUDE_FROM_ALL TRUE)
|
|
|
|
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
|
|
|
|
PROPERTIES FOLDER "ASan dynamic tests")
|
|
|
|
set(EXCLUDE_FROM_ALL FALSE)
|
|
|
|
endif()
|