blob: 8184c3d3638acc262b812619fdf988643c84a82a [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
29if( NOT CLANG_BUILT_STANDALONE )
30
31 set(CLANG_TEST_DEPS
32 clang clang-headers
33 c-index-test diagtool arcmt-test c-arcmt-test
Alexander Kornienko77b1ae52012-07-26 01:44:18 +000034 clang-check
Chandler Carruth82a53bd2012-06-30 10:14:27 +000035 llvm-dis llc opt FileCheck count not
36 )
Chandler Carruth1e537f42012-07-02 21:37:04 +000037 set(CLANG_TEST_PARAMS
38 clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
39 )
40
Chandler Carruth82a53bd2012-06-30 10:14:27 +000041 if(LLVM_INCLUDE_TESTS)
42 list(APPEND CLANG_TEST_DEPS ClangUnitTests)
Chandler Carruth1e537f42012-07-02 21:37:04 +000043 list(APPEND CLANG_TEST_PARAMS
44 clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
45 )
Chandler Carruth82a53bd2012-06-30 10:14:27 +000046 endif()
47 add_lit_testsuite(check-clang "Running the Clang regression tests"
48 ${CMAKE_CURRENT_BINARY_DIR}
Chandler Carruth1e537f42012-07-02 21:37:04 +000049 PARAMS ${CLANG_TEST_PARAMS}
Chandler Carruth82a53bd2012-06-30 10:14:27 +000050 DEPENDS ${CLANG_TEST_DEPS}
51 ARGS ${CLANG_TEST_EXTRA_ARGS}
52 )
53 set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
54
55else()
56
57 include(FindPythonInterp)
58 if(PYTHONINTERP_FOUND)
59 if( LLVM_MAIN_SRC_DIR )
Chandler Carruth56e9b0d2012-07-02 20:14:59 +000060 set(LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py")
Chandler Carruth82a53bd2012-06-30 10:14:27 +000061 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 Takumi378d2a12011-02-23 12:07:49 +000067 endif()
Oscar Fuentes57ca32b2011-02-05 19:08:56 +000068
Chandler Carruth82a53bd2012-06-30 10:14:27 +000069 set(LIT_ARGS "${CLANG_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}")
70 separate_arguments(LIT_ARGS)
Douglas Gregor79865192009-06-05 23:57:17 +000071
Chandler Carruth82a53bd2012-06-30 10:14:27 +000072 add_custom_target(check-clang
Jeffrey Yasskin718b01d2011-02-15 07:54:28 +000073 COMMAND ${PYTHON_EXECUTABLE}
Chandler Carruth82a53bd2012-06-30 10:14:27 +000074 ${LIT}
75 --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
Chandler Carruth82a53bd2012-06-30 10:14:27 +000076 --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
Alexander Kornienko77b1ae52012-07-26 01:44:18 +000083 clang-check
Chandler Carruth82a53bd2012-06-30 10:14:27 +000084 )
85 set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
NAKAMURA Takumi582c1fb2011-07-20 16:35:49 +000086 endif()
NAKAMURA Takumif0d9d8b2010-12-10 02:58:03 +000087
Daniel Dunbare9a73232009-11-03 07:25:53 +000088endif()
Chandler Carruth82a53bd2012-06-30 10:14:27 +000089
90# Add a legacy target spelling: clang-test
Chandler Carruth4a263922012-07-02 21:46:03 +000091add_custom_target(clang-test)
92add_dependencies(clang-test check-clang)
Chandler Carruth82a53bd2012-06-30 10:14:27 +000093set_target_properties(clang-test PROPERTIES FOLDER "Clang tests")