Skip to content

Commit

Permalink
[OpenMP][libomptarget] Separate lit tests for different offloading ta…
Browse files Browse the repository at this point in the history
…rgets (1/2)

This patch creates a separate test directory for each offloading target to be
tested. This allows to test multiple architectures in one configuration, while
still see all failing tests separately. The lit test names include the target
triple, so that it will be easier to spot the failing target.

This patch also allows to mark expected failing tests based on the
target-triple, as the currently used triple is added to the lit "features":
```
// XFAIL: nvptx64-nvidia-cuda
```

Differential Revision: https://reviews.llvm.org/D101315
  • Loading branch information
jprotze committed Apr 27, 2021
1 parent fb7be0d commit b845217
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
15 changes: 11 additions & 4 deletions openmp/libomptarget/test/CMakeLists.txt
Expand Up @@ -12,8 +12,15 @@ else()
set(LIBOMPTARGET_DEBUG False)
endif()

add_openmp_testsuite(check-libomptarget "Running libomptarget tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS omptarget omp ${LIBOMPTARGET_TESTED_PLUGINS})
string(REGEX MATCHALL "([^\ ]+\ |[^\ ]+$)" SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}")
foreach(CURRENT_TARGET IN LISTS SYSTEM_TARGETS)
string(STRIP "${CURRENT_TARGET}" CURRENT_TARGET)
add_openmp_testsuite(check-libomptarget-${CURRENT_TARGET} "Running libomptarget tests" ${CMAKE_CURRENT_BINARY_DIR}/${CURRENT_TARGET} DEPENDS omptarget omp ${LIBOMPTARGET_TESTED_PLUGINS})
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 lit.site.cfg @ONLY)
# 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_openmp_testsuite(check-libomptarget "Running libomptarget tests" ${LIBOMPTARGET_LIT_TESTSUITES} EXCLUDE_FROM_CHECK_ALL DEPENDS omptarget omp ${LIBOMPTARGET_TESTED_PLUGINS})
30 changes: 28 additions & 2 deletions openmp/libomptarget/test/lit.cfg
Expand Up @@ -24,7 +24,7 @@ def append_dynamic_library_path(name, value, sep):
config.environment[name] = value

# name: The name of this test suite.
config.name = 'libomptarget'
config.name = 'libomptarget :: ' + config.libomptarget_current_target

# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.c', '.cpp', '.cc']
Expand Down Expand Up @@ -57,6 +57,8 @@ for feature in config.test_compiler_features:
if config.libomptarget_debug:
config.available_features.add('libomptarget-debug')

config.available_features.add(config.libomptarget_current_target)

# Setup environment to find dynamic library at runtime
if config.operating_system == 'Windows':
append_dynamic_library_path('PATH', config.library_dir, ";")
Expand Down Expand Up @@ -84,7 +86,31 @@ else: # Unices
for libomptarget_target in config.libomptarget_all_targets:
# Is this target in the current system? If so create a compile, run and test
# command. Otherwise create command that return false.
if libomptarget_target in config.libomptarget_system_targets:
if libomptarget_target == config.libomptarget_current_target:
config.substitutions.append(("%libomptarget-compilexx-run-and-check-generic",
"%libomptarget-compilexx-run-and-check-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compile-run-and-check-generic",
"%libomptarget-compile-run-and-check-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compilexx-and-run-generic",
"%libomptarget-compilexx-and-run-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compile-and-run-generic",
"%libomptarget-compile-and-run-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compilexx-generic",
"%libomptarget-compilexx-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compile-generic",
"%libomptarget-compile-" + libomptarget_target))
config.substitutions.append(("%libomptarget-run-generic",
"%libomptarget-run-" + libomptarget_target))
config.substitutions.append(("%libomptarget-run-fail-generic",
"%libomptarget-run-fail-" + libomptarget_target))
config.substitutions.append(("%clangxx-generic",
"%clangxx-" + libomptarget_target))
config.substitutions.append(("%clang-generic",
"%clang-" + libomptarget_target))
config.substitutions.append(("%fcheck-generic",
config.libomptarget_filecheck + " %s"))


config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \
libomptarget_target, \
"%libomptarget-compilexx-and-run-" + libomptarget_target + \
Expand Down
4 changes: 2 additions & 2 deletions openmp/libomptarget/test/lit.site.cfg.in
Expand Up @@ -5,13 +5,13 @@ config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@"
config.test_compiler_features = @OPENMP_TEST_COMPILER_FEATURES@
config.test_openmp_flags = "@OPENMP_TEST_OPENMP_FLAGS@"
config.test_extra_flags = "@OPENMP_TEST_FLAGS@"
config.libomptarget_obj_root = "@CMAKE_CURRENT_BINARY_DIR@"
config.libomptarget_obj_root = "@CMAKE_CURRENT_BINARY_DIR@/@CURRENT_TARGET@"
config.library_dir = "@LIBOMPTARGET_LIBRARY_DIR@"
config.omp_header_directory = "@LIBOMPTARGET_OPENMP_HEADER_FOLDER@"
config.omp_host_rtl_directory = "@LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER@"
config.operating_system = "@CMAKE_SYSTEM_NAME@"
config.libomptarget_all_targets = "@LIBOMPTARGET_ALL_TARGETS@".split()
config.libomptarget_system_targets = "@LIBOMPTARGET_SYSTEM_TARGETS@".split()
config.libomptarget_current_target = "@CURRENT_TARGET@"
config.libomptarget_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@"
config.libomptarget_not = "@OPENMP_NOT_EXECUTABLE@"
config.libomptarget_debug = @LIBOMPTARGET_DEBUG@
Expand Down

0 comments on commit b845217

Please sign in to comment.