[Openmp-commits] [openmp] [WIP] [OpenMP] Add unit tests for nextgen plugins (PR #74398)

Jan Patrick Lehr via Openmp-commits openmp-commits at lists.llvm.org
Thu Dec 7 02:10:45 PST 2023


================
@@ -0,0 +1,146 @@
+#include "Shared/PluginAPI.h"
+#include "omptarget.h"
+#include "gtest/gtest.h"
+
+const int DEVICE_ID = 0, DEVICE_TWO = 1;
+bool setup_map[DEVICE_TWO + 1];
+
+int init_test_device(int ID) {
+  if (setup_map[ID]) {
+    return OFFLOAD_SUCCESS;
+  }
+  if (__tgt_rtl_init_plugin() == OFFLOAD_FAIL ||
+      __tgt_rtl_init_device(ID) == OFFLOAD_FAIL) {
+    return OFFLOAD_FAIL;
+  }
+  setup_map[ID] = true;
+  return OFFLOAD_SUCCESS;
+}
+
+// Test plugin initialization
+TEST(NextgenPluginsTest, PluginInit) {
----------------
jplehr wrote:

Is there a reason for not using a test fixture for this instead of the global variables?

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


More information about the Openmp-commits mailing list