@@ -98,6 +98,7 @@ TEST_F(clGetDeviceIDsTests, GivenDeviceTypeCpuWhenGettingDeviceIdsThenDeviceNotF
9898}
9999
100100TEST (clGetDeviceIDsTest, givenMultipleRootDevicesWhenGetDeviceIdsThenAllRootDevicesAreReturned) {
101+ platformsImpl.clear ();
101102 constexpr auto numRootDevices = 3u ;
102103 VariableBackup<UltHwConfig> backup (&ultHwConfig);
103104 ultHwConfig.useMockedGetDevicesFunc = false ;
@@ -114,6 +115,7 @@ TEST(clGetDeviceIDsTest, givenMultipleRootDevicesWhenGetDeviceIdsThenAllRootDevi
114115 }
115116}
116117TEST (clGetDeviceIDsTest, givenMultipleRootDevicesWhenGetDeviceIdsButNumEntriesIsLowerThanNumDevicesThenSubsetOfRootDevicesIsReturned) {
118+ platformsImpl.clear ();
117119 constexpr auto numRootDevices = 3u ;
118120 VariableBackup<UltHwConfig> backup (&ultHwConfig);
119121 ultHwConfig.useMockedGetDevicesFunc = false ;
@@ -144,6 +146,7 @@ TEST(clGetDeviceIDsTest, givenMultipleRootDevicesWhenGetDeviceIdsButNumEntriesIs
144146}
145147
146148TEST (clGetDeviceIDsTest, givenMultipleRootDevicesAndLimitedNumberOfReturnedDevicesWhenGetDeviceIdsThenLimitedNumberOfRootDevicesIsReturned) {
149+ platformsImpl.clear ();
147150 constexpr auto numRootDevices = 3u ;
148151 VariableBackup<UltHwConfig> backup (&ultHwConfig);
149152 ultHwConfig.useMockedGetDevicesFunc = false ;
@@ -168,4 +171,24 @@ TEST(clGetDeviceIDsTest, givenMultipleRootDevicesAndLimitedNumberOfReturnedDevic
168171 }
169172 EXPECT_EQ (devices[numDevices], dummyDevice);
170173}
174+ TEST (clGetDeviceIDsNegativeTests, whenFailToCreateDeviceThenclGetDeviceIDsReturnsNoDeviceError) {
175+ struct FailingPlatform : Platform {
176+ using Platform::Platform;
177+ RootDevice *createRootDevice (uint32_t rootDeviceIndex) const override { return nullptr ; }
178+ };
179+ VariableBackup<decltype (Platform::createFunc)> createFuncBackup{&Platform::createFunc};
180+ Platform::createFunc = [](ExecutionEnvironment &executionEnvironment) -> std::unique_ptr<Platform> {
181+ return std::make_unique<FailingPlatform>(executionEnvironment);
182+ };
183+ platformsImpl.clear ();
184+
185+ constexpr auto numRootDevices = 3u ;
186+ cl_uint numDevices = 0 ;
187+ cl_uint numEntries = numRootDevices;
188+ cl_device_id devices[numRootDevices];
189+
190+ auto retVal = clGetDeviceIDs (nullptr , CL_DEVICE_TYPE_ALL, numEntries, devices, &numDevices);
191+ EXPECT_EQ (CL_DEVICE_NOT_FOUND, retVal);
192+ EXPECT_EQ (numDevices, 0u );
193+ }
171194} // namespace ULT
0 commit comments