| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 1 | # Test runner infrastructure for Clang. This configures the Clang test trees |
| 2 | # for use by Lit, and delegates to LLVM's lit test handlers. |
| 3 | # |
| 4 | # If this is a stand-alone Clang build, we fake up our own Lit support here |
| 5 | # rather than relying on LLVM's. |
| Douglas Gregor | 0770532 | 2009-06-05 16:00:31 +0000 | [diff] [blame] | 6 | |
| Daniel Dunbar | 0669670 | 2009-11-07 23:53:32 +0000 | [diff] [blame] | 7 | set(CLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") |
| 8 | set(CLANG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..") |
| 9 | |
| Chandler Carruth | 8279aa7 | 2012-06-29 00:39:23 +0000 | [diff] [blame] | 10 | configure_lit_site_cfg( |
| Daniel Dunbar | 0669670 | 2009-11-07 23:53:32 +0000 | [diff] [blame] | 11 | ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in |
| Chandler Carruth | 8279aa7 | 2012-06-29 00:39:23 +0000 | [diff] [blame] | 12 | ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg |
| 13 | ) |
| Daniel Dunbar | 0669670 | 2009-11-07 23:53:32 +0000 | [diff] [blame] | 14 | |
| Chandler Carruth | 8279aa7 | 2012-06-29 00:39:23 +0000 | [diff] [blame] | 15 | configure_lit_site_cfg( |
| NAKAMURA Takumi | 22ec660 | 2011-02-03 09:01:12 +0000 | [diff] [blame] | 16 | ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in |
| 17 | ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg |
| Chandler Carruth | 8279aa7 | 2012-06-29 00:39:23 +0000 | [diff] [blame] | 18 | ) |
| NAKAMURA Takumi | 22ec660 | 2011-02-03 09:01:12 +0000 | [diff] [blame] | 19 | |
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 20 | if( PATH_TO_LLVM_BUILD ) |
| 21 | set(CLANG_TEST_EXTRA_ARGS "--path=${CLANG_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}") |
| 22 | endif() |
| 23 | |
| 24 | option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF) |
| 25 | if(CLANG_TEST_USE_VG) |
| 26 | set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg") |
| 27 | endif () |
| 28 | |
| 29 | if( NOT CLANG_BUILT_STANDALONE ) |
| 30 | |
| 31 | set(CLANG_TEST_DEPS |
| 32 | clang clang-headers |
| 33 | c-index-test diagtool arcmt-test c-arcmt-test |
| 34 | clang-check |
| 35 | llvm-dis llc opt FileCheck count not |
| 36 | ) |
| Chandler Carruth | 3bf1d5d | 2012-07-02 21:37:04 +0000 | [diff] [blame] | 37 | set(CLANG_TEST_PARAMS |
| 38 | clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg |
| 39 | ) |
| 40 | |
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 41 | if(LLVM_INCLUDE_TESTS) |
| 42 | list(APPEND CLANG_TEST_DEPS ClangUnitTests) |
| Chandler Carruth | 3bf1d5d | 2012-07-02 21:37:04 +0000 | [diff] [blame] | 43 | list(APPEND CLANG_TEST_PARAMS |
| 44 | clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg |
| 45 | ) |
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 46 | endif() |
| 47 | add_lit_testsuite(check-clang "Running the Clang regression tests" |
| 48 | ${CMAKE_CURRENT_BINARY_DIR} |
| Chandler Carruth | 3bf1d5d | 2012-07-02 21:37:04 +0000 | [diff] [blame] | 49 | PARAMS ${CLANG_TEST_PARAMS} |
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 50 | DEPENDS ${CLANG_TEST_DEPS} |
| 51 | ARGS ${CLANG_TEST_EXTRA_ARGS} |
| 52 | ) |
| 53 | set_target_properties(check-clang PROPERTIES FOLDER "Clang tests") |
| 54 | |
| 55 | else() |
| 56 | |
| 57 | include(FindPythonInterp) |
| 58 | if(PYTHONINTERP_FOUND) |
| 59 | if( LLVM_MAIN_SRC_DIR ) |
| Chandler Carruth | 6b963db | 2012-07-02 20:14:59 +0000 | [diff] [blame] | 60 | set(LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py") |
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 61 | else() |
| 62 | set(LIT "${PATH_TO_LLVM_BUILD}/bin/${CMAKE_CFG_INTDIR}/llvm-lit") |
| 63 | # Installed LLVM does not contain ${CMAKE_CFG_INTDIR} in paths. |
| 64 | if( NOT EXISTS ${LIT} ) |
| 65 | set(LIT "${PATH_TO_LLVM_BUILD}/bin/llvm-lit") |
| 66 | endif() |
| NAKAMURA Takumi | ff75d8d | 2011-02-23 12:07:49 +0000 | [diff] [blame] | 67 | endif() |
| Oscar Fuentes | 84cb394 | 2011-02-05 19:08:56 +0000 | [diff] [blame] | 68 | |
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 69 | set(LIT_ARGS "${CLANG_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}") |
| 70 | separate_arguments(LIT_ARGS) |
| Douglas Gregor | 30018a6 | 2009-06-05 23:57:17 +0000 | [diff] [blame] | 71 | |
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 72 | add_custom_target(check-clang |
| Jeffrey Yasskin | cd3858b | 2011-02-15 07:54:28 +0000 | [diff] [blame] | 73 | COMMAND ${PYTHON_EXECUTABLE} |
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 74 | ${LIT} |
| 75 | --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg |
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 76 | --param build_config=${CMAKE_CFG_INTDIR} |
| 77 | --param build_mode=${RUNTIME_BUILD_MODE} |
| 78 | ${LIT_ARGS} |
| 79 | ${CMAKE_CURRENT_BINARY_DIR} |
| 80 | COMMENT "Running Clang regression tests" |
| 81 | DEPENDS clang clang-headers |
| 82 | c-index-test diagtool arcmt-test c-arcmt-test |
| 83 | clang-check |
| 84 | ) |
| 85 | set_target_properties(check-clang PROPERTIES FOLDER "Clang tests") |
| NAKAMURA Takumi | 6657e97 | 2011-07-20 16:35:49 +0000 | [diff] [blame] | 86 | endif() |
| NAKAMURA Takumi | b761ee6 | 2010-12-10 02:58:03 +0000 | [diff] [blame] | 87 | |
| Daniel Dunbar | a3b52d7 | 2009-11-03 07:25:53 +0000 | [diff] [blame] | 88 | endif() |
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 89 | |
| 90 | # Add a legacy target spelling: clang-test |
| Chandler Carruth | dc2e4bc | 2012-07-02 21:46:03 +0000 | [diff] [blame^] | 91 | add_custom_target(clang-test) |
| 92 | add_dependencies(clang-test check-clang) |
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 93 | set_target_properties(clang-test PROPERTIES FOLDER "Clang tests") |