1 set(ASAN_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
5 if(CAN_TARGET_arm_android)
6 # This is only true if we are cross-compiling.
7 # Build all tests with host compiler and use host tools.
8 set(ASAN_TEST_TARGET_CC ${CMAKE_C_COMPILER})
9 get_filename_component(ASAN_TEST_LLVM_TOOLS_DIR ${CMAKE_C_COMPILER} PATH)
10 set(ASAN_TEST_CONFIG_SUFFIX "-arm-android")
11 set(ASAN_TEST_BITS "32")
12 get_target_flags_for_arch(arm_android ASAN_TEST_TARGET_CFLAGS)
13 configure_lit_site_cfg(
14 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
15 ${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig/lit.site.cfg
17 list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig)
20 if(CAN_TARGET_x86_64 OR CAN_TARGET_powerpc64)
21 set(ASAN_TEST_CONFIG_SUFFIX "64")
22 set(ASAN_TEST_BITS "64")
23 set(ASAN_TEST_TARGET_CFLAGS ${TARGET_64_BIT_CFLAGS})
24 set(ASAN_TEST_DYNAMIC False)
25 configure_lit_site_cfg(
26 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
27 ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig/lit.site.cfg
29 list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig)
30 if(COMPILER_RT_BUILD_SHARED_ASAN)
31 set(ASAN_TEST_CONFIG_SUFFIX "64-Dynamic")
32 set(ASAN_TEST_DYNAMIC True)
33 configure_lit_site_cfg(
34 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
35 ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig-dynamic/lit.site.cfg)
36 list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig-dynamic)
41 set(ASAN_TEST_CONFIG_SUFFIX "32")
42 set(ASAN_TEST_BITS "32")
43 set(ASAN_TEST_TARGET_CFLAGS ${TARGET_32_BIT_CFLAGS})
44 set(ASAN_TEST_DYNAMIC False)
45 set(ASAN_TEST_TARGET_ARCH "i386")
46 configure_lit_site_cfg(
47 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
48 ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig/lit.site.cfg
50 list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig)
51 if(COMPILER_RT_BUILD_SHARED_ASAN)
52 set(ASAN_TEST_CONFIG_SUFFIX "32-Dynamic")
53 set(ASAN_TEST_DYNAMIC True)
54 configure_lit_site_cfg(
55 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
56 ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic/lit.site.cfg)
57 list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic)
61 if(COMPILER_RT_INCLUDE_TESTS)
62 configure_lit_site_cfg(
63 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
64 ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
67 set(ASAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
68 if(NOT COMPILER_RT_STANDALONE_BUILD)
69 list(APPEND ASAN_TEST_DEPS asan)
72 # FIXME: support unit test in the android test runner
73 if(COMPILER_RT_INCLUDE_TESTS AND NOT CAN_TARGET_arm_android)
74 list(APPEND ASAN_TEST_DEPS AsanUnitTests)
75 list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit)
77 add_lit_testsuite(check-asan "Running the AddressSanitizer tests"
79 DEPENDS ${ASAN_TEST_DEPS})
80 set_target_properties(check-asan PROPERTIES FOLDER "ASan tests")