1# Needed for lit support
2include(AddLLVM)
3
4configure_lit_site_cfg(
5  ${CMAKE_CURRENT_SOURCE_DIR}/lit.common.configured.in
6  ${CMAKE_CURRENT_BINARY_DIR}/lit.common.configured)
7
8# BlocksRuntime and builtins testsuites are not yet ported to lit.
9# add_subdirectory(BlocksRuntime)
10# add_subdirectory(builtins)
11
12set(SANITIZER_COMMON_LIT_TEST_DEPS)
13if(COMPILER_RT_STANDALONE_BUILD)
14  add_executable(FileCheck IMPORTED GLOBAL)
15  set_property(TARGET FileCheck PROPERTY IMPORTED_LOCATION ${LLVM_TOOLS_BINARY_DIR}/FileCheck)
16  list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS FileCheck)
17endif()
18
19# When ANDROID, we build tests with the host compiler (i.e. CMAKE_C_COMPILER),
20# and run tests with tools from the host toolchain.
21if(NOT ANDROID)
22  if(NOT COMPILER_RT_STANDALONE_BUILD)
23    # Use LLVM utils and Clang from the same build tree.
24    list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS
25      clang clang-headers FileCheck count not llvm-config llvm-nm llvm-objdump
26      llvm-symbolizer compiler-rt-headers sancov)
27    if (COMPILER_RT_HAS_PROFILE)
28      list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS profile)
29    endif()
30    if (WIN32)
31      list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS KillTheDoctor)
32    endif()
33  endif()
34  if(CMAKE_HOST_UNIX)
35    list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS SanitizerLintCheck)
36  endif()
37endif()
38
39# Run sanitizer tests only if we're sure that clang would produce
40# working binaries.
41if(COMPILER_RT_CAN_EXECUTE_TESTS)
42  if(COMPILER_RT_HAS_ASAN)
43    add_subdirectory(asan)
44  endif()
45  if(COMPILER_RT_HAS_DFSAN)
46    add_subdirectory(dfsan)
47  endif()
48  if(COMPILER_RT_HAS_LSAN)
49    add_subdirectory(lsan)
50  endif()
51  if(COMPILER_RT_HAS_MSAN)
52    add_subdirectory(msan)
53  endif()
54  if(COMPILER_RT_HAS_PROFILE)
55    add_subdirectory(profile)
56  endif()
57  if(COMPILER_RT_HAS_SANITIZER_COMMON)
58    add_subdirectory(sanitizer_common)
59  endif()
60  if(COMPILER_RT_HAS_TSAN)
61    add_subdirectory(tsan)
62  endif()
63  if(COMPILER_RT_HAS_UBSAN)
64    add_subdirectory(ubsan)
65  endif()
66  # CFI tests require diagnostic mode, which is implemented in UBSan.
67  if(COMPILER_RT_HAS_UBSAN)
68    add_subdirectory(cfi)
69  endif()
70  if(COMPILER_RT_HAS_SAFESTACK)
71    add_subdirectory(safestack)
72  endif()
73  if(COMPILER_RT_HAS_ESAN)
74    add_subdirectory(esan)
75  endif()
76  if(COMPILER_RT_HAS_SCUDO)
77    add_subdirectory(scudo)
78  endif()
79endif()
80
81if(COMPILER_RT_STANDALONE_BUILD)
82  # Now that we've traversed all the directories and know all the lit testsuites,
83  # introduce a rule to run to run all of them.
84  get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
85  get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS)
86  add_lit_target(check-all
87    "Running all regression tests"
88    ${LLVM_LIT_TESTSUITES}
89    DEPENDS ${LLVM_LIT_DEPENDS})
90endif()
91