@@ -400,13 +400,37 @@ TEST_F(WholeGraphUpdateTest, EmptyNode) {
400400 GraphExec.update (UpdateGraph);
401401}
402402
403+ // Vars and callbacks for tracking how many times mocked functions are called
404+ static int GetInfoCount = 0 ;
405+ static int AppendKernelLaunchCount = 0 ;
406+ static ur_result_t redefinedCommandBufferGetInfoExpAfter (void *pParams) {
407+ GetInfoCount++;
408+ return UR_RESULT_SUCCESS;
409+ }
410+ static ur_result_t
411+ redefinedCommandBufferAppendKernelLaunchExpAfter (void *pParams) {
412+ AppendKernelLaunchCount++;
413+ return UR_RESULT_SUCCESS;
414+ }
415+
403416TEST_F (CommandGraphTest, CheckFinalizeBehavior) {
404417 // Check that both finalize with and without updatable property work as
405418 // expected
406419 auto Node = Graph.add (
407420 [&](sycl::handler &cgh) { cgh.single_task <TestKernel<>>([]() {}); });
421+ mock::getCallbacks ().set_after_callback (
422+ " urCommandBufferGetInfoExp" , &redefinedCommandBufferGetInfoExpAfter);
423+ mock::getCallbacks ().set_after_callback (
424+ " urCommandBufferAppendKernelLaunchExp" ,
425+ &redefinedCommandBufferAppendKernelLaunchExpAfter);
408426
409427 ASSERT_NO_THROW (Graph.finalize (experimental::property::graph::updatable{}));
428+ // GetInfo and AppendKernelLaunch should be called once each time a node is
429+ // added to a command buffer during finalization
430+ ASSERT_EQ (GetInfoCount, 1 );
431+ ASSERT_EQ (AppendKernelLaunchCount, 1 );
410432
411433 ASSERT_NO_THROW (Graph.finalize ());
434+ ASSERT_EQ (GetInfoCount, 2 );
435+ ASSERT_EQ (AppendKernelLaunchCount, 2 );
412436}
0 commit comments