Adds a `check-offload-unit` target for running the liboffload unit test suite. This unit test binary runs the tests for every available device. This can optionally filtered to devices from a single platform, but the check target runs on everything. The target is not part of `check-offload` and does not get propagated to the top level build. I'm not sure if either of these things are desirable, but I'm happy to look into it if we want. Also remove the `offload/unittests/Plugins` test as it's dead code and doesn't build.
78 lines
2.7 KiB
CMake
78 lines
2.7 KiB
CMake
# CMakeLists.txt file for unit testing OpenMP offloading runtime library.
|
|
if(NOT OPENMP_TEST_COMPILER_ID STREQUAL "Clang" OR
|
|
OPENMP_TEST_COMPILER_VERSION VERSION_LESS 6.0.0)
|
|
message(STATUS "Can only test with Clang compiler in version 6.0.0 or later.")
|
|
message(WARNING "The check-offload target will not be available!")
|
|
return()
|
|
endif()
|
|
|
|
if(LIBOMPTARGET_ENABLE_DEBUG)
|
|
set(LIBOMPTARGET_DEBUG True)
|
|
else()
|
|
set(LIBOMPTARGET_DEBUG False)
|
|
endif()
|
|
|
|
if (NOT OPENMP_STANDALONE_BUILD AND "compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
|
|
set(LIBOMPTARGET_TEST_GPU_PGO True)
|
|
else()
|
|
set(LIBOMPTARGET_TEST_GPU_PGO False)
|
|
endif()
|
|
|
|
# Replace the space from user's input with ";" in case that CMake add escape
|
|
# char into the lit command.
|
|
string(REPLACE " " ";" LIBOMPTARGET_LIT_ARG_LIST "${LIBOMPTARGET_LIT_ARGS}")
|
|
|
|
find_package(CUDAToolkit QUIET)
|
|
if(CUDAToolkit_FOUND)
|
|
get_filename_component(CUDA_ROOT "${CUDAToolkit_BIN_DIR}" DIRECTORY ABSOLUTE)
|
|
get_filename_component(CUDA_LIBDIR "${CUDA_cudart_static_LIBRARY}" DIRECTORY)
|
|
endif()
|
|
|
|
set(OMP_DEPEND)
|
|
if(TARGET omp)
|
|
set(OMP_DEPEND omp)
|
|
endif()
|
|
|
|
string(REGEX MATCHALL "([^\ ]+\ |[^\ ]+$)" SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}")
|
|
foreach(CURRENT_TARGET IN LISTS SYSTEM_TARGETS)
|
|
string(STRIP "${CURRENT_TARGET}" CURRENT_TARGET)
|
|
|
|
add_offload_testsuite(check-libomptarget-${CURRENT_TARGET}
|
|
"Running libomptarget tests"
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CURRENT_TARGET}
|
|
DEPENDS omptarget ${OMP_DEPEND} ${LIBOMPTARGET_TESTED_PLUGINS}
|
|
ARGS ${LIBOMPTARGET_LIT_ARG_LIST})
|
|
list(APPEND LIBOMPTARGET_LIT_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CURRENT_TARGET})
|
|
|
|
# Configure the lit.site.cfg.in file
|
|
set(AUTO_GEN_COMMENT "## Autogenerated by libomptarget configuration.\n# Do not edit!")
|
|
configure_file(lit.site.cfg.in ${CURRENT_TARGET}/lit.site.cfg @ONLY)
|
|
endforeach()
|
|
|
|
|
|
add_offload_testsuite(check-libomptarget
|
|
"Running libomptarget tests"
|
|
${LIBOMPTARGET_LIT_TESTSUITES}
|
|
EXCLUDE_FROM_CHECK_ALL
|
|
DEPENDS llvm-offload-device-info omptarget ${OMP_DEPEND} ${LIBOMPTARGET_TESTED_PLUGINS}
|
|
ARGS ${LIBOMPTARGET_LIT_ARG_LIST})
|
|
|
|
add_offload_testsuite(check-offload
|
|
"Running libomptarget tests"
|
|
${LIBOMPTARGET_LIT_TESTSUITES}
|
|
EXCLUDE_FROM_CHECK_ALL
|
|
DEPENDS llvm-offload-device-info omptarget ${OMP_DEPEND} ${LIBOMPTARGET_TESTED_PLUGINS}
|
|
ARGS ${LIBOMPTARGET_LIT_ARG_LIST})
|
|
|
|
# Add liboffload unit tests - the test binary will run on all available devices
|
|
configure_lit_site_cfg(
|
|
${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg
|
|
MAIN_CONFIG
|
|
${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.cfg.py)
|
|
|
|
add_lit_testsuite(check-offload-unit "Running offload unittest suites"
|
|
${CMAKE_CURRENT_BINARY_DIR}/unit
|
|
EXCLUDE_FROM_CHECK_ALL
|
|
DEPENDS LLVMOffload OffloadUnitTests)
|