[llvm] [offload] add parameterized unit tests (PR #209115)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 4 02:33:40 PDT 2026


================
@@ -204,46 +207,68 @@ struct OffloadDeviceTest
     return Backend;
   }
 
+  const OffloadParam<T> &getParamTuple() const { return this->GetParam(); }
+
+  const T &getTestParam() { return std::get<1>(getParamTuple()); }
+
   ol_device_handle_t Device = nullptr;
 };
 
-struct OffloadPlatformTest : OffloadDeviceTest {
+// In order to avoid code duplication, the unparameterized versions of fixtures
+// are aliases for parameterized fixtures, with `int` type chosen arbitrarily as
+// an ignored parameter type. The single mock parameter of value `0` is combined
+// with the devices in the provided macros, yielding tuples
+// `std::tuple<TestEnvironment::Device, int>`. The hidden `int` parameter is not
+// used, but it enables users to instantiate unparameterized tests without the
+// knowledge about the details related to the implementation of fixtures.
+// Moreover, it allows for modifying only one version of the fixture, without
+// the need to also change the other version: either parameterized or
+// unparameterized.
+using OffloadDeviceTest = OffloadDeviceTestWithParam<int>;
----------------
EuphoricThinking wrote:

I will try to reword it maybe

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


More information about the llvm-commits mailing list