blob: 8da2ba4ab44814b97076f937ea164b7fe073f35b [file] [log] [blame]
Chandler Carruth82a53bd2012-06-30 10:14:27 +00001# 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 Gregoreb357b62009-06-05 16:00:31 +00006
Daniel Dunbar1e634922009-11-07 23:53:32 +00007set(CLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
8set(CLANG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..")
9
Chandler Carruth65cf6242012-06-29 00:39:23 +000010configure_lit_site_cfg(
Daniel Dunbar1e634922009-11-07 23:53:32 +000011 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
Chandler Carruth65cf6242012-06-29 00:39:23 +000012 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
13 )
Daniel Dunbar1e634922009-11-07 23:53:32 +000014
Chandler Carruth65cf6242012-06-29 00:39:23 +000015configure_lit_site_cfg(
NAKAMURA Takumic3189e92011-02-03 09:01:12 +000016 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
17 ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
Chandler Carruth65cf6242012-06-29 00:39:23 +000018 )
NAKAMURA Takumic3189e92011-02-03 09:01:12 +000019
Chandler Carruth82a53bd2012-06-30 10:14:27 +000020if( PATH_TO_LLVM_BUILD )
21 set(CLANG_TEST_EXTRA_ARGS "--path=${CLANG_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}")
22endif()
23
24option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF)
25if(CLANG_TEST_USE_VG)
26 set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg")
27endif ()
28
Jordan Rose6bbaa772013-02-08 07:28:25 +000029set(CLANG_TEST_DEPS
30 clang clang-headers
31 c-index-test diagtool arcmt-test c-arcmt-test
32 clang-check
33 )
34set(CLANG_TEST_PARAMS
35 clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
36 )
Chandler Carruth82a53bd2012-06-30 10:14:27 +000037
Jordan Rose6bbaa772013-02-08 07:28:25 +000038if(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 )
43endif()
44
45if( NOT CLANG_BUILT_STANDALONE )
46 list(APPEND CLANG_TEST_DEPS
NAKAMURA Takumicc128e92013-01-22 01:52:04 +000047 llc opt FileCheck count not
Chandler Carruth82a53bd2012-06-30 10:14:27 +000048 )
Chandler Carruth1e537f42012-07-02 21:37:04 +000049
Chandler Carruth82a53bd2012-06-30 10:14:27 +000050 add_lit_testsuite(check-clang "Running the Clang regression tests"
51 ${CMAKE_CURRENT_BINARY_DIR}
Chandler Carruth1e537f42012-07-02 21:37:04 +000052 PARAMS ${CLANG_TEST_PARAMS}
Chandler Carruth82a53bd2012-06-30 10:14:27 +000053 DEPENDS ${CLANG_TEST_DEPS}
54 ARGS ${CLANG_TEST_EXTRA_ARGS}
55 )
56 set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
57
58else()
59
60 include(FindPythonInterp)
61 if(PYTHONINTERP_FOUND)
62 if( LLVM_MAIN_SRC_DIR )
Chandler Carruth56e9b0d2012-07-02 20:14:59 +000063 set(LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py")
Chandler Carruth82a53bd2012-06-30 10:14:27 +000064 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 Takumi378d2a12011-02-23 12:07:49 +000070 endif()
Oscar Fuentes57ca32b2011-02-05 19:08:56 +000071
Chandler Carruth82a53bd2012-06-30 10:14:27 +000072 set(LIT_ARGS "${CLANG_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}")
73 separate_arguments(LIT_ARGS)
Jordan Rose6bbaa772013-02-08 07:28:25 +000074
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 Gregor79865192009-06-05 23:57:17 +000080
Chandler Carruth82a53bd2012-06-30 10:14:27 +000081 add_custom_target(check-clang
Jeffrey Yasskin718b01d2011-02-15 07:54:28 +000082 COMMAND ${PYTHON_EXECUTABLE}
Chandler Carruth82a53bd2012-06-30 10:14:27 +000083 ${LIT}
Chandler Carruth82a53bd2012-06-30 10:14:27 +000084 ${LIT_ARGS}
85 ${CMAKE_CURRENT_BINARY_DIR}
Jordan Rose6bbaa772013-02-08 07:28:25 +000086 ${CLANG_TEST_EXTRA_ARGS}
Chandler Carruth82a53bd2012-06-30 10:14:27 +000087 COMMENT "Running Clang regression tests"
Jordan Rose6bbaa772013-02-08 07:28:25 +000088 DEPENDS ${CLANG_TEST_DEPS}
Chandler Carruth82a53bd2012-06-30 10:14:27 +000089 )
90 set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
NAKAMURA Takumi582c1fb2011-07-20 16:35:49 +000091 endif()
NAKAMURA Takumif0d9d8b2010-12-10 02:58:03 +000092
Daniel Dunbare9a73232009-11-03 07:25:53 +000093endif()
Chandler Carruth82a53bd2012-06-30 10:14:27 +000094
95# Add a legacy target spelling: clang-test
Chandler Carruth4a263922012-07-02 21:46:03 +000096add_custom_target(clang-test)
97add_dependencies(clang-test check-clang)
Chandler Carruth82a53bd2012-06-30 10:14:27 +000098set_target_properties(clang-test PROPERTIES FOLDER "Clang tests")