@@ -147,6 +147,10 @@ static AssertHappened ExpectedToOutput = {
147147static constexpr int KernelLaunchCounterBase = 0 ;
148148static constexpr int MemoryMapCounterBase = 1000 ;
149149static int MemoryMapCounter = MemoryMapCounterBase;
150+ #ifndef _WIN32
151+ static int KernelLaunchCounter = KernelLaunchCounterBase;
152+ static constexpr int PauseWaitOnIdx = KernelLaunchCounterBase + 1 ;
153+ #endif
150154
151155// Mock redifinitions
152156static ur_result_t redefinedKernelGetGroupInfoAfter (void *pParams) {
@@ -165,6 +169,39 @@ static ur_result_t redefinedKernelGetGroupInfoAfter(void *pParams) {
165169 return UR_RESULT_SUCCESS;
166170}
167171
172+ #ifndef _WIN32
173+ static ur_result_t redefinedEnqueueKernelLaunchAfter (void *pParams) {
174+ auto params = *static_cast <ur_enqueue_kernel_launch_params_t *>(pParams);
175+ static ur_event_handle_t UserKernelEvent = **params.pphEvent ;
176+ int Val = KernelLaunchCounter++;
177+ // This output here is to reduce amount of time requried to debug/reproduce a
178+ // failing test upon feature break
179+ printf (" Enqueued %i\n " , Val);
180+
181+ if (PauseWaitOnIdx == Val) {
182+ // It should be copier kernel. Check if it depends on user's one.
183+ EXPECT_EQ (*params.pnumEventsInWaitList , 1U );
184+ EXPECT_EQ (*params.pphEventWaitList [0 ], UserKernelEvent);
185+ }
186+
187+ return UR_RESULT_SUCCESS;
188+ }
189+
190+ static ur_result_t redefinedEventWaitPositive (void *pParams) {
191+ auto params = *static_cast <ur_event_wait_params_t *>(pParams);
192+ // there should be two events: one is for memory map and the other is for
193+ // copier kernel
194+ assert (*params.pnumEvents == 2 );
195+
196+ int EventIdx1 = reinterpret_cast <int *>((*params.pphEventWaitList )[0 ])[0 ];
197+ int EventIdx2 = reinterpret_cast <int *>((*params.pphEventWaitList )[1 ])[0 ];
198+ // This output here is to reduce amount of time requried to debug/reproduce
199+ // a failing test upon feature break
200+ printf (" Waiting for events %i, %i\n " , EventIdx1, EventIdx2);
201+ return UR_RESULT_SUCCESS;
202+ }
203+ #endif
204+
168205static ur_result_t redefinedEventWaitNegative (void *pParams) {
169206 auto params = *static_cast <ur_enqueue_events_wait_params_t *>(pParams);
170207 // For negative tests we do not expect the copier kernel to be used, so
@@ -190,6 +227,20 @@ static ur_result_t redefinedEnqueueMemBufferMapAfter(void *pParams) {
190227 return UR_RESULT_SUCCESS;
191228}
192229
230+ #ifndef _WIN32
231+ static void setupMock (sycl::unittest::UrMock<> &Mock) {
232+ using namespace sycl ::detail;
233+ mock::getCallbacks ().set_after_callback (" urKernelGetGroupInfo" ,
234+ &redefinedKernelGetGroupInfoAfter);
235+ mock::getCallbacks ().set_after_callback (" urEnqueueKernelLaunch" ,
236+ &redefinedEnqueueKernelLaunchAfter);
237+ mock::getCallbacks ().set_after_callback (" urEnqueueMemBufferMap" ,
238+ &redefinedEnqueueMemBufferMapAfter);
239+ mock::getCallbacks ().set_before_callback (" urEventWait" ,
240+ &redefinedEventWaitPositive);
241+ }
242+ #endif
243+
193244namespace TestInteropKernel {
194245const sycl::context *Context = nullptr ;
195246const sycl::device *Device = nullptr ;
0 commit comments