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

@@ -34,6 +34,7 @@
#include "shared/test/common/helpers/gtest_helpers.h"
#include "shared/test/common/helpers/kernel_binary_helper.h"
#include "shared/test/common/helpers/mock_file_io.h"
#include "shared/test/common/helpers/stream_capture.h"
#include "shared/test/common/helpers/test_files.h"
#include "shared/test/common/libult/global_environment.h"
#include "shared/test/common/libult/ult_command_stream_receiver.h"
@@ -3088,7 +3089,8 @@ using ProgramBinTest = Test<ProgramSimpleFixture>;
TEST_F(ProgramBinTest, givenPrintProgramBinaryProcessingTimeSetWhenBuildProgramThenProcessingTimeIsPrinted) {
DebugManagerStateRestore restorer;
debugManager.flags.PrintProgramBinaryProcessingTime.set(true);
testing::internal::CaptureStdout();
StreamCapture capture;
capture.captureStdout();
createProgramFromBinary(pContext, pContext->getDevices(), "simple_kernels");
@@ -3096,7 +3098,7 @@ TEST_F(ProgramBinTest, givenPrintProgramBinaryProcessingTimeSetWhenBuildProgramT
pProgram->getDevices(),
nullptr);
auto output = testing::internal::GetCapturedStdout();
auto output = capture.getCapturedStdout();
EXPECT_FALSE(output.compare(0, 14, "Elapsed time: "));
EXPECT_EQ(CL_SUCCESS, retVal);
}