test: StreamCapture on pipes

Enhance StreamCapture class to mimic gtest's CaptureStdout/Stderr functionality.
Store data in a pipe instead of a temporary file like gtest
resulting in faster test execution

Signed-off-by: Marcel Skierkowski <marcel.skierkowski@intel.com>
This commit is contained in:
Marcel Skierkowski
2025-06-06 16:24:08 +00:00
committed by Compute-Runtime-Automation
parent 767755df94
commit a52260ce63
66 changed files with 970 additions and 711 deletions

View File

@@ -8,6 +8,7 @@
#include "shared/source/built_ins/sip.h"
#include "shared/source/os_interface/windows/wddm_allocation.h"
#include "shared/source/os_interface/windows/wddm_debug.h"
#include "shared/test/common/helpers/stream_capture.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_sip.h"
#include "shared/test/common/mocks/windows/mock_wddm_eudebug.h"
@@ -920,11 +921,12 @@ TEST_F(DebugApiWindowsTest, givenEscapeReturnTimeoutWhenReadAndHandleEventCalled
auto session = std::make_unique<MockDebugSessionWindows>(config, device);
session->wddm = mockWddm;
::testing::internal::CaptureStdout();
StreamCapture capture;
capture.captureStdout();
mockWddm->numEvents = 1;
mockWddm->eventQueue[0].escapeReturnStatus = DBGUMD_RETURN_READ_EVENT_TIMEOUT_EXPIRED;
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, session->readAndHandleEvent(100));
auto errorMessage = ::testing::internal::GetCapturedStdout();
auto errorMessage = capture.getCapturedStdout();
EXPECT_EQ(std::string(""), errorMessage);
}