Skip to content

Commit 459df31

Browse files
committed
Add test for DPCTLSyclPlatform_GetDevices toTestDPCTLSyclPlatformInterface
1 parent 481d266 commit 459df31

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

libsyclinterface/tests/test_sycl_platform_interface.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,26 @@ void check_platform_default_context(
9292
EXPECT_NO_FATAL_FAILURE(DPCTLContext_Delete(CRef));
9393
}
9494

95+
void check_platform_get_devices(__dpctl_keep const DPCTLSyclPlatformRef PRef)
96+
{
97+
DPCTLDeviceVectorRef DVRef = nullptr;
98+
size_t nDevices = 0;
99+
100+
DPCTLSyclDeviceType defDTy = DPCTLSyclDeviceType::DPCTL_ALL;
101+
EXPECT_NO_FATAL_FAILURE(DVRef = DPCTLPlatform_GetDevices(PRef, defDTy));
102+
EXPECT_TRUE(DVRef != nullptr);
103+
EXPECT_NO_FATAL_FAILURE(nDevices = DPCTLDeviceVector_Size(DVRef));
104+
for (auto i = 0ul; i < nDevices; ++i) {
105+
DPCTLSyclDeviceRef DRef = nullptr;
106+
EXPECT_NO_FATAL_FAILURE(DRef = DPCTLDeviceVector_GetAt(DV, i));
107+
ASSERT_TRUE(DRef != nullptr);
108+
EXPECT_NO_FATAL_FAILURE(DPCTLDevice_Delete(DRef));
109+
}
110+
111+
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceVector_Clear(DVRef));
112+
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceVector_Delete(DVRef));
113+
}
114+
95115
} // namespace
96116

97117
struct TestDPCTLSyclPlatformInterface
@@ -282,6 +302,11 @@ TEST_P(TestDPCTLSyclPlatformInterface, ChkAreEqNullArg)
282302
ASSERT_TRUE(DPCTLPlatform_Hash(Null_PRef) == 0);
283303
}
284304

305+
TEST_P(TestDPCTLSyclPlatformInterface, ChkGetDevices)
306+
{
307+
check_platform_get_devices(PRef);
308+
}
309+
285310
TEST_F(TestDPCTLSyclDefaultPlatform, ChkGetName) { check_platform_name(PRef); }
286311

287312
TEST_F(TestDPCTLSyclDefaultPlatform, ChkGetVendor)

0 commit comments

Comments
 (0)