diff --git a/runtime/command_stream/tbx_command_stream_receiver_hw.inl b/runtime/command_stream/tbx_command_stream_receiver_hw.inl index f8952054a3..3d3f8fd406 100644 --- a/runtime/command_stream/tbx_command_stream_receiver_hw.inl +++ b/runtime/command_stream/tbx_command_stream_receiver_hw.inl @@ -156,6 +156,12 @@ CommandStreamReceiver *TbxCommandStreamReceiverHw::create(const std:: executionEnvironment.initAubCenter(localMemoryEnabled, fullName, CommandStreamReceiverType::CSR_TBX_WITH_AUB); csr = new CommandStreamReceiverWithAUBDump>(baseName, executionEnvironment); + if (csr->aubManager) { + if (!csr->aubManager->isOpen()) { + csr->aubManager->open(fullName); + UNRECOVERABLE_IF(!csr->aubManager->isOpen()); + } + } } else { csr = new TbxCommandStreamReceiverHw(executionEnvironment); } diff --git a/unit_tests/command_stream/tbx_command_stream_tests.cpp b/unit_tests/command_stream/tbx_command_stream_tests.cpp index d25d31e588..0c0edf8097 100644 --- a/unit_tests/command_stream/tbx_command_stream_tests.cpp +++ b/unit_tests/command_stream/tbx_command_stream_tests.cpp @@ -482,3 +482,26 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpThenFileNameIsE std::unique_ptr> tbxCsr(reinterpret_cast *>(TbxCommandStreamReceiver::create("aubfile", true, executionEnvironment))); EXPECT_STREQ(fullName.c_str(), executionEnvironment.aubFileNameReceived.c_str()); } + +HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpThenOpenIsCalledOnAubManagerToOpenFileStream) { + MockExecutionEnvironment executionEnvironment; + executionEnvironment.setHwInfo(*platformDevices); + + std::unique_ptr> tbxCsrWithAubDump(reinterpret_cast *>( + TbxCommandStreamReceiver::create("aubfile", true, executionEnvironment))); + EXPECT_TRUE(tbxCsrWithAubDump->aubManager->isOpen()); +} + +HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpSeveralTimesThenOpenIsCalledOnAubManagerOnceOnly) { + MockExecutionEnvironment executionEnvironment(*platformDevices, true); + executionEnvironment.setHwInfo(*platformDevices); + + auto tbxCsrWithAubDump1 = std::unique_ptr>(reinterpret_cast *>( + TbxCommandStreamReceiverHw::create("aubfile", true, executionEnvironment))); + + auto tbxCsrWithAubDump2 = std::unique_ptr>(reinterpret_cast *>( + TbxCommandStreamReceiverHw::create("aubfile", true, executionEnvironment))); + + auto mockManager = reinterpret_cast(executionEnvironment.aubCenter->getAubManager()); + EXPECT_EQ(1u, mockManager->openCalledCnt); +}