diff --git a/level_zero/core/source/cmdqueue/cmdqueue_hw.inl b/level_zero/core/source/cmdqueue/cmdqueue_hw.inl index a283fbaede..824efce36a 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_hw.inl +++ b/level_zero/core/source/cmdqueue/cmdqueue_hw.inl @@ -42,6 +42,7 @@ ze_result_t CommandQueueHw::createFence(const ze_fence_desc_t *de template ze_result_t CommandQueueHw::destroy() { + this->printFunctionsPrintfOutput(); delete commandStream; buffers.destroy(this->getDevice()->getNEODevice()->getMemoryManager()); delete this; diff --git a/level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h b/level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h index c6ae396843..a527b42728 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h +++ b/level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h @@ -58,6 +58,7 @@ template struct MockCommandQueueHw : public L0::CommandQueueHw { using BaseClass = ::L0::CommandQueueHw; using BaseClass::commandStream; + using BaseClass::printfFunctionContainer; MockCommandQueueHw(L0::Device *device, NEO::CommandStreamReceiver *csr, const ze_command_queue_desc_t *desc) : L0::CommandQueueHw(device, csr, desc) { } diff --git a/level_zero/core/test/unit_tests/mocks/mock_kernel.h b/level_zero/core/test/unit_tests/mocks/mock_kernel.h index 37ad217de2..53bc579852 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_kernel.h +++ b/level_zero/core/test/unit_tests/mocks/mock_kernel.h @@ -86,8 +86,13 @@ struct Mock<::L0::Kernel> : public ::L0::KernelImp { return nullptr; } + void printPrintfOutput() override { + printPrintfOutputCalledTimes++; + } + WhiteBox<::L0::KernelImmutableData> immutableData; NEO::KernelDescriptor descriptor; + uint32_t printPrintfOutputCalledTimes = 0; }; } // namespace ult diff --git a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp index 9a0d3deb10..72ac4b30ab 100644 --- a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp @@ -15,6 +15,7 @@ #include "level_zero/core/source/driver/driver_handle_imp.h" #include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" #include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h" +#include "level_zero/core/test/unit_tests/mocks/mock_kernel.h" #include "level_zero/core/test/unit_tests/mocks/mock_memory_manager.h" namespace L0 { @@ -156,5 +157,23 @@ TEST_F(CommandQueueCreate, givenCmdQueueWithBlitCopyWhenExecutingCopyBlitCommand commandQueue->destroy(); } +using CommandQueueDestroySupport = IsAtLeastProduct; +using CommandQueueDestroy = Test; + +HWTEST2_F(CommandQueueDestroy, whenCommandQueueDestroyIsCalledPrintPrintfOutputIsCalled, CommandQueueDestroySupport) { + ze_command_queue_desc_t desc = {}; + desc.version = ZE_COMMAND_QUEUE_DESC_VERSION_CURRENT; + auto csr = std::unique_ptr(neoDevice->createCommandStreamReceiver()); + auto commandQueue = new MockCommandQueueHw(device, csr.get(), &desc); + commandQueue->initialize(false); + + Mock kernel; + commandQueue->printfFunctionContainer.push_back(&kernel); + + EXPECT_EQ(0u, kernel.printPrintfOutputCalledTimes); + commandQueue->destroy(); + EXPECT_EQ(1u, kernel.printPrintfOutputCalledTimes); +} + } // namespace ult } // namespace L0 \ No newline at end of file