f4a2713ac8
Change-Id: Ia40e9ffdf29b5dab2f122f673ff6802a58bc690f
98 lines
2.8 KiB
CMake
98 lines
2.8 KiB
CMake
# Test runner infrastructure for Clang. This configures the Clang test trees
|
|
# for use by Lit, and delegates to LLVM's lit test handlers.
|
|
#
|
|
# If this is a stand-alone Clang build, we fake up our own Lit support here
|
|
# rather than relying on LLVM's.
|
|
|
|
set(CLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
|
set(CLANG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..")
|
|
|
|
configure_lit_site_cfg(
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
|
)
|
|
|
|
configure_lit_site_cfg(
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
|
|
)
|
|
|
|
if( PATH_TO_LLVM_BUILD )
|
|
set(CLANG_TEST_EXTRA_ARGS "--path=${CLANG_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}")
|
|
endif()
|
|
|
|
option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF)
|
|
if(CLANG_TEST_USE_VG)
|
|
set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg")
|
|
endif ()
|
|
|
|
set(CLANG_TEST_DEPS
|
|
clang clang-headers
|
|
c-index-test diagtool arcmt-test c-arcmt-test
|
|
clang-check clang-format
|
|
)
|
|
set(CLANG_TEST_PARAMS
|
|
clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
|
)
|
|
|
|
if(CLANG_INCLUDE_TESTS)
|
|
list(APPEND CLANG_TEST_DEPS ClangUnitTests)
|
|
list(APPEND CLANG_TEST_PARAMS
|
|
clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
|
|
)
|
|
endif()
|
|
|
|
if( NOT CLANG_BUILT_STANDALONE )
|
|
list(APPEND CLANG_TEST_DEPS
|
|
llc opt FileCheck count not llvm-symbolizer
|
|
)
|
|
|
|
add_lit_testsuite(check-clang "Running the Clang regression tests"
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
|
PARAMS ${CLANG_TEST_PARAMS}
|
|
DEPENDS ${CLANG_TEST_DEPS}
|
|
ARGS ${CLANG_TEST_EXTRA_ARGS}
|
|
)
|
|
set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
|
|
|
|
else()
|
|
|
|
include(FindPythonInterp)
|
|
if(PYTHONINTERP_FOUND)
|
|
if( LLVM_MAIN_SRC_DIR )
|
|
set(LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py")
|
|
else()
|
|
set(LIT "${PATH_TO_LLVM_BUILD}/bin/${CMAKE_CFG_INTDIR}/llvm-lit")
|
|
# Installed LLVM does not contain ${CMAKE_CFG_INTDIR} in paths.
|
|
if( NOT EXISTS ${LIT} )
|
|
set(LIT "${PATH_TO_LLVM_BUILD}/bin/llvm-lit")
|
|
endif()
|
|
endif()
|
|
|
|
set(LIT_ARGS "${CLANG_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}")
|
|
separate_arguments(LIT_ARGS)
|
|
|
|
list(APPEND CLANG_TEST_PARAMS build_mode=${CMAKE_CFG_INTDIR})
|
|
|
|
foreach(param ${CLANG_TEST_PARAMS})
|
|
list(APPEND LIT_ARGS --param ${param})
|
|
endforeach()
|
|
|
|
add_custom_target(check-clang
|
|
COMMAND ${PYTHON_EXECUTABLE}
|
|
${LIT}
|
|
${LIT_ARGS}
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
|
${CLANG_TEST_EXTRA_ARGS}
|
|
COMMENT "Running Clang regression tests"
|
|
DEPENDS ${CLANG_TEST_DEPS}
|
|
)
|
|
set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
|
|
endif()
|
|
|
|
endif()
|
|
|
|
# Add a legacy target spelling: clang-test
|
|
add_custom_target(clang-test)
|
|
add_dependencies(clang-test check-clang)
|
|
set_target_properties(clang-test PROPERTIES FOLDER "Clang tests")
|