@@ -316,3 +316,71 @@ TEST_F(TestDPCTLDeviceMgrNullReference, ChkGetPositionInDevices)
316
316
EXPECT_NO_FATAL_FAILURE (
317
317
DPCTLDeviceMgr_GetPositionInDevices (nullDRef, mask));
318
318
}
319
+
320
+ struct TestDPCTLGetCompositeDevices : public ::testing::Test
321
+ {
322
+ DPCTLDeviceVectorRef DV = nullptr ;
323
+ size_t nDevices = 0 ;
324
+
325
+ TestDPCTLGetCompositeDevices ()
326
+ {
327
+ EXPECT_NO_FATAL_FAILURE (DV = DPCTLDeviceMgr_GetCompositeDevices ());
328
+ EXPECT_TRUE (DV != nullptr );
329
+ EXPECT_NO_FATAL_FAILURE (nDevices = DPCTLDeviceVector_Size (DV));
330
+ }
331
+
332
+ void SetUp ()
333
+ {
334
+ if (!nDevices) {
335
+ GTEST_SKIP_ (" Skipping as no composite devices available" );
336
+ }
337
+ }
338
+
339
+ ~TestDPCTLGetCompositeDevices ()
340
+ {
341
+ EXPECT_NO_FATAL_FAILURE (DPCTLDeviceVector_Clear (DV));
342
+ EXPECT_NO_FATAL_FAILURE (DPCTLDeviceVector_Delete (DV));
343
+ }
344
+ };
345
+
346
+ TEST_F (TestDPCTLGetCompositeDevices, ChkGetAt)
347
+ {
348
+ for (auto i = 0ul ; i < nDevices; ++i) {
349
+ DPCTLSyclDeviceRef DRef = nullptr ;
350
+ EXPECT_NO_FATAL_FAILURE (DRef = DPCTLDeviceVector_GetAt (DV, i));
351
+ ASSERT_TRUE (DRef != nullptr );
352
+ }
353
+ }
354
+
355
+ TEST_F (TestDPCTLGetCompositeDevices, ChkCompositeAspect)
356
+ {
357
+ for (auto i = 0ul ; i < nDevices; ++i) {
358
+ DPCTLSyclDeviceRef DRef = nullptr ;
359
+ EXPECT_NO_FATAL_FAILURE (DRef = DPCTLDeviceVector_GetAt (DV, i));
360
+ ASSERT_TRUE (DRef != nullptr );
361
+ ASSERT_TRUE (
362
+ DPCTLDevice_HasAspect (DRef, DPCTLSyclAspectType::is_composite));
363
+ }
364
+ }
365
+
366
+ TEST_F (TestDPCTLGetCompositeDevices, ChkComponentDevices)
367
+ {
368
+ for (auto i = 0ul ; i < nDevices; ++i) {
369
+ DPCTLSyclDeviceRef DRef = nullptr ;
370
+ EXPECT_NO_FATAL_FAILURE (DRef = DPCTLDeviceVector_GetAt (DV, i));
371
+ ASSERT_TRUE (DRef != nullptr );
372
+ DPCTLDeviceVectorRef CDV = nullptr ;
373
+ size_t nComponents = 0 ;
374
+ EXPECT_NO_FATAL_FAILURE (CDV = DPCTLDevice_GetComponentDevices (DRef));
375
+ EXPECT_NO_FATAL_FAILURE (nComponents = DPCTLDeviceVector_Size (CDV));
376
+ for (auto j = 0ul ; j < nComponents; ++j) {
377
+ DPCTLSyclDeviceRef CDRef = nullptr ;
378
+ EXPECT_NO_FATAL_FAILURE (CDRef = DPCTLDeviceVector_GetAt (CDV, j));
379
+ ASSERT_TRUE (CDRef != nullptr );
380
+ ASSERT_TRUE (DPCTLDevice_HasAspect (
381
+ CDRef, DPCTLSyclAspectType::is_component));
382
+ }
383
+ EXPECT_NO_FATAL_FAILURE (DPCTLDeviceVector_Clear (CDV));
384
+ EXPECT_NO_FATAL_FAILURE (DPCTLDeviceVector_Delete (CDV));
385
+ }
386
+ }
0 commit comments