Skip to content

Commit 60f1e49

Browse files
committed
Add function call count checking to new finalize behaviour test
1 parent 3a2cef8 commit 60f1e49

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

sycl/unittests/Extensions/CommandGraph/Update.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
403416
TEST_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

Comments
 (0)