| 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 |  | 
| Jordan Rose | 08bf4fd | 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 | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 37 |  | 
| Jordan Rose | 08bf4fd | 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 | df0b43d | 2013-01-22 01:52:04 +0000 | [diff] [blame] | 47 | llc opt FileCheck count not | 
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 48 | ) | 
| Chandler Carruth | 3bf1d5d | 2012-07-02 21:37:04 +0000 | [diff] [blame] | 49 |  | 
| Chandler Carruth | 8a62907 | 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 | 3bf1d5d | 2012-07-02 21:37:04 +0000 | [diff] [blame] | 52 | PARAMS ${CLANG_TEST_PARAMS} | 
| Chandler Carruth | 8a62907 | 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 | 6b963db | 2012-07-02 20:14:59 +0000 | [diff] [blame] | 63 | set(LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py") | 
| Chandler Carruth | 8a62907 | 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 | ff75d8d | 2011-02-23 12:07:49 +0000 | [diff] [blame] | 70 | endif() | 
| Oscar Fuentes | 84cb394 | 2011-02-05 19:08:56 +0000 | [diff] [blame] | 71 |  | 
| Chandler Carruth | 8a62907 | 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 | 08bf4fd | 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 | 30018a6 | 2009-06-05 23:57:17 +0000 | [diff] [blame] | 80 |  | 
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 81 | add_custom_target(check-clang | 
| Jeffrey Yasskin | cd3858b | 2011-02-15 07:54:28 +0000 | [diff] [blame] | 82 | COMMAND ${PYTHON_EXECUTABLE} | 
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 83 | ${LIT} | 
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 84 | ${LIT_ARGS} | 
|  | 85 | ${CMAKE_CURRENT_BINARY_DIR} | 
| Jordan Rose | 08bf4fd | 2013-02-08 07:28:25 +0000 | [diff] [blame^] | 86 | ${CLANG_TEST_EXTRA_ARGS} | 
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 87 | COMMENT "Running Clang regression tests" | 
| Jordan Rose | 08bf4fd | 2013-02-08 07:28:25 +0000 | [diff] [blame^] | 88 | DEPENDS ${CLANG_TEST_DEPS} | 
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 89 | ) | 
|  | 90 | set_target_properties(check-clang PROPERTIES FOLDER "Clang tests") | 
| NAKAMURA Takumi | 6657e97 | 2011-07-20 16:35:49 +0000 | [diff] [blame] | 91 | endif() | 
| NAKAMURA Takumi | b761ee6 | 2010-12-10 02:58:03 +0000 | [diff] [blame] | 92 |  | 
| Daniel Dunbar | a3b52d7 | 2009-11-03 07:25:53 +0000 | [diff] [blame] | 93 | endif() | 
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 94 |  | 
|  | 95 | # Add a legacy target spelling: clang-test | 
| Chandler Carruth | dc2e4bc | 2012-07-02 21:46:03 +0000 | [diff] [blame] | 96 | add_custom_target(clang-test) | 
|  | 97 | add_dependencies(clang-test check-clang) | 
| Chandler Carruth | 8a62907 | 2012-06-30 10:14:27 +0000 | [diff] [blame] | 98 | set_target_properties(clang-test PROPERTIES FOLDER "Clang tests") |