blob: 040d19bcc3b6f110273b3ef6fceead2c091f23f5 [file] [log] [blame]
Chris Bienemana58d0652016-02-17 16:38:541# Needed for lit support
2include(AddLLVM)
3
Alexey Samsonov81a2b462014-02-14 11:00:074configure_lit_site_cfg(
5 ${CMAKE_CURRENT_SOURCE_DIR}/lit.common.configured.in
6 ${CMAKE_CURRENT_BINARY_DIR}/lit.common.configured)
7
Erik Pilkington0490e1c52017-03-09 17:02:168# BlocksRuntime (and most of builtins) testsuites are not yet ported to lit.
Alexey Samsonov81a2b462014-02-14 11:00:079# add_subdirectory(BlocksRuntime)
Alexey Samsonovba869e72014-02-14 11:42:2210
Alexey Samsonovaa980c72014-02-19 10:04:2911set(SANITIZER_COMMON_LIT_TEST_DEPS)
Filipe Cabecinhasa1225be2015-02-20 03:41:0712if(COMPILER_RT_STANDALONE_BUILD)
13 add_executable(FileCheck IMPORTED GLOBAL)
14 set_property(TARGET FileCheck PROPERTY IMPORTED_LOCATION ${LLVM_TOOLS_BINARY_DIR}/FileCheck)
15 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS FileCheck)
16endif()
17
Alexey Samsonovb73db722014-02-18 07:52:4018# When ANDROID, we build tests with the host compiler (i.e. CMAKE_C_COMPILER),
19# and run tests with tools from the host toolchain.
Alexey Samsonovaa980c72014-02-19 10:04:2920if(NOT ANDROID)
21 if(NOT COMPILER_RT_STANDALONE_BUILD)
22 # Use LLVM utils and Clang from the same build tree.
23 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS
Alexey Samsonove243d452015-12-07 22:43:3024 clang clang-headers FileCheck count not llvm-config llvm-nm llvm-objdump
Reid Klecknere1e344e2016-11-14 17:37:5025 llvm-readobj llvm-symbolizer compiler-rt-headers sancov)
Reid Kleckner04748b92014-11-21 23:09:5126 if (COMPILER_RT_HAS_PROFILE)
27 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS profile)
28 endif()
Peter Collingbournea68d90f2015-07-02 22:08:3829 if (WIN32)
30 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS KillTheDoctor)
31 endif()
Alexey Samsonovaa980c72014-02-19 10:04:2932 endif()
Sean Silva9af25702016-04-06 23:18:0933 if(CMAKE_HOST_UNIX)
Alexey Samsonovb73db722014-02-18 07:52:4034 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS SanitizerLintCheck)
35 endif()
36endif()
37
Francis Ricci57a3f452017-06-27 19:18:0138function(compiler_rt_test_runtime runtime)
39 string(TOUPPER ${runtime} runtime_uppercase)
40 if(COMPILER_RT_HAS_${runtime_uppercase})
41 add_subdirectory(${runtime})
42 foreach(directory ${ARGN})
43 add_subdirectory(${directory})
44 endforeach()
45 endif()
46endfunction()
47
48function(compiler_rt_test_sanitizer sanitizer)
49 string(TOLOWER ${sanitizer} sanitizer_lowercase)
50 list(FIND COMPILER_RT_SANITIZERS_TO_BUILD ${sanitizer_lowercase} result)
51 if(NOT ${result} EQUAL -1)
52 compiler_rt_test_runtime(${sanitizer} ${ARGN})
53 endif()
54endfunction()
55
Alexey Samsonovba869e72014-02-14 11:42:2256# Run sanitizer tests only if we're sure that clang would produce
57# working binaries.
58if(COMPILER_RT_CAN_EXECUTE_TESTS)
Erik Pilkington0490e1c52017-03-09 17:02:1659 if(COMPILER_RT_BUILD_BUILTINS)
60 add_subdirectory(builtins)
61 endif()
Michal Gorny2bcd94f2017-04-26 07:35:3662 if(COMPILER_RT_BUILD_SANITIZERS)
Francis Ricci57a3f452017-06-27 19:18:0163 compiler_rt_test_runtime(interception)
64
65 compiler_rt_test_runtime(lsan)
Francis Ricci07fa7942017-06-27 17:24:2666 # CFI tests require diagnostic mode, which is implemented in UBSan.
Francis Ricci57a3f452017-06-27 19:18:0167 compiler_rt_test_runtime(ubsan cfi)
68 compiler_rt_test_runtime(sanitizer_common)
69
70 compiler_rt_test_sanitizer(asan)
71 compiler_rt_test_sanitizer(dfsan)
72 compiler_rt_test_sanitizer(msan)
73 compiler_rt_test_sanitizer(tsan)
74 compiler_rt_test_sanitizer(safestack)
75 compiler_rt_test_sanitizer(esan)
76 compiler_rt_test_sanitizer(scudo)
77
78 compiler_rt_test_runtime(profile)
Chris Bieneman5c64ddf2015-12-10 00:40:5879 endif()
Francis Ricci57a3f452017-06-27 19:18:0180 if(COMPILER_RT_BUILD_XRAY)
81 compiler_rt_test_runtime(xray)
Dean Michael Berris68e74842016-08-08 03:10:2282 endif()
Alexey Samsonovba869e72014-02-14 11:42:2283endif()
Alexey Samsonov04e7ad22014-02-20 12:36:2684
85if(COMPILER_RT_STANDALONE_BUILD)
86 # Now that we've traversed all the directories and know all the lit testsuites,
87 # introduce a rule to run to run all of them.
88 get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
89 get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS)
Chris Bieneman5968c3a2016-08-19 22:17:4890 add_lit_target(check-compiler-rt
Alexey Samsonov04e7ad22014-02-20 12:36:2691 "Running all regression tests"
92 ${LLVM_LIT_TESTSUITES}
93 DEPENDS ${LLVM_LIT_DEPENDS})
Chris Bieneman5968c3a2016-08-19 22:17:4894 if(NOT TARGET check-all)
95 add_custom_target(check-all)
96 endif()
Chris Bieneman5f254622016-09-01 18:26:5197 add_custom_target(compiler-rt-test-depends DEPENDS ${LLVM_LIT_DEPENDS})
Chris Bieneman5968c3a2016-08-19 22:17:4898 add_dependencies(check-all check-compiler-rt)
Alexey Samsonov04e7ad22014-02-20 12:36:2699endif()