@@ -62,6 +62,18 @@ ur_result_t redefinedDevicePartitionAfter(void *pParams) {
6262 **params.ppNumDevicesRet = *params.pNumDevices ;
6363 return UR_RESULT_SUCCESS ;
6464}
65+ ur_result_t redefinedPlatformGet (void *pParams) {
66+ auto params = reinterpret_cast <ur_platform_get_params_t *>(pParams);
67+ if (*params->ppNumPlatforms )
68+ **params->ppNumPlatforms = 2 ;
69+
70+ if (*params->pphPlatforms && *params->pNumEntries > 0 ) {
71+ (*params->pphPlatforms )[0 ] = reinterpret_cast <ur_platform_handle_t >(1 );
72+ (*params->pphPlatforms )[1 ] = reinterpret_cast <ur_platform_handle_t >(2 );
73+ }
74+
75+ return UR_RESULT_SUCCESS ;
76+ }
6577
6678// Check that the device is verified to be either a member of the context or a
6779// descendant of its member.
@@ -71,6 +83,8 @@ TEST(QueueDeviceCheck, CheckDeviceRestriction) {
7183 detail::SYCLConfig<detail::SYCL_ENABLE_DEFAULT_CONTEXTS >::reset);
7284
7385 sycl::unittest::UrMock<> Mock;
86+ mock::getCallbacks ().set_replace_callback (" urPlatformGet" ,
87+ &redefinedPlatformGet);
7488 sycl::platform Plt = sycl::platform ();
7589
7690 UrPlatform = detail::getSyclObjImpl (Plt)->getHandleRef ();
@@ -116,12 +130,15 @@ TEST(QueueDeviceCheck, CheckDeviceRestriction) {
116130 // Device is neither of the two.
117131 {
118132 ParentDevice = nullptr ;
119- device Device = detail::createSyclObjFromImpl<device>(
120- std::make_shared<detail::device_impl>(
121- reinterpret_cast <ur_device_handle_t >(0x01 ),
122- *detail::getSyclObjImpl (Plt)));
133+
134+ auto Plts = sycl::platform::get_platforms ();
135+ EXPECT_TRUE (Plts.size () == 2 );
136+ sycl::platform OtherPlt = Plts[1 ];
137+
138+ device Device = OtherPlt.get_devices ()[0 ];
123139 queue Q{Device};
124- EXPECT_NE (Q.get_context (), DefaultCtx);
140+ auto Ctx = Q.get_context ();
141+ EXPECT_NE (Ctx, DefaultCtx);
125142 try {
126143 queue Q2 {DefaultCtx, Device};
127144 EXPECT_TRUE (false );
0 commit comments