• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1set(ASAN_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
2
3set(ASAN_TESTSUITES)
4
5if(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  set(ASAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS})
10  get_filename_component(ASAN_TEST_LLVM_TOOLS_DIR ${CMAKE_C_COMPILER} PATH)
11  set(ASAN_TEST_CONFIG_SUFFIX "-arm-android")
12  set(ASAN_TEST_BITS "32")
13  set(ASAN_TEST_DYNAMIC True)
14  set(ASAN_TEST_TARGET_ARCH "arm-android")
15  configure_lit_site_cfg(
16    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
17    ${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig/lit.site.cfg
18    )
19  list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig)
20endif()
21
22if(CAN_TARGET_arm)
23  # This is only true if we are cross-compiling.
24  # Build all tests with host compiler and use host tools.
25  set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
26  set(ASAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS})
27  set(ASAN_TEST_CONFIG_SUFFIX "-arm-linux")
28  set(ASAN_TEST_BITS "32")
29  set(ASAN_TEST_DYNAMIC False)
30  configure_lit_site_cfg(
31    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
32    ${CMAKE_CURRENT_BINARY_DIR}/ARMLinuxConfig/lit.site.cfg
33    )
34  list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/ARMLinuxConfig)
35endif()
36
37if(CAN_TARGET_aarch64)
38  # This is only true if we are cross-compiling.
39  # Build all tests with host compiler and use host tools.
40  set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
41  set(ASAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS})
42  set(ASAN_TEST_CONFIG_SUFFIX "-aarch64-linux")
43  set(ASAN_TEST_BITS "64")
44  set(ASAN_TEST_DYNAMIC False)
45  configure_lit_site_cfg(
46    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
47    ${CMAKE_CURRENT_BINARY_DIR}/AArch64LinuxConfig/lit.site.cfg
48    )
49  list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/AArch64LinuxConfig)
50endif()
51
52if(CAN_TARGET_x86_64 OR CAN_TARGET_powerpc64)
53  set(ASAN_TEST_CONFIG_SUFFIX "64")
54  set(ASAN_TEST_BITS "64")
55  set(ASAN_TEST_TARGET_CFLAGS ${TARGET_64_BIT_CFLAGS})
56  set(ASAN_TEST_DYNAMIC False)
57  configure_lit_site_cfg(
58    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
59    ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig/lit.site.cfg
60    )
61  list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig)
62  if(COMPILER_RT_BUILD_SHARED_ASAN)
63    set(ASAN_TEST_CONFIG_SUFFIX "64-Dynamic")
64    set(ASAN_TEST_DYNAMIC True)
65    configure_lit_site_cfg(
66      ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
67      ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig-dynamic/lit.site.cfg)
68    list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig-dynamic)
69  endif()
70endif()
71
72if(CAN_TARGET_i386)
73  set(ASAN_TEST_CONFIG_SUFFIX "32")
74  set(ASAN_TEST_BITS "32")
75  set(ASAN_TEST_TARGET_CFLAGS ${TARGET_32_BIT_CFLAGS})
76  set(ASAN_TEST_DYNAMIC False)
77  set(ASAN_TEST_TARGET_ARCH "i386")
78  configure_lit_site_cfg(
79    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
80    ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig/lit.site.cfg
81    )
82  list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig)
83  if(COMPILER_RT_BUILD_SHARED_ASAN)
84    set(ASAN_TEST_CONFIG_SUFFIX "32-Dynamic")
85    set(ASAN_TEST_DYNAMIC True)
86    configure_lit_site_cfg(
87      ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
88      ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic/lit.site.cfg)
89    list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic)
90  endif()
91endif()
92
93if(CAN_TARGET_mips)
94  set(ASAN_TEST_CONFIG_SUFFIX "32")
95  set(ASAN_TEST_BITS "32")
96  set(ASAN_TEST_TARGET_CFLAGS ${TARGET_32_BIT_CFLAGS})
97  set(ASAN_TEST_DYNAMIC False)
98  configure_lit_site_cfg(
99    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
100    ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig/lit.site.cfg
101    )
102  list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig)
103  if(COMPILER_RT_BUILD_SHARED_ASAN)
104    set(ASAN_TEST_CONFIG_SUFFIX "32-Dynamic")
105    set(ASAN_TEST_DYNAMIC True)
106    configure_lit_site_cfg(
107      ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
108      ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic/lit.site.cfg)
109    list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic)
110  endif()
111endif()
112
113if(COMPILER_RT_INCLUDE_TESTS)
114  configure_lit_site_cfg(
115    ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
116    ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
117endif()
118
119set(ASAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
120if(COMPILER_RT_STANDALONE_BUILD)
121  list(APPEND ASAN_TEST_DEPS ${LLVM_TOOLS_BINARY_DIR}/FileCheck)
122else()
123  list(APPEND ASAN_TEST_DEPS asan)
124endif()
125
126# FIXME: support unit test in the android test runner
127if(COMPILER_RT_INCLUDE_TESTS AND NOT CAN_TARGET_arm_android)
128  list(APPEND ASAN_TEST_DEPS AsanUnitTests)
129  list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit)
130endif()
131add_lit_testsuite(check-asan "Running the AddressSanitizer tests"
132  ${ASAN_TESTSUITES}
133  DEPENDS ${ASAN_TEST_DEPS})
134set_target_properties(check-asan PROPERTIES FOLDER "ASan tests")
135