1 # Needed for lit support in standalone builds.
4 pythonize_bool(LLVM_ENABLE_EXPENSIVE_CHECKS)
5 configure_compiler_rt_lit_site_cfg(
6 ${CMAKE_CURRENT_SOURCE_DIR}/lit.common.configured.in
7 ${CMAKE_CURRENT_BINARY_DIR}/lit.common.configured)
9 # BlocksRuntime (and most of builtins) testsuites are not yet ported to lit.
10 # add_subdirectory(BlocksRuntime)
12 set(SANITIZER_COMMON_LIT_TEST_DEPS)
14 if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
15 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS profile)
18 # When ANDROID, we build tests with the host compiler (i.e. CMAKE_C_COMPILER),
19 # and run tests with tools from the host toolchain.
21 if(NOT COMPILER_RT_STANDALONE_BUILD AND NOT RUNTIMES_BUILD)
22 # Use LLVM utils and Clang from the same build tree.
23 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS
24 clang clang-resource-headers FileCheck count not llvm-config llvm-nm llvm-objdump
25 llvm-readobj llvm-symbolizer compiler-rt-headers sancov)
27 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS KillTheDoctor)
32 function(compiler_rt_test_runtime runtime)
33 string(TOUPPER ${runtime} runtime_uppercase)
34 if(COMPILER_RT_HAS_${runtime_uppercase})
35 add_subdirectory(${runtime})
36 foreach(directory ${ARGN})
37 add_subdirectory(${directory})
42 # Run sanitizer tests only if we're sure that clang would produce
44 if(COMPILER_RT_CAN_EXECUTE_TESTS)
45 if(COMPILER_RT_BUILD_BUILTINS)
46 add_subdirectory(builtins)
48 if(COMPILER_RT_BUILD_SANITIZERS)
49 compiler_rt_test_runtime(interception)
51 compiler_rt_test_runtime(lsan)
52 # CFI tests require diagnostic mode, which is implemented in UBSan.
53 compiler_rt_test_runtime(ubsan cfi)
54 compiler_rt_test_runtime(sanitizer_common)
56 # OpenBSD not supporting asan, cannot run the tests
57 if(COMPILER_RT_BUILD_LIBFUZZER AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD" AND NOT ANDROID)
58 compiler_rt_test_runtime(fuzzer)
61 foreach(sanitizer ${COMPILER_RT_SANITIZERS_TO_BUILD})
62 # cfi testing is gated on ubsan
63 if(NOT ${sanitizer} STREQUAL cfi)
64 compiler_rt_test_runtime(${sanitizer})
68 if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
69 compiler_rt_test_runtime(profile)
71 if(COMPILER_RT_BUILD_XRAY)
72 compiler_rt_test_runtime(xray)
74 if(COMPILER_RT_BUILD_CRT AND COMPILER_RT_HAS_CRT)
77 # ShadowCallStack does not yet provide a runtime with compiler-rt, the tests
78 # include their own minimal runtime
79 add_subdirectory(shadowcallstack)
82 if(COMPILER_RT_STANDALONE_BUILD)
83 # Now that we've traversed all the directories and know all the lit testsuites,
84 # introduce a rule to run to run all of them.
85 get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
86 get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS)
87 add_lit_target(check-compiler-rt
88 "Running all regression tests"
89 ${LLVM_LIT_TESTSUITES}
90 DEPENDS ${LLVM_LIT_DEPENDS})
91 if(NOT TARGET check-all)
92 add_custom_target(check-all)
94 add_custom_target(compiler-rt-test-depends DEPENDS ${LLVM_LIT_DEPENDS})
95 add_dependencies(check-all check-compiler-rt)