[llvm] [Offload] Add check-offload-unit for liboffload unittests (PR #137312)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 25 06:02:01 PDT 2025


================
@@ -63,3 +63,37 @@ add_offload_testsuite(check-offload
   EXCLUDE_FROM_CHECK_ALL
   DEPENDS llvm-offload-device-info omptarget ${OMP_DEPEND} ${LIBOMPTARGET_TESTED_PLUGINS}
   ARGS ${LIBOMPTARGET_LIT_ARG_LIST})
+
+# Add liboffload unit tests based on available devices rather than configured targets
+macro(add_offload_unittest_suite target_name)
+  set(OFFLOAD_PLATFORM ${target_name})
+  string(TOLOWER "${OFFLOAD_PLATFORM}" SUITE_NAME)
+
+  configure_lit_site_cfg(
+    ${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.in
+    ${CMAKE_CURRENT_BINARY_DIR}/unit/${SUITE_NAME}/lit.site.cfg
+    MAIN_CONFIG
+    ${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.cfg.py)
+
+  add_lit_testsuite(check-offload-unit-${SUITE_NAME} "Running offload unittest suite for ${SUITE_NAME}"
+    ${CMAKE_CURRENT_BINARY_DIR}/unit/${SUITE_NAME}
+    EXCLUDE_FROM_CHECK_ALL
+    DEPENDS OffloadUnitTests)
+
+  list(APPEND OFFLOAD_UNIT_TEST_SUITES ${CMAKE_CURRENT_BINARY_DIR}/unit/${SUITE_NAME})
+endmacro()
+
+set (OFFLOAD_UNIT_TEST_SUITES "")
+
+if (LIBOMPTARGET_FOUND_NVIDIA_GPU)
----------------
jhuber6 wrote:

I feel like the unit tests should be mostly generic. For the `lit` tests in OpenMP we have features that mark the tests as unsupported if it requires a specific GPU. For this, it'd probably be ideal to just return success if it's not an AMD GPU for example, that's still something to test.

https://github.com/llvm/llvm-project/pull/137312


More information about the llvm-commits mailing list