From a52260ce63806fd4729776b20e831ee401a0f4de Mon Sep 17 00:00:00 2001 From: Marcel Skierkowski Date: Fri, 6 Jun 2025 16:24:08 +0000 Subject: [PATCH] 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 --- .../sources/cmdlist/test_cmdlist_1.cpp | 6 +- .../sources/debugger/test_l0_debugger_2.cpp | 6 +- .../test_l0_debugger_sba_tracking.cpp | 16 +- .../sources/device/test_l0_device.cpp | 11 +- .../unit_tests/sources/event/test_event.cpp | 31 +- .../unit_tests/sources/kernel/test_kernel.cpp | 26 +- .../debug/windows/test_debug_api_windows.cpp | 6 +- .../command_queue/enqueue_kernel_2_tests.cpp | 11 +- .../command_stream_receiver_mt_tests.cpp | 38 +- .../context/driver_diagnostics_tests.cpp | 51 +- opencl/test/unit_test/event/event_tests.cpp | 16 +- .../test/unit_test/linux/main_linux_dll.cpp | 43 +- .../unit_test/mem_obj/buffer_bcs_tests.cpp | 6 +- .../mem_obj/buffer_pool_alloc_tests.cpp | 6 +- .../decoder/encoder_tests.cpp | 8 +- .../decoder/zebin_manipulator_tests.cpp | 11 +- .../offline_compiler/ocloc_api_tests.cpp | 63 +-- .../ocloc_fatbinary_tests.cpp | 68 +-- .../ocloc_fcl_facade_tests.cpp | 22 +- .../ocloc_igc_facade_tests.cpp | 22 +- .../offline_compiler_tests.cpp | 159 ++++--- .../offline_compiler/offline_linker_tests.cpp | 40 +- .../offline_compiler/stdout_capturer.h | 4 +- .../ptl/offline_compiler_tests_ptl.cpp | 6 +- .../pvc/offline_compiler_tests_pvc.cpp | 13 +- .../dg2/offline_compiler_tests_dg2.cpp | 16 +- .../unit_test/profiling/profiling_tests.cpp | 23 +- .../test/unit_test/program/program_tests.cpp | 6 +- .../{stdout_capture.h => stream_capture.h} | 52 +- .../command_stream_receiver_tests.cpp | 23 +- .../linux/default_cl_cache_config_tests.cpp | 8 +- .../windows/default_cl_cache_config_tests.cpp | 8 +- .../debug_settings_manager_tests.cpp | 46 +- .../debug_settings_manager_linux_tests.cpp | 6 +- .../direct_submission_tests_2.cpp | 6 +- .../encoders/test_encode_dispatch_kernel.cpp | 6 +- .../compression_tests_xe2_and_later.cpp | 6 +- .../unit_test/gmm_helper/gmm_helper_tests.cpp | 11 +- .../helpers/blit_commands_helper_tests.cpp | 6 +- ...st_blit_commands_helper_xehp_and_later.cpp | 6 +- .../gdi_interface_logging_tests.cpp | 445 +++++++++--------- .../os_interface/linux/ccs_mode_tests.cpp | 11 +- .../linux/drm_buffer_object_tests.cpp | 36 +- .../linux/drm_command_stream_tests_1.cpp | 21 +- ...and_stream_xehp_and_later_prelim_tests.cpp | 6 +- .../linux/drm_memory_info_prelim_tests.cpp | 8 +- .../linux/drm_memory_info_tests.cpp | 8 +- ...m_memory_manager_localmem_prelim_tests.cpp | 16 +- .../linux/drm_memory_manager_tests.cpp | 20 +- .../linux/drm_query_topology_prelim_tests.cpp | 13 +- .../linux/drm_system_info_tests.cpp | 11 +- .../os_interface/linux/drm_tests.cpp | 21 +- .../linux/drm_with_prelim_tests.cpp | 11 +- .../linux/file_logger_linux_tests.cpp | 6 +- .../linux/ioctl_helper_tests_dg1.cpp | 11 +- .../linux/ioctl_helper_tests_prelim.cpp | 6 +- .../linux/ioctl_helper_tests_upstream.cpp | 20 +- .../linux/product_helper_linux_tests.cpp | 6 +- .../linux/xe/ccs_mode_xe_tests.cpp | 11 +- .../windows/device_command_stream_tests.cpp | 6 +- .../windows/gdi_interface_tests.cpp | 13 +- .../cpu_page_fault_manager_tests.cpp | 21 +- .../unit_test/program/printf_helper_tests.cpp | 6 +- .../utilities/debug_settings_reader_tests.cpp | 11 +- .../test/unit_test/utilities/logger_tests.cpp | 11 +- .../utilities/x86_64/cpuinfo_tests_x86_64.cpp | 8 +- 66 files changed, 970 insertions(+), 711 deletions(-) rename shared/test/common/helpers/{stdout_capture.h => stream_capture.h} (52%) diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp index 86ce28e4d4..8dbb42ccb7 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp @@ -15,6 +15,7 @@ #include "shared/test/common/cmd_parse/gen_cmd_parse.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/relaxed_ordering_commands_helper.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/unit_test_helper.h" #include "shared/test/common/libult/ult_command_stream_receiver.h" #include "shared/test/common/mocks/mock_command_stream_receiver.h" @@ -868,7 +869,8 @@ TEST_F(CommandListMemAdvisePageFault, givenValidDeviceMemPtrAndPageFaultHandlerA EXPECT_EQ(handlerWithHints, reinterpret_cast(mockPageFaultManager->gpuDomainHandler)); - testing::internal::CaptureStdout(); // start capturing + StreamCapture capture; + capture.captureStdout(); // start capturing NEO::CpuPageFaultManager::PageFaultData pageData; pageData.cmdQ = deviceImp; @@ -878,7 +880,7 @@ TEST_F(CommandListMemAdvisePageFault, givenValidDeviceMemPtrAndPageFaultHandlerA flags = deviceImp->memAdviseSharedAllocations[allocData]; EXPECT_EQ(0, flags.cpuMigrationBlocked); - std::string output = testing::internal::GetCapturedStdout(); // stop capturing + std::string output = capture.getCapturedStdout(); // stop capturing std::string expectedString = "UMD transferred shared allocation"; uint32_t occurrences = 0u; diff --git a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_2.cpp b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_2.cpp index 6642811f2e..9742d0187d 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_2.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_2.cpp @@ -9,6 +9,7 @@ #include "shared/source/helpers/preamble.h" #include "shared/source/helpers/register_offsets.h" #include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/libult/ult_command_stream_receiver.h" #include "shared/test/common/test_macros/hw_test.h" @@ -111,7 +112,8 @@ HWTEST_P(L0DebuggerWithBlitterTest, givenDebuggerLogsDisabledWhenCommandListIsSy NEO::debugManager.flags.DebuggerLogBitmask.set(0); EXPECT_NE(nullptr, device->getL0Debugger()); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); ze_command_queue_desc_t queueDesc = {}; ze_result_t returnValue = ZE_RESULT_SUCCESS; @@ -119,7 +121,7 @@ HWTEST_P(L0DebuggerWithBlitterTest, givenDebuggerLogsDisabledWhenCommandListIsSy commandList->executeCommandListImmediate(false); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); size_t pos = output.find("Debugger: SBA"); EXPECT_EQ(std::string::npos, pos); diff --git a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp index 32438c538e..8033ec0be8 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp @@ -11,6 +11,7 @@ #include "shared/source/helpers/register_offsets.h" #include "shared/source/indirect_heap/indirect_heap.h" #include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_gmm_helper.h" #include "shared/test/common/test_macros/hw_test.h" @@ -276,7 +277,8 @@ HWTEST2_F(L0DebuggerTest, givenDebuggingEnabledAndDebuggerLogsWhenCommandQueueIs DebugManagerStateRestore restorer; NEO::debugManager.flags.DebuggerLogBitmask.set(255); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); ze_command_queue_desc_t queueDesc = {}; ze_result_t returnValue; @@ -294,7 +296,7 @@ HWTEST2_F(L0DebuggerTest, givenDebuggingEnabledAndDebuggerLogsWhenCommandQueueIs commandQueue->synchronize(0); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); size_t pos = output.find("INFO: Debugger: SBA stored ssh"); EXPECT_NE(std::string::npos, pos); @@ -313,7 +315,8 @@ HWTEST2_F(L0DebuggerSimpleTest, givenNullL0DebuggerAndDebuggerLogsWhenCommandQue NEO::debugManager.flags.DebuggerLogBitmask.set(255); EXPECT_EQ(nullptr, device->getL0Debugger()); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); ze_command_queue_desc_t queueDesc = {}; ze_result_t returnValue; @@ -331,7 +334,7 @@ HWTEST2_F(L0DebuggerSimpleTest, givenNullL0DebuggerAndDebuggerLogsWhenCommandQue commandQueue->synchronize(0); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); size_t pos = output.find("Debugger: SBA"); EXPECT_EQ(std::string::npos, pos); @@ -345,7 +348,8 @@ HWTEST2_F(L0DebuggerTest, givenL0DebuggerAndDebuggerLogsDisabledWhenCommandQueue NEO::debugManager.flags.DebuggerLogBitmask.set(0); EXPECT_NE(nullptr, device->getL0Debugger()); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); ze_command_queue_desc_t queueDesc = {}; ze_result_t returnValue; @@ -363,7 +367,7 @@ HWTEST2_F(L0DebuggerTest, givenL0DebuggerAndDebuggerLogsDisabledWhenCommandQueue commandQueue->synchronize(0); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); size_t pos = output.find("Debugger: SBA"); EXPECT_EQ(std::string::npos, pos); diff --git a/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp b/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp index 0420fa60ed..ddcb5e3b0b 100644 --- a/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp +++ b/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp @@ -25,6 +25,7 @@ #include "shared/test/common/helpers/mock_product_helper_hw.h" #include "shared/test/common/helpers/raii_gfx_core_helper.h" #include "shared/test/common/helpers/raii_product_helper.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/libult/ult_command_stream_receiver.h" #include "shared/test/common/mocks/mock_command_stream_receiver.h" #include "shared/test/common/mocks/mock_compiler_product_helper.h" @@ -2007,10 +2008,11 @@ TEST_F(DeviceTest, givenPrintGlobalTimestampIsSetWhenGetGlobalTimestampIsCalledT capabilityTable.timestampValidBits = 36; capabilityTable.kernelTimestampValidBits = 32; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); ze_result_t result = device->getGlobalTimestamps(&hostTs, &deviceTs); EXPECT_EQ(ZE_RESULT_SUCCESS, result); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); // Considering kernelTimestampValidBits(32) auto gpuTimeStamp = cpuDeviceTime->mockGpuTimeInNs & 0xFFFFFFFF; const std::string expectedString("Host timestamp in ns : 0 | Device timestamp in ns : " + @@ -2038,10 +2040,11 @@ TEST_F(DeviceTest, givenPrintGlobalTimestampIsSetAnd64bitTimestampWhenGetGlobalT uint64_t hostTs = 0u; uint64_t deviceTs = 0u; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); ze_result_t result = device->getGlobalTimestamps(&hostTs, &deviceTs); EXPECT_EQ(ZE_RESULT_SUCCESS, result); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); const std::string expectedString("Host timestamp in ns : 0 | Device timestamp in ns : " + std::to_string(static_cast(neoDevice->getProfilingTimerResolution()) * cpuDeviceTime->mockGpuTimeInNs) + diff --git a/level_zero/core/test/unit_tests/sources/event/test_event.cpp b/level_zero/core/test/unit_tests/sources/event/test_event.cpp index 37a099d4ea..630bc399d4 100644 --- a/level_zero/core/test/unit_tests/sources/event/test_event.cpp +++ b/level_zero/core/test/unit_tests/sources/event/test_event.cpp @@ -12,6 +12,7 @@ #include "shared/source/utilities/buffer_pool_allocator.inl" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/engine_descriptor_helper.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/mocks/mock_csr.h" #include "shared/test/common/mocks/mock_device.h" @@ -2753,9 +2754,10 @@ HWTEST_F(TimestampEventCreate, givenFlagPrintCalculatedTimestampsWhenCallQueryKe event->hostAddressFromPool = &data; ze_kernel_timestamp_result_t result = {}; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); event->queryKernelTimestamp(&result); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::stringstream expected; expected << "globalStartTS: " << result.global.kernelStart << ", " << "globalEndTS: " << result.global.kernelEnd << ", " @@ -2785,9 +2787,10 @@ TEST_F(TimestampEventUsedPacketSignalCreate, givenFlagPrintTimestampPacketConten auto packedCount = 2u; event->setPacketsInUse(packedCount); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); event->queryKernelTimestamp(&results); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::stringstream expected; for (uint32_t i = 0; i < packedCount; i++) { @@ -2894,9 +2897,10 @@ HWTEST2_F(TimestampEventCreateMultiKernel, givenFlagPrintTimestampPacketContents event->setPacketsInUse(packedCount); ze_kernel_timestamp_result_t results; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); event->queryKernelTimestamp(&results); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::stringstream expected; auto i = 0u; for (uint32_t kernelId = 0u; kernelId < kernelCount; kernelId++) { @@ -4313,7 +4317,8 @@ TEST_F(EventTests, givenDebugFlagSetWhenCallingResetThenSynchronizeBeforeReset) *reinterpret_cast(event->hostAddressFromPool) = Event::STATE_SIGNALED; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); EXPECT_EQ(0u, event->hostSynchronizeCalled); @@ -4321,7 +4326,7 @@ TEST_F(EventTests, givenDebugFlagSetWhenCallingResetThenSynchronizeBeforeReset) EXPECT_EQ(1u, event->hostSynchronizeCalled); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput(""); EXPECT_EQ(expectedOutput, output); } @@ -4335,7 +4340,8 @@ TEST_F(EventTests, givenDebugFlagSetWhenCallingResetThenPrintLogAndSynchronizeBe { event->failOnNextQueryStatus = false; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); EXPECT_EQ(0u, event->hostSynchronizeCalled); @@ -4343,7 +4349,7 @@ TEST_F(EventTests, givenDebugFlagSetWhenCallingResetThenPrintLogAndSynchronizeBe EXPECT_EQ(1u, event->hostSynchronizeCalled); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput(""); EXPECT_EQ(expectedOutput, output); } @@ -4351,7 +4357,8 @@ TEST_F(EventTests, givenDebugFlagSetWhenCallingResetThenPrintLogAndSynchronizeBe { event->failOnNextQueryStatus = true; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); EXPECT_EQ(1u, event->hostSynchronizeCalled); @@ -4359,7 +4366,7 @@ TEST_F(EventTests, givenDebugFlagSetWhenCallingResetThenPrintLogAndSynchronizeBe EXPECT_EQ(2u, event->hostSynchronizeCalled); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); char expectedStr[128] = {}; snprintf(expectedStr, 128, "\nzeEventHostReset: Event %p not ready. Calling zeEventHostSynchronize.", event.get()); diff --git a/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp b/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp index ad585dc6fc..90bb4890b3 100644 --- a/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp +++ b/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp @@ -26,6 +26,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/engine_descriptor_helper.h" #include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/libult/ult_command_stream_receiver.h" #include "shared/test/common/mocks/mock_bindless_heaps_helper.h" #include "shared/test/common/mocks/mock_device.h" @@ -3873,9 +3874,10 @@ HWTEST_F(PrintfHandlerTests, givenKernelWithPrintfWhenPrintingOutputWithBlitterU printfAllocation[0] = 8; printfAllocation[1] = 0; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); PrintfHandler::printOutput(kernelImmutableData.get(), &mockAllocation, &deviceImp, true); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); auto bcsEngine = device->tryGetEngine(NEO::EngineHelpers::getBcsEngineType(device->getRootDeviceEnvironment(), device->getDeviceBitfield(), device->getSelectorCopyEngine(), true), EngineUsage::internal); if (bcsEngine) { @@ -3937,10 +3939,11 @@ HWTEST_F(PrintfHandlerTests, givenPrintDebugMessagesAndKernelWithPrintfWhenBlitt printfAllocation[0] = 8; printfAllocation[1] = 0; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); testing::internal::CaptureStderr(); PrintfHandler::printOutput(kernelImmutableData.get(), &mockAllocation, &deviceImp, true); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string error = testing::internal::GetCapturedStderr(); EXPECT_EQ(1u, bcsCsr->blitBufferCalled); @@ -3975,9 +3978,10 @@ TEST_F(KernelPatchtokensPrintfStringMapTests, givenKernelWithPrintfStringsMapUsa printfAllocation[0] = 8; printfAllocation[1] = 0; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); kernel->printPrintfOutput(false); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_STREQ(expectedString.c_str(), output.c_str()); } @@ -4003,9 +4007,10 @@ TEST_F(KernelPatchtokensPrintfStringMapTests, givenKernelWithPrintfStringsMapUsa printfAllocation[0] = 8; printfAllocation[1] = 0; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); kernel->printPrintfOutput(false); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_STREQ("", output.c_str()); } @@ -4031,9 +4036,10 @@ TEST_F(KernelPatchtokensPrintfStringMapTests, givenKernelWithPrintfStringsMapUsa printfAllocation[0] = 8; printfAllocation[1] = 0; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); kernel->printPrintfOutput(false); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_STREQ(expectedString.c_str(), output.c_str()); } diff --git a/level_zero/tools/test/unit_tests/sources/debug/windows/test_debug_api_windows.cpp b/level_zero/tools/test/unit_tests/sources/debug/windows/test_debug_api_windows.cpp index cd7826caa0..9226907f92 100644 --- a/level_zero/tools/test/unit_tests/sources/debug/windows/test_debug_api_windows.cpp +++ b/level_zero/tools/test/unit_tests/sources/debug/windows/test_debug_api_windows.cpp @@ -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(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); } diff --git a/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp index b968137d9e..8013a90761 100644 --- a/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp @@ -16,6 +16,7 @@ #include "shared/test/common/cmd_parse/gen_cmd_parse.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/relaxed_ordering_commands_helper.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_csr.h" #include "shared/test/common/mocks/mock_direct_submission_hw.h" #include "shared/test/common/mocks/mock_timestamp_container.h" @@ -681,9 +682,10 @@ HWTEST_P(EnqueueKernelPrintfTest, GivenKernelWithPrintfBlockedByEventWhenEventUn pOutEvent->release(); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); userEvent->setStatus(CL_COMPLETE); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_STREQ("test", output.c_str()); } @@ -726,9 +728,10 @@ HWTEST_P(EnqueueKernelPrintfTest, GivenKernelWithPrintfWithStringMapDisbaledAndI pOutEvent->release(); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); userEvent->setStatus(CL_COMPLETE); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_STREQ("", output.c_str()); } diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_mt_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_mt_tests.cpp index 9d81d39d99..8d41938121 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_mt_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_mt_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -8,6 +8,7 @@ #include "shared/source/os_interface/os_thread.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/mocks/mock_csr.h" #include "shared/test/common/mocks/mock_device.h" #include "shared/test/common/test_macros/hw_test.h" @@ -35,7 +36,8 @@ struct CommandStreamReceiverMtTest : public ClDeviceFixture, HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadWhenSettingFlagProgressThenFunctionAsksTwiceForConfirmation) { DebugManagerStateRestore restore; debugManager.flags.PauseOnEnqueue.set(0); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); int32_t executionStamp = 0; auto mockCSR = new MockCsr(executionStamp, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); @@ -80,7 +82,7 @@ HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadWhenSettingFlagProgre } EXPECT_EQ(2u, confirmationCounter); - auto output = testing::internal::GetCapturedStdout(); + auto output = capture.getCapturedStdout(); EXPECT_TRUE(hasSubstr(output, std::string("Debug break: Press enter to start workload"))); EXPECT_TRUE(hasSubstr(output, std::string("Debug break: Workload ended, press enter to continue"))); mockCSR->userPauseConfirmation->join(); @@ -91,7 +93,8 @@ HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadBeforeWalkerOnlyWhenS DebugManagerStateRestore restore; debugManager.flags.PauseOnEnqueue.set(0); debugManager.flags.PauseOnGpuMode.set(0); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); int32_t executionStamp = 0; auto mockCSR = new MockCsr(executionStamp, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); @@ -123,7 +126,7 @@ HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadBeforeWalkerOnlyWhenS EXPECT_EQ(1u, confirmationCounter); - auto output = testing::internal::GetCapturedStdout(); + auto output = capture.getCapturedStdout(); EXPECT_TRUE(hasSubstr(output, std::string("Debug break: Press enter to start workload"))); EXPECT_FALSE(hasSubstr(output, std::string("Debug break: Workload ended, press enter to continue"))); mockCSR->userPauseConfirmation->join(); @@ -134,7 +137,8 @@ HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadAfterWalkerOnlyWhenSe DebugManagerStateRestore restore; debugManager.flags.PauseOnEnqueue.set(0); debugManager.flags.PauseOnGpuMode.set(1); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); int32_t executionStamp = 0; auto mockCSR = new MockCsr(executionStamp, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); @@ -166,7 +170,7 @@ HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadAfterWalkerOnlyWhenSe EXPECT_EQ(1u, confirmationCounter); - auto output = testing::internal::GetCapturedStdout(); + auto output = capture.getCapturedStdout(); EXPECT_FALSE(hasSubstr(output, std::string("Debug break: Press enter to start workload"))); EXPECT_TRUE(hasSubstr(output, std::string("Debug break: Workload ended, press enter to continue"))); mockCSR->userPauseConfirmation->join(); @@ -176,7 +180,8 @@ HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadAfterWalkerOnlyWhenSe HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadOnEachEnqueueWhenSettingFlagProgressThenFunctionAsksMultipleTimesForConfirmation) { DebugManagerStateRestore restore; debugManager.flags.PauseOnEnqueue.set(-2); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); int32_t executionStamp = 0; auto mockCSR = new MockCsr(executionStamp, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); @@ -253,7 +258,7 @@ HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadOnEachEnqueueWhenSett EXPECT_EQ(4u, confirmationCounter); - auto output = testing::internal::GetCapturedStdout(); + auto output = capture.getCapturedStdout(); EXPECT_TRUE(hasSubstr(output, std::string("Debug break: Press enter to start workload"))); EXPECT_TRUE(hasSubstr(output, std::string("Debug break: Workload ended, press enter to continue"))); mockCSR->userPauseConfirmation->join(); @@ -263,7 +268,8 @@ HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadOnEachEnqueueWhenSett HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadOnEachBlitWhenSettingFlagProgressThenFunctionAsksMultipleTimesForConfirmation) { DebugManagerStateRestore restore; debugManager.flags.PauseOnBlitCopy.set(-2); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); int32_t executionStamp = 0; auto mockCSR = new MockCsr(executionStamp, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); @@ -340,7 +346,7 @@ HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadOnEachBlitWhenSetting EXPECT_EQ(4u, confirmationCounter); - auto output = testing::internal::GetCapturedStdout(); + auto output = capture.getCapturedStdout(); EXPECT_TRUE(hasSubstr(output, std::string("Debug break: Press enter to start workload"))); EXPECT_TRUE(hasSubstr(output, std::string("Debug break: Workload ended, press enter to continue"))); mockCSR->userPauseConfirmation->join(); @@ -350,7 +356,8 @@ HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadOnEachBlitWhenSetting HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadWhenTerminatingAtFirstStageThenFunctionEndsCorrectly) { DebugManagerStateRestore restore; debugManager.flags.PauseOnEnqueue.set(0); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); int32_t executionStamp = 0; auto mockCSR = new MockCsr(executionStamp, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); @@ -368,7 +375,7 @@ HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadWhenTerminatingAtFirs } EXPECT_EQ(0u, confirmationCounter); - auto output = testing::internal::GetCapturedStdout(); + auto output = capture.getCapturedStdout(); EXPECT_EQ(0u, output.length()); mockCSR->userPauseConfirmation->join(); mockCSR->userPauseConfirmation.reset(); @@ -377,7 +384,8 @@ HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadWhenTerminatingAtFirs HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadWhenTerminatingAtSecondStageThenFunctionEndsCorrectly) { DebugManagerStateRestore restore; debugManager.flags.PauseOnEnqueue.set(0); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); int32_t executionStamp = 0; auto mockCSR = new MockCsr(executionStamp, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); @@ -404,7 +412,7 @@ HWTEST_F(CommandStreamReceiverMtTest, givenDebugPauseThreadWhenTerminatingAtSeco *mockCSR->debugPauseStateAddress = DebugPauseState::terminate; } - auto output = testing::internal::GetCapturedStdout(); + auto output = capture.getCapturedStdout(); EXPECT_TRUE(hasSubstr(output, std::string("Debug break: Press enter to start workload"))); EXPECT_FALSE(hasSubstr(output, std::string("Debug break: Workload ended, press enter to continue"))); EXPECT_EQ(1u, confirmationCounter); diff --git a/opencl/test/unit_test/context/driver_diagnostics_tests.cpp b/opencl/test/unit_test/context/driver_diagnostics_tests.cpp index 041b019c4b..d815c96864 100644 --- a/opencl/test/unit_test/context/driver_diagnostics_tests.cpp +++ b/opencl/test/unit_test/context/driver_diagnostics_tests.cpp @@ -11,6 +11,7 @@ #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/memory_manager/os_agnostic_memory_manager.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/stream_capture.h" #include "opencl/source/command_queue/cl_local_work_size.h" #include "opencl/source/helpers/cl_memory_properties_helpers.h" @@ -364,7 +365,8 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeEnabledWhenHintI auto context = Context::create(nullptr, ClDeviceVector(&clDevice, 1), nullptr, nullptr, retVal); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto buffer = std::unique_ptr(Buffer::create( context, CL_MEM_READ_ONLY, @@ -372,7 +374,7 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeEnabledWhenHintI nullptr, retVal)); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_NE(0u, output.size()); EXPECT_EQ('\n', output[0]); @@ -389,7 +391,8 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsAndBadHintLevelWhenAction auto context = Context::create(nullptr, ClDeviceVector(&clDevice, 1), nullptr, nullptr, retVal); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto buffer = Buffer::create( context, CL_MEM_READ_ONLY, @@ -397,7 +400,7 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsAndBadHintLevelWhenAction nullptr, retVal); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_EQ(0u, output.size()); buffer->release(); @@ -441,13 +444,14 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeEnabledWhenCallF mockKernel.mockKernel->auxTranslationRequired = true; mockKernel.mockKernel->setArgBuffer(0, sizeof(cl_mem *), &clMem); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[KERNEL_ARGUMENT_AUX_TRANSLATION], mockKernel.mockKernel->getKernelInfo().kernelDescriptor.kernelMetadata.kernelName.c_str(), 0, mockKernel.mockKernel->getKernelInfo().getExtendedMetadata(0).argName.c_str()); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_NE(0u, output.size()); EXPECT_TRUE(containsHint(expectedHint, userData)); } @@ -476,13 +480,14 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeEnabledWhenCallF mockKernel.mockKernel->auxTranslationRequired = true; mockKernel.mockKernel->setArgSvmAlloc(0, ptr, &gfxAllocation, 0u); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[KERNEL_ARGUMENT_AUX_TRANSLATION], mockKernel.mockKernel->getKernelInfo().kernelDescriptor.kernelMetadata.kernelName.c_str(), 0, mockKernel.mockKernel->getKernelInfo().getExtendedMetadata(0).argName.c_str()); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_NE(0u, output.size()); EXPECT_TRUE(containsHint(expectedHint, userData)); @@ -505,13 +510,14 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeEnabledWhenCallF mockKernel.mockKernel->initialize(); mockKernel.mockKernel->setUnifiedMemoryExecInfo(&gfxAllocation); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[KERNEL_ALLOCATION_AUX_TRANSLATION], mockKernel.mockKernel->getKernelInfo().kernelDescriptor.kernelMetadata.kernelName.c_str(), ptr, 128); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_NE(0u, output.size()); EXPECT_TRUE(containsHint(expectedHint, userData)); @@ -543,13 +549,14 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeEnabledWhenCallF allocData.device = &pDevice->getDevice(); context->getSVMAllocsManager()->insertSVMAlloc(allocData); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[KERNEL_ALLOCATION_AUX_TRANSLATION], mockKernel.mockKernel->getKernelInfo().kernelDescriptor.kernelMetadata.kernelName.c_str(), ptr, 128); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_NE(0u, output.size()); EXPECT_TRUE(containsHint(expectedHint, userData)); @@ -581,11 +588,12 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeEnabledWhenKerne mockKernel.mockKernel->auxTranslationRequired = true; mockKernel.mockKernel->setArgSvmAlloc(0, ptr, &gfxAllocation, 0u); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_EQ(0u, output.size()); delete gfxAllocation.getDefaultGmm(); @@ -611,11 +619,12 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeDisabledWhenCall mockKernel.mockKernel->auxTranslationRequired = true; mockKernel.mockKernel->setArgSvmAlloc(0, ptr, &gfxAllocation, 0u); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_EQ(0u, output.size()); delete gfxAllocation.getDefaultGmm(); @@ -635,11 +644,12 @@ TEST_F(PerformanceHintTest, whenCallingFillWithKernelObjsForAuxTranslationOnNull mockKernel.mockKernel->initialize(); mockKernel.mockKernel->setArgSvmAlloc(0, nullptr, nullptr, 0u); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_EQ(0u, output.size()); } @@ -658,10 +668,11 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeDisabledWhenCall mockKernel.mockKernel->initialize(); mockKernel.mockKernel->setUnifiedMemoryExecInfo(&gfxAllocation); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_EQ(0u, output.size()); delete gfxAllocation.getDefaultGmm(); diff --git a/opencl/test/unit_test/event/event_tests.cpp b/opencl/test/unit_test/event/event_tests.cpp index 46231ac00e..cc2385af69 100644 --- a/opencl/test/unit_test/event/event_tests.cpp +++ b/opencl/test/unit_test/event/event_tests.cpp @@ -15,6 +15,7 @@ #include "shared/source/utilities/perf_counter.h" #include "shared/source/utilities/tag_allocator.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_allocation_properties.h" #include "shared/test/common/mocks/mock_csr.h" #include "shared/test/common/mocks/mock_device.h" @@ -563,7 +564,8 @@ TEST_F(InternalsEventTest, GivenSubmitCommandTrueWhenSubmittingCommandsThenRefAp TEST_F(InternalsEventTest, givenBlockedKernelWithPrintfWhenSubmittedThenPrintOutput) { MockCommandQueue mockCmdQueue(mockContext, pClDevice, nullptr, false); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); MockEvent event(&mockCmdQueue, CL_COMMAND_NDRANGE_KERNEL, 0, 0); auto cmdStream = new LinearStream(pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties({pDevice->getRootDeviceIndex(), 4096, AllocationType::commandBuffer, pDevice->getDeviceBitfield()})); @@ -606,7 +608,7 @@ TEST_F(InternalsEventTest, givenBlockedKernelWithPrintfWhenSubmittedThenPrintOut EXPECT_EQ(mockCmdQueue.getHeaplessStateInitEnabled() ? 2u : 1u, mockCmdQueue.latestTaskCountWaited); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_STREQ("test", output.c_str()); EXPECT_FALSE(surface->isResident(pDevice->getDefaultEngine().osContext->getContextId())); } @@ -615,7 +617,8 @@ TEST_F(InternalsEventTest, givenGpuHangOnCmdQueueWaitFunctionAndBlockedKernelWit MockCommandQueue mockCmdQueue(mockContext, pClDevice, nullptr, false); mockCmdQueue.waitUntilCompleteReturnValue = WaitStatus::gpuHang; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); MockEvent event(&mockCmdQueue, CL_COMMAND_NDRANGE_KERNEL, 0, 0); auto cmdStream = new LinearStream(pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties({pDevice->getRootDeviceIndex(), 4096, AllocationType::commandBuffer, pDevice->getDeviceBitfield()})); @@ -657,14 +660,15 @@ TEST_F(InternalsEventTest, givenGpuHangOnCmdQueueWaitFunctionAndBlockedKernelWit event.submitCommand(false); EXPECT_EQ(Event::executionAbortedDueToGpuHang, event.peekExecutionStatus()); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_STREQ("test", output.c_str()); } TEST_F(InternalsEventTest, givenGpuHangOnPrintingEnqueueOutputAndBlockedKernelWithPrintfWhenSubmittedThenEventIsAbortedAndHangIsReported) { MockCommandQueue mockCmdQueue(mockContext, pClDevice, nullptr, false); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); MockEvent event(&mockCmdQueue, CL_COMMAND_NDRANGE_KERNEL, 0, 0); auto cmdStream = new LinearStream(pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties({pDevice->getRootDeviceIndex(), 4096, AllocationType::commandBuffer, pDevice->getDeviceBitfield()})); @@ -706,7 +710,7 @@ TEST_F(InternalsEventTest, givenGpuHangOnPrintingEnqueueOutputAndBlockedKernelWi event.submitCommand(false); EXPECT_EQ(Event::executionAbortedDueToGpuHang, event.peekExecutionStatus()); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_TRUE(output.empty()); } diff --git a/opencl/test/unit_test/linux/main_linux_dll.cpp b/opencl/test/unit_test/linux/main_linux_dll.cpp index 7a915237d7..df13a3ee98 100644 --- a/opencl/test/unit_test/linux/main_linux_dll.cpp +++ b/opencl/test/unit_test/linux/main_linux_dll.cpp @@ -22,6 +22,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/default_hw_info.inl" #include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/ult_hw_config.inl" #include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/libult/signal_utils.h" @@ -194,7 +195,8 @@ TEST_F(DrmSimpleTests, GivenSelectedExistingDeviceWhenOpenDirFailsThenRetryOpeni } TEST_F(DrmSimpleTests, givenPrintIoctlEntriesWhenCallIoctlThenIoctlIsPrinted) { - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto drm = DrmWrap::createDrm(*(mockExecutionEnvironment.rootDeviceEnvironments[0].get())); @@ -204,7 +206,7 @@ TEST_F(DrmSimpleTests, givenPrintIoctlEntriesWhenCallIoctlThenIoctlIsPrinted) { uint32_t contextId = 1u; drm->destroyDrmContext(contextId); - std::string output = ::testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_STREQ(output.c_str(), "IOCTL DRM_IOCTL_I915_GEM_CONTEXT_DESTROY called\nIOCTL DRM_IOCTL_I915_GEM_CONTEXT_DESTROY returns 0\n"); } @@ -218,7 +220,8 @@ struct DrmFailedIoctlTests : public ::testing::Test { }; TEST_F(DrmFailedIoctlTests, givenPrintIoctlEntriesWhenCallFailedIoctlThenExpectedIoctlIsPrinted) { - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto drm = DrmWrap::createDrm(*(mockExecutionEnvironment.rootDeviceEnvironments[0].get())); @@ -229,7 +232,7 @@ TEST_F(DrmFailedIoctlTests, givenPrintIoctlEntriesWhenCallFailedIoctlThenExpecte uint32_t vmId = 100u; drm->queryVmId(contextId, vmId); - std::string output = ::testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_STREQ(output.c_str(), "IOCTL DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM called\nIOCTL DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM returns -1, errno 9(Bad file descriptor)\n"); } @@ -318,11 +321,12 @@ TEST_F(DrmSimpleTests, givenPrintIoctlTimesWhenCallIoctlThenStatisticsAreGathere EXPECT_EQ(1u, destroyData->second.count); EXPECT_NE(0, destroyData->second.totalTime); - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); drm.reset(); - std::string output = ::testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_STRNE("", output.c_str()); std::string_view requestString("Request"); @@ -521,12 +525,13 @@ TEST_F(DrmTests, GivenUnknownDeviceWhenCreatingDrmThenNullIsReturned) { revisionId = -1; ::testing::internal::CaptureStderr(); - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto drm = DrmWrap::createDrm(*mockRootDeviceEnvironment); EXPECT_EQ(drm, nullptr); std::string errStr = ::testing::internal::GetCapturedStderr(); EXPECT_TRUE(hasSubstr(errStr, std::string("FATAL: Unknown device: deviceId: ffff, revisionId: ffff"))); - ::testing::internal::GetCapturedStdout(); + capture.getCapturedStdout(); } TEST_F(DrmTests, GivenKnownDeviceWhenCreatingDrmThenHwInfoIsProperlySet) { @@ -738,7 +743,8 @@ TEST_F(DrmTests, givenEnabledDebuggingAndVmBindNotAvailableWhenDrmIsCreatedThenP DebugManagerStateRestore restore; ::testing::internal::CaptureStderr(); - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); debugManager.flags.CreateMultipleSubDevices.set(2); debugManager.flags.UseVmBind.set(0); @@ -750,7 +756,7 @@ TEST_F(DrmTests, givenEnabledDebuggingAndVmBindNotAvailableWhenDrmIsCreatedThenP EXPECT_NE(drm, nullptr); if (drm->isPerContextVMRequired()) { - ::testing::internal::GetCapturedStdout(); + capture.getCapturedStdout(); ::testing::internal::GetCapturedStderr(); GTEST_SKIP(); } @@ -762,7 +768,7 @@ TEST_F(DrmTests, givenEnabledDebuggingAndVmBindNotAvailableWhenDrmIsCreatedThenP EXPECT_NE(0u, static_cast(drm.get())->virtualMemoryIds.size()); debugManager.flags.PrintDebugMessages.set(false); - ::testing::internal::GetCapturedStdout(); + capture.getCapturedStdout(); std::string errStr = ::testing::internal::GetCapturedStderr(); auto &compilerProductHelper = drm->getRootDeviceEnvironment().getHelper(); @@ -798,7 +804,8 @@ TEST_F(DrmTests, givenDrmIsCreatedWhenCreateVirtualMemoryFailsThenReturnVirtualM failOnVirtualMemoryCreate = -1; ::testing::internal::CaptureStderr(); - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto drm = DrmWrap::createDrm(*mockRootDeviceEnvironment); EXPECT_NE(drm, nullptr); @@ -809,7 +816,7 @@ TEST_F(DrmTests, givenDrmIsCreatedWhenCreateVirtualMemoryFailsThenReturnVirtualM if (!drm->isPerContextVMRequired()) { EXPECT_TRUE(hasSubstr(errStr, std::string("INFO: Device doesn't support GEM Virtual Memory"))); } - ::testing::internal::GetCapturedStdout(); + capture.getCapturedStdout(); } TEST(SysCalls, WhenSysCallsPollCalledThenCallIsRedirectedToOs) { @@ -990,7 +997,8 @@ TEST_F(DrmTests, whenDrmIsCreatedAndQueryEngineInfoFailsThenWarningIsReported) { DrmQueryConfig::failOnQueryEngineInfo = true; ::testing::internal::CaptureStderr(); - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); MockExecutionEnvironment mockExecutionEnvironment; auto drm = DrmWrap::createDrm(*mockExecutionEnvironment.rootDeviceEnvironments[0]); @@ -998,7 +1006,7 @@ TEST_F(DrmTests, whenDrmIsCreatedAndQueryEngineInfoFailsThenWarningIsReported) { std::string errStr = ::testing::internal::GetCapturedStderr(); EXPECT_TRUE(hasSubstr(errStr, std::string("WARNING: Failed to query engine info\n"))); - ::testing::internal::GetCapturedStdout(); + capture.getCapturedStdout(); } TEST_F(DrmTests, whenDrmIsCreatedAndQueryMemoryInfoFailsThenWarningIsReported) { @@ -1010,7 +1018,8 @@ TEST_F(DrmTests, whenDrmIsCreatedAndQueryMemoryInfoFailsThenWarningIsReported) { DrmQueryConfig::failOnQueryMemoryInfo = true; ::testing::internal::CaptureStderr(); - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); MockExecutionEnvironment mockExecutionEnvironment; auto drm = DrmWrap::createDrm(*mockExecutionEnvironment.rootDeviceEnvironments[0]); @@ -1018,5 +1027,5 @@ TEST_F(DrmTests, whenDrmIsCreatedAndQueryMemoryInfoFailsThenWarningIsReported) { std::string errStr = ::testing::internal::GetCapturedStderr(); EXPECT_TRUE(hasSubstr(errStr, std::string("WARNING: Failed to query memory info\n"))); - ::testing::internal::GetCapturedStdout(); + capture.getCapturedStdout(); } diff --git a/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp index 40b5994cb9..7ae69adba3 100644 --- a/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp @@ -13,6 +13,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/engine_descriptor_helper.h" #include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/unit_test_helper.h" #include "shared/test/common/mocks/mock_memory_manager.h" #include "shared/test/common/mocks/mock_os_context.h" @@ -314,11 +315,12 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenDebugFlagSetWhenDispatchingBlitCommandsT uint64_t bufferGpuAddr = bufferForBlt->getGraphicsAllocation(0)->getGpuAddress(); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); commandQueue->enqueueWriteBuffer(bufferForBlt.get(), CL_TRUE, 0, copySize, myHostPtr.get(), nullptr, 0, nullptr, nullptr); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_NE(0u, output.size()); char expectedStr[512] = {}; diff --git a/opencl/test/unit_test/mem_obj/buffer_pool_alloc_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_pool_alloc_tests.cpp index 5153f4bac3..f3d4d3af42 100644 --- a/opencl/test/unit_test/mem_obj/buffer_pool_alloc_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_pool_alloc_tests.cpp @@ -11,6 +11,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/mock_product_helper_hw.h" #include "shared/test/common/helpers/raii_product_helper.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_ail_configuration.h" #include "shared/test/common/mocks/mock_memory_manager.h" #include "shared/test/common/mocks/mock_product_helper.h" @@ -563,13 +564,14 @@ TEST_F(AggregatedSmallBuffersEnabledTestFailPoolInit, givenAggregatedSmallBuffer using AggregatedSmallBuffersEnabledTestDoNotRunSetup = AggregatedSmallBuffersTestTemplate<1, false, false>; TEST_F(AggregatedSmallBuffersEnabledTestDoNotRunSetup, givenAggregatedSmallBuffersEnabledWhenPoolInitializedThenPerformanceHintsNotProvided) { - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); debugManager.flags.PrintDriverDiagnostics.set(1); setUpImpl(); EXPECT_TRUE(poolAllocator->isAggregatedSmallBuffersEnabled(context.get())); EXPECT_FALSE(poolAllocator->bufferPools.empty()); EXPECT_NE(context->driverDiagnostics, nullptr); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_EQ(0u, output.size()); } diff --git a/opencl/test/unit_test/offline_compiler/decoder/encoder_tests.cpp b/opencl/test/unit_test/offline_compiler/decoder/encoder_tests.cpp index 93e39f3202..f42152323d 100644 --- a/opencl/test/unit_test/offline_compiler/decoder/encoder_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/decoder/encoder_tests.cpp @@ -8,7 +8,7 @@ #include "shared/offline_compiler/source/decoder/binary_decoder.h" #include "shared/source/helpers/aligned_memory.h" #include "shared/source/helpers/array_count.h" -#include "shared/test/common/helpers/stdout_capture.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/test_files.h" #include "opencl/test/unit_test/offline_compiler/environment.h" @@ -51,7 +51,7 @@ TEST(EncoderTests, GivenFlagsWhichRequireMoreArgsWithoutThemWhenParsingThenError constexpr auto suppressMessages{false}; MockEncoder encoder{suppressMessages}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = encoder.validateInput(args); const auto output{capture.getCapturedStdout()}; @@ -113,7 +113,7 @@ TEST(EncoderTests, GivenMissingDumpFlagAndArgHelperOutputEnabledWhenParsingValid encoder.mockArgHelper->hasOutput = true; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = encoder.validateInput(args); const auto output{capture.getCapturedStdout()}; @@ -129,7 +129,7 @@ TEST(EncoderTests, GivenMissingPTMFileWhenEncodingThenErrorIsReturnedAndLogIsPri constexpr auto suppressMessages{false}; MockEncoder encoder{suppressMessages}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = encoder.encode(); const auto output{capture.getCapturedStdout()}; diff --git a/opencl/test/unit_test/offline_compiler/decoder/zebin_manipulator_tests.cpp b/opencl/test/unit_test/offline_compiler/decoder/zebin_manipulator_tests.cpp index 43138dfcf6..45538eef90 100644 --- a/opencl/test/unit_test/offline_compiler/decoder/zebin_manipulator_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/decoder/zebin_manipulator_tests.cpp @@ -10,7 +10,7 @@ #include "shared/source/device_binary_format/elf/elf.h" #include "shared/source/device_binary_format/elf/elf_encoder.h" #include "shared/source/helpers/product_config_helper.h" -#include "shared/test/common/helpers/stdout_capture.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/mocks/mock_elf.h" #include "shared/test/common/mocks/mock_io_functions.h" @@ -214,7 +214,7 @@ TEST_F(ZebinManipulatorValidateInputTests, GivenInvalidInputWhenValidatingInputT "asm/disasm", "-unknown_arg"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); auto retVal = NEO::Zebin::Manipulator::validateInput(args, &iga, &argHelper, arguments); const auto output{capture.getCapturedStdout()}; @@ -229,7 +229,7 @@ TEST_F(ZebinManipulatorValidateInputTests, GivenMissingFileWhenValidatingInputTh "-dump", "./dump/"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); auto retVal = NEO::Zebin::Manipulator::validateInput(args, &iga, &argHelper, arguments); const auto output{capture.getCapturedStdout()}; @@ -244,7 +244,8 @@ TEST_F(ZebinManipulatorValidateInputTests, GivenMissingSecondPartOfTheArgumentWh "-arg"}; for (const auto halfArg : {"-file", "-device", "-dump"}) { args[2] = halfArg; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); auto retVal = NEO::Zebin::Manipulator::validateInput(args, &iga, &argHelper, arguments); const auto output{capture.getCapturedStdout()}; @@ -261,7 +262,7 @@ TEST_F(ZebinManipulatorValidateInputTests, GivenValidArgsButDumpNotSpecifiedWhen "-file", "binary.bin"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); auto retVal = NEO::Zebin::Manipulator::validateInput(args, &iga, &argHelper, arguments); const auto output{capture.getCapturedStdout()}; diff --git a/opencl/test/unit_test/offline_compiler/ocloc_api_tests.cpp b/opencl/test/unit_test/offline_compiler/ocloc_api_tests.cpp index 35339ad8e4..2d59ad4578 100644 --- a/opencl/test/unit_test/offline_compiler/ocloc_api_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/ocloc_api_tests.cpp @@ -21,7 +21,7 @@ #include "shared/source/helpers/string.h" #include "shared/test/common/helpers/gtest_helpers.h" #include "shared/test/common/helpers/mock_file_io.h" -#include "shared/test/common/helpers/stdout_capture.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/mocks/mock_io_functions.h" #include "shared/test/common/mocks/mock_os_library.h" @@ -106,7 +106,7 @@ TEST_F(OclocApiTest, WhenGoodArgsAreGivenThenSuccessIsReturned) { gEnvironment->devicePrefix.c_str()}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -159,7 +159,7 @@ TEST_F(OclocApiTest, GivenQuietModeAndValidArgumentsWhenRunningOclocThenSuccessI gEnvironment->devicePrefix.c_str()}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -270,7 +270,8 @@ TEST(OclocApiTests, GivenNoQueryWhenQueryingThenErrorIsReturned) { "ocloc", "query"}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -288,7 +289,8 @@ TEST(OclocApiTests, GivenInvalidQueryWhenQueryingThenErrorIsReturned) { "query", "unknown_query"}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -305,7 +307,8 @@ TEST(OclocApiTests, givenNoAcronymWhenIdsCommandIsInvokeThenErrorIsReported) { "ocloc", "ids"}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -323,7 +326,8 @@ TEST(OclocApiTests, givenUnknownAcronymWhenIdsCommandIsInvokeThenErrorIsReported "ids", "unk"}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -390,7 +394,7 @@ TEST_F(OclocApiTest, WhenGoodFamilyNameIsProvidedThenSuccessIsReturned) { family.c_str()}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -427,7 +431,7 @@ TEST(OclocApiTests, WhenArgsWithMissingFileAreGivenThenErrorMessageIsProduced) { gEnvironment->devicePrefix.c_str()}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -465,7 +469,7 @@ TEST(OclocApiTests, givenInputOptionsAndInternalOptionsWhenCmdlineIsPrintedThenB "-options", "-D DEBUG -cl-kernel-arg-info", "-internal_options", "-internalOption1 -internal-option-2"}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -507,7 +511,7 @@ TEST(OclocApiTests, givenInputOptionsCalledOptionsWhenCmdlineIsPrintedThenQuotes "-options", "-options", "-internal_options", "-internalOption"}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -639,7 +643,7 @@ TEST(OclocApiTests, GivenHelpParameterWhenDecodingThenHelpMsgIsPrintedAndSuccess "--help"}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -663,7 +667,7 @@ TEST(OclocApiTests, GivenNonExistingFileWhenDecodingThenAbortIsCalled) { "test_files/created"}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -682,7 +686,7 @@ TEST(OclocApiTests, GivenMissingFileNameWhenDecodingThenErrorIsReturned) { "-file"}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -767,7 +771,7 @@ TEST_F(OclocApiTest, GivenOnlySpirVWithMultipleDevicesWhenCompilingThenFirstDevi } } - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -818,7 +822,7 @@ TEST(OclocApiTests, GivenHelpParameterWhenEncodingThenHelpMsgIsPrintedAndSuccess "--help"}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -851,7 +855,7 @@ TEST(OclocApiTests, GivenMissingDumpFileNameWhenEncodingThenErrorIsReturned) { "-dump"}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -888,7 +892,7 @@ TEST(OclocApiTests, GivenValidArgumentsAndMissingPtmFileWhenEncodingThenErrorIsR "test_files/binary_gen.bin"}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -907,7 +911,7 @@ TEST(OclocApiTests, GiveMultiCommandHelpArgumentsWhenInvokingOclocThenHelpIsPrin "--help"}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -942,7 +946,7 @@ TEST(OclocApiTests, GivenNonexistentFileWhenValidateIsInvokedThenErrorIsPrinted) "some_special_nonexistent_file.gen"}; unsigned int argc = sizeof(argv) / sizeof(argv[0]); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -961,7 +965,7 @@ TEST(OclocApiTests, GivenCommandWithoutArgsWhenOclocIsInvokedThenHelpIsPrinted) "ocloc"}; unsigned int argc = sizeof(argv) / sizeof(argv[0]); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -982,7 +986,7 @@ TEST(OclocApiTests, GivenHelpArgumentWhenOclocIsInvokedThenHelpIsPrinted) { unsigned int argc = sizeof(argv) / sizeof(argv[0]); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -1002,7 +1006,7 @@ TEST(OclocApiTests, GivenHelpParameterWhenLinkingThenHelpMsgIsPrintedAndSuccessI "--help"}; unsigned int argc = sizeof(argv) / sizeof(argv[0]); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -1020,7 +1024,7 @@ TEST(OclocApiTests, GivenInvalidParameterWhenLinkingThenErrorIsReturned) { "--dummy_param"}; unsigned int argc = sizeof(argv) / sizeof(argv[0]); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -1040,7 +1044,8 @@ TEST(OclocApiTests, GivenInvalidCommandLineWhenConcatenatingThenErrorIsReturned) "ocloc", "concat"}; unsigned int argc = sizeof(argv) / sizeof(argv[0]); - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -1091,7 +1096,8 @@ TEST(OclocApiTests, GivenValidCommandLineAndFatBinariesWhenConcatenatingThenNewF "-out", "catFatBinary.ar"}; unsigned int argc = sizeof(argv) / sizeof(argv[0]); - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 2, sourcesData, sourcesLen, sourcesName, @@ -1175,7 +1181,7 @@ TEST_F(OclocApiTest, GivenVerboseModeWhenCompilingThenPrintCommandLine) { "-v"}; unsigned int argc = sizeof(argv) / sizeof(const char *); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, @@ -1233,7 +1239,8 @@ struct OclocFallbackTests : ::testing::Test { &numOutputs, &dataOutputs, &lenOutputs, &nameOutputs); return retVal; } else { - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); testing::internal::CaptureStderr(); diff --git a/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.cpp b/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.cpp index 4bc74eb425..d6b08cde33 100644 --- a/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.cpp @@ -20,7 +20,7 @@ #include "shared/source/helpers/product_config_helper.h" #include "shared/source/release_helper/release_helper.h" #include "shared/test/common/helpers/gtest_helpers.h" -#include "shared/test/common/helpers/stdout_capture.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/mocks/mock_io_functions.h" @@ -337,7 +337,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenClosedRangeTooExtensiveWhenProdu "-device", target}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -398,7 +398,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoTargetsOfProductsWhenFatBinar "-device", acronymsTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -437,7 +437,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoVersionsOfProductConfigsWhenF "-device", acronymsTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -471,7 +471,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenProductsAcronymsWithoutDashesWhe "-device", acronymsTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -510,7 +510,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenBinaryOutputNameOptionWhenBuildi "-device", acronymsTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -550,7 +550,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenBinaryOutputDirOptionWhenBuildin "-device", acronymsTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -580,7 +580,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenBinaryOutputDirOptionWhenBuildin "-device", acronymsTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -691,7 +691,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoTargetsOfReleasesWhenFatBinar "-device", acronymsTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -733,7 +733,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoTargetsOfFamiliesWhenFatBinar "-device", acronymsTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -776,7 +776,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenProductsClosedRangeWhenFatBinary "-device", acronymsTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -815,7 +815,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenProductsClosedRangeWithoutDashes "-device", acronymsTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -905,7 +905,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenClosedRangeWithOneFamilyBeingGen "-device", acronymsTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -952,7 +952,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenFamiliesClosedRangeWhenFatBinary "-device", acronymsTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -986,7 +986,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenOpenRangeFromProductWhenFatBinar "-device", acronymsTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1024,7 +1024,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenOpenRangeFromProductWithoutDashe "-device", acronymsTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1059,7 +1059,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenOpenRangeToProductWhenFatBinaryB "-device", acronymsTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1202,7 +1202,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenOpenRangeFromReleaseWhenFatBinar "-device", releasesTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1235,7 +1235,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenDeviceOptionsForNotCompiledDevic enabledProductsAcronyms[2].str(), "deviceOptions"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); [[maybe_unused]] int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1280,7 +1280,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenDeviceOptionsForCompiledDeviceAn enabledProductsAcronyms[0].str(), "deviceOptions"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); [[maybe_unused]] int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1333,7 +1333,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenDeviceOptionsForMultipleDevicesS productsForDeviceOptions.str().c_str(), "deviceOptions"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); [[maybe_unused]] int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1374,7 +1374,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenOpenRangeToReleaseWhenFatBinaryB "-device", releasesTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1560,7 +1560,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenOpenRangeFromFamilyWhenFatBinary "-device", familiesTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1602,7 +1602,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenOpenRangeToFamilyWhenFatBinaryBu "-device", familiesTarget}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1750,7 +1750,7 @@ TEST_F(OclocFatBinaryTest, givenDeviceFlagWithoutConsecutiveArgumentWhenBuilding "ocloc", "-device"}; - ::StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = buildFatBinary(args, &mockArgHelper); const auto output{capture.getCapturedStdout()}; @@ -1775,7 +1775,7 @@ TEST_F(OclocFatBinaryTest, givenFlagsWhichRequireMoreArgsWithoutThemWhenBuilding devices, flag}; - ::StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = buildFatBinary(args, &mockArgHelper); const auto output{capture.getCapturedStdout()}; @@ -1945,7 +1945,7 @@ TEST_F(OclocFatBinaryTest, givenEmptyFileWhenAppendingGenericIrThenInvalidFileIs mockArgHelperFilesMap[emptyFile] = ""; mockArgHelper.shouldLoadDataFromFileReturnZeroSize = true; - ::StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto errorCode{appendGenericIr(ar, emptyFile, &mockArgHelper, dummyOptions)}; const auto output{capture.getCapturedStdout()}; @@ -1960,7 +1960,7 @@ TEST_F(OclocFatBinaryTest, givenInvalidIrFileWhenAppendingGenericIrThenInvalidFi std::string dummyOptions{"-cl-opt-disable "}; mockArgHelperFilesMap[dummyFile] = "This is not IR!"; - ::StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto errorCode{appendGenericIr(ar, dummyFile, &mockArgHelper, dummyOptions)}; const auto output{capture.getCapturedStdout()}; @@ -2019,7 +2019,7 @@ TEST_F(OclocTest, givenPreviousCompilationSuccessAndFailingBuildWhenBuildingFatb const auto mockArgHelper = mockOfflineCompiler.uniqueHelper.get(); const auto deviceConfig = getDeviceConfig(mockOfflineCompiler, mockArgHelper); - ::StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const int previousReturnValue{OCLOC_SUCCESS}; const auto buildResult = buildFatBinaryForTarget(previousReturnValue, argv, pointerSize, ar, &mockOfflineCompiler, mockArgHelper, deviceConfig); @@ -2066,7 +2066,7 @@ TEST_F(OclocTest, givenNonEmptyBuildLogWhenBuildingFatbinaryForTargetThenBuildLo const auto mockArgHelper = mockOfflineCompiler.uniqueHelper.get(); const auto deviceConfig = getDeviceConfig(mockOfflineCompiler, mockArgHelper); - ::StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const int previousReturnValue{OCLOC_SUCCESS}; const auto buildResult = buildFatBinaryForTarget(previousReturnValue, argv, pointerSize, ar, &mockOfflineCompiler, mockArgHelper, deviceConfig); @@ -2080,7 +2080,7 @@ TEST_F(OclocTest, givenNonEmptyBuildLogWhenBuildingFatbinaryForTargetThenBuildLo } TEST_F(OclocTest, givenNonEmptyBuildLogWhenBuildingFatbinaryForTargetThenBuildLogIsNotPrinted) { - ::StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const std::vector argv = { @@ -2120,7 +2120,7 @@ TEST_F(OclocTest, givenListOfDeprecatedAcronymsThenUseThemAsIs) { return; } - ::StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); std::vector argv = { @@ -2180,7 +2180,7 @@ TEST_F(OclocTest, givenListOfGenericAcronymsThenUseThemAsIs) { GTEST_SKIP(); } - ::StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); std::vector argv = { @@ -2252,7 +2252,7 @@ TEST_F(OclocTest, givenQuietModeWhenBuildingFatbinaryForTargetThenNothingIsPrint const auto mockArgHelper = mockOfflineCompiler.uniqueHelper.get(); const auto deviceConfig = getDeviceConfig(mockOfflineCompiler, mockArgHelper); - ::StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const int previousReturnValue{OCLOC_SUCCESS}; const auto buildResult = buildFatBinaryForTarget(previousReturnValue, argv, pointerSize, ar, &mockOfflineCompiler, mockArgHelper, deviceConfig); diff --git a/opencl/test/unit_test/offline_compiler/ocloc_fcl_facade_tests.cpp b/opencl/test/unit_test/offline_compiler/ocloc_fcl_facade_tests.cpp index 87a6990349..6668422a3e 100644 --- a/opencl/test/unit_test/offline_compiler/ocloc_fcl_facade_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/ocloc_fcl_facade_tests.cpp @@ -11,7 +11,7 @@ #include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/os_interface/os_inc_base.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" -#include "shared/test/common/helpers/stdout_capture.h" +#include "shared/test/common/helpers/stream_capture.h" #include "mock/mock_ocloc_fcl_facade.h" @@ -23,7 +23,7 @@ TEST_F(OclocFclFacadeTest, GivenMissingFclLibraryWhenPreparingFclThenFailureIsRe MockOclocFclFacade mockFclFacade{&mockArgHelper}; mockFclFacade.shouldFailLoadingOfFclLib = true; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto fclPreparationResult{mockFclFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -41,7 +41,7 @@ TEST_F(OclocFclFacadeTest, GivenFailingLoadingOfFclSymbolsWhenPreparingFclThenFa MockOclocFclFacade mockFclFacade{&mockArgHelper}; mockFclFacade.shouldFailLoadingOfFclCreateMainFunction = true; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto fclPreparationResult{mockFclFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -57,7 +57,7 @@ TEST_F(OclocFclFacadeTest, GivenFailingCreationOfFclMainWhenPreparingFclThenFail MockOclocFclFacade mockFclFacade{&mockArgHelper}; mockFclFacade.shouldFailCreationOfFclMain = true; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto fclPreparationResult{mockFclFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -77,7 +77,7 @@ TEST_F(OclocFclFacadeTest, GivenIncompatibleFclInterfacesWhenPreparingFclThenFai mockFclFacade.isFclInterfaceCompatibleReturnValue = false; mockFclFacade.getIncompatibleInterfaceReturnValue = "SomeImportantInterface"; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto fclPreparationResult{mockFclFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -93,7 +93,7 @@ TEST_F(OclocFclFacadeTest, GivenFailingCreationOfFclDeviceContextWhenPreparingFc MockOclocFclFacade mockFclFacade{&mockArgHelper}; mockFclFacade.shouldFailCreationOfFclDeviceContext = true; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto fclPreparationResult{mockFclFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -109,7 +109,7 @@ TEST_F(OclocFclFacadeTest, GivenNoneErrorsSetAndNotPopulateFclInterfaceWhenPrepa MockOclocFclFacade mockFclFacade{&mockArgHelper}; mockFclFacade.shouldPopulateFclInterfaceReturnValue = false; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto fclPreparationResult{mockFclFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -125,7 +125,7 @@ TEST_F(OclocFclFacadeTest, GivenPopulateFclInterfaceAndInvalidFclDeviceContextWh mockFclFacade.shouldPopulateFclInterfaceReturnValue = true; mockFclFacade.shouldReturnInvalidFclPlatformHandle = true; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto fclPreparationResult{mockFclFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -143,7 +143,7 @@ TEST_F(OclocFclFacadeTest, GivenPopulateFclInterfaceWhenPreparingFclThenSuccessI MockOclocFclFacade mockFclFacade{&mockArgHelper}; mockFclFacade.shouldPopulateFclInterfaceReturnValue = true; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto fclPreparationResult{mockFclFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -158,7 +158,7 @@ TEST_F(OclocFclFacadeTest, GivenPopulateFclInterfaceWhenPreparingFclThenSuccessI TEST_F(OclocFclFacadeTest, GivenNoneErrorsSetWhenPreparingFclThenSuccessIsReported) { MockOclocFclFacade mockFclFacade{&mockArgHelper}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto fclPreparationResult{mockFclFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -174,7 +174,7 @@ TEST_F(OclocFclFacadeTest, GivenNoneErrorsSetWhenPreparingFclThenSuccessIsReport TEST_F(OclocFclFacadeTest, GivenInitializedFclWhenGettingIncompatibleInterfaceThenEmptyStringIsReturned) { MockOclocFclFacade mockFclFacade{&mockArgHelper}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto fclPreparationResult{mockFclFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; diff --git a/opencl/test/unit_test/offline_compiler/ocloc_igc_facade_tests.cpp b/opencl/test/unit_test/offline_compiler/ocloc_igc_facade_tests.cpp index 6e385f66d2..cb2855a700 100644 --- a/opencl/test/unit_test/offline_compiler/ocloc_igc_facade_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/ocloc_igc_facade_tests.cpp @@ -11,7 +11,7 @@ #include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/os_interface/os_inc_base.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" -#include "shared/test/common/helpers/stdout_capture.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_compilers.h" #include "mock/mock_ocloc_igc_facade.h" @@ -24,7 +24,7 @@ TEST_F(OclocIgcFacadeTest, GivenMissingIgcLibraryWhenPreparingIgcThenFailureIsRe MockOclocIgcFacade mockIgcFacade{&mockArgHelper}; mockIgcFacade.shouldFailLoadingOfIgcLib = true; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); std::string libName = "invalidigc.so"; auto igcNameGuard = NEO::pushIgcDllName(libName.c_str()); @@ -44,7 +44,7 @@ TEST_F(OclocIgcFacadeTest, GivenFailingLoadingOfIgcSymbolsWhenPreparingIgcThenFa MockOclocIgcFacade mockIgcFacade{&mockArgHelper}; mockIgcFacade.shouldFailLoadingOfIgcCreateMainFunction = true; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto igcPreparationResult{mockIgcFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -60,7 +60,7 @@ TEST_F(OclocIgcFacadeTest, GivenFailingCreationOfIgcMainWhenPreparingIgcThenFail MockOclocIgcFacade mockIgcFacade{&mockArgHelper}; mockIgcFacade.shouldFailCreationOfIgcMain = true; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto igcPreparationResult{mockIgcFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -80,7 +80,7 @@ TEST_F(OclocIgcFacadeTest, GivenIncompatibleIgcInterfacesWhenPreparingIgcThenFai mockIgcFacade.isIgcInterfaceCompatibleReturnValue = false; mockIgcFacade.getIncompatibleInterfaceReturnValue = "SomeImportantInterface"; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto igcPreparationResult{mockIgcFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -96,7 +96,7 @@ TEST_F(OclocIgcFacadeTest, GivenMissingPatchtokenInterfaceWhenPreparingIgcThenFa MockOclocIgcFacade mockIgcFacade{&mockArgHelper}; mockIgcFacade.isPatchtokenInterfaceSupportedReturnValue = false; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto igcPreparationResult{mockIgcFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -112,7 +112,7 @@ TEST_F(OclocIgcFacadeTest, GivenFailingCreationOfIgcDeviceContextWhenPreparingIg MockOclocIgcFacade mockIgcFacade{&mockArgHelper}; mockIgcFacade.shouldFailCreationOfIgcDeviceContext = true; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto igcPreparationResult{mockIgcFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -134,7 +134,7 @@ TEST_F(OclocIgcFacadeTest, GivenInvalidIgcDeviceContextWhenPreparingIgcThenFailu MockOclocIgcFacade mockIgcFacade{&mockArgHelper}; mockIgcFacade.*invalidReturnFlag = true; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto igcPreparationResult{mockIgcFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -150,7 +150,7 @@ TEST_F(OclocIgcFacadeTest, GivenInvalidIgcDeviceContextWhenPreparingIgcThenFailu TEST_F(OclocIgcFacadeTest, GivenNoneErrorsSetWhenPreparingIgcThenSuccessIsReported) { MockOclocIgcFacade mockIgcFacade{&mockArgHelper}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto igcPreparationResult{mockIgcFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -163,7 +163,7 @@ TEST_F(OclocIgcFacadeTest, GivenNoneErrorsSetWhenPreparingIgcThenSuccessIsReport TEST_F(OclocIgcFacadeTest, GivenInitializedIgcWhenGettingIncompatibleInterfaceThenEmptyStringIsReturned) { MockOclocIgcFacade mockIgcFacade{&mockArgHelper}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto igcPreparationResult{mockIgcFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; @@ -180,7 +180,7 @@ TEST_F(OclocIgcFacadeTest, GivenFailingCreationOfIgcDeviceContext3WhenGettingRev MockOclocIgcFacade mockIgcFacade{&mockArgHelper}; mockIgcFacade.shouldFailCreationOfIgcDeviceContext3 = true; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto igcPreparationResult{mockIgcFacade.initialize(hwInfo)}; const auto output{capture.getCapturedStdout()}; diff --git a/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp b/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp index 9d66ca2263..743848ef3f 100644 --- a/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp @@ -24,7 +24,7 @@ #include "shared/source/helpers/product_config_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/stdout_capture.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/mocks/mock_compiler_cache.h" #include "shared/test/common/mocks/mock_compilers.h" @@ -259,7 +259,7 @@ TEST_F(MultiCommandTests, GivenMissingTextFileWithArgsWhenBuildingMultiCommandTh "-q", }; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); auto pMultiCommand = std::unique_ptr(MultiCommand::create(argv, retVal, oclocArgHelperWithoutInput.get())); std::string output = capture.getCapturedStdout(); @@ -288,7 +288,8 @@ TEST_F(MultiCommandTests, GivenLackOfClFileWhenBuildingMultiCommandThenInvalidFi int numOfBuild = 4; createFileWithArgs(singleArgs, numOfBuild); - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); auto pMultiCommand = std::unique_ptr(MultiCommand::create(argv, retVal, oclocArgHelperWithoutInput.get())); std::string output = capture.getCapturedStdout(); @@ -345,7 +346,7 @@ TEST(MultiCommandWhiteboxTest, GivenVerboseModeWhenShowingResultsThenLogsArePrin mockMultiCommand.retValues = {OCLOC_SUCCESS, OCLOC_INVALID_FILE}; mockMultiCommand.quiet = false; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = mockMultiCommand.showResults(); const auto output = capture.getCapturedStdout(); @@ -376,7 +377,7 @@ TEST(MultiCommandWhiteboxTest, GivenVerboseModeAndDefinedOutputFilenameAndDirect const auto singleArgsCopy{singleArgs}; const size_t buildId{0}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); mockMultiCommand.addAdditionalOptionsToSingleCommandLine(singleArgs, buildId); const auto output = capture.getCapturedStdout(); @@ -393,7 +394,7 @@ TEST(MultiCommandWhiteboxTest, GivenHelpArgumentsWhenInitializingThenHelpIsPrint const auto args{singleArgs}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = mockMultiCommand.initialize(args); const auto output = capture.getCapturedStdout(); @@ -426,7 +427,7 @@ TEST(MultiCommandWhiteboxTest, GivenCommandLineWithApostrophesWhenSplittingLineI std::vector outputArgs{}; const std::size_t numberOfBuild{0}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = mockMultiCommand.splitLineInSeparateArgs(outputArgs, commandLine, numberOfBuild); const auto output = capture.getCapturedStdout(); @@ -451,7 +452,7 @@ TEST(MultiCommandWhiteboxTest, GivenCommandLineWithMissingApostropheWhenSplittin std::vector outputArgs{}; const std::size_t numberOfBuild{0}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = mockMultiCommand.splitLineInSeparateArgs(outputArgs, commandLine, numberOfBuild); const auto output = capture.getCapturedStdout(); @@ -485,7 +486,7 @@ TEST(MultiCommandWhiteboxTest, GivenTwoValidCommandLinesAndVerboseModeWhenRunnin mockMultiCommand.lines.push_back(validLine); mockMultiCommand.lines.push_back(validLine); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); mockMultiCommand.runBuilds("ocloc"); const auto output = capture.getCapturedStdout(); @@ -516,7 +517,7 @@ TEST(MultiCommandWhiteboxTest, GivenArgsWithQuietModeAndEmptyMulticommandFileWhe "commands.txt", "-q"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = mockMultiCommand.initialize(args); const auto output = capture.getCapturedStdout(); @@ -539,7 +540,7 @@ TEST(MultiCommandWhiteboxTest, GivenInvalidArgsWhenInitializingThenErrorIsReturn "commands.txt", "-invalid_option"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = mockMultiCommand.initialize(args); const auto output = capture.getCapturedStdout(); @@ -621,7 +622,7 @@ TEST_F(MockOfflineCompilerTests, givenDeviceIdValueWhenInitHwInfoThenCorrectValu mockOfflineCompiler.deviceName = deviceIDStr.str(); EXPECT_FALSE(mockOfflineCompiler.deviceName.empty()); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName); std::string output = capture.getCapturedStdout(); @@ -658,7 +659,7 @@ TEST_F(MockOfflineCompilerTests, givenDeviceIdAndRevisionIdValueWhenInitHwInfoTh mockOfflineCompiler.revisionId = 0x0; EXPECT_FALSE(mockOfflineCompiler.deviceName.empty()); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName); std::string output = capture.getCapturedStdout(); @@ -919,7 +920,7 @@ TEST_F(OfflineCompilerTests, GivenHelpOptionOnQueryThenSuccessIsReturned) { "query", "--help"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = OfflineCompiler::query(argv.size(), argv, oclocArgHelperWithoutInput.get()); std::string output = capture.getCapturedStdout(); @@ -936,7 +937,7 @@ TEST_F(OfflineCompilerTests, GivenHelpOptionOnIdsThenSuccessIsReturned) { "ids", helpFlag.str()}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = OfflineCompiler::queryAcronymIds(argv.size(), argv, oclocArgHelperWithoutInput.get()); std::string output = capture.getCapturedStdout(); @@ -976,7 +977,8 @@ TEST_F(OfflineCompilerTests, givenFamilyAcronymWhenIdsCommandIsInvokeThenSuccess familyAcronym}; std::stringstream expectedOutput; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); int retVal = OfflineCompiler::queryAcronymIds(argv.size(), argv, oclocArgHelperWithoutInput.get()); std::string output = capture.getCapturedStdout(); @@ -1010,7 +1012,8 @@ TEST_F(OfflineCompilerTests, givenReleaseAcronymWhenIdsCommandIsInvokeThenSucces releaseAcronym.str()}; std::stringstream expectedOutput; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); int retVal = OfflineCompiler::queryAcronymIds(argv.size(), argv, oclocArgHelperWithoutInput.get()); std::string output = capture.getCapturedStdout(); @@ -1044,7 +1047,8 @@ TEST_F(OfflineCompilerTests, givenProductAcronymWhenIdsCommandIsInvokeThenSucces productAcronym.str()}; std::stringstream expectedOutput; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); int retVal = OfflineCompiler::queryAcronymIds(argv.size(), argv, oclocArgHelperWithoutInput.get()); std::string output = capture.getCapturedStdout(); @@ -1094,7 +1098,7 @@ TEST_F(OfflineCompilerTests, GivenFlagsWhichRequireMoreArgsWithoutThemWhenParsin MockOfflineCompiler mockOfflineCompiler{}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = mockOfflineCompiler.parseCommandLine(argv.size(), argv); const auto output{capture.getCapturedStdout()}; @@ -1165,7 +1169,7 @@ TEST_F(OfflineCompilerTests, givenIncorrectConfigFlagWhenParsingCommandLineThenE MockOfflineCompiler mockOfflineCompiler{}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = mockOfflineCompiler.parseCommandLine(argv.size(), argv); const auto output{capture.getCapturedStdout()}; @@ -1214,7 +1218,7 @@ TEST_F(OfflineCompilerTests, Given32BitModeFlagAnd64BitModeFlagWhenParsingThenEr MockOfflineCompiler mockOfflineCompiler{}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = mockOfflineCompiler.parseCommandLine(argv.size(), argv); const auto output{capture.getCapturedStdout()}; @@ -1485,7 +1489,8 @@ TEST_F(OfflineCompilerTests, givenProperDeviceIdHexAsDeviceArgumentThenSuccessIs deviceString.str()}; oclocArgHelperWithoutInput->getPrinterRef().setSuppressMessages(false); - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); EXPECT_EQ(pOfflineCompiler->getHardwareInfo().platform.usDeviceID, deviceId); @@ -1509,7 +1514,7 @@ TEST_F(OfflineCompilerTests, givenIncorrectDeviceIdHexThenInvalidDeviceIsReturne "-device", "0x0"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); @@ -1526,7 +1531,8 @@ TEST_F(OfflineCompilerTests, givenDeviceNumerationWithMissingRevisionValueWhenIn clCopybufferFilename.c_str(), "-device", "9.1."}; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1542,7 +1548,8 @@ TEST_F(OfflineCompilerTests, givenDeviceNumerationWithInvalidPatternThenInvalidD clCopybufferFilename.c_str(), "-device", "9.1.."}; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1558,7 +1565,8 @@ TEST_F(OfflineCompilerTests, givenDeviceNumerationWithMissingMajorValueWhenInval clCopybufferFilename.c_str(), "-device", ".1.2"}; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1574,7 +1582,8 @@ TEST_F(OfflineCompilerTests, givenDeviceNumerationWhenInvalidRevisionValueIsPass clCopybufferFilename.c_str(), "-device", "9.0.a"}; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1590,7 +1599,8 @@ TEST_F(OfflineCompilerTests, givenDeviceNumerationWhenInvalidMinorValueIsPassedT clCopybufferFilename.c_str(), "-device", "9.a"}; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1606,7 +1616,8 @@ TEST_F(OfflineCompilerTests, givenDeviceNumerationWhenPassedValuesAreOutOfRangeT clCopybufferFilename.c_str(), "-device", "256.350"}; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1622,7 +1633,8 @@ TEST_F(OfflineCompilerTests, givenDeviceIpVersionWhenPassedValueNotExistThenInva clCopybufferFilename.c_str(), "-device", "1234"}; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1659,7 +1671,8 @@ TEST_F(OfflineCompilerTests, givenIncorrectDeviceIdWithIncorrectHexPatternThenIn clCopybufferFilename.c_str(), "-device", "0xnonexist"}; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); auto output = capture.getCapturedStdout(); @@ -1854,7 +1867,7 @@ TEST_F(OfflineCompilerTests, givenValidArgumentsAndFclInitFailureWhenInitIsPerfo mockOfflineCompiler.mockFclFacade->shouldFailLoadingOfFclLib = true; mockOfflineCompiler.uniqueHelper->filesMap = filesMap; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto initResult = mockOfflineCompiler.initialize(argv.size(), argv); EXPECT_EQ(OCLOC_SUCCESS, initResult); @@ -1885,7 +1898,8 @@ TEST_F(OfflineCompilerTests, givenValidArgumentsAndIgcInitFailureWhenInitIsPerfo std::string libName = "invalidigc.so"; auto igcNameGuard = NEO::pushIgcDllName(libName.c_str()); mockOfflineCompiler.mockIgcFacade->shouldFailLoadingOfIgcLib = true; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); const auto initResult = mockOfflineCompiler.initialize(argv.size(), argv); EXPECT_EQ(OCLOC_SUCCESS, initResult); @@ -2193,7 +2207,7 @@ TEST_F(OfflineCompilerTests, GivenArgsWhenBuildingThenBuildSucceeds) { EXPECT_NE(nullptr, pOfflineCompiler); EXPECT_EQ(CL_SUCCESS, retVal); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); retVal = pOfflineCompiler->build(); std::string output = capture.getCapturedStdout(); @@ -2236,7 +2250,7 @@ TEST_F(OfflineCompilerTests, GivenArgsWhenBuildingWithDeviceConfigValueThenBuild EXPECT_NE(nullptr, pOfflineCompiler); EXPECT_EQ(CL_SUCCESS, retVal); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); retVal = pOfflineCompiler->build(); std::string output = capture.getCapturedStdout(); @@ -2279,7 +2293,7 @@ TEST_F(OfflineCompilerTests, GivenArgsWhenBuildingWithDeviceIpVersionValueThenBu EXPECT_NE(nullptr, pOfflineCompiler); EXPECT_EQ(CL_SUCCESS, retVal); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); retVal = pOfflineCompiler->build(); std::string output = capture.getCapturedStdout(); @@ -2498,7 +2512,7 @@ TEST_F(OfflineCompilerTests, WhenFclNotNeededThenDontLoadIt) { MockOfflineCompiler offlineCompiler; offlineCompiler.uniqueHelper->filesMap = filesMap; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); auto ret = offlineCompiler.initialize(argv.size(), argv, true); EXPECT_EQ(OCLOC_SUCCESS, ret); @@ -2620,7 +2634,7 @@ TEST_F(OfflineCompilerTests, GivenInvalidFileWhenBuildingThenInvalidFileErrorIsR "-device", gEnvironment->devicePrefix.c_str()}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); retVal = pOfflineCompiler->build(); @@ -2639,7 +2653,7 @@ TEST_F(OfflineCompilerTests, GivenInvalidFlagWhenBuildingThenInvalidCommandLineE "-device", gEnvironment->devicePrefix.c_str()}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); std::string output = capture.getCapturedStdout(); @@ -2656,7 +2670,7 @@ TEST_F(OfflineCompilerTests, GivenInvalidOptionsWhenBuildingThenInvalidCommandLi "-file", }; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); pOfflineCompiler = OfflineCompiler::create(argvA.size(), argvA, true, retVal, oclocArgHelperWithoutInput.get()); std::string output = capture.getCapturedStdout(); @@ -2691,7 +2705,7 @@ TEST_F(OfflineCompilerTests, GivenNonexistantDeviceWhenCompilingThenInvalidDevic "-device", "foobar"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); std::string output = capture.getCapturedStdout(); @@ -2730,7 +2744,8 @@ TEST_F(OfflineCompilerTests, GivenInvalidKernelWhenBuildingThenBuildProgramFailu EXPECT_EQ(CL_SUCCESS, retVal); gEnvironment->SetInputFileName("invalid_file_name"); - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); retVal = pOfflineCompiler->build(); @@ -2939,7 +2954,7 @@ TEST(OfflineCompilerTest, WhenParsingCmdLineThenOptionsAreReadCorrectly) { auto mockOfflineCompiler = std::make_unique(); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); mockOfflineCompiler->parseCommandLine(argv.size(), argv); std::string output = capture.getCapturedStdout(); @@ -2975,7 +2990,7 @@ TEST(OfflineCompilerTest, GivenUnsupportedDeviceWhenInitHardwareInfoThenInvalidD auto deviceName = "unk"; std::stringstream resString; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); auto retVal = mockOfflineCompiler->initHardwareInfo(deviceName); EXPECT_EQ(retVal, OCLOC_INVALID_DEVICE); @@ -3138,7 +3153,7 @@ TEST(OfflineCompilerTest, GivenValidParamWhenGettingHardwareInfoThenSuccessIsRet auto mockOfflineCompiler = std::unique_ptr(new MockOfflineCompiler()); ASSERT_NE(nullptr, mockOfflineCompiler); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); EXPECT_EQ(CL_INVALID_DEVICE, mockOfflineCompiler->initHardwareInfo("invalid")); @@ -3508,7 +3523,7 @@ TEST(OfflineCompilerTest, givenLlvmInputOptionPassedWhenCmdLineParsedThenInputFi auto mockOfflineCompiler = std::unique_ptr(new MockOfflineCompiler()); ASSERT_NE(nullptr, mockOfflineCompiler); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); mockOfflineCompiler->parseCommandLine(argv.size(), argv); std::string output = capture.getCapturedStdout(); @@ -3532,7 +3547,7 @@ TEST(OfflineCompilerTest, givenSpirvInputOptionPassedWhenCmdLineParsedThenInputF auto mockOfflineCompiler = std::unique_ptr(new MockOfflineCompiler()); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); mockOfflineCompiler->parseCommandLine(argv.size(), argv); std::string output = capture.getCapturedStdout(); @@ -3792,7 +3807,7 @@ TEST(OfflineCompilerTest, givenInternalOptionsWhenCmdLineParsedThenOptionsAreApp auto mockOfflineCompiler = std::unique_ptr(new MockOfflineCompiler()); ASSERT_NE(nullptr, mockOfflineCompiler); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); mockOfflineCompiler->parseCommandLine(argv.size(), argv); std::string output = capture.getCapturedStdout(); @@ -3814,7 +3829,7 @@ TEST(OfflineCompilerTest, givenOptionsWhenCmdLineParsedThenOptionsAreAppendedToO auto mockOfflineCompiler = std::unique_ptr(new MockOfflineCompiler()); ASSERT_NE(nullptr, mockOfflineCompiler); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); mockOfflineCompiler->parseCommandLine(argv.size(), argv); std::string output = capture.getCapturedStdout(); @@ -3874,7 +3889,7 @@ TEST_F(OfflineCompilerTests, givenDeviceOptionsWithDeprecatedDeviceAcronymWhenCm deviceName.c_str(), "devOptions"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); mockOfflineCompiler->uniqueHelper->filesMap = filesMap; const auto result = mockOfflineCompiler->parseCommandLine(argv.size(), argv); @@ -3912,7 +3927,8 @@ TEST_F(OfflineCompilerTests, givenUnknownDeviceAcronymInDeviceOptionsWhenParsing ASSERT_NE(nullptr, mockOfflineCompiler); mockOfflineCompiler->uniqueHelper->filesMap = filesMap; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); const auto result = mockOfflineCompiler->parseCommandLine(argv.size(), argv); const std::string output = capture.getCapturedStdout(); @@ -3938,7 +3954,7 @@ TEST(OfflineCompilerTest, givenDeviceOptionsInWrongFormatWhenCmdLineParsedThenDe auto mockOfflineCompiler = std::unique_ptr(new MockOfflineCompiler()); ASSERT_NE(nullptr, mockOfflineCompiler); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); mockOfflineCompiler->parseCommandLine(argv.size(), argv); std::string output = capture.getCapturedStdout(); @@ -4111,7 +4127,7 @@ TEST(OfflineCompilerTest, givenDeviceOptionsForMultipleDevicesSeparatedByCommasW productForDeviceOptions1.c_str(), "devOptions2"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = mockOfflineCompiler->parseCommandLine(argv.size(), argv); const std::string output = capture.getCapturedStdout(); @@ -4140,7 +4156,8 @@ TEST_F(OfflineCompilerTests, givenDashOOptionWhenCmdLineParsedThenBinaryOutputNa ASSERT_NE(nullptr, mockOfflineCompiler); mockOfflineCompiler->uniqueHelper->filesMap = filesMap; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); auto retVal = mockOfflineCompiler->parseCommandLine(argv.size(), argv); std::string output = capture.getCapturedStdout(); @@ -4173,7 +4190,8 @@ TEST_F(OfflineCompilerTests, givenDashOAndOtherInvalidOptionsWhenCmdLineParsedTh ASSERT_NE(nullptr, mockOfflineCompiler); mockOfflineCompiler->uniqueHelper->filesMap = filesMap; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); auto retVal = mockOfflineCompiler->parseCommandLine(argv.size(), argv); std::string output = capture.getCapturedStdout(); @@ -4199,7 +4217,8 @@ TEST_F(OfflineCompilerTests, givenDashOAndOtherInvalidOptionsWhenCmdLineParsedTh ASSERT_NE(nullptr, mockOfflineCompiler); mockOfflineCompiler->uniqueHelper->filesMap = filesMap; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); auto retVal = mockOfflineCompiler->parseCommandLine(argv2.size(), argv2); std::string output = capture.getCapturedStdout(); @@ -4278,7 +4297,7 @@ __kernel void shouldfail(global ushort *dst) { "-device", gEnvironment->devicePrefix.c_str()}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); auto retVal = Ocloc::Commands::compile(mockOfflineCompiler->argHelper, args); EXPECT_NE(retVal, OCLOC_SUCCESS); @@ -4303,7 +4322,7 @@ __kernel void shouldfail(global ushort *dst) { "-device", gEnvironment->devicePrefix.c_str()}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); auto retVal = Ocloc::Commands::compile(mockOfflineCompiler->argHelper, args); EXPECT_NE(retVal, OCLOC_SUCCESS); @@ -4332,7 +4351,7 @@ __kernel void shouldfail(global ushort *dst) { "-device", gEnvironment->devicePrefix.c_str()}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); auto retVal = Ocloc::Commands::compile(mockOfflineCompiler->argHelper, args); EXPECT_NE(retVal, OCLOC_SUCCESS); @@ -4818,7 +4837,7 @@ TEST_F(OfflineCompilerTests, whenDetectedPotentialInputTypeMismatchThenEmitsWarn int caseNum = 0; for (auto &c : cases) { - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); ocloc.inputCodeType = IGC::CodeType::oclC; @@ -5019,7 +5038,7 @@ TEST_F(OfflineCompilerTests, givenFormatFlagWithUnknownFormatPassedThenPrintWarn "--format", "banana"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = ocloc.initialize(argvUnknownFormatEnforced.size(), argvUnknownFormatEnforced); const auto output = capture.getCapturedStdout(); @@ -5063,7 +5082,7 @@ TEST_F(OfflineCompilerTests, GivenStatefulAddressModeWhenInvalidArgsPAssedThenEr "-stateful_address_mode", "wrong"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = ocloc.initialize(argvA.size(), argvA); ASSERT_EQ(OCLOC_INVALID_COMMAND_LINE, retVal); @@ -5102,7 +5121,8 @@ TEST_F(OfflineCompilerTests, GivenInvalidHeaplessModeOptionWhenOclocArgsAreParse gEnvironment->devicePrefix.c_str(), "-heapless_mode", "invalid"}; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); int retVal = ocloc.parseCommandLine(args.size(), args); EXPECT_EQ(OCLOC_INVALID_COMMAND_LINE, retVal); @@ -5123,7 +5143,8 @@ TEST_F(OfflineCompilerTests, GivenValidHeaplessModeOptionWhenOclocArgsAreParsedT gEnvironment->devicePrefix.c_str(), "-heapless_mode", heaplessMode}; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); int retVal = ocloc.parseCommandLine(args.size(), args); EXPECT_EQ(OCLOC_SUCCESS, retVal); @@ -5168,7 +5189,8 @@ TEST(OclocArgHelperTest, GivenOutputSuppressMessagesAndSaveItToFile) { EXPECT_TRUE(helper->messagePrinter.isSuppressed()); ConstStringRef printMsg = "Hello world!"; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); helper->printf(printMsg.data()); std::string capturedStdout = capture.getCapturedStdout(); @@ -5258,7 +5280,8 @@ TEST(OclocArgHelperTest, GivenNoOutputPrintMessages) { nullptr, nullptr, nullptr, nullptr); EXPECT_FALSE(helper.messagePrinter.isSuppressed()); ConstStringRef printMsg = "Hello world!"; - StdoutCapture capture; + + StreamCapture capture; capture.captureStdout(); helper.printf(printMsg.data()); std::string capturedStdout = capture.getCapturedStdout(); @@ -5571,7 +5594,7 @@ __kernel void CopyBuffer(__global unsigned int *src, __global unsigned int *dst) "-device", gEnvironment->devicePrefix.c_str()}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = mockOfflineCompiler->initialize(argv.size(), argv); std::string output = capture.getCapturedStdout(); @@ -5623,7 +5646,7 @@ __kernel void CopyBuffer(__global unsigned int *src, __global unsigned int *dst) "-device", gEnvironment->devicePrefix.c_str()}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); int retVal = mockOfflineCompiler->initialize(argv.size(), argv); std::string output = capture.getCapturedStdout(); diff --git a/opencl/test/unit_test/offline_compiler/offline_linker_tests.cpp b/opencl/test/unit_test/offline_compiler/offline_linker_tests.cpp index 53d1267688..757e8c5920 100644 --- a/opencl/test/unit_test/offline_compiler/offline_linker_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/offline_linker_tests.cpp @@ -13,7 +13,7 @@ #include "shared/source/helpers/string.h" #include "shared/source/os_interface/os_inc_base.h" #include "shared/test/common/helpers/mock_file_io.h" -#include "shared/test/common/helpers/stdout_capture.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_compilers.h" #include "environment.h" @@ -211,7 +211,7 @@ TEST_F(OfflineLinkerTest, GivenUnknownArgumentWhenParsingThenErrorIsReported) { "link", "-some_new_unknown_command"}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); MockOfflineLinker mockOfflineLinker{&mockArgHelper, std::move(mockOclocIgcFacade)}; const auto result = mockOfflineLinker.initialize(argv.size(), argv); @@ -236,7 +236,7 @@ TEST_F(OfflineLinkerTest, GivenFlagsWhichRequireMoreArgsWithoutThemWhenParsingTh mockOclocIgcFacade = std::make_unique(&mockArgHelper); MockOfflineLinker mockOfflineLinker{&mockArgHelper, std::move(mockOclocIgcFacade)}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto result = mockOfflineLinker.parseCommand(argv.size(), argv); const auto output{capture.getCapturedStdout()}; @@ -252,7 +252,7 @@ TEST_F(OfflineLinkerTest, GivenCommandWithoutInputFilesWhenVerificationIsPerform MockOfflineLinker mockOfflineLinker{&mockArgHelper, std::move(mockOclocIgcFacade)}; mockOfflineLinker.inputFilenames = {}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto verificationResult = mockOfflineLinker.verifyLinkerCommand(); const auto output{capture.getCapturedStdout()}; @@ -272,7 +272,7 @@ TEST_F(OfflineLinkerTest, GivenCommandWithEmptyFilenameWhenVerificationIsPerform MockOfflineLinker mockOfflineLinker{&mockArgHelper, std::move(mockOclocIgcFacade)}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto verificationResult = mockOfflineLinker.initialize(argv.size(), argv); const auto output{capture.getCapturedStdout()}; @@ -296,7 +296,7 @@ TEST_F(OfflineLinkerTest, GivenCommandWithNonexistentInputFileWhenVerificationIs const auto parsingResult = mockOfflineLinker.parseCommand(argv.size(), argv); ASSERT_EQ(OCLOC_SUCCESS, parsingResult); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto verificationResult = mockOfflineLinker.verifyLinkerCommand(); const auto output{capture.getCapturedStdout()}; @@ -322,7 +322,7 @@ TEST_F(OfflineLinkerTest, GivenCommandWithInvalidOutputFormatWhenVerificationIsP const auto parsingResult = mockOfflineLinker.parseCommand(argv.size(), argv); ASSERT_EQ(OCLOC_SUCCESS, parsingResult); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto verificationResult = mockOfflineLinker.verifyLinkerCommand(); const auto output{capture.getCapturedStdout()}; @@ -349,7 +349,7 @@ TEST_F(OfflineLinkerTest, GivenValidCommandWhenVerificationIsPerformedThenSucces const auto parsingResult = mockOfflineLinker.parseCommand(argv.size(), argv); ASSERT_EQ(OCLOC_SUCCESS, parsingResult); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto verificationResult = mockOfflineLinker.verifyLinkerCommand(); const auto output{capture.getCapturedStdout()}; @@ -371,7 +371,7 @@ TEST_F(OfflineLinkerTest, GivenEmptyFileWhenLoadingInputFilesThenErrorIsReturned MockOfflineLinker mockOfflineLinker{&mockArgHelper, std::move(mockOclocIgcFacade)}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto initializationResult = mockOfflineLinker.initialize(argv.size(), argv); const auto output{capture.getCapturedStdout()}; @@ -391,7 +391,7 @@ TEST_F(OfflineLinkerTest, GivenValidFileWithUnknownFormatWhenLoadingInputFilesTh MockOfflineLinker mockOfflineLinker{&mockArgHelper, std::move(mockOclocIgcFacade)}; mockOfflineLinker.inputFilenames.push_back(filename); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto readingResult = mockOfflineLinker.loadInputFilesContent(); const auto output{capture.getCapturedStdout()}; @@ -413,7 +413,7 @@ TEST_F(OfflineLinkerTest, GivenValidFilesWithValidFormatsWhenLoadingInputFilesTh mockOfflineLinker.inputFilenames.push_back(firstFilename); mockOfflineLinker.inputFilenames.push_back(secondFilename); - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto readingResult = mockOfflineLinker.loadInputFilesContent(); const auto output{capture.getCapturedStdout()}; @@ -453,7 +453,7 @@ TEST_F(OfflineLinkerTest, GivenValidFilesWhenInitializationIsSuccessfulThenLinkM MockOfflineLinker mockOfflineLinker{&mockArgHelper, std::move(mockOclocIgcFacade)}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto initializationResult = mockOfflineLinker.initialize(argv.size(), argv); const auto output{capture.getCapturedStdout()}; @@ -560,7 +560,7 @@ TEST_F(OfflineLinkerTest, GivenValidInputFileContentsAndFailingIGCWhenLlvmBcOutp mockOfflineLinker.outputFormat = IGC::CodeType::llvmBc; mockOfflineLinker.operationMode = OperationMode::linkFiles; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto linkingResult{mockOfflineLinker.execute()}; const auto output{capture.getCapturedStdout()}; @@ -592,7 +592,7 @@ TEST_F(OfflineLinkerTest, GivenValidInputFileContentsAndIGCSignalingSuccessButRe mockOfflineLinker.outputFormat = IGC::CodeType::llvmBc; mockOfflineLinker.operationMode = OperationMode::linkFiles; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto linkingResult{mockOfflineLinker.execute()}; const auto output{capture.getCapturedStdout()}; @@ -624,7 +624,7 @@ TEST_F(OfflineLinkerTest, GivenValidInputFileContentsAndInvalidTranslationOutput mockOfflineLinker.outputFormat = IGC::CodeType::llvmBc; mockOfflineLinker.operationMode = OperationMode::linkFiles; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto linkingResult{mockOfflineLinker.execute()}; const auto output{capture.getCapturedStdout()}; @@ -639,7 +639,7 @@ TEST_F(OfflineLinkerTest, GivenValidInputFileContentsAndInvalidTranslationOutput TEST_F(OfflineLinkerTest, GivenUninitializedLinkerWhenExecuteIsInvokedThenErrorIsIssued) { MockOfflineLinker mockOfflineLinker{&mockArgHelper, std::move(mockOclocIgcFacade)}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto executionResult{mockOfflineLinker.execute()}; const auto output{capture.getCapturedStdout()}; @@ -652,7 +652,7 @@ TEST_F(OfflineLinkerTest, GivenHelpRequestWhenExecuteIsInvokedThenHelpIsPrinted) MockOfflineLinker mockOfflineLinker{&mockArgHelper, std::move(mockOclocIgcFacade)}; mockOfflineLinker.operationMode = OperationMode::showHelp; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto executionResult{mockOfflineLinker.execute()}; const auto output{capture.getCapturedStdout()}; @@ -665,7 +665,7 @@ TEST_F(OfflineLinkerTest, GivenInvalidOperationModeWhenExecuteIsInvokedThenError MockOfflineLinker mockOfflineLinker{&mockArgHelper, std::move(mockOclocIgcFacade)}; mockOfflineLinker.operationMode = static_cast(7); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange) - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto executionResult{mockOfflineLinker.execute()}; const auto output{capture.getCapturedStdout()}; @@ -701,7 +701,7 @@ TEST_F(OfflineLinkerTest, GivenEmptyHwInfoTableWhenInitializationIsPerformedThen MockOfflineLinker mockOfflineLinker{&mockArgHelper, std::move(mockOclocIgcFacade)}; mockOfflineLinker.shouldReturnEmptyHardwareInfoTable = true; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto initializationResult = mockOfflineLinker.initialize(argv.size(), argv); const auto output{capture.getCapturedStdout()}; @@ -730,7 +730,7 @@ TEST_F(OfflineLinkerTest, GivenMissingIgcLibraryWhenInitializationIsPerformedThe mockOclocIgcFacade->shouldFailLoadingOfIgcLib = true; MockOfflineLinker mockOfflineLinker{&mockArgHelper, std::move(mockOclocIgcFacade)}; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); const auto initializationResult = mockOfflineLinker.initialize(argv.size(), argv); const auto output{capture.getCapturedStdout()}; diff --git a/opencl/test/unit_test/offline_compiler/stdout_capturer.h b/opencl/test/unit_test/offline_compiler/stdout_capturer.h index f7a51c502e..8edaf77855 100644 --- a/opencl/test/unit_test/offline_compiler/stdout_capturer.h +++ b/opencl/test/unit_test/offline_compiler/stdout_capturer.h @@ -7,7 +7,7 @@ #pragma once -#include "shared/test/common/helpers/stdout_capture.h" +#include "shared/test/common/helpers/stream_capture.h" #include @@ -36,7 +36,7 @@ class StdoutCapturer { } private: - StdoutCapture capture; + StreamCapture capture; bool outputAcquired{false}; }; diff --git a/opencl/test/unit_test/offline_compiler/xe3_core/ptl/offline_compiler_tests_ptl.cpp b/opencl/test/unit_test/offline_compiler/xe3_core/ptl/offline_compiler_tests_ptl.cpp index 2dd6572acc..f586db4384 100644 --- a/opencl/test/unit_test/offline_compiler/xe3_core/ptl/offline_compiler_tests_ptl.cpp +++ b/opencl/test/unit_test/offline_compiler/xe3_core/ptl/offline_compiler_tests_ptl.cpp @@ -8,7 +8,7 @@ #include "shared/offline_compiler/source/ocloc_arg_helper.h" #include "shared/source/helpers/product_config_helper.h" #include "shared/source/xe3_core/hw_info_xe3_core.h" -#include "shared/test/common/helpers/stdout_capture.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/test_macros/header/per_product_test_definitions.h" #include "shared/test/common/test_macros/test.h" @@ -28,7 +28,7 @@ PTLTEST_F(PtlOfflineCompilerTests, givenPtlHDeviceIdValueWhenInitHwInfoThenCorre std::stringstream deviceIDStr, expectedOutput; deviceIDStr << "0x" << std::hex << deviceID; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); mockOfflineCompiler.initHardwareInfo(deviceIDStr.str()); std::string output = capture.getCapturedStdout(); @@ -49,7 +49,7 @@ PTLTEST_F(PtlOfflineCompilerTests, givenPtlUDeviceIdValueWhenInitHwInfoThenCorre deviceIDStr << "0x" << std::hex << deviceID; - StdoutCapture capture; + StreamCapture capture; capture.captureStdout(); mockOfflineCompiler.initHardwareInfo(deviceIDStr.str()); std::string output = capture.getCapturedStdout(); diff --git a/opencl/test/unit_test/offline_compiler/xe_hpc_core/pvc/offline_compiler_tests_pvc.cpp b/opencl/test/unit_test/offline_compiler/xe_hpc_core/pvc/offline_compiler_tests_pvc.cpp index 2cb5a9ca2f..359454c385 100644 --- a/opencl/test/unit_test/offline_compiler/xe_hpc_core/pvc/offline_compiler_tests_pvc.cpp +++ b/opencl/test/unit_test/offline_compiler/xe_hpc_core/pvc/offline_compiler_tests_pvc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Intel Corporation + * Copyright (C) 2022-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -8,6 +8,7 @@ #include "shared/source/helpers/constants.h" #include "shared/source/xe_hpc_core/hw_cmds_pvc.h" #include "shared/source/xe_hpc_core/pvc/device_ids_configs_pvc.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/test_macros/header/per_product_test_definitions.h" #include "shared/test/common/xe_hpc_core/pvc/product_configs_pvc.h" @@ -49,9 +50,10 @@ PVCTEST_F(PvcOfflineCompilerTests, givenPvcDeviceAndRevisionIdValueWhenInitHwInf deviceIDStr << "0x" << std::hex << deviceID; deviceStr = mockOfflineCompiler.argHelper->productConfigHelper->getAcronymForProductConfig(config.value); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); mockOfflineCompiler.initHardwareInfo(deviceIDStr.str()); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); expectedOutput << "Auto-detected target based on " << deviceIDStr.str() << " device id: " << deviceStr << "\n"; EXPECT_STREQ(output.c_str(), expectedOutput.str().c_str()); @@ -76,9 +78,10 @@ PVCTEST_F(PvcOfflineCompilerTests, givenPvcXtVgDeviceAndRevisionIdValueWhenInitH deviceIDStr << "0x" << std::hex << deviceID; deviceStr = mockOfflineCompiler.argHelper->productConfigHelper->getAcronymForProductConfig(config.value); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); mockOfflineCompiler.initHardwareInfo(deviceIDStr.str()); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); expectedOutput << "Auto-detected target based on " << deviceIDStr.str() << " device id: " << deviceStr << "\n"; EXPECT_STREQ(output.c_str(), expectedOutput.str().c_str()); diff --git a/opencl/test/unit_test/offline_compiler/xe_hpg_core/dg2/offline_compiler_tests_dg2.cpp b/opencl/test/unit_test/offline_compiler/xe_hpg_core/dg2/offline_compiler_tests_dg2.cpp index 4f56e63456..a3ed077771 100644 --- a/opencl/test/unit_test/offline_compiler/xe_hpg_core/dg2/offline_compiler_tests_dg2.cpp +++ b/opencl/test/unit_test/offline_compiler/xe_hpg_core/dg2/offline_compiler_tests_dg2.cpp @@ -7,6 +7,7 @@ #include "shared/source/helpers/constants.h" #include "shared/source/xe_hpg_core/hw_cmds_dg2.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/test_macros/header/per_product_test_definitions.h" #include "opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.h" @@ -55,9 +56,10 @@ DG2TEST_F(Dg2OfflineCompilerTests, givenDg2G10DeviceAndRevisionIdValueWhenInitHw deviceIDStr << "0x" << std::hex << deviceID; deviceStr = mockOfflineCompiler.argHelper->productConfigHelper->getAcronymForProductConfig(config.value); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); mockOfflineCompiler.initHardwareInfo(deviceIDStr.str()); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); expectedOutput << "Auto-detected target based on " << deviceIDStr.str() << " device id: " << deviceStr << "\n"; EXPECT_STREQ(output.c_str(), expectedOutput.str().c_str()); @@ -84,9 +86,10 @@ DG2TEST_F(Dg2OfflineCompilerTests, givenDg2G11DeviceAndRevisionIdValueWhenInitHw deviceIDStr << "0x" << std::hex << deviceID; deviceStr = mockOfflineCompiler.argHelper->productConfigHelper->getAcronymForProductConfig(config.value); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); mockOfflineCompiler.initHardwareInfo(deviceIDStr.str()); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); expectedOutput << "Auto-detected target based on " << deviceIDStr.str() << " device id: " << deviceStr << "\n"; EXPECT_STREQ(output.c_str(), expectedOutput.str().c_str()); @@ -108,9 +111,10 @@ DG2TEST_F(Dg2OfflineCompilerTests, givenDg2G12DeviceAndRevisionIdValueWhenInitHw deviceIDStr << "0x" << std::hex << deviceID; deviceStr = mockOfflineCompiler.argHelper->productConfigHelper->getAcronymForProductConfig(dg2G12Config.value); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); mockOfflineCompiler.initHardwareInfo(deviceIDStr.str()); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); expectedOutput << "Auto-detected target based on " << deviceIDStr.str() << " device id: " << deviceStr << "\n"; EXPECT_STREQ(output.c_str(), expectedOutput.str().c_str()); diff --git a/opencl/test/unit_test/profiling/profiling_tests.cpp b/opencl/test/unit_test/profiling/profiling_tests.cpp index 4a1dcfbfcb..c5d1cb3738 100644 --- a/opencl/test/unit_test/profiling/profiling_tests.cpp +++ b/opencl/test/unit_test/profiling/profiling_tests.cpp @@ -10,6 +10,7 @@ #include "shared/source/utilities/perf_counter.h" #include "shared/source/utilities/tag_allocator.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_timestamp_container.h" #include "shared/test/common/test_macros/test.h" #include "shared/test/common/utilities/base_object_utils.h" @@ -624,7 +625,8 @@ HWTEST_F(ProfilingTests, givenDebugFlagSetWhenWaitingForTimestampThenPrint) { queue->timestampPacketContainer = std::make_unique(); auto container = queue->timestampPacketContainer.get(); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); Range copyEngineStates; WaitStatus status; @@ -633,13 +635,13 @@ HWTEST_F(ProfilingTests, givenDebugFlagSetWhenWaitingForTimestampThenPrint) { queue->waitForTimestamps(copyEngineStates, status, container, nullptr); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_NE(output.npos, output.find("Waiting for TS 0x")); EXPECT_NE(output.npos, output.find("Waiting for TS completed")); EXPECT_EQ(output.npos, output.find("Waiting for TS failed")); - testing::internal::CaptureStdout(); + capture.captureStdout(); auto &csr = static_cast &>(queue->getGpgpuCommandStreamReceiver()); csr.forceReturnGpuHang = true; @@ -647,7 +649,7 @@ HWTEST_F(ProfilingTests, givenDebugFlagSetWhenWaitingForTimestampThenPrint) { node->storage = 1; queue->waitForTimestamps(copyEngineStates, status, container, nullptr); - output = testing::internal::GetCapturedStdout(); + output = capture.getCapturedStdout(); EXPECT_NE(output.npos, output.find("Waiting for TS 0x")); EXPECT_EQ(output.npos, output.find("Waiting for TS completed")); @@ -658,20 +660,20 @@ HWTEST_F(ProfilingTests, givenDebugFlagSetWhenWaitingForTimestampThenPrint) { event.timestampPacketContainer->add(node.get()); - testing::internal::CaptureStdout(); + capture.captureStdout(); node->failCountdown = 2; node->storage = 1; event.areTimestampsCompleted(); - output = testing::internal::GetCapturedStdout(); + output = capture.getCapturedStdout(); EXPECT_NE(output.npos, output.find("Checking TS 0x")); EXPECT_EQ(output.npos, output.find("TS ready")); EXPECT_NE(output.npos, output.find("TS not ready")); - testing::internal::CaptureStdout(); + capture.captureStdout(); event.areTimestampsCompleted(); - output = testing::internal::GetCapturedStdout(); + output = capture.getCapturedStdout(); EXPECT_NE(output.npos, output.find("Checking TS 0x")); EXPECT_NE(output.npos, output.find("TS ready")); @@ -1463,7 +1465,8 @@ TEST_F(ProfilingTimestampPacketsTest, givenTimestampPacketWithoutProfilingDataWh TEST_F(ProfilingTimestampPacketsTest, givenPrintTimestampPacketContentsSetWhenCalcProfilingDataThenTimeStampsArePrinted) { DebugManagerStateRestore restorer; debugManager.flags.PrintTimestampPacketContents.set(true); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto &device = reinterpret_cast(cmdQ->getDevice()); auto &csr = device.getUltCommandStreamReceiver(); @@ -1483,7 +1486,7 @@ TEST_F(ProfilingTimestampPacketsTest, givenPrintTimestampPacketContentsSetWhenCa ev->calcProfilingData(); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::stringstream expected; expected << "Timestamp 0, cmd type: " << ev->getCommandType() << ", "; diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index 2ed4df799d..54cc4ce251 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -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; 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); } diff --git a/shared/test/common/helpers/stdout_capture.h b/shared/test/common/helpers/stream_capture.h similarity index 52% rename from shared/test/common/helpers/stdout_capture.h rename to shared/test/common/helpers/stream_capture.h index a51a56a55f..80fd246e1f 100644 --- a/shared/test/common/helpers/stdout_capture.h +++ b/shared/test/common/helpers/stream_capture.h @@ -20,29 +20,46 @@ #include #endif -class StdoutCapture { +class StreamCapture { public: void captureStdout() { + captureStream(stdout, pipefdStdout, saveStdout); + } + + void captureStderr() { + captureStream(stderr, pipefdStderr, saveStderr); + } + + std::string getCapturedStdout() { + return getCapturedStream(stdout, pipefdStdout, saveStdout); + } + + std::string getCapturedStderr() { + return getCapturedStream(stderr, pipefdStderr, saveStderr); + } + + private: + void captureStream(FILE *stream, int pipefd[2], int &savedFd) { #ifdef _WIN32 _pipe(pipefd, 4096, O_TEXT); - fflush(stdout); - saveStdout = _dup(_fileno(stdout)); - _dup2(pipefd[1], _fileno(stdout)); + fflush(stream); + savedFd = _dup(_fileno(stream)); + _dup2(pipefd[1], _fileno(stream)); _close(pipefd[1]); #else - fflush(stdout); + fflush(stream); pipe(pipefd); - saveStdout = dup(fileno(stdout)); - dup2(pipefd[1], fileno(stdout)); + savedFd = dup(fileno(stream)); + dup2(pipefd[1], fileno(stream)); close(pipefd[1]); #endif } - std::string getCapturedStdout() { + std::string getCapturedStream(FILE *stream, int pipefd[2], int &savedFd) { #ifdef _WIN32 - fflush(stdout); - _dup2(saveStdout, _fileno(stdout)); - _close(saveStdout); + fflush(stream); + _dup2(savedFd, _fileno(stream)); + _close(savedFd); char buffer[4096]; int count = _read(pipefd[0], buffer, sizeof(buffer) - 1); @@ -52,9 +69,9 @@ class StdoutCapture { } return ""; #else - fflush(stdout); - dup2(saveStdout, fileno(stdout)); - close(saveStdout); + fflush(stream); + dup2(savedFd, fileno(stream)); + close(savedFd); constexpr size_t bufferSize = 4096; char buffer[bufferSize]; @@ -67,7 +84,8 @@ class StdoutCapture { #endif } - private: - int pipefd[2]; + int pipefdStdout[2]; + int pipefdStderr[2]; int saveStdout; -}; \ No newline at end of file + int saveStderr; +}; diff --git a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp index e5b6ebc696..538ecfb389 100644 --- a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp +++ b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp @@ -39,6 +39,7 @@ #include "shared/test/common/helpers/dispatch_flags_helper.h" #include "shared/test/common/helpers/engine_descriptor_helper.h" #include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/unit_test_helper.h" #include "shared/test/common/mocks/mock_allocation_properties.h" #include "shared/test/common/mocks/mock_bindless_heaps_helper.h" @@ -65,6 +66,8 @@ #include #include +StreamCapture capture; + namespace NEO { extern ApiSpecificConfig::ApiType apiTypeForUlts; } // namespace NEO @@ -1738,11 +1741,12 @@ TEST(CommandStreamReceiverSimpleTest, givenNewResourceFlushEnabledWhenProvidingN csr.useNewResourceImplicitFlush = true; csr.newResources = false; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); csr.checkForNewResources(10u, GraphicsAllocation::objectNotUsed, mockAllocation); EXPECT_TRUE(csr.newResources); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_NE(0u, output.size()); EXPECT_STREQ("New resource detected of type 0\n", output.c_str()); } @@ -1761,11 +1765,12 @@ TEST(CommandStreamReceiverSimpleTest, givenPrintfTagAllocationAddressFlagEnabled MockCommandStreamReceiver csr(executionEnvironment, 0, deviceBitfield); csr.setupContext(*osContext); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); csr.initializeTagAllocation(); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_NE(0u, output.size()); char expectedStr[128]; @@ -2537,12 +2542,13 @@ HWTEST_F(CommandStreamReceiverTest, givenMultipleActivePartitionsWhenWaitLogIsEn waitParams.waitTimeout = std::numeric_limits::max(); constexpr TaskCountType taskCount = 1; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); WaitStatus status = csr.waitForCompletionWithTimeout(waitParams, taskCount); EXPECT_EQ(WaitStatus::ready, status); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::stringstream expectedOutput; @@ -2570,12 +2576,13 @@ HWTEST_F(CommandStreamReceiverTest, givenAubCsrWhenLogWaitingForCompletionEnable WaitParams waitParams; waitParams.waitTimeout = std::numeric_limits::max(); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); WaitStatus status = csr.waitForCompletionWithTimeout(waitParams, 0); EXPECT_EQ(WaitStatus::ready, status); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput1 = "Aub dump wait for task count"; std::string expectedOutput2 = "Aub dump wait completed"; diff --git a/shared/test/unit_test/compiler_interface/linux/default_cl_cache_config_tests.cpp b/shared/test/unit_test/compiler_interface/linux/default_cl_cache_config_tests.cpp index d02e69bec5..28ca21d731 100644 --- a/shared/test/unit_test/compiler_interface/linux/default_cl_cache_config_tests.cpp +++ b/shared/test/unit_test/compiler_interface/linux/default_cl_cache_config_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Intel Corporation + * Copyright (C) 2023-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -10,6 +10,7 @@ #include "shared/source/os_interface/sys_calls_common.h" #include "shared/source/utilities/io_functions.h" #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_io_functions.h" #include "shared/test/common/os_interface/linux/sys_calls_linux_ult.h" @@ -36,9 +37,10 @@ TEST(ClCacheDefaultConfigLinuxTest, GivenPrintDebugMessagesWhenCacheIsEnabledThe mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_DIR"] = "ult\\directory\\"; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto cacheConfig = NEO::getDefaultCompilerCacheConfig(); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_TRUE(cacheConfig.enabled); EXPECT_STREQ(output.c_str(), "NEO_CACHE_PERSISTENT is enabled. Cache is located in: ult\\directory\\\n\n"); diff --git a/shared/test/unit_test/compiler_interface/windows/default_cl_cache_config_tests.cpp b/shared/test/unit_test/compiler_interface/windows/default_cl_cache_config_tests.cpp index b53c5f5dea..f6793512bd 100644 --- a/shared/test/unit_test/compiler_interface/windows/default_cl_cache_config_tests.cpp +++ b/shared/test/unit_test/compiler_interface/windows/default_cl_cache_config_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -12,6 +12,7 @@ #include "shared/source/os_interface/windows/sys_calls.h" #include "shared/source/utilities/debug_settings_reader.h" #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_io_functions.h" #include "shared/test/common/test_macros/test.h" @@ -281,9 +282,10 @@ TEST_F(ClCacheDefaultConfigWindowsTest, GivenPrintDebugMessagesWhenCacheIsEnable DWORD getFileAttributesResultMock = FILE_ATTRIBUTE_DIRECTORY; VariableBackup pathExistsMockBackup(&NEO::SysCalls::getFileAttributesResult, getFileAttributesResultMock); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto cacheConfig = NEO::getDefaultCompilerCacheConfig(); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_TRUE(cacheConfig.enabled); EXPECT_STREQ(output.c_str(), "NEO_CACHE_PERSISTENT is enabled. Cache is located in: ult\\directory\\\n\n"); diff --git a/shared/test/unit_test/debug_settings/debug_settings_manager_tests.cpp b/shared/test/unit_test/debug_settings/debug_settings_manager_tests.cpp index 42d9332408..ed0d111fd3 100644 --- a/shared/test/unit_test/debug_settings/debug_settings_manager_tests.cpp +++ b/shared/test/unit_test/debug_settings/debug_settings_manager_tests.cpp @@ -14,6 +14,7 @@ #include "shared/test/common/debug_settings/debug_settings_manager_fixture.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/mocks/mock_io_functions.h" #include "shared/test/common/mocks/mock_product_helper.h" @@ -129,7 +130,8 @@ TEST(DebugSettingsManager, givenReaderImplInDebugManagerWhenSettingDifferentRead } TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledWithNoPrefixWhenCallingDumpFlagsThenFlagsAreWrittenToDumpFile) { - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); FullyEnabledTestDebugManager debugManager; VariableBackup backup(&apiTypeForUlts, ApiSpecificConfig::L0); @@ -160,7 +162,7 @@ TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledWithNoPrefixWhenCalling #undef DECLARE_DEBUG_VARIABLE std::remove(FullyEnabledTestDebugManager::settingsDumpFileName); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); ASSERT_NE(0u, output.size()); EXPECT_NE(std::string::npos, output.find("Non-default value of debug variable: TbxServer = 192.168.0.1")); @@ -170,7 +172,8 @@ TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledWithNoPrefixWhenCalling } TEST(DebugSettingsManager, DISABLED_givenPrintDebugSettingsEnabledWithNeoPrefixWhenCallingDumpFlagsThenFlagsAreWrittenToDumpFile) { - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); FullyEnabledTestDebugManager debugManager; VariableBackup backup(&apiTypeForUlts, ApiSpecificConfig::L0); @@ -201,7 +204,7 @@ TEST(DebugSettingsManager, DISABLED_givenPrintDebugSettingsEnabledWithNeoPrefixW #undef DECLARE_DEBUG_VARIABLE std::remove(FullyEnabledTestDebugManager::settingsDumpFileName); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); ASSERT_NE(0u, output.size()); EXPECT_NE(std::string::npos, output.find("Non-default value of debug variable: NEO_TbxServer = 192.168.0.1")); @@ -211,7 +214,8 @@ TEST(DebugSettingsManager, DISABLED_givenPrintDebugSettingsEnabledWithNeoPrefixW } TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledWithLevelZeroPrefixWhenCallingDumpFlagsThenFlagsAreWrittenToDumpFile) { - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); FullyEnabledTestDebugManager debugManager; VariableBackup backup(&apiTypeForUlts, ApiSpecificConfig::L0); @@ -242,7 +246,7 @@ TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledWithLevelZeroPrefixWhen #undef DECLARE_DEBUG_VARIABLE std::remove(FullyEnabledTestDebugManager::settingsDumpFileName); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); ASSERT_NE(0u, output.size()); EXPECT_NE(std::string::npos, output.find("Non-default value of debug variable: NEO_L0_TbxServer = 192.168.0.1")); @@ -252,7 +256,8 @@ TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledWithLevelZeroPrefixWhen } TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledWithOclPrefixWhenCallingDumpFlagsThenFlagsAreWrittenToDumpFile) { - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); FullyEnabledTestDebugManager debugManager; VariableBackup backup(&apiTypeForUlts, ApiSpecificConfig::OCL); @@ -283,7 +288,7 @@ TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledWithOclPrefixWhenCallin #undef DECLARE_DEBUG_VARIABLE std::remove(FullyEnabledTestDebugManager::settingsDumpFileName); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); ASSERT_NE(0u, output.size()); EXPECT_NE(std::string::npos, output.find("Non-default value of debug variable: NEO_OCL_TbxServer = 192.168.0.1")); @@ -293,7 +298,8 @@ TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledWithOclPrefixWhenCallin } TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledWithMixedPrefixWhenCallingDumpFlagsThenFlagsAreWrittenToDumpFile) { - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); FullyEnabledTestDebugManager debugManager; VariableBackup backup(&apiTypeForUlts, ApiSpecificConfig::L0); @@ -324,7 +330,7 @@ TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledWithMixedPrefixWhenCall #undef DECLARE_DEBUG_VARIABLE std::remove(FullyEnabledTestDebugManager::settingsDumpFileName); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); ASSERT_NE(0u, output.size()); EXPECT_NE(std::string::npos, output.find("Non-default value of debug variable: NEO_L0_TbxServer = 192.168.0.1")); @@ -334,7 +340,8 @@ TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledWithMixedPrefixWhenCall } TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledOnDisabledDebugManagerWhenCallingDumpFlagsThenFlagsAreNotWrittenToDumpFile) { - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); FullyDisabledTestDebugManager debugManager; debugManager.flags.PrintDebugSettings.set(true); @@ -342,7 +349,7 @@ TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledOnDisabledDebugManagerW debugManager.dumpFlags(); std::remove(FullyDisabledTestDebugManager::settingsDumpFileName); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); ASSERT_EQ(0u, output.size()); } @@ -414,9 +421,10 @@ TEST(DebugSettingsManager, GivenLogsEnabledAndDumpToFileWhenPrintDebuggerLogCall std::remove(logFile); - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); PRINT_DEBUGGER_LOG(stdout, "test %s", "log"); - auto output = ::testing::internal::GetCapturedStdout(); + auto output = capture.getCapturedStdout(); EXPECT_EQ(0u, output.size()); auto logFileExists = fileExists(logFile); @@ -440,10 +448,11 @@ TEST(DebugSettingsManager, GivenLogsDisabledAndDumpToFileWhenPrintDebuggerLogCal auto logFile = NEO::fileLoggerInstance().getLogFileName(); std::remove(logFile); - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); PRINT_DEBUGGER_LOG(stdout, "test %s", "log"); - auto output = ::testing::internal::GetCapturedStdout(); + auto output = capture.getCapturedStdout(); EXPECT_EQ(0u, output.size()); auto logFileExists = fileExists(logFile); @@ -489,9 +498,10 @@ TEST(DebugSettingsManager, GivenLogsEnabledWhenLogCacheOperationCalledThenString } TEST(DebugLog, WhenLogDebugStringCalledThenNothingIsPrintedToStdout) { - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); logDebugString("test log"); - auto output = ::testing::internal::GetCapturedStdout(); + auto output = capture.getCapturedStdout(); EXPECT_EQ(0u, output.size()); } diff --git a/shared/test/unit_test/debug_settings/linux/debug_settings_manager_linux_tests.cpp b/shared/test/unit_test/debug_settings/linux/debug_settings_manager_linux_tests.cpp index 4a7f0bd0f6..f415ca3183 100644 --- a/shared/test/unit_test/debug_settings/linux/debug_settings_manager_linux_tests.cpp +++ b/shared/test/unit_test/debug_settings/linux/debug_settings_manager_linux_tests.cpp @@ -8,6 +8,7 @@ #include "shared/source/helpers/file_io.h" #include "shared/source/utilities/debug_file_reader.h" #include "shared/test/common/debug_settings/debug_settings_manager_fixture.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/mocks/mock_io_functions.h" #include "shared/test/common/mocks/mock_settings_reader.h" @@ -41,7 +42,8 @@ TEST(DebugSettingsManager, givenDisabledDebugManagerAndMockEnvVariableWhenCreate } TEST(DebugSettingsManager, givenPrintDebugSettingsAndDebugKeysReadEnabledOnDisabledDebugManagerWhenCallingDumpFlagsThenFlagsAreWrittenToDumpFile) { - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); FullyDisabledTestDebugManager debugManager; debugManager.flags.PrintDebugSettings.set(true); debugManager.flags.LoopAtDriverInit.set(true); @@ -66,7 +68,7 @@ TEST(DebugSettingsManager, givenPrintDebugSettingsAndDebugKeysReadEnabledOnDisab #undef DECLARE_DEBUG_SCOPED_V #undef DECLARE_DEBUG_VARIABLE std::remove(FullyDisabledTestDebugManager::settingsDumpFileName); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); ASSERT_NE(0u, output.size()); EXPECT_NE(std::string::npos, output.find("Non-default value of debug variable: TbxServer = 192.168.0.1")); diff --git a/shared/test/unit_test/direct_submission/direct_submission_tests_2.cpp b/shared/test/unit_test/direct_submission/direct_submission_tests_2.cpp index 0ab39ffede..bdc48467d6 100644 --- a/shared/test/unit_test/direct_submission/direct_submission_tests_2.cpp +++ b/shared/test/unit_test/direct_submission/direct_submission_tests_2.cpp @@ -25,6 +25,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/dispatch_flags_helper.h" #include "shared/test/common/helpers/relaxed_ordering_commands_helper.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/ult_hw_config.h" #include "shared/test/common/helpers/unit_test_helper.h" #include "shared/test/common/helpers/variable_backup.h" @@ -705,14 +706,15 @@ HWTEST_F(DirectSubmissionDispatchBufferTest, givenDirectSubmissionPrintBuffersWh FlushStampTracker flushStamp(true); MockDirectSubmissionHw> directSubmission(*pDevice->getDefaultEngine().commandStreamReceiver); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); bool ret = directSubmission.initialize(false); EXPECT_TRUE(ret); ret = directSubmission.dispatchCommandBuffer(batchBuffer, flushStamp); EXPECT_TRUE(ret); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); auto pos = output.find("Ring buffer 0"); EXPECT_TRUE(pos != std::string::npos); diff --git a/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp b/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp index 36c7458f21..972373e978 100644 --- a/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp +++ b/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp @@ -18,6 +18,7 @@ #include "shared/test/common/device_binary_format/patchtokens_tests.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/unit_test_helper.h" #include "shared/test/common/mocks/mock_device.h" #include "shared/test/common/mocks/mock_l0_debugger.h" @@ -1111,9 +1112,10 @@ HWTEST2_F(EncodeDispatchKernelTest, givenPrintKernelDispatchParametersWhenEncodi DebugManagerStateRestore restore; debugManager.flags.PrintKernelDispatchParameters.set(true); - testing::internal::CaptureStdout(); // start capturing + StreamCapture capture; + capture.captureStdout(); // start capturing EncodeDispatchKernel::template encode(*cmdContainer.get(), dispatchArgs); - std::string outputString = testing::internal::GetCapturedStdout(); // stop capturing + std::string outputString = capture.getCapturedStdout(); // stop capturing EXPECT_NE(std::string::npos, outputString.find("kernel")); EXPECT_NE(std::string::npos, outputString.find("grfCount")); diff --git a/shared/test/unit_test/gmm_helper/compression_tests_xe2_and_later.cpp b/shared/test/unit_test/gmm_helper/compression_tests_xe2_and_later.cpp index 6becb2bec6..3d653e8637 100644 --- a/shared/test/unit_test/gmm_helper/compression_tests_xe2_and_later.cpp +++ b/shared/test/unit_test/gmm_helper/compression_tests_xe2_and_later.cpp @@ -14,6 +14,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.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_execution_environment.h" #include "shared/test/common/mocks/mock_gmm.h" #include "shared/test/common/test_macros/hw_test.h" @@ -74,12 +75,13 @@ HWTEST2_F(GmmAdditionalCompressionSettingsTests, givenDebugFlagSetWhenCreatingGm DebugManagerStateRestore restore; debugManager.flags.PrintGmmCompressionParams.set(true); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto gmm = std::make_unique(getGmmHelper()); auto &flags = gmm->resourceParams.Flags; - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); ASSERT_NE(0u, output.size()); char expectedStr[512] = {}; diff --git a/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp b/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp index bb743cac6e..7400db2625 100644 --- a/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp +++ b/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp @@ -13,6 +13,7 @@ #include "shared/test/common/fixtures/mock_execution_environment_gmm_fixture.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/mocks/mock_gmm.h" #include "shared/test/common/mocks/mock_gmm_client_context.h" #include "shared/test/common/mocks/mock_gmm_resource_info.h" @@ -549,7 +550,8 @@ TEST_F(GmmHelperTests, givenDebugFlagSetWhenCreatingResourceThenPrintCompression DebugManagerStateRestore restore; debugManager.flags.PrintGmmCompressionParams.set(true); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); StorageInfo storageInfo; GmmRequirements gmmRequirements{}; @@ -558,7 +560,7 @@ TEST_F(GmmHelperTests, givenDebugFlagSetWhenCreatingResourceThenPrintCompression auto gmm = std::make_unique(getGmmHelper(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, storageInfo, gmmRequirements); auto &flags = gmm->resourceParams.Flags; - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); ASSERT_NE(0u, output.size()); char expectedStr[512] = {}; @@ -578,14 +580,15 @@ TEST_F(GmmHelperTests, givenDebugFlagSetWhenCreatingImageResourceThenPrintCompre imgDesc.imageHeight = 17; imgDesc.imageDepth = 17; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); auto gmm = MockGmm::queryImgParams(getGmmHelper(), imgInfo, true); auto &flags = gmm->resourceParams.Flags; - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); ASSERT_NE(0u, output.size()); char expectedStr[512] = {}; diff --git a/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp b/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp index 497dc5b96d..520edd8578 100644 --- a/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp +++ b/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp @@ -16,6 +16,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/mock_product_helper_hw.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_device.h" #include "shared/test/common/mocks/mock_graphics_allocation.h" #include "shared/test/common/mocks/mock_timestamp_container.h" @@ -721,10 +722,11 @@ HWTEST2_F(BlitTests, givenMemoryAndImageWhenDispatchCopyImageCallThenCommandAdde HWTEST2_F(BlitTests, whenPrintImageBlitBlockCopyCommandIsCalledThenCmdDetailsAreNotPrintedToStdOutput, BlitPlatforms) { auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); NEO::BlitCommandsHelper::printImageBlitBlockCopyCommand(bltCmd, 0); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput(""); EXPECT_EQ(expectedOutput, output); } diff --git a/shared/test/unit_test/helpers/test_blit_commands_helper_xehp_and_later.cpp b/shared/test/unit_test/helpers/test_blit_commands_helper_xehp_and_later.cpp index 0270e8fedc..d09f79abb4 100644 --- a/shared/test/unit_test/helpers/test_blit_commands_helper_xehp_and_later.cpp +++ b/shared/test/unit_test/helpers/test_blit_commands_helper_xehp_and_later.cpp @@ -18,6 +18,7 @@ #include "shared/test/common/cmd_parse/hw_parse.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/raii_product_helper.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/unit_test_helper.h" #include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/mocks/mock_gmm.h" @@ -455,10 +456,11 @@ HWTEST2_F(BlitTests, givenDebugVariableWhenDispatchBlitCommandsForImageRegionIsC blitProperties.srcSize = {1, 1, 1}; blitProperties.dstSize = {1, 1, 1}; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); BlitCommandsHelper::dispatchBlitCommandsForImageRegion(blitProperties, stream, pDevice->getRootDeviceEnvironmentRef()); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::stringstream expectedOutput; expectedOutput << "Slice index: 0\n" << "ColorDepth: 0\n" diff --git a/shared/test/unit_test/os_interface/gdi_interface_logging_tests.cpp b/shared/test/unit_test/os_interface/gdi_interface_logging_tests.cpp index ed68648f11..3810bcb7a0 100644 --- a/shared/test/unit_test/os_interface/gdi_interface_logging_tests.cpp +++ b/shared/test/unit_test/os_interface/gdi_interface_logging_tests.cpp @@ -9,6 +9,7 @@ #include "shared/source/os_interface/windows/gdi_interface_logging.h" #include "shared/source/os_interface/windows/sharedata_wrapper.h" #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_io_functions.h" #include "shared/test/common/test_macros/test.h" @@ -106,9 +107,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingOpenAdapterFro << " 0x" << param.AdapterLuid.LowPart << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); @@ -116,9 +118,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingOpenAdapterFro << std::hex << status << " " << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -130,9 +132,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingCloseAdapterTh << "D3DKMT_CLOSEADAPTER" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); @@ -140,9 +143,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingCloseAdapterTh << std::hex << status << " " << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -154,9 +157,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingQueryAdapterIn << "D3DKMT_QUERYADAPTERINFO" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); @@ -164,9 +168,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingQueryAdapterIn << std::hex << status << " " << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -184,9 +188,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingEscapeThenExpe << " Flags 0x" << std::hex << param.Flags.Value << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); @@ -194,9 +199,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingEscapeThenExpe << std::hex << status << " " << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -208,9 +213,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingCreateDeviceTh << "D3DKMT_CREATEDEVICE" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); @@ -218,9 +224,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingCreateDeviceTh << std::hex << status << " " << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -232,9 +238,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingDestroyDeviceT << "D3DKMT_DESTROYDEVICE" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); @@ -242,9 +249,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingDestroyDeviceT << std::hex << status << " " << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -261,9 +268,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingCreateContextT << " Flags 0x" << std::hex << param.Flags.Value << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); @@ -271,9 +279,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingCreateContextT << std::hex << status << " " << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -285,9 +293,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingDestroyContext << "D3DKMT_DESTROYCONTEXT" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); status = 0xC00001; @@ -296,9 +305,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingDestroyContext << std::hex << status << " " << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -313,9 +322,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingCreateAllocati << std::hex << flagsValue << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); @@ -323,9 +333,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingCreateAllocati << std::hex << status << " " << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -337,9 +347,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingOpenResourceTh << "D3DKMT_OPENRESOURCE" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); @@ -347,9 +358,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingOpenResourceTh << std::hex << status << " " << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -361,9 +372,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingQueryResourceI << "D3DKMT_QUERYRESOURCEINFO" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); @@ -371,9 +383,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingQueryResourceI << std::hex << status << " " << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -387,9 +399,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingCreateSynchron << param.Info.Type << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); @@ -397,9 +410,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingCreateSynchron << std::hex << status << " " << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -411,19 +424,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingDestroySynchro << "D3DKMT_DESTROYSYNCHRONIZATIONOBJECT" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -437,19 +450,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingSignalSynchron << param.Flags.Value << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -461,19 +474,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingWaitForSynchro << "D3DKMT_WAITFORSYNCHRONIZATIONOBJECT" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -489,19 +502,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingCreateSynchron << " Info Flags 0x" << std::hex << param.Info.Flags.Value << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -515,19 +528,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingGetDeviceState << param.StateType << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -545,9 +558,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingMakeResidentTh << " Flags 0x" << std::hex << param.Flags.Value << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); @@ -557,9 +571,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingMakeResidentTh << " NumBytesToTrim 0x" << std::hex << param.NumBytesToTrim << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -576,9 +590,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingEvictThenExpec << " Flags 0x" << std::hex << param.Flags.Value << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); @@ -587,9 +602,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingEvictThenExpec << " NumBytesToTrim 0x" << std::hex << param.NumBytesToTrim << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -603,19 +618,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingWaitForSynchro << std::hex << param.Flags.Value << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -629,19 +644,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingSignalSynchron << param.Flags.Value << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -653,19 +668,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingWaitForSynchro << "D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMGPU" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -677,19 +692,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingSignalSynchron << "D3DKMT_SIGNALSYNCHRONIZATIONOBJECTFROMGPU" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -703,19 +718,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingCreatePagingQu << param.Priority << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -727,19 +742,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingDestroyPagingQ << "D3DDDI_DESTROYPAGINGQUEUE" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -753,19 +768,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingLock2ThenExpec << std::hex << param.Flags.Value << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -777,19 +792,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingUnlock2ThenExp << "D3DKMT_UNLOCK2" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -801,19 +816,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingInvalidateCach << "D3DKMT_INVALIDATECACHE" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -835,9 +850,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingMapGpuVirtualA << " SizeInPages 0x" << param.SizeInPages << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); @@ -847,9 +863,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingMapGpuVirtualA << " PagingFenceValue " << std::dec << param.PagingFenceValue << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -873,9 +889,10 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingReserveGpuVirt << " ReservationType " << std::dec << param.ReservationType << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); @@ -885,9 +902,9 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingReserveGpuVirt << " PagingFenceValue " << std::dec << param.PagingFenceValue << std::endl; - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -903,19 +920,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingFreeGpuVirtual << " Size 0x" << param.Size << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -927,19 +944,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingUpdateGpuVirtu << "D3DKMT_UPDATEGPUVIRTUALADDRESS" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -957,19 +974,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingCreateContextV << " ClientHint " << std::dec << param.ClientHint << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -995,19 +1012,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingSubmitCommandT << " Header MonitorFenceValue 0x" << cmdBufferHeader.MonitorFenceValue << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -1021,19 +1038,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingOpenSyncObject << std::hex << param.Flags.Value << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -1045,19 +1062,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingOpenSyncObject << "D3DKMT_OPENSYNCOBJECTNTHANDLEFROMNAME" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -1072,19 +1089,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingDestroyAllocat << std::hex << param.Flags.Value << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -1096,19 +1113,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingRegisterTrimNo << "D3DKMT_REGISTERTRIMNOTIFICATION" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -1120,19 +1137,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingUnregisterTrim << "D3DKMT_UNREGISTERTRIMNOTIFICATION" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -1144,19 +1161,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingOpenResourceFr << "D3DKMT_OPENRESOURCEFROMNTHANDLE" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -1168,19 +1185,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingQueryResourceF << "D3DKMT_QUERYRESOURCEINFOFROMNTHANDLE" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -1194,19 +1211,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingCreateHwQueueT << std::hex << param.Flags.Value << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -1218,19 +1235,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingDestroyHwQueue << "D3DKMT_DESTROYHWQUEUE" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -1242,19 +1259,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingSubmitCommandT << "D3DKMT_SUBMITCOMMANDTOHWQUEUE" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -1266,19 +1283,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingSetAllocationP << "D3DKMT_SETALLOCATIONPRIORITY" << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } @@ -1292,19 +1309,19 @@ TEST_F(GdiInterfaceLoggingTest, WhenGdiLoggingIsEnabledWhenLoggingSetContextSche << param.Priority << std::endl; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); GdiLogging::logEnter(¶m); - std::string logEnterStr = testing::internal::GetCapturedStdout(); + std::string logEnterStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logEnterStr.c_str()); expectedOutput.str(std::string()); expectedOutput << logExitBegin << std::hex << status << " " << std::endl; - - testing::internal::CaptureStdout(); + capture.captureStdout(); GdiLogging::logExit(status, ¶m); - std::string logExitStr = testing::internal::GetCapturedStdout(); + std::string logExitStr = capture.getCapturedStdout(); EXPECT_STREQ(expectedOutput.str().c_str(), logExitStr.c_str()); } diff --git a/shared/test/unit_test/os_interface/linux/ccs_mode_tests.cpp b/shared/test/unit_test/os_interface/linux/ccs_mode_tests.cpp index d4b18d7bf2..f92bed4599 100644 --- a/shared/test/unit_test/os_interface/linux/ccs_mode_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/ccs_mode_tests.cpp @@ -9,6 +9,7 @@ #include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/utilities/directory.h" #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/libult/linux/drm_mock.h" #include "shared/test/common/mocks/mock_driver_model.h" @@ -242,13 +243,14 @@ TEST_F(CcsModeTest, GivenValidCcsModeAndOpenSysCallFailsWithNoPermissionsWhenCon DebugManagerStateRestore restorer; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); testing::internal::CaptureStderr(); debugManager.flags.ZEX_NUMBER_OF_CCS.set("2"); executionEnvironment->configureCcsMode(); - std::string stdOutString = testing::internal::GetCapturedStdout(); + std::string stdOutString = capture.getCapturedStdout(); std::string stdErrString = testing::internal::GetCapturedStderr(); std::string expectedOutput = "No read and write permissions for /sys/class/drm/card0/gt/gt0/ccs_mode, System administrator needs to grant permissions to allow modification of this file from user space\n"; @@ -281,13 +283,14 @@ TEST_F(CcsModeTest, GivenValidCcsModeAndOpenSysCallFailsWithNoAccessWhenConfigur DebugManagerStateRestore restorer; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); testing::internal::CaptureStderr(); debugManager.flags.ZEX_NUMBER_OF_CCS.set("2"); executionEnvironment->configureCcsMode(); - std::string stdOutString = testing::internal::GetCapturedStdout(); + std::string stdOutString = capture.getCapturedStdout(); std::string stdErrString = testing::internal::GetCapturedStderr(); std::string expectedOutput = "No read and write permissions for /sys/class/drm/card0/gt/gt0/ccs_mode, System administrator needs to grant permissions to allow modification of this file from user space\n"; diff --git a/shared/test/unit_test/os_interface/linux/drm_buffer_object_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_buffer_object_tests.cpp index 168bfc47e2..8598d2c609 100644 --- a/shared/test/unit_test/os_interface/linux/drm_buffer_object_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_buffer_object_tests.cpp @@ -9,6 +9,7 @@ #include "shared/source/os_interface/os_interface.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/libult/linux/drm_mock.h" #include "shared/test/common/mocks/linux/mock_drm_allocation.h" #include "shared/test/common/mocks/linux/mock_drm_wrappers.h" @@ -177,11 +178,12 @@ TEST_F(DrmBufferObjectTest, givenResidentBOWhenPrintExecutionBufferIsSetToTrueTh bo->setAddress(reinterpret_cast(buff.get())); BufferObject *boArray[1] = {bo.get()}; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto ret = bo->pin(boArray, 1, osContext.get(), 0, 1); EXPECT_EQ(0, ret); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); auto idx = output.find("drm_i915_gem_execbuffer2 {"); size_t expectedValue = 29; EXPECT_EQ(expectedValue, idx); @@ -198,11 +200,12 @@ TEST_F(DrmBufferObjectTest, whenPrintBOCreateDestroyResultFlagIsSetAndCloseIsCal DebugManagerStateRestore stateRestore; debugManager.flags.PrintBOCreateDestroyResult.set(true); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); bool result = bo->close(); EXPECT_EQ(true, result); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); size_t idx = output.find("Calling gem close on handle: BO-"); size_t expectedValue = 0; EXPECT_EQ(expectedValue, idx); @@ -217,21 +220,23 @@ TEST_F(DrmBufferObjectTest, whenPrintBOCreateDestroyResultFlagIsSetAndCloseIsCal MockBufferObjectHandleWrapper sharedBoHandleWrapper = bo->acquireSharedOwnershipOfBoHandle(); EXPECT_TRUE(bo->isBoHandleShared()); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); bool result = bo->close(); EXPECT_EQ(true, result); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); size_t idx = output.find("Skipped closing BO-"); size_t expectedValue = 0u; EXPECT_EQ(expectedValue, idx); } - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); bool result = bo->close(); EXPECT_EQ(true, result); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); size_t idx = output.find("Calling gem close on handle: BO-"); size_t expectedValue = 0; EXPECT_EQ(expectedValue, idx); @@ -243,11 +248,12 @@ TEST_F(DrmBufferObjectTest, whenPrintExecutionBufferIsSetToTrueThenMessageFoundI debugManager.flags.PrintExecutionBuffer.set(true); ExecObject execObjectsStorage = {}; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto ret = bo->exec(0, 0, 0, false, osContext.get(), 0, 1, nullptr, 0u, &execObjectsStorage, 0, 0); EXPECT_EQ(0, ret); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); auto idx = output.find("drm_i915_gem_execbuffer2 {"); size_t expectedValue = 29; EXPECT_EQ(expectedValue, idx); @@ -520,22 +526,24 @@ TEST(DrmBufferObject, givenPrintBOBindingResultWhenBOBindAndUnbindSucceedsThenPr auto osContext = engines[contextId].osContext; osContext->ensureContextInitialized(false); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); bo.bind(osContext, 0, false); EXPECT_TRUE(bo.bindInfo[contextId][0]); - std::string bindOutput = testing::internal::GetCapturedStdout(); + std::string bindOutput = capture.getCapturedStdout(); std::stringstream expected; expected << "bind BO-0 to VM 0, drmVmId = " << drm->latestCreatedVmId << ", range: 0 - 0, size: 0, result: 0\n"; EXPECT_STREQ(bindOutput.c_str(), expected.str().c_str()) << bindOutput; expected.str(""); - testing::internal::CaptureStdout(); + + capture.captureStdout(); bo.unbind(osContext, 0); EXPECT_FALSE(bo.bindInfo[contextId][0]); - std::string unbindOutput = testing::internal::GetCapturedStdout(); + std::string unbindOutput = capture.getCapturedStdout(); expected << "unbind BO-0 from VM 0, drmVmId = " << drm->latestCreatedVmId << ", range: 0 - 0, size: 0, result: 0\n"; EXPECT_STREQ(unbindOutput.c_str(), expected.str().c_str()) << unbindOutput; } diff --git a/shared/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp b/shared/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp index 455e70dba5..43d5006491 100644 --- a/shared/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp @@ -27,6 +27,7 @@ #include "shared/test/common/helpers/dispatch_flags_helper.h" #include "shared/test/common/helpers/engine_descriptor_helper.h" #include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/libult/linux/drm_mock.h" #include "shared/test/common/mocks/linux/mock_drm_allocation.h" #include "shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h" @@ -219,7 +220,8 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenPrintIndicesEnabledWhenFlushThenPr EncodeNoop::alignToCacheLine(cs); BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed()); - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); csr->flush(batchBuffer, csr->getResidencyAllocations()); const std::string engineType = EngineHelpers::engineTypeToString(csr->getOsContext().getEngineType()); const std::string engineUsage = EngineHelpers::engineUsageToString(csr->getOsContext().getEngineUsage()); @@ -228,7 +230,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenPrintIndicesEnabledWhenFlushThenPr << ", Sub-Devices Mask: " << csr->getOsContext().getDeviceBitfield().to_ulong() << ", EngineId: " << csr->getOsContext().getEngineType() << " (" << engineType << ", " << engineUsage << ")\n"; - EXPECT_TRUE(hasSubstr(::testing::internal::GetCapturedStdout(), expectedValue.str())); + EXPECT_TRUE(hasSubstr(capture.getCapturedStdout(), expectedValue.str())); } HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenDrmContextIdWhenFlushingThenSetIdToAllExecBuffersAndObjects) { @@ -1128,11 +1130,12 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenPrintBOsForSubmitWhenPrint residency.push_back(&allocation1); residency.push_back(&allocation2); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); EXPECT_EQ(SubmissionStatus::success, static_cast *>(csr)->printBOsForSubmit(residency, cmdBuffer)); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::vector bos; allocation1.makeBOsResident(&csr->getOsContext(), 0, &bos, true, false); @@ -1166,11 +1169,12 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenPrintBOsForSubmitAndFailur residency.push_back(&allocation1); residency.push_back(&allocation2); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); EXPECT_EQ(SubmissionStatus::outOfHostMemory, static_cast *>(csr)->printBOsForSubmit(residency, cmdBuffer)); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_TRUE(output.empty()); } @@ -1191,10 +1195,11 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenPrintBOsForSubmitAndFailur residency.push_back(&allocation1); residency.push_back(&allocation2); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); EXPECT_EQ(SubmissionStatus::outOfHostMemory, static_cast *>(csr)->printBOsForSubmit(residency, cmdBuffer)); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_TRUE(output.empty()); } diff --git a/shared/test/unit_test/os_interface/linux/drm_command_stream_xehp_and_later_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_command_stream_xehp_and_later_prelim_tests.cpp index 56c276d674..276a24e0d3 100644 --- a/shared/test/unit_test/os_interface/linux/drm_command_stream_xehp_and_later_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_command_stream_xehp_and_later_prelim_tests.cpp @@ -12,6 +12,7 @@ #include "shared/source/os_interface/sys_calls_common.h" #include "shared/test/common/helpers/batch_buffer_helper.h" #include "shared/test/common/helpers/engine_descriptor_helper.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_allocation_properties.h" #include "shared/test/common/os_interface/linux/device_command_stream_fixture_prelim.h" #include "shared/test/common/os_interface/linux/drm_command_stream_fixture.h" @@ -464,7 +465,8 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenPrintIndicesEnabledWhenFlushThenPr EncodeNoop::alignToCacheLine(cs); BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed()); - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); csr->flush(batchBuffer, csr->getResidencyAllocations()); const std::string engineType = EngineHelpers::engineTypeToString(csr->getOsContext().getEngineType()); const std::string engineUsage = EngineHelpers::engineUsageToString(csr->getOsContext().getEngineUsage()); @@ -477,7 +479,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenPrintIndicesEnabledWhenFlushThenPr for (uint32_t contextIndex = 0; contextIndex < drmContextIds.size(); contextIndex++) { expectedValue << SysCalls::getProcessId() << ": Drm Submission of contextIndex: " << contextIndex << ", with context id " << drmContextIds[contextIndex] << "\n"; } - EXPECT_STREQ(::testing::internal::GetCapturedStdout().c_str(), expectedValue.str().c_str()); + EXPECT_STREQ(capture.getCapturedStdout().c_str(), expectedValue.str().c_str()); } struct DrmImplicitScalingCommandStreamTest : ::testing::Test { diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_info_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_info_prelim_tests.cpp index e159e9c85b..177553b13a 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_info_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_info_prelim_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Intel Corporation + * Copyright (C) 2022-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -10,6 +10,7 @@ #include "shared/source/os_interface/linux/memory_info.h" #include "shared/source/os_interface/linux/numa_library.h" #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/libult/linux/drm_mock_helper.h" #include "shared/test/common/libult/linux/drm_query_mock.h" @@ -359,11 +360,12 @@ TEST_F(MultiTileMemoryInfoPrelimTest, whenDebugVariablePrintMemoryRegionSizeIsSe setupMemoryInfo(regionInfo, 0); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::mainBank); EXPECT_EQ(16 * MemoryConstants::gigaByte, regionSize); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput("Memory type: 0, memory instance: 1, region size: 17179869184\n"); EXPECT_EQ(expectedOutput, output); } diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_info_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_info_tests.cpp index 394768dd08..894fa6e687 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_info_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_info_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -10,6 +10,7 @@ #include "shared/source/os_interface/linux/memory_info.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/test_macros/hw_test.h" #include "shared/test/unit_test/os_interface/linux/drm_mock_impl.h" @@ -162,11 +163,12 @@ TEST(MemoryInfo, whenDebugVariablePrintMemoryRegionSizeIsSetAndGetMemoryRegionSi auto memoryInfo = std::make_unique(regionInfo, *drm); ASSERT_NE(nullptr, memoryInfo); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::mainBank); EXPECT_EQ(16 * MemoryConstants::gigaByte, regionSize); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput("Memory type: 0, memory instance: 1, region size: 17179869184\n"); EXPECT_EQ(expectedOutput, output); } diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_prelim_tests.cpp index 000992721d..b760278c36 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_prelim_tests.cpp @@ -15,6 +15,7 @@ #include "shared/source/os_interface/linux/allocator_helper.h" #include "shared/source/utilities/heap_allocator.h" #include "shared/test/common/helpers/batch_buffer_helper.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/libult/linux/drm_mock_helper.h" #include "shared/test/common/libult/linux/drm_mock_prelim_context.h" #include "shared/test/common/libult/linux/drm_query_mock.h" @@ -2032,7 +2033,8 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenPrintBOCreateDestroyResultFla mock->engineInfoQueried = false; mock->queryEngineInfo(); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto bo = std::unique_ptr(memoryManager->createBufferObjectInMemoryRegion(0u, nullptr, AllocationType::buffer, @@ -2045,7 +2047,7 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenPrintBOCreateDestroyResultFla false)); EXPECT_NE(nullptr, bo); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 65536, param: 0x1000000010001, memory class: 1, memory instance: 256 }\nGEM_CREATE_EXT has returned: 0 BO-1 with size: 65536\n"); EXPECT_EQ(expectedOutput, output); } @@ -2072,7 +2074,8 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenPrintBOCreateDestroyResultFla SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::sharedUnifiedMemory, 1, rootDeviceIndices, deviceBitfields); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto ptr = unifiedMemoryManager.createSharedUnifiedMemoryAllocation(MemoryConstants::pageSize64k, unifiedMemoryProperties, nullptr); EXPECT_NE(nullptr, ptr); @@ -2081,7 +2084,7 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenPrintBOCreateDestroyResultFla unifiedMemoryManager.freeSVMAlloc(ptr); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); auto idx = output.find("Performing GEM_CREATE_EXT with { size: 2097152, param: 0x1000000010001, memory class: 0, memory instance: 1, memory class: 1, memory instance: 256 }\n\ GEM_CREATE_EXT has returned: 0 BO-1 with size: 2097152\n"); @@ -2722,7 +2725,8 @@ HWTEST_TEMPLATED_F(DrmMemoryManagerTestPrelim, size_t size = 4096u; AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::bufferHostMemory, false, {}); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, true, true, nullptr); ASSERT_NE(nullptr, graphicsAllocation); @@ -2747,7 +2751,7 @@ HWTEST_TEMPLATED_F(DrmMemoryManagerTestPrelim, memoryManager->freeGraphicsMemory(graphicsAllocation); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_EQ(expectedOutput.str(), output); } diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index 39195c8206..b17ced1308 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -22,6 +22,7 @@ #include "shared/source/release_helper/release_helper.h" #include "shared/test/common/helpers/engine_descriptor_helper.h" #include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/linux/mock_drm_allocation.h" #include "shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h" #include "shared/test/common/mocks/linux/mock_drm_memory_manager.h" @@ -101,23 +102,24 @@ HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenDebugFlagSetWhenUsingMmapFunctions MockDrmMemoryManager memoryManager(GemCloseWorkerMode::gemCloseWorkerInactive, false, false, *executionEnvironment); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); size_t len = 2; off_t offset = 6; void *ptr = reinterpret_cast(0x1234); void *retPtr = memoryManager.mmapFunction(ptr, len, 3, 4, 5, offset); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); char expected1[256] = {}; sprintf(expected1, "mmap(%p, %zu, %d, %d, %d, %ld) = %p, errno: %d \n", ptr, len, 3, 4, 5, offset, retPtr, errno); EXPECT_NE(std::string::npos, output.find(expected1)); - testing::internal::CaptureStdout(); + capture.captureStdout(); int retVal = memoryManager.munmapFunction(retPtr, len); - output = testing::internal::GetCapturedStdout(); + output = capture.getCapturedStdout(); char expected2[256] = {}; sprintf(expected2, "munmap(%p, %zu) = %d, errno: %d \n", retPtr, len, retVal, errno); @@ -1138,12 +1140,13 @@ HWTEST_TEMPLATED_F(DrmMemoryManagerTest, whenPrintBOCreateDestroyResultIsSetAndA mock->ioctlExpected.gemUserptr = 1; mock->ioctlExpected.gemClose = 1; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); BufferObject *bo = memoryManager->allocUserptr(0, (size_t)1024, AllocationType::externalHostPtr, rootDeviceIndex); ASSERT_NE(nullptr, bo); debugManager.flags.PrintBOCreateDestroyResult.set(false); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); size_t idx = output.find("Created new BO with GEM_USERPTR, handle: BO-"); size_t expectedValue = 0; EXPECT_EQ(expectedValue, idx); @@ -4281,7 +4284,8 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest, AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::sharedBuffer, false, {}); debugManager.flags.PrintBOCreateDestroyResult.set(true); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, false, nullptr); ASSERT_NE(nullptr, allocation); @@ -4294,7 +4298,7 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest, memoryManger.freeGraphicsMemory(allocation); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_EQ(expectedOutput.str(), output); } diff --git a/shared/test/unit_test/os_interface/linux/drm_query_topology_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_query_topology_prelim_tests.cpp index 07a286b69b..e5fd4b8cd3 100644 --- a/shared/test/unit_test/os_interface/linux/drm_query_topology_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_query_topology_prelim_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Intel Corporation + * Copyright (C) 2022-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -12,6 +12,7 @@ #include "shared/source/os_interface/product_helper.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/libult/linux/drm_mock_prelim_context.h" #include "shared/test/common/libult/linux/drm_query_mock.h" #include "shared/test/common/mocks/linux/mock_drm_allocation.h" @@ -398,10 +399,11 @@ TEST(DrmQueryTest, givenPrintIoctlDebugFlagSetWhenCallingQueryPageFaultSupportTh bool hasPageFaultSupport = true; drm.context.hasPageFaultQueryValue = hasPageFaultSupport; - testing::internal::CaptureStdout(); // start capturing + StreamCapture capture; + capture.captureStdout(); // start capturing drm.queryPageFaultSupport(); debugManager.flags.PrintIoctlEntries.set(false); - std::string outputString = testing::internal::GetCapturedStdout(); // stop capturing + std::string outputString = capture.getCapturedStdout(); // stop capturing if (productHelper.isPageFaultSupported()) { std::string expectedString = "DRM_IOCTL_I915_GETPARAM: param: PRELIM_I915_PARAM_HAS_PAGE_FAULT, output value: 1, retCode: 0\n"; @@ -421,10 +423,11 @@ TEST(DrmQueryTest, givenPrintIoctlDebugFlagNotSetWhenIsPageFaultSupportedCalledT bool hasPageFaultSupport = true; drm.context.hasPageFaultQueryValue = hasPageFaultSupport; - testing::internal::CaptureStdout(); // start capturing + StreamCapture capture; + capture.captureStdout(); // start capturing drm.queryPageFaultSupport(); debugManager.flags.PrintIoctlEntries.set(false); - std::string outputString = testing::internal::GetCapturedStdout(); // stop capturing + std::string outputString = capture.getCapturedStdout(); // stop capturing EXPECT_TRUE(outputString.empty()); } diff --git a/shared/test/unit_test/os_interface/linux/drm_system_info_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_system_info_tests.cpp index abf66565f0..cf74c30baa 100644 --- a/shared/test/unit_test/os_interface/linux/drm_system_info_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_system_info_tests.cpp @@ -12,6 +12,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.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/libult/linux/drm_mock.h" #include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/os_interface/linux/drm_mock_device_blob.h" @@ -76,7 +77,8 @@ TEST(DrmSystemInfoTest, givenSetupHardwareInfoWhenQuerySystemInfoFalseThenSystem auto setupHardwareInfo = [](HardwareInfo *, bool, const ReleaseHelper *) {}; DeviceDescriptor device = {0, &hwInfo, setupHardwareInfo}; - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); ::testing::internal::CaptureStderr(); DebugManagerStateRestore restorer; @@ -86,7 +88,7 @@ TEST(DrmSystemInfoTest, givenSetupHardwareInfoWhenQuerySystemInfoFalseThenSystem EXPECT_EQ(ret, 0); EXPECT_EQ(nullptr, drm.getSystemInfo()); - EXPECT_TRUE(isEmpty(::testing::internal::GetCapturedStdout())); + EXPECT_TRUE(isEmpty(capture.getCapturedStdout())); EXPECT_FALSE(isEmpty(::testing::internal::GetCapturedStderr())); } @@ -233,7 +235,8 @@ TEST(DrmSystemInfoTest, givenSetupHardwareInfoWhenQuerySystemInfoFailsThenSystem auto setupHardwareInfo = [](HardwareInfo *, bool, const ReleaseHelper *) {}; DeviceDescriptor device = {0, &hwInfo, setupHardwareInfo}; - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); ::testing::internal::CaptureStderr(); DebugManagerStateRestore restorer; debugManager.flags.PrintDebugMessages.set(true); @@ -245,7 +248,7 @@ TEST(DrmSystemInfoTest, givenSetupHardwareInfoWhenQuerySystemInfoFailsThenSystem EXPECT_EQ(ret, 0); EXPECT_EQ(nullptr, drm.getSystemInfo()); - EXPECT_TRUE(hasSubstr(::testing::internal::GetCapturedStdout(), "INFO: System Info query failed!\n")); + EXPECT_TRUE(hasSubstr(capture.getCapturedStdout(), "INFO: System Info query failed!\n")); auto &productHelper = executionEnvironment->rootDeviceEnvironments[0]->getHelper(); if (productHelper.isPlatformQuerySupported()) { EXPECT_TRUE(hasSubstr(::testing::internal::GetCapturedStderr(), "Size got from PRELIM_DRM_I915_QUERY_HW_IP_VERSION query does not match PrelimI915::prelim_drm_i915_query_hw_ip_version size\n")); diff --git a/shared/test/unit_test/os_interface/linux/drm_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_tests.cpp index 81000d9bea..199ce3833b 100644 --- a/shared/test/unit_test/os_interface/linux/drm_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_tests.cpp @@ -21,6 +21,7 @@ #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/engine_descriptor_helper.h" #include "shared/test/common/helpers/raii_gfx_core_helper.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.h" #include "shared/test/common/mocks/linux/mock_drm_memory_manager.h" @@ -857,11 +858,12 @@ TEST(DrmTest, givenPrintIoctlDebugFlagSetWhenGettingTimestampFrequencyThenCaptur int frequency = 0; - testing::internal::CaptureStdout(); // start capturing + StreamCapture capture; + capture.captureStdout(); // start capturing int ret = drm.getTimestampFrequency(frequency); debugManager.flags.PrintIoctlEntries.set(false); - std::string outputString = testing::internal::GetCapturedStdout(); // stop capturing + std::string outputString = capture.getCapturedStdout(); // stop capturing EXPECT_EQ(0, ret); EXPECT_EQ(1000, frequency); @@ -879,10 +881,11 @@ TEST(DrmTest, givenPrintIoctlDebugFlagNotSetWhenGettingTimestampFrequencyThenCap int frequency = 0; - testing::internal::CaptureStdout(); // start capturing + StreamCapture capture; + capture.captureStdout(); // start capturing int ret = drm.getTimestampFrequency(frequency); - std::string outputString = testing::internal::GetCapturedStdout(); // stop capturing + std::string outputString = capture.getCapturedStdout(); // stop capturing EXPECT_EQ(0, ret); EXPECT_EQ(1000, frequency); @@ -900,11 +903,12 @@ TEST(DrmTest, givenPrintIoctlDebugFlagSetWhenGettingOATimestampFrequencyThenCapt int frequency = 0; - testing::internal::CaptureStdout(); // start capturing + StreamCapture capture; + capture.captureStdout(); // start capturing int ret = drm.getOaTimestampFrequency(frequency); debugManager.flags.PrintIoctlEntries.set(false); - std::string outputString = testing::internal::GetCapturedStdout(); // stop capturing + std::string outputString = capture.getCapturedStdout(); // stop capturing EXPECT_EQ(0, ret); EXPECT_EQ(123456, frequency); @@ -1560,10 +1564,11 @@ TEST(DrmDeathTest, GivenResetStatsWithValidFaultWhenIsGpuHangIsCalledThenProcess std::string expectedString = std::string(buf.get()); ::testing::internal::CaptureStderr(); - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); EXPECT_THROW(drm.isGpuHangDetected(mockOsContextLinux), std::runtime_error); auto stderrString = ::testing::internal::GetCapturedStderr(); - auto stdoutString = ::testing::internal::GetCapturedStdout(); + auto stdoutString = capture.getCapturedStdout(); EXPECT_EQ(expectedString, stderrString); EXPECT_EQ(expectedString, stdoutString); } diff --git a/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp index 70e3bc7f5a..aa48afc04e 100644 --- a/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp @@ -17,6 +17,7 @@ #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/engine_descriptor_helper.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.h" #include "shared/test/common/libult/linux/drm_query_mock.h" @@ -221,13 +222,14 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtWithChunkingThenGet debugManager.flags.NumberOfBOChunks.set(2); size_t allocSize = 2 * MemoryConstants::pageSize64k; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto ioctlHelper = drm->getIoctlHelper(); uint32_t handle = 0; uint32_t getNumOfChunks = 2; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; ioctlHelper->createGemExt(memClassInstance, allocSize, handle, 0, {}, -1, true, getNumOfChunks, std::nullopt, std::nullopt, std::nullopt); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput("GEM_CREATE_EXT BO-1 with BOChunkingSize 65536, chunkingParamRegion.param.data 65536, numOfChunks 2\n"); EXPECT_EQ(expectedOutput, output); EXPECT_EQ(2u, getNumOfChunks); @@ -250,14 +252,15 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtWithDebugFlagThenPr DebugManagerStateRestore stateRestore; debugManager.flags.PrintBOCreateDestroyResult.set(true); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto ioctlHelper = drm->getIoctlHelper(); uint32_t handle = 0; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; uint32_t numOfChunks = 0; ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt, std::nullopt); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, param: 0x1000000010001, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT has returned: 0 BO-1 with size: 1024\n"); EXPECT_EQ(expectedOutput, output); } diff --git a/shared/test/unit_test/os_interface/linux/file_logger_linux_tests.cpp b/shared/test/unit_test/os_interface/linux/file_logger_linux_tests.cpp index 0c3047a15c..6fe2a9486c 100644 --- a/shared/test/unit_test/os_interface/linux/file_logger_linux_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/file_logger_linux_tests.cpp @@ -8,6 +8,7 @@ #include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/utilities/logger_neo_only.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/libult/linux/drm_mock.h" #include "shared/test/common/mocks/linux/mock_drm_allocation.h" #include "shared/test/common/mocks/mock_execution_environment.h" @@ -116,9 +117,10 @@ TEST(FileLogger, givenLogAllocationStdoutWhenLogAllocationThenLogToStdoutInstead allocation.bufferObjects[0] = &bo; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); logAllocation(fileLogger, &allocation, nullptr); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::thread::id thisThread = std::this_thread::get_id(); diff --git a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_dg1.cpp b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_dg1.cpp index ad476ca7b3..271e461aa6 100644 --- a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_dg1.cpp +++ b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_dg1.cpp @@ -11,6 +11,7 @@ #include "shared/source/os_interface/linux/ioctl_helper.h" #include "shared/source/os_interface/linux/memory_info.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/test_macros/header/per_product_test_definitions.h" #include "shared/test/common/test_macros/test.h" @@ -49,14 +50,15 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WithDrmTipWhenCreateGemExtWithDebugFlagTh auto drm = std::make_unique(*executionEnvironment->rootDeviceEnvironments[0]); drm->ioctlCallsCount = 0; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto ioctlHelper = drm->getIoctlHelper(); uint32_t handle = 0; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; uint32_t numOfChunks = 0; auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt, false); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT with EXT_MEMORY_REGIONS has returned: 0 BO-1 with size: 1024\n"); EXPECT_EQ(expectedOutput, output); EXPECT_EQ(1u, drm->ioctlCallsCount); @@ -71,14 +73,15 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WhenCreateGemExtWithDebugFlagThenPrintDeb auto drm = std::make_unique(*executionEnvironment->rootDeviceEnvironments[0]); drm->ioctlCallsCount = 0; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto ioctlHelper = drm->getIoctlHelper(); uint32_t handle = 0; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; uint32_t numOfChunks = 0; auto ret = ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt, false); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT with EXT_MEMORY_REGIONS has returned: -1 BO-0 with size: 1024\nGEM_CREATE_EXT with EXT_SETPARAM has returned: 0 BO-1 with size: 1024\n"); EXPECT_EQ(expectedOutput, output); EXPECT_EQ(2u, drm->ioctlCallsCount); diff --git a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp index 75d5aee1be..99d8d9c1bc 100644 --- a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp +++ b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp @@ -15,6 +15,7 @@ #include "shared/source/os_interface/product_helper.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/engine_descriptor_helper.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.h" #include "shared/test/common/mocks/linux/mock_os_time_linux.h" @@ -503,7 +504,8 @@ struct MockIoctlHelperPrelim20 : IoctlHelperPrelim20 { TEST(IoctlPrelimHelperCreateGemExtTests, givenPrelimWhenCreateGemExtWithMemPolicyThenMemPolicyExtensionsIsAdded) { DebugManagerStateRestore stateRestore; debugManager.flags.PrintBOCreateDestroyResult.set(true); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto executionEnvironment = std::make_unique(); auto drm = std::make_unique(*executionEnvironment->rootDeviceEnvironments[0]); @@ -519,7 +521,7 @@ TEST(IoctlPrelimHelperCreateGemExtTests, givenPrelimWhenCreateGemExtWithMemPolic mockIoctlHelper.initialize(); auto ret = mockIoctlHelper.createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, memPolicyMode, memPolicy, false); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedSubstring("memory policy:"); EXPECT_EQ(0, ret); EXPECT_TRUE(mockIoctlHelper.lastGemCreateContainedMemPolicy); diff --git a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_upstream.cpp b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_upstream.cpp index 1f7db8a34f..de0cf28a0e 100644 --- a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_upstream.cpp +++ b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_upstream.cpp @@ -12,6 +12,7 @@ #include "shared/source/os_interface/product_helper.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/linux/mock_os_time_linux.h" #include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/test_macros/test.h" @@ -376,14 +377,15 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenCreateGemExtWithDebugFlagThenPri auto ioctlHelper = drm->getIoctlHelper(); debugManager.flags.PrintBOCreateDestroyResult.set(true); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); uint32_t handle = 0; MemRegionsVec memClassInstance = {{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}}; uint32_t numOfChunks = 0; ioctlHelper->createGemExt(memClassInstance, 1024, handle, 0, {}, -1, false, numOfChunks, std::nullopt, std::nullopt, false); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT with EXT_MEMORY_REGIONS has returned: 0 BO-1 with size: 1024\n"); EXPECT_EQ(expectedOutput, output); } @@ -438,7 +440,8 @@ TEST(IoctlHelperTestsUpstream, givenSetPatSupportedWhenCreateGemExtWithDebugFlag MockIoctlHelperUpstream mockIoctlHelper{*drm}; debugManager.flags.PrintBOCreateDestroyResult.set(true); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); uint32_t handle = 0; mockIoctlHelper.isSetPatSupported = true; @@ -447,7 +450,7 @@ TEST(IoctlHelperTestsUpstream, givenSetPatSupportedWhenCreateGemExtWithDebugFlag uint64_t patIndex = 5; mockIoctlHelper.createGemExt(memClassInstance, 1024, handle, patIndex, {}, -1, false, numOfChunks, std::nullopt, std::nullopt, false); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, memory class: 1, memory instance: 0, pat index: 5 }\nGEM_CREATE_EXT with EXT_MEMORY_REGIONS with EXT_SET_PAT has returned: 0 BO-1 with size: 1024\n"); EXPECT_EQ(expectedOutput, output); } @@ -461,17 +464,18 @@ TEST(IoctlHelperUpstreamTest, whenDetectExtSetPatSupportIsCalledWithDebugFlagThe MockIoctlHelperUpstream mockIoctlHelper{*drm}; debugManager.flags.PrintBOCreateDestroyResult.set(true); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); mockIoctlHelper.overrideGemCreateExtReturnValue = 0; mockIoctlHelper.detectExtSetPatSupport(); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput("EXT_SET_PAT support is: enabled\n"); EXPECT_EQ(expectedOutput, output); - testing::internal::CaptureStdout(); + capture.captureStdout(); mockIoctlHelper.overrideGemCreateExtReturnValue = -1; mockIoctlHelper.detectExtSetPatSupport(); - output = testing::internal::GetCapturedStdout(); + output = capture.getCapturedStdout(); expectedOutput = "EXT_SET_PAT support is: disabled\n"; EXPECT_EQ(expectedOutput, output); } diff --git a/shared/test/unit_test/os_interface/linux/product_helper_linux_tests.cpp b/shared/test/unit_test/os_interface/linux/product_helper_linux_tests.cpp index 2d22478ccb..59d88c4a67 100644 --- a/shared/test/unit_test/os_interface/linux/product_helper_linux_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/product_helper_linux_tests.cpp @@ -16,6 +16,7 @@ #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/mock_product_helper_hw.h" #include "shared/test/common/helpers/raii_product_helper.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/test_macros/hw_test.h" #include "shared/test/common/test_macros/test.h" @@ -169,7 +170,8 @@ TEST_F(MockProductHelperTestLinux, givenDebugFlagSetWhenConfiguringHwInfoThenPri DebugManagerStateRestore restore; debugManager.flags.PrintIoctlEntries.set(true); - testing::internal::CaptureStdout(); // start capturing + StreamCapture capture; + capture.captureStdout(); // start capturing int ret = mockProductHelper->configureHwInfoDrm(&pInHwInfo, &outHwInfo, *executionEnvironment->rootDeviceEnvironments[0].get()); EXPECT_EQ(0, ret); @@ -178,7 +180,7 @@ TEST_F(MockProductHelperTestLinux, givenDebugFlagSetWhenConfiguringHwInfoThenPri }}; debugManager.flags.PrintIoctlEntries.set(false); - std::string output = testing::internal::GetCapturedStdout(); // stop capturing + std::string output = capture.getCapturedStdout(); // stop capturing for (const auto &expectedString : expectedStrings) { EXPECT_NE(std::string::npos, output.find(expectedString)); } diff --git a/shared/test/unit_test/os_interface/linux/xe/ccs_mode_xe_tests.cpp b/shared/test/unit_test/os_interface/linux/xe/ccs_mode_xe_tests.cpp index 513d41dc23..8c7161874f 100644 --- a/shared/test/unit_test/os_interface/linux/xe/ccs_mode_xe_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/xe/ccs_mode_xe_tests.cpp @@ -9,6 +9,7 @@ #include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/utilities/directory.h" #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_driver_model.h" #include "shared/test/common/os_interface/linux/sys_calls_linux_ult.h" @@ -537,13 +538,14 @@ TEST_F(CcsModeXeTest, GivenXeDrmAndValidCcsModeAndOpenSysCallFailsWithNoPermissi DebugManagerStateRestore restorer; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); testing::internal::CaptureStderr(); debugManager.flags.ZEX_NUMBER_OF_CCS.set("2"); executionEnvironment->configureCcsMode(); - std::string stdOutString = testing::internal::GetCapturedStdout(); + std::string stdOutString = capture.getCapturedStdout(); std::string stdErrString = testing::internal::GetCapturedStderr(); std::string expectedOutput = "No read and write permissions for /sys/class/drm/card0/device/tile0/gt0/ccs_mode, System administrator needs to grant permissions to allow modification of this file from user space\n"; @@ -622,13 +624,14 @@ TEST_F(CcsModeXeTest, GivenXeDrmAndValidCcsModeAndOpenSysCallFailsWithNoAccessWh DebugManagerStateRestore restorer; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); testing::internal::CaptureStderr(); debugManager.flags.ZEX_NUMBER_OF_CCS.set("2"); executionEnvironment->configureCcsMode(); - std::string stdOutString = testing::internal::GetCapturedStdout(); + std::string stdOutString = capture.getCapturedStdout(); std::string stdErrString = testing::internal::GetCapturedStderr(); std::string expectedOutput = "No read and write permissions for /sys/class/drm/card0/device/tile0/gt0/ccs_mode, System administrator needs to grant permissions to allow modification of this file from user space\n"; diff --git a/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp b/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp index 83c55aa71b..28f3efe6be 100644 --- a/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp @@ -26,6 +26,7 @@ #include "shared/test/common/helpers/dispatch_flags_helper.h" #include "shared/test/common/helpers/engine_descriptor_helper.h" #include "shared/test/common/helpers/execution_environment_helper.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_device.h" #include "shared/test/common/mocks/mock_gmm_page_table_mngr.h" #include "shared/test/common/mocks/mock_io_functions.h" @@ -242,7 +243,8 @@ TEST_F(WddmCommandStreamTest, givenPrintIndicesEnabledWhenFlushThenPrintIndices) ASSERT_NE(nullptr, commandBuffer); LinearStream cs(commandBuffer); BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed()); - ::testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); csr->flush(batchBuffer, csr->getResidencyAllocations()); const std::string engineType = EngineHelpers::engineTypeToString(csr->getOsContext().getEngineType()); @@ -256,7 +258,7 @@ TEST_F(WddmCommandStreamTest, givenPrintIndicesEnabledWhenFlushThenPrintIndices) auto osContextWin = static_cast(&csr->getOsContext()); expectedValue << SysCalls::getProcessId() << ": Wddm Submission with context handle " << osContextWin->getWddmContextHandle() << " and HwQueue handle " << osContextWin->getHwQueue().handle << "\n"; - EXPECT_STREQ(::testing::internal::GetCapturedStdout().c_str(), expectedValue.str().c_str()); + EXPECT_STREQ(capture.getCapturedStdout().c_str(), expectedValue.str().c_str()); memoryManager->freeGraphicsMemory(commandBuffer); } diff --git a/shared/test/unit_test/os_interface/windows/gdi_interface_tests.cpp b/shared/test/unit_test/os_interface/windows/gdi_interface_tests.cpp index 38f0c090d5..96b3975a20 100644 --- a/shared/test/unit_test/os_interface/windows/gdi_interface_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/gdi_interface_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -11,6 +11,7 @@ #include "shared/source/os_interface/windows/gdi_interface_logging.h" #include "shared/source/os_interface/windows/os_inc.h" #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_io_functions.h" #include "shared/test/common/mocks/windows/mock_gdi_interface.h" @@ -58,7 +59,8 @@ TEST(GdiInterface, givenPrintKmdTimesWhenCallThkWrapperThenRecordTime) { auto gdi = std::make_unique(); EXPECT_TRUE(gdi->isInitialized()); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); D3DKMT_OPENADAPTERFROMLUID param = {}; gdi->openAdapterFromLuid(¶m); @@ -68,7 +70,7 @@ TEST(GdiInterface, givenPrintKmdTimesWhenCallThkWrapperThenRecordTime) { gdi->closeAdapter(&closeAdapter); gdi.reset(); - auto output = testing::internal::GetCapturedStdout(); + auto output = capture.getCapturedStdout(); EXPECT_TRUE(output.find("\n--- Gdi statistics ---\n") != std::string::npos); } @@ -115,7 +117,8 @@ TEST(GdiInterface, GivenGdiLoggingSupportWhenLoggingEnabledAndLoggingToFileNotUs debugManager.flags.LogGdiCalls.set(true); debugManager.flags.LogGdiCallsToFile.set(false); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); std::unique_ptr gdi = std::make_unique(); EXPECT_EQ(0u, NEO::IoFunctions::mockFopenCalled); @@ -127,6 +130,6 @@ TEST(GdiInterface, GivenGdiLoggingSupportWhenLoggingEnabledAndLoggingToFileNotUs gdi.reset(nullptr); EXPECT_EQ(0u, NEO::IoFunctions::mockFcloseCalled); - testing::internal::GetCapturedStdout(); + capture.getCapturedStdout(); } #endif diff --git a/shared/test/unit_test/page_fault_manager/cpu_page_fault_manager_tests.cpp b/shared/test/unit_test/page_fault_manager/cpu_page_fault_manager_tests.cpp index 4593d82ad7..5ecd5a4309 100644 --- a/shared/test/unit_test/page_fault_manager/cpu_page_fault_manager_tests.cpp +++ b/shared/test/unit_test/page_fault_manager/cpu_page_fault_manager_tests.cpp @@ -9,6 +9,7 @@ #include "shared/source/page_fault_manager/tbx_page_fault_manager.h" #include "shared/test/common/fixtures/cpu_page_fault_manager_tests_fixture.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_graphics_allocation.h" #include "shared/test/common/test_macros/test_checks_shared.h" @@ -191,11 +192,12 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocsWhenMovingToGpuDomainWithPr EXPECT_EQ(pageFaultManager->memoryData.size(), 3u); pageFaultManager->memoryData.at(alloc3).domain = CpuPageFaultManager::AllocationDomain::gpu; - testing::internal::CaptureStdout(); // start capturing + StreamCapture capture; + capture.captureStdout(); // start capturing pageFaultManager->moveAllocationsWithinUMAllocsManagerToGpuDomain(unifiedMemoryManager.get()); - std::string output = testing::internal::GetCapturedStdout(); // stop capturing + std::string output = capture.getCapturedStdout(); // stop capturing std::string expectedString = "UMD transferred shared allocation"; uint32_t occurrences = 0u; @@ -391,11 +393,12 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocWhenMoveToGpuDomainWithPrint EXPECT_EQ(pageFaultManager->memoryData.size(), 1u); EXPECT_EQ(pageFaultManager->transferToCpuCalled, 0); - testing::internal::CaptureStdout(); // start capturing + StreamCapture capture; + capture.captureStdout(); // start capturing pageFaultManager->moveAllocationToGpuDomain(alloc); - std::string output = testing::internal::GetCapturedStdout(); // stop capturing + std::string output = capture.getCapturedStdout(); // stop capturing std::string expectedString = "UMD transferred shared allocation"; uint32_t occurrences = 0u; @@ -587,7 +590,8 @@ TEST_F(PageFaultManagerTest, whenVerifyingPagefaultWithPrintUsmSharedMigrationDe pageFaultManager->moveAllocationToGpuDomain(alloc); - testing::internal::CaptureStdout(); // start capturing + StreamCapture capture; + capture.captureStdout(); // start capturing EXPECT_EQ(pageFaultManager->protectMemoryCalled, 1); EXPECT_EQ(pageFaultManager->transferToGpuCalled, 0); @@ -596,7 +600,7 @@ TEST_F(PageFaultManagerTest, whenVerifyingPagefaultWithPrintUsmSharedMigrationDe pageFaultManager->verifyAndHandlePageFault(alloc, true); - std::string output = testing::internal::GetCapturedStdout(); // stop capturing + std::string output = capture.getCapturedStdout(); // stop capturing EXPECT_EQ(pageFaultManager->allowMemoryAccessCalled, 1); EXPECT_EQ(pageFaultManager->transferToCpuCalled, 1); @@ -626,7 +630,8 @@ TEST_F(PageFaultManagerTest, givenTbxWhenVerifyingPagefaultWithPrintUsmSharedMig pageFaultManager->insertAllocation(alloc, 10, unifiedMemoryManager.get(), nullptr, memoryProperties); pageFaultManager->moveAllocationToGpuDomain(alloc); - testing::internal::CaptureStdout(); // start capturing + StreamCapture capture; + capture.captureStdout(); // start capturing EXPECT_EQ(pageFaultManager->protectMemoryCalled, 1); EXPECT_EQ(pageFaultManager->transferToGpuCalled, 0); @@ -635,7 +640,7 @@ TEST_F(PageFaultManagerTest, givenTbxWhenVerifyingPagefaultWithPrintUsmSharedMig pageFaultManager->verifyAndHandlePageFault(alloc, true); - std::string output = testing::internal::GetCapturedStdout(); // stop capturing + std::string output = capture.getCapturedStdout(); // stop capturing EXPECT_EQ(pageFaultManager->allowMemoryAccessCalled, 1); EXPECT_EQ(pageFaultManager->transferToCpuCalled, 1); diff --git a/shared/test/unit_test/program/printf_helper_tests.cpp b/shared/test/unit_test/program/printf_helper_tests.cpp index 02d1e09652..d22e12f958 100644 --- a/shared/test/unit_test/program/printf_helper_tests.cpp +++ b/shared/test/unit_test/program/printf_helper_tests.cpp @@ -8,6 +8,7 @@ #include "shared/source/helpers/aligned_memory.h" #include "shared/source/helpers/string.h" #include "shared/source/program/print_formatter.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_graphics_allocation.h" #include "shared/test/common/mocks/mock_kernel_info.h" @@ -1009,9 +1010,10 @@ TEST_F(PrintFormatterTest, GivenTypeSmallerThan4BThenItIsReadAs4BValue) { } TEST(printToStdoutTest, GivenStringWhenPrintingToStdoutThenOutputOccurs) { - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); printToStdout("test"); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_STREQ("test", output.c_str()); } diff --git a/shared/test/unit_test/utilities/debug_settings_reader_tests.cpp b/shared/test/unit_test/utilities/debug_settings_reader_tests.cpp index c2ba33cb9d..0f8a2a3e89 100644 --- a/shared/test/unit_test/utilities/debug_settings_reader_tests.cpp +++ b/shared/test/unit_test/utilities/debug_settings_reader_tests.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/helpers/api_specific_config.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_settings_reader.h" #include "shared/test/common/test_macros/test.h" @@ -85,17 +86,19 @@ TEST(SettingsReader, GivenRegKeyWhenCreatingOsReaderThenReaderIsCreated) { TEST(SettingsReader, GivenTrueWhenPrintingDebugStringThenPrintsToOutput) { int i = 4; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); PRINT_DEBUG_STRING(true, stdout, "testing error %d", i); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_STRNE(output.c_str(), ""); } TEST(SettingsReader, GivenFalseWhenPrintingDebugStringThenNoOutput) { int i = 4; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); PRINT_DEBUG_STRING(false, stderr, "Error String %d", i); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_STREQ(output.c_str(), ""); } } // namespace SettingsReaderTests \ No newline at end of file diff --git a/shared/test/unit_test/utilities/logger_tests.cpp b/shared/test/unit_test/utilities/logger_tests.cpp index f2d9c5667e..04cefa70ea 100644 --- a/shared/test/unit_test/utilities/logger_tests.cpp +++ b/shared/test/unit_test/utilities/logger_tests.cpp @@ -14,6 +14,7 @@ #include "shared/source/utilities/logger_neo_only.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/utilities/base_object_utils.h" #include "gtest/gtest.h" @@ -543,10 +544,11 @@ TEST(AllocationTypeLoggingSingle, givenDebugVariableToCaptureAllocationTypeWhenF GraphicsAllocation graphicsAllocation(0, 1u /*num gmms*/, AllocationType::commandBuffer, nullptr, 0, 0, MemoryPool::memoryNull, MemoryManager::maxOsContextCount, 0llu); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); logAllocation(fileLogger, &graphicsAllocation, nullptr); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput = "Created Graphics Allocation of type COMMAND_BUFFER\n"; EXPECT_STREQ(output.c_str(), expectedOutput.c_str()); @@ -566,10 +568,11 @@ TEST(AllocationTypeLoggingSingle, givenLogAllocationTypeWhenLoggingAllocationThe bool logFileCreated = virtualFileExists(fileLogger.getLogFileName()); EXPECT_FALSE(logFileCreated); - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); logAllocation(fileLogger, &graphicsAllocation, nullptr); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); std::string expectedOutput = "Created Graphics Allocation of type COMMAND_BUFFER\n"; EXPECT_STREQ(output.c_str(), expectedOutput.c_str()); diff --git a/shared/test/unit_test/utilities/x86_64/cpuinfo_tests_x86_64.cpp b/shared/test/unit_test/utilities/x86_64/cpuinfo_tests_x86_64.cpp index e46c7de338..c59f45852a 100644 --- a/shared/test/unit_test/utilities/x86_64/cpuinfo_tests_x86_64.cpp +++ b/shared/test/unit_test/utilities/x86_64/cpuinfo_tests_x86_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -7,6 +7,7 @@ #include "shared/source/utilities/cpu_info.h" #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 "shared/test/unit_test/mocks/mock_cpuid_functions.h" @@ -83,9 +84,10 @@ TEST_F(CpuInfoTest, GivenPrintCpuFlagsEnabledWhenGettingVirtualAddressSizeThenCp CpuInfo testCpuInfo; - testing::internal::CaptureStdout(); + StreamCapture capture; + capture.captureStdout(); auto addressSize = testCpuInfo.getVirtualAddressSize(); - std::string output = testing::internal::GetCapturedStdout(); + std::string output = capture.getCapturedStdout(); EXPECT_EQ(36u, addressSize); std::string expectedString = "CPUFlags:\nCLFlush: 1 Avx2: 1 WaitPkg: 1\nVirtual Address Size 36\n";