Skip to content

Commit 4e54dde

Browse files
committed
Add test for DPCTLSyclPlatform_GetDevices to TestDPCTLSyclPlatformInterface
1 parent e5f56a4 commit 4e54dde

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

libsyclinterface/tests/test_sycl_platform_interface.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
//===----------------------------------------------------------------------===//
2626

2727
#include "dpctl_sycl_context_interface.h"
28+
#include "dpctl_sycl_device_interface.h"
2829
#include "dpctl_sycl_device_selector_interface.h"
2930
#include "dpctl_sycl_platform_interface.h"
3031
#include "dpctl_sycl_platform_manager.h"
@@ -92,6 +93,26 @@ void check_platform_default_context(
9293
EXPECT_NO_FATAL_FAILURE(DPCTLContext_Delete(CRef));
9394
}
9495

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

97118
struct TestDPCTLSyclPlatformInterface
@@ -282,6 +303,11 @@ TEST_P(TestDPCTLSyclPlatformInterface, ChkAreEqNullArg)
282303
ASSERT_TRUE(DPCTLPlatform_Hash(Null_PRef) == 0);
283304
}
284305

306+
TEST_P(TestDPCTLSyclPlatformInterface, ChkGetDevices)
307+
{
308+
check_platform_get_devices(PRef);
309+
}
310+
285311
TEST_F(TestDPCTLSyclDefaultPlatform, ChkGetName) { check_platform_name(PRef); }
286312

287313
TEST_F(TestDPCTLSyclDefaultPlatform, ChkGetVendor)

0 commit comments

Comments
 (0)