Chandler Carruth | 82a53bd | 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 | eb357b6 | 2009-06-05 16:00:31 +0000 | [diff] [blame] | 6 | |
Daniel Dunbar | 1e63492 | 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 | 65cf624 | 2012-06-29 00:39:23 +0000 | [diff] [blame] | 10 | configure_lit_site_cfg( |
Daniel Dunbar | 1e63492 | 2009-11-07 23:53:32 +0000 | [diff] [blame] | 11 | ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in |
Chandler Carruth | 65cf624 | 2012-06-29 00:39:23 +0000 | [diff] [blame] | 12 | ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg |
| 13 | ) |
Daniel Dunbar | 1e63492 | 2009-11-07 23:53:32 +0000 | [diff] [blame] | 14 | |
Chandler Carruth | 65cf624 | 2012-06-29 00:39:23 +0000 | [diff] [blame] | 15 | configure_lit_site_cfg( |
NAKAMURA Takumi | c3189e9 | 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 | 65cf624 | 2012-06-29 00:39:23 +0000 | [diff] [blame] | 18 | ) |
NAKAMURA Takumi | c3189e9 | 2011-02-03 09:01:12 +0000 | [diff] [blame] | 19 | |
Chandler Carruth | 82a53bd | 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 | |
Jordan Rose | 6bbaa77 | 2013-02-08 07:28:25 +0000 | [diff] [blame] | 29 | set(CLANG_TEST_DEPS |
| 30 | clang clang-headers |
| 31 | c-index-test diagtool arcmt-test c-arcmt-test |
| 32 | clang-check |
| 33 | ) |
| 34 | set(CLANG_TEST_PARAMS |
| 35 | clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg |
| 36 | ) |
Chandler Carruth | 82a53bd | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 37 | |
Jordan Rose | 6bbaa77 | 2013-02-08 07:28:25 +0000 | [diff] [blame] | 38 | if(CLANG_INCLUDE_TESTS) |
| 39 | list(APPEND CLANG_TEST_DEPS ClangUnitTests) |
| 40 | list(APPEND CLANG_TEST_PARAMS |
| 41 | clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg |
| 42 | ) |
| 43 | endif() |
| 44 | |
| 45 | if( NOT CLANG_BUILT_STANDALONE ) |
| 46 | list(APPEND CLANG_TEST_DEPS |
NAKAMURA Takumi | cc128e9 | 2013-01-22 01:52:04 +0000 | [diff] [blame] | 47 | llc opt FileCheck count not |
Chandler Carruth | 82a53bd | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 48 | ) |
Chandler Carruth | 1e537f4 | 2012-07-02 21:37:04 +0000 | [diff] [blame] | 49 | |
Chandler Carruth | 82a53bd | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 50 | add_lit_testsuite(check-clang "Running the Clang regression tests" |
| 51 | ${CMAKE_CURRENT_BINARY_DIR} |
Chandler Carruth | 1e537f4 | 2012-07-02 21:37:04 +0000 | [diff] [blame] | 52 | PARAMS ${CLANG_TEST_PARAMS} |
Chandler Carruth | 82a53bd | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 53 | DEPENDS ${CLANG_TEST_DEPS} |
| 54 | ARGS ${CLANG_TEST_EXTRA_ARGS} |
| 55 | ) |
| 56 | set_target_properties(check-clang PROPERTIES FOLDER "Clang tests") |
| 57 | |
| 58 | else() |
| 59 | |
| 60 | include(FindPythonInterp) |
| 61 | if(PYTHONINTERP_FOUND) |
| 62 | if( LLVM_MAIN_SRC_DIR ) |
Chandler Carruth | 56e9b0d | 2012-07-02 20:14:59 +0000 | [diff] [blame] | 63 | set(LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py") |
Chandler Carruth | 82a53bd | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 64 | else() |
| 65 | set(LIT "${PATH_TO_LLVM_BUILD}/bin/${CMAKE_CFG_INTDIR}/llvm-lit") |
| 66 | # Installed LLVM does not contain ${CMAKE_CFG_INTDIR} in paths. |
| 67 | if( NOT EXISTS ${LIT} ) |
| 68 | set(LIT "${PATH_TO_LLVM_BUILD}/bin/llvm-lit") |
| 69 | endif() |
NAKAMURA Takumi | 378d2a1 | 2011-02-23 12:07:49 +0000 | [diff] [blame] | 70 | endif() |
Oscar Fuentes | 57ca32b | 2011-02-05 19:08:56 +0000 | [diff] [blame] | 71 | |
Chandler Carruth | 82a53bd | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 72 | set(LIT_ARGS "${CLANG_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}") |
| 73 | separate_arguments(LIT_ARGS) |
Jordan Rose | 6bbaa77 | 2013-02-08 07:28:25 +0000 | [diff] [blame] | 74 | |
| 75 | list(APPEND CLANG_TEST_PARAMS build_mode=${CMAKE_CFG_INTDIR}) |
| 76 | |
| 77 | foreach(param ${CLANG_TEST_PARAMS}) |
| 78 | list(APPEND LIT_ARGS --param ${param}) |
| 79 | endforeach() |
Douglas Gregor | 7986519 | 2009-06-05 23:57:17 +0000 | [diff] [blame] | 80 | |
Chandler Carruth | 82a53bd | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 81 | add_custom_target(check-clang |
Jeffrey Yasskin | 718b01d | 2011-02-15 07:54:28 +0000 | [diff] [blame] | 82 | COMMAND ${PYTHON_EXECUTABLE} |
Chandler Carruth | 82a53bd | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 83 | ${LIT} |
Chandler Carruth | 82a53bd | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 84 | ${LIT_ARGS} |
| 85 | ${CMAKE_CURRENT_BINARY_DIR} |
Jordan Rose | 6bbaa77 | 2013-02-08 07:28:25 +0000 | [diff] [blame] | 86 | ${CLANG_TEST_EXTRA_ARGS} |
Chandler Carruth | 82a53bd | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 87 | COMMENT "Running Clang regression tests" |
Jordan Rose | 6bbaa77 | 2013-02-08 07:28:25 +0000 | [diff] [blame] | 88 | DEPENDS ${CLANG_TEST_DEPS} |
Chandler Carruth | 82a53bd | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 89 | ) |
| 90 | set_target_properties(check-clang PROPERTIES FOLDER "Clang tests") |
NAKAMURA Takumi | 582c1fb | 2011-07-20 16:35:49 +0000 | [diff] [blame] | 91 | endif() |
NAKAMURA Takumi | f0d9d8b | 2010-12-10 02:58:03 +0000 | [diff] [blame] | 92 | |
Daniel Dunbar | e9a7323 | 2009-11-03 07:25:53 +0000 | [diff] [blame] | 93 | endif() |
Chandler Carruth | 82a53bd | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 94 | |
| 95 | # Add a legacy target spelling: clang-test |
Chandler Carruth | 4a26392 | 2012-07-02 21:46:03 +0000 | [diff] [blame] | 96 | add_custom_target(clang-test) |
| 97 | add_dependencies(clang-test check-clang) |
Chandler Carruth | 82a53bd | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 98 | set_target_properties(clang-test PROPERTIES FOLDER "Clang tests") |