Chris Bieneman | a58d065 | 2016-02-17 16:38:54 | [diff] [blame] | 1 | # Needed for lit support |
| 2 | include(AddLLVM) |
| 3 | |
Alexey Samsonov | 81a2b46 | 2014-02-14 11:00:07 | [diff] [blame] | 4 | configure_lit_site_cfg( |
| 5 | ${CMAKE_CURRENT_SOURCE_DIR}/lit.common.configured.in |
| 6 | ${CMAKE_CURRENT_BINARY_DIR}/lit.common.configured) |
| 7 | |
Erik Pilkington | 0490e1c5 | 2017-03-09 17:02:16 | [diff] [blame] | 8 | # BlocksRuntime (and most of builtins) testsuites are not yet ported to lit. |
Alexey Samsonov | 81a2b46 | 2014-02-14 11:00:07 | [diff] [blame] | 9 | # add_subdirectory(BlocksRuntime) |
Alexey Samsonov | ba869e7 | 2014-02-14 11:42:22 | [diff] [blame] | 10 | |
Alexey Samsonov | aa980c7 | 2014-02-19 10:04:29 | [diff] [blame] | 11 | set(SANITIZER_COMMON_LIT_TEST_DEPS) |
Filipe Cabecinhas | a1225be | 2015-02-20 03:41:07 | [diff] [blame] | 12 | if(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) |
| 16 | endif() |
| 17 | |
Alexey Samsonov | b73db72 | 2014-02-18 07:52:40 | [diff] [blame] | 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. |
Alexey Samsonov | aa980c7 | 2014-02-19 10:04:29 | [diff] [blame] | 20 | if(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 Samsonov | e243d45 | 2015-12-07 22:43:30 | [diff] [blame] | 24 | clang clang-headers FileCheck count not llvm-config llvm-nm llvm-objdump |
Reid Kleckner | e1e344e | 2016-11-14 17:37:50 | [diff] [blame] | 25 | llvm-readobj llvm-symbolizer compiler-rt-headers sancov) |
Reid Kleckner | 04748b9 | 2014-11-21 23:09:51 | [diff] [blame] | 26 | if (COMPILER_RT_HAS_PROFILE) |
| 27 | list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS profile) |
| 28 | endif() |
Peter Collingbourne | a68d90f | 2015-07-02 22:08:38 | [diff] [blame] | 29 | if (WIN32) |
| 30 | list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS KillTheDoctor) |
| 31 | endif() |
Alexey Samsonov | aa980c7 | 2014-02-19 10:04:29 | [diff] [blame] | 32 | endif() |
Sean Silva | 9af2570 | 2016-04-06 23:18:09 | [diff] [blame] | 33 | if(CMAKE_HOST_UNIX) |
Alexey Samsonov | b73db72 | 2014-02-18 07:52:40 | [diff] [blame] | 34 | list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS SanitizerLintCheck) |
| 35 | endif() |
| 36 | endif() |
| 37 | |
Francis Ricci | 57a3f45 | 2017-06-27 19:18:01 | [diff] [blame^] | 38 | function(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() |
| 46 | endfunction() |
| 47 | |
| 48 | function(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() |
| 54 | endfunction() |
| 55 | |
Alexey Samsonov | ba869e7 | 2014-02-14 11:42:22 | [diff] [blame] | 56 | # Run sanitizer tests only if we're sure that clang would produce |
| 57 | # working binaries. |
| 58 | if(COMPILER_RT_CAN_EXECUTE_TESTS) |
Erik Pilkington | 0490e1c5 | 2017-03-09 17:02:16 | [diff] [blame] | 59 | if(COMPILER_RT_BUILD_BUILTINS) |
| 60 | add_subdirectory(builtins) |
| 61 | endif() |
Michal Gorny | 2bcd94f | 2017-04-26 07:35:36 | [diff] [blame] | 62 | if(COMPILER_RT_BUILD_SANITIZERS) |
Francis Ricci | 57a3f45 | 2017-06-27 19:18:01 | [diff] [blame^] | 63 | compiler_rt_test_runtime(interception) |
| 64 | |
| 65 | compiler_rt_test_runtime(lsan) |
Francis Ricci | 07fa794 | 2017-06-27 17:24:26 | [diff] [blame] | 66 | # CFI tests require diagnostic mode, which is implemented in UBSan. |
Francis Ricci | 57a3f45 | 2017-06-27 19:18:01 | [diff] [blame^] | 67 | 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 Bieneman | 5c64ddf | 2015-12-10 00:40:58 | [diff] [blame] | 79 | endif() |
Francis Ricci | 57a3f45 | 2017-06-27 19:18:01 | [diff] [blame^] | 80 | if(COMPILER_RT_BUILD_XRAY) |
| 81 | compiler_rt_test_runtime(xray) |
Dean Michael Berris | 68e7484 | 2016-08-08 03:10:22 | [diff] [blame] | 82 | endif() |
Alexey Samsonov | ba869e7 | 2014-02-14 11:42:22 | [diff] [blame] | 83 | endif() |
Alexey Samsonov | 04e7ad2 | 2014-02-20 12:36:26 | [diff] [blame] | 84 | |
| 85 | if(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 Bieneman | 5968c3a | 2016-08-19 22:17:48 | [diff] [blame] | 90 | add_lit_target(check-compiler-rt |
Alexey Samsonov | 04e7ad2 | 2014-02-20 12:36:26 | [diff] [blame] | 91 | "Running all regression tests" |
| 92 | ${LLVM_LIT_TESTSUITES} |
| 93 | DEPENDS ${LLVM_LIT_DEPENDS}) |
Chris Bieneman | 5968c3a | 2016-08-19 22:17:48 | [diff] [blame] | 94 | if(NOT TARGET check-all) |
| 95 | add_custom_target(check-all) |
| 96 | endif() |
Chris Bieneman | 5f25462 | 2016-09-01 18:26:51 | [diff] [blame] | 97 | add_custom_target(compiler-rt-test-depends DEPENDS ${LLVM_LIT_DEPENDS}) |
Chris Bieneman | 5968c3a | 2016-08-19 22:17:48 | [diff] [blame] | 98 | add_dependencies(check-all check-compiler-rt) |
Alexey Samsonov | 04e7ad2 | 2014-02-20 12:36:26 | [diff] [blame] | 99 | endif() |