mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 23:56:39 +08:00
test: Restore StreamCapture usage in l0_tools tests
Signed-off-by: Marcel Skierkowski <marcel.skierkowski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
3390504ba1
commit
492b81d02d
@@ -8,6 +8,7 @@
|
||||
#include "shared/source/helpers/gfx_core_helper.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
#include "shared/test/common/helpers/gtest_helpers.h"
|
||||
#include "shared/test/common/helpers/stream_capture.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
@@ -515,12 +516,13 @@ TEST(DebugSession, GivenLogsEnabledWhenPrintBitmaskCalledThenBitmaskIsPrinted) {
|
||||
DebugManagerStateRestore restorer;
|
||||
NEO::debugManager.flags.DebuggerLogBitmask.set(255);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
StreamCapture capture;
|
||||
capture.captureStdout();
|
||||
|
||||
uint64_t bitmask[2] = {0x404080808080, 0x1111ffff1111ffff};
|
||||
DebugSession::printBitmask(reinterpret_cast<uint8_t *>(bitmask), sizeof(bitmask));
|
||||
|
||||
auto output = ::testing::internal::GetCapturedStdout();
|
||||
auto output = capture.getCapturedStdout();
|
||||
|
||||
EXPECT_TRUE(hasSubstr(output, std::string("\nINFO: Bitmask: ")));
|
||||
EXPECT_TRUE(hasSubstr(output, std::string("[0] = 0x0000404080808080")));
|
||||
@@ -531,12 +533,13 @@ TEST(DebugSession, GivenLogsDisabledWhenPrintBitmaskCalledThenBitmaskIsNotPrinte
|
||||
DebugManagerStateRestore restorer;
|
||||
NEO::debugManager.flags.DebuggerLogBitmask.set(0);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
StreamCapture capture;
|
||||
capture.captureStdout();
|
||||
|
||||
uint64_t bitmask[2] = {0x404080808080, 0x1111ffff1111ffff};
|
||||
DebugSession::printBitmask(reinterpret_cast<uint8_t *>(bitmask), sizeof(bitmask));
|
||||
|
||||
auto output = ::testing::internal::GetCapturedStdout();
|
||||
auto output = capture.getCapturedStdout();
|
||||
|
||||
EXPECT_EQ(0u, output.size());
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/stream_capture.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
#include "level_zero/tools/source/debug/eu_thread.h"
|
||||
@@ -152,12 +153,13 @@ TEST(EuThread, GivenEnabledErrorLogsWhenThreadStateStoppedAndVerifyingStopWithEv
|
||||
euThread.verifyStopped(1);
|
||||
euThread.stopThread(1u);
|
||||
|
||||
::testing::internal::CaptureStderr();
|
||||
StreamCapture capture;
|
||||
capture.captureStderr();
|
||||
|
||||
EXPECT_FALSE(euThread.verifyStopped(2));
|
||||
EXPECT_TRUE(euThread.isRunning());
|
||||
|
||||
auto message = ::testing::internal::GetCapturedStderr();
|
||||
auto message = capture.getCapturedStderr();
|
||||
// Trim message and remove timestamp + first space
|
||||
size_t pos = message.find(']');
|
||||
message.erase(0, pos + 2);
|
||||
@@ -207,12 +209,13 @@ TEST(EuThread, GivenEnabledErrorLogsWhenThreadStateStoppedAndVerifyingStopWithOd
|
||||
|
||||
euThread.verifyStopped(1);
|
||||
|
||||
::testing::internal::CaptureStderr();
|
||||
StreamCapture capture;
|
||||
capture.captureStderr();
|
||||
|
||||
EXPECT_TRUE(euThread.verifyStopped(7));
|
||||
EXPECT_TRUE(euThread.isStopped());
|
||||
|
||||
auto message = ::testing::internal::GetCapturedStderr();
|
||||
auto message = capture.getCapturedStderr();
|
||||
// Trim message and remove timestamp + first space
|
||||
size_t pos = message.find(']');
|
||||
message.erase(0, pos + 2);
|
||||
@@ -230,12 +233,13 @@ TEST(EuThread, GivenEnabledErrorLogsWhenThreadStateRunningAndVerifyingStopWithOd
|
||||
euThread.verifyStopped(1);
|
||||
euThread.resumeThread();
|
||||
|
||||
::testing::internal::CaptureStderr();
|
||||
StreamCapture capture;
|
||||
capture.captureStderr();
|
||||
|
||||
EXPECT_TRUE(euThread.verifyStopped(1));
|
||||
EXPECT_TRUE(euThread.isStopped());
|
||||
|
||||
auto message = ::testing::internal::GetCapturedStderr();
|
||||
auto message = capture.getCapturedStderr();
|
||||
// Trim message and remove timestamp + first space
|
||||
size_t pos = message.find(']');
|
||||
message.erase(0, pos + 2);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "shared/source/release_helper/release_helper.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/gtest_helpers.h"
|
||||
#include "shared/test/common/helpers/stream_capture.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/libult/linux/drm_query_mock.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
@@ -316,11 +317,12 @@ TEST(DebugSessionLinuxi915Test, GivenLogsEnabledWhenPrintContextVmsCalledThenMap
|
||||
|
||||
EXPECT_EQ(2u, sessionMock->clientHandleToConnection[sessionMock->clientHandle]->contextsCreated.size());
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
StreamCapture capture;
|
||||
capture.captureStdout();
|
||||
|
||||
sessionMock->printContextVms();
|
||||
|
||||
auto map = ::testing::internal::GetCapturedStdout();
|
||||
auto map = capture.getCapturedStdout();
|
||||
|
||||
EXPECT_TRUE(hasSubstr(map, std::string("INFO: Context - VM map:")));
|
||||
EXPECT_TRUE(hasSubstr(map, std::string("Context = 0 : 1")));
|
||||
@@ -346,11 +348,12 @@ TEST(DebugSessionLinuxi915Test, GivenLogsDisabledWhenPrintContextVmsCalledThenMa
|
||||
|
||||
EXPECT_EQ(2u, sessionMock->clientHandleToConnection[sessionMock->clientHandle]->contextsCreated.size());
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
StreamCapture capture;
|
||||
capture.captureStdout();
|
||||
|
||||
sessionMock->printContextVms();
|
||||
|
||||
auto map = ::testing::internal::GetCapturedStdout();
|
||||
auto map = capture.getCapturedStdout();
|
||||
|
||||
EXPECT_TRUE(map.empty());
|
||||
}
|
||||
@@ -996,13 +999,14 @@ TEST_F(DebugApiLinuxTest, GivenDebuggerLogsWhenOpenDebuggerFailsThenCorrectMessa
|
||||
mockDrm->context.debuggerOpenRetval = -1;
|
||||
mockDrm->baseErrno = false;
|
||||
mockDrm->errnoRetVal = 22;
|
||||
::testing::internal::CaptureStderr();
|
||||
StreamCapture capture;
|
||||
capture.captureStderr();
|
||||
auto session = DebugSession::create(config, device, result, !device->getNEODevice()->isSubDevice());
|
||||
|
||||
EXPECT_EQ(nullptr, session);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, result);
|
||||
|
||||
auto errorMessage = ::testing::internal::GetCapturedStderr();
|
||||
auto errorMessage = capture.getCapturedStderr();
|
||||
// Trim errorMessage and remove timestamp + first space
|
||||
size_t pos = errorMessage.find(']');
|
||||
errorMessage.erase(0, pos + 2);
|
||||
@@ -1053,14 +1057,14 @@ TEST_F(DebugApiLinuxTest, GivenDebuggerLogsWhenOpenDebuggerSucceedsThenCorrectMe
|
||||
mockDrm->context.debuggerOpenRetval = 10;
|
||||
mockDrm->baseErrno = false;
|
||||
mockDrm->errnoRetVal = 0;
|
||||
::testing::internal::CaptureStdout();
|
||||
|
||||
StreamCapture capture;
|
||||
capture.captureStdout();
|
||||
auto session = std::unique_ptr<DebugSession>(DebugSession::create(config, device, result, !device->getNEODevice()->isSubDevice()));
|
||||
|
||||
EXPECT_NE(nullptr, session);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
auto errorMessage = ::testing::internal::GetCapturedStdout();
|
||||
auto errorMessage = capture.getCapturedStdout();
|
||||
EXPECT_TRUE(hasSubstr(errorMessage, std::string("INFO: PRELIM_DRM_IOCTL_I915_DEBUGGER_OPEN: open.pid: 4660, open.events: 0, debugFd: 10\n")));
|
||||
}
|
||||
|
||||
@@ -1131,7 +1135,8 @@ TEST_F(DebugApiLinuxTest, GivenPrintDebugMessagesWhenDebugSessionClosesConnectio
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
::testing::internal::CaptureStderr();
|
||||
StreamCapture capture;
|
||||
capture.captureStderr();
|
||||
|
||||
auto session = std::make_unique<MockDebugSessionLinuxi915>(config, device, 10);
|
||||
|
||||
@@ -1149,7 +1154,7 @@ TEST_F(DebugApiLinuxTest, GivenPrintDebugMessagesWhenDebugSessionClosesConnectio
|
||||
NEO::SysCalls::closeFuncArgPassed = 0;
|
||||
NEO::SysCalls::closeFuncRetVal = 0;
|
||||
|
||||
auto errorMessage = ::testing::internal::GetCapturedStderr();
|
||||
auto errorMessage = capture.getCapturedStderr();
|
||||
// Trim errorMessage and remove timestamp + first space
|
||||
size_t pos = errorMessage.find(']');
|
||||
errorMessage.erase(0, pos + 2);
|
||||
@@ -2320,7 +2325,8 @@ TEST_F(DebugApiLinuxTest, GivenDebuggerLogsWhenReadEventFailsDuringInitializatio
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
::testing::internal::CaptureStderr();
|
||||
StreamCapture capture;
|
||||
capture.captureStderr();
|
||||
|
||||
auto session = std::make_unique<MockDebugSessionLinuxi915>(config, device, 10);
|
||||
ASSERT_NE(nullptr, session);
|
||||
@@ -2343,7 +2349,7 @@ TEST_F(DebugApiLinuxTest, GivenDebuggerLogsWhenReadEventFailsDuringInitializatio
|
||||
EXPECT_EQ(ZE_RESULT_NOT_READY, result);
|
||||
EXPECT_EQ(2, session->getInternalEventCounter);
|
||||
|
||||
auto errorMessage = ::testing::internal::GetCapturedStderr();
|
||||
auto errorMessage = capture.getCapturedStderr();
|
||||
auto pos = errorMessage.find("PRELIM_I915_DEBUG_IOCTL_READ_EVENT failed: retCode: -1 errno =");
|
||||
EXPECT_NE(std::string::npos, pos);
|
||||
}
|
||||
@@ -3195,11 +3201,12 @@ TEST_F(DebugApiLinuxTest, GivenDebuggerLogsAndUnhandledEventTypeWhenHandlingEven
|
||||
|
||||
session->ioctlHandler.reset(handler);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
StreamCapture capture;
|
||||
capture.captureStdout();
|
||||
|
||||
session->handleEvent(&event);
|
||||
|
||||
auto errorMessage = ::testing::internal::GetCapturedStdout();
|
||||
auto errorMessage = capture.getCapturedStdout();
|
||||
std::stringstream expectedMessage;
|
||||
expectedMessage << "PRELIM_I915_DEBUG_IOCTL_READ_EVENT type: UNHANDLED ";
|
||||
expectedMessage << PRELIM_DRM_I915_DEBUG_EVENT_MAX_EVENT + 1;
|
||||
@@ -5074,14 +5081,15 @@ TEST_F(DebugApiLinuxTest, GivenDebuggerLogsAndFailingReadUuidEventIoctlWhenHandl
|
||||
auto handler = new MockIoctlHandlerI915;
|
||||
session->ioctlHandler.reset(handler);
|
||||
|
||||
::testing::internal::CaptureStderr();
|
||||
StreamCapture capture;
|
||||
capture.captureStderr();
|
||||
errno = 0;
|
||||
session->handleEvent(reinterpret_cast<prelim_drm_i915_debug_event *>(&uuid));
|
||||
|
||||
EXPECT_EQ(1, handler->ioctlCalled);
|
||||
EXPECT_EQ(0u, session->getClassHandleToIndex().size());
|
||||
|
||||
auto errorMessage = ::testing::internal::GetCapturedStderr();
|
||||
auto errorMessage = capture.getCapturedStderr();
|
||||
// Trim errorMessage and remove timestamp + first space
|
||||
size_t pos = errorMessage.find(']');
|
||||
errorMessage.erase(0, pos + 2);
|
||||
@@ -5208,7 +5216,8 @@ TEST_F(DebugApiLinuxTest, GivenContextParamEventWhenTypeIsParamEngineThenEventIs
|
||||
i915_engine_class_instance ci = {drm_i915_gem_engine_class::I915_ENGINE_CLASS_RENDER, 1};
|
||||
memcpy(classInstance, &ci, sizeof(i915_engine_class_instance));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
StreamCapture capture;
|
||||
capture.captureStdout();
|
||||
|
||||
session->handleEvent(&contextParamEvent->base);
|
||||
alignedFree(memory);
|
||||
@@ -5221,7 +5230,7 @@ TEST_F(DebugApiLinuxTest, GivenContextParamEventWhenTypeIsParamEngineThenEventIs
|
||||
session->clientHandleToConnection[MockDebugSessionLinuxi915::mockClientHandle]->vmToTile.find(vmId));
|
||||
EXPECT_EQ(0u, session->clientHandleToConnection[MockDebugSessionLinuxi915::mockClientHandle]->vmToTile[vmId]);
|
||||
|
||||
auto infoMessage = ::testing::internal::GetCapturedStdout();
|
||||
auto infoMessage = capture.getCapturedStdout();
|
||||
EXPECT_TRUE(hasSubstr(infoMessage, std::string("I915_CONTEXT_PARAM_ENGINES ctx_id = 20 param = 10 value = 0")));
|
||||
}
|
||||
|
||||
@@ -5319,13 +5328,14 @@ TEST_F(DebugApiLinuxTest, GivenDebuggerErrorLogsWhenContextParamWithInvalidConte
|
||||
contextParamEvent.ctx_handle = 77;
|
||||
contextParamEvent.param = {.ctx_id = 3, .size = 8, .param = I915_CONTEXT_PARAM_VM, .value = vmId};
|
||||
|
||||
::testing::internal::CaptureStderr();
|
||||
StreamCapture capture;
|
||||
capture.captureStderr();
|
||||
session->handleEvent(&contextParamEvent.base);
|
||||
|
||||
EXPECT_EQ(session->clientHandleToConnection[contextParamEvent.client_handle]->contextsCreated.end(),
|
||||
session->clientHandleToConnection[contextParamEvent.client_handle]->contextsCreated.find(77));
|
||||
|
||||
auto errorMessage = ::testing::internal::GetCapturedStderr();
|
||||
auto errorMessage = capture.getCapturedStderr();
|
||||
// Trim errorMessage and remove timestamp + first space
|
||||
size_t pos = errorMessage.find(']');
|
||||
errorMessage.erase(0, pos + 2);
|
||||
@@ -5357,14 +5367,15 @@ TEST_F(DebugApiLinuxTest, GivenDebuggerInfoLogsWhenHandlingContextParamEventWith
|
||||
contextParamEvent.ctx_handle = contextHandle;
|
||||
contextParamEvent.param = {.ctx_id = 3, .size = 8, .param = I915_CONTEXT_PARAM_BAN_PERIOD, .value = vmId};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
StreamCapture capture;
|
||||
capture.captureStdout();
|
||||
|
||||
session->handleEvent(&contextParamEvent.base);
|
||||
|
||||
EXPECT_EQ(session->clientHandleToConnection[contextParamEvent.client_handle]->contextsCreated.end(),
|
||||
session->clientHandleToConnection[contextParamEvent.client_handle]->contextsCreated.find(77));
|
||||
|
||||
auto errorMessage = ::testing::internal::GetCapturedStdout();
|
||||
auto errorMessage = capture.getCapturedStdout();
|
||||
EXPECT_TRUE(hasSubstr(errorMessage, std::string("client_handle = 1 ctx_handle = 20\n")));
|
||||
EXPECT_TRUE(hasSubstr(errorMessage, std::string("INFO: I915_CONTEXT_PARAM UNHANDLED = 1\n")));
|
||||
}
|
||||
@@ -5931,7 +5942,8 @@ TEST_F(DebugApiLinuxTest, givenEnginesEventHandledThenLrcToContextHandleMapIsFil
|
||||
engines2->engines[2].lrc_handle = 5;
|
||||
engines2->engines[3].lrc_handle = 0;
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
StreamCapture capture;
|
||||
capture.captureStdout();
|
||||
|
||||
NEO::debugManager.flags.DebuggerLogBitmask.set(NEO::DebugVariables::DEBUGGER_LOG_BITMASK::LOG_INFO);
|
||||
|
||||
@@ -5954,7 +5966,7 @@ TEST_F(DebugApiLinuxTest, givenEnginesEventHandledThenLrcToContextHandleMapIsFil
|
||||
EXPECT_EQ(40u, session->clientHandleToConnection[clientHandle]->lrcToContextHandle[4]);
|
||||
EXPECT_EQ(40u, session->clientHandleToConnection[clientHandle]->lrcToContextHandle[5]);
|
||||
|
||||
auto infoMessage = ::testing::internal::GetCapturedStdout();
|
||||
auto infoMessage = capture.getCapturedStdout();
|
||||
EXPECT_TRUE(hasSubstr(infoMessage, std::string("ENGINES event: client_handle = 34, ctx_handle = 20, num_engines = 2 CREATE")));
|
||||
EXPECT_TRUE(hasSubstr(infoMessage, std::string("ENGINES event: client_handle = 34, ctx_handle = 40, num_engines = 4 CREATE")));
|
||||
EXPECT_TRUE(hasSubstr(infoMessage, std::string("ENGINES event: client_handle = 34, ctx_handle = 20, num_engines = 2 DESTROY")));
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "shared/source/release_helper/release_helper.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/gtest_helpers.h"
|
||||
#include "shared/test/common/helpers/stream_capture.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/libult/linux/drm_mock_helper.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
@@ -2911,11 +2912,12 @@ TEST_F(DebugApiLinuxTestXe, GivenMultipleExecQueuePlacementEventForSameVmHandleW
|
||||
engineClassInstance[0].engineInstance = 1;
|
||||
engineClassInstance[0].gtId = 0;
|
||||
|
||||
::testing::internal::CaptureStderr();
|
||||
StreamCapture capture;
|
||||
capture.captureStderr();
|
||||
session->handleEvent(&execQueuePlacements->base);
|
||||
alignedFree(memory);
|
||||
|
||||
auto infoMessage = ::testing::internal::GetCapturedStderr();
|
||||
auto infoMessage = capture.getCapturedStderr();
|
||||
EXPECT_EQ(1u, session->clientHandleToConnection[client1.clientHandle]->vmToTile[vmHandle]);
|
||||
EXPECT_TRUE(hasSubstr(infoMessage, std::string("tileIndex = 1 already present. Attempt to overwrite with tileIndex = 0")));
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/stream_capture.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_io_functions.h"
|
||||
@@ -598,11 +599,12 @@ TEST_F(DebugApiTest, givenZeAffinityMaskAndEnabledDebugMessagesWhenDebugAttachCa
|
||||
MockDeviceImp deviceImp(neoDevice);
|
||||
deviceImp.debugSession.reset(new DebugSessionMock(config, &deviceImp));
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
StreamCapture capture;
|
||||
capture.captureStdout();
|
||||
zet_debug_session_handle_t debugSession = nullptr;
|
||||
zetDebugAttach(deviceImp.toHandle(), &config, &debugSession);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
std::string output = capture.getCapturedStdout();
|
||||
EXPECT_EQ(std::string("ZE_AFFINITY_MASK is not recommended while using program debug API\n"), output);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user