From f0d5cf7530cd655f4f5d6f1508d65d0d49beb683 Mon Sep 17 00:00:00 2001 From: Marcel Skierkowski Date: Fri, 20 Jun 2025 14:18:39 +0000 Subject: [PATCH] test: StreamCaptureStdErr on pipes Store data in a pipe instead of a temporary file like gtest resulting in faster test execution Signed-off-by: Marcel Skierkowski --- .../test_cmdlist_append_launch_kernel_2.cpp | 10 +-- .../debugger/linux/test_l0_debugger_linux.cpp | 10 +-- .../windows/test_l0_debugger_windows.cpp | 6 +- .../unit_tests/sources/event/test_event.cpp | 5 +- .../unit_tests/sources/kernel/test_kernel.cpp | 9 +-- .../sources/kernel/test_kernel_2.cpp | 6 +- .../unit_tests/sources/module/test_module.cpp | 11 ++-- .../api/cl_enqueue_nd_range_kernel_tests.inl | 13 ++-- .../command_queue/local_work_size_tests.cpp | 11 ++-- opencl/test/unit_test/kernel/kernel_tests.cpp | 10 +-- .../test/unit_test/linux/main_linux_dll.cpp | 22 +++---- .../offline_compiler/ocloc_api_tests.cpp | 4 +- .../test/unit_test/program/program_tests.cpp | 10 +-- .../assert_handler/assert_handler_tests.cpp | 13 ++-- .../windows/compiler_cache_tests_windows.cpp | 61 +++++++++++------- .../unit_test/device/neo_device_tests.cpp | 6 +- .../patchtokens_decoder_tests.cpp | 8 ++- .../execution_environment_tests.cpp | 6 +- .../os_interface/linux/ccs_mode_tests.cpp | 8 +-- .../linux/drm_buffer_object_tests.cpp | 9 +-- .../linux/drm_engine_info_prelim_tests.cpp | 8 ++- .../linux/drm_memory_info_prelim_tests.cpp | 5 +- .../linux/drm_system_info_tests.cpp | 10 +-- .../os_interface/linux/drm_tests.cpp | 14 ++-- .../linux/drm_with_prelim_tests.cpp | 10 +-- .../linux/xe/ccs_mode_xe_tests.cpp | 8 +-- .../linux/xe/ioctl_helper_xe_tests.cpp | 6 +- .../os_interface/windows/wddm_tests.cpp | 64 +++++++++++-------- 28 files changed, 213 insertions(+), 150 deletions(-) diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_2.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_2.cpp index 303765748d..a412792233 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_2.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_2.cpp @@ -14,6 +14,7 @@ #include "shared/source/kernel/implicit_args_helper.h" #include "shared/source/utilities/software_tags_manager.h" #include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/unit_test_helper.h" #include "shared/test/common/mocks/mock_bindless_heaps_helper.h" #include "shared/test/common/mocks/mock_compilers.h" @@ -1258,18 +1259,19 @@ HWTEST_F(CommandListAppendLaunchKernel, givenKernelWithSlmSizeExceedingLocalMemo pCommandList->initialize(device, NEO::EngineGroupType::compute, 0u); CmdListKernelLaunchParams launchParams = {}; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); auto result = pCommandList->appendLaunchKernelWithParams(&kernel, groupCount, nullptr, launchParams); EXPECT_EQ(ZE_RESULT_SUCCESS, result); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_EQ(std::string(""), output); auto localMemSize = static_cast(device->getNEODevice()->getDeviceInfo().localMemSize); kernel.immutableData.kernelDescriptor->kernelAttributes.slmInlineSize = localMemSize + 10u; - ::testing::internal::CaptureStderr(); + capture.captureStderr(); result = pCommandList->appendLaunchKernelWithParams(&kernel, groupCount, nullptr, launchParams); const char *pStr = nullptr; @@ -1278,7 +1280,7 @@ HWTEST_F(CommandListAppendLaunchKernel, givenKernelWithSlmSizeExceedingLocalMemo EXPECT_NE(0, strcmp(pStr, emptyString.c_str())); EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY, result); - output = testing::internal::GetCapturedStderr(); + output = capture.getCapturedStderr(); const auto &slmInlineSize = kernel.immutableData.kernelDescriptor->kernelAttributes.slmInlineSize; std::string expectedOutput = "Size of SLM (" + std::to_string(slmInlineSize) + ") larger than available (" + std::to_string(localMemSize) + ")\n"; EXPECT_EQ(expectedOutput, output); diff --git a/level_zero/core/test/unit_tests/sources/debugger/linux/test_l0_debugger_linux.cpp b/level_zero/core/test/unit_tests/sources/debugger/linux/test_l0_debugger_linux.cpp index 0a0ee6da67..c96bca486f 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/linux/test_l0_debugger_linux.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/linux/test_l0_debugger_linux.cpp @@ -9,6 +9,7 @@ #include "shared/source/helpers/compiler_product_helper.h" #include "shared/source/kernel/debug_data.h" #include "shared/source/os_interface/os_interface.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/unit_test_helper.h" #include "shared/test/common/libult/linux/drm_mock.h" #include "shared/test/common/mocks/linux/mock_drm_allocation.h" @@ -196,19 +197,20 @@ TEST(L0DebuggerLinux, givenPrintDebugSettingsAndIncorrectSetupWhenInitializingDe executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(osInterface); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr(drmMock)); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); auto result = NEO::WhiteBox::initDebuggingInOs(osInterface); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_EQ(std::string("Debugging not enabled. VmBind: 0, per-context VMs: 1\n"), output); EXPECT_FALSE(result); drmMock->bindAvailable = true; drmMock->setPerContextVMRequired(false); - ::testing::internal::CaptureStderr(); + capture.captureStderr(); result = NEO::WhiteBox::initDebuggingInOs(osInterface); - output = testing::internal::GetCapturedStderr(); + output = capture.getCapturedStderr(); auto drm = osInterface->getDriverModel()->as(); if (drm->getRootDeviceEnvironment().getHelper().isHeaplessModeEnabled(*defaultHwInfo)) { EXPECT_NE(std::string("Debugging not enabled. VmBind: 1, per-context VMs: 0\n"), output); diff --git a/level_zero/core/test/unit_tests/sources/debugger/windows/test_l0_debugger_windows.cpp b/level_zero/core/test/unit_tests/sources/debugger/windows/test_l0_debugger_windows.cpp index 66f860449e..d392f858e1 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/windows/test_l0_debugger_windows.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/windows/test_l0_debugger_windows.cpp @@ -12,6 +12,7 @@ #include "shared/source/os_interface/windows/os_environment_win.h" #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_device.h" #include "shared/test/common/mocks/windows/mock_gdi_interface.h" #include "shared/test/common/mocks/windows/mock_wddm_eudebug.h" @@ -188,13 +189,14 @@ TEST_F(L0DebuggerWindowsTest, givenDebuggerL0NotifyModuleDestroyCalledAndModuleD DebugManagerStateRestore restorer; NEO::debugManager.flags.DebuggerLogBitmask.set(255); - testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); wddm->moduleCreateNotificationPassedParam.ntStatus = STATUS_UNSUCCESSFUL; auto debugger = static_cast(neoDevice->getDebugger()); debugger->notifyModuleDestroy(0x80000000); EXPECT_EQ(1u, wddm->moduleCreateNotifyCalled); - EXPECT_TRUE(hasSubstr(testing::internal::GetCapturedStderr(), std::string("KM_ESCAPE_EUDBG_UMD_MODULE_DESTROY_NOTIFY: Failed - Status:"))); + EXPECT_TRUE(hasSubstr(capture.getCapturedStderr(), std::string("KM_ESCAPE_EUDBG_UMD_MODULE_DESTROY_NOTIFY: Failed - Status:"))); } TEST_F(L0DebuggerWindowsTest, givenProgramDebuggingEnabledAndDebugAttachAvailableWhenInitializingDriverThenSuccessIsReturned) { 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 455b0471e0..769f51da81 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 @@ -791,13 +791,14 @@ TEST_F(EventPoolIPCHandleTests, ze_result_t res = eventPool->getIpcHandle(&ipcHandle); EXPECT_EQ(res, ZE_RESULT_SUCCESS); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); ze_event_pool_handle_t ipcEventPoolHandle = {}; res = context->openEventPoolIpcHandle(ipcHandle, &ipcEventPoolHandle); EXPECT_EQ(res, ZE_RESULT_ERROR_INVALID_ARGUMENT); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); std::string expectedOutput("IPC handle max event packets 2 does not match context devices max event packet 1\n"); EXPECT_EQ(expectedOutput, output); 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 ed79108acc..a090a4c37f 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 @@ -192,7 +192,8 @@ TEST_F(KernelInitTest, givenKernelToInitWhenItHasTooBigScratchSizeThenInvalidBin TEST_F(KernelInitTest, givenKernelToInitWhenPrivateSurfaceAllocationFailsThenOutOfDeviceMemoryIsRetutned) { DebugManagerStateRestore restorer; debugManager.flags.PrintDebugMessages.set(true); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); uint32_t perHwThreadPrivateMemorySizeRequested = 32u; @@ -213,7 +214,7 @@ TEST_F(KernelInitTest, givenKernelToInitWhenPrivateSurfaceAllocationFailsThenOut device->getNEODevice()->getExecutionEnvironment()->memoryManager.swap(otherMemoryManager); - auto output = ::testing::internal::GetCapturedStderr(); + auto output = capture.getCapturedStderr(); std::string errorMsg = "Failed to allocate private surface"; EXPECT_NE(std::string::npos, output.find(errorMsg)); } @@ -3981,10 +3982,10 @@ HWTEST_F(PrintfHandlerTests, givenPrintDebugMessagesAndKernelWithPrintfWhenBlitt StreamCapture capture; capture.captureStdout(); - testing::internal::CaptureStderr(); + capture.captureStderr(); PrintfHandler::printOutput(kernelImmutableData.get(), &mockAllocation, &deviceImp, true); std::string output = capture.getCapturedStdout(); - std::string error = testing::internal::GetCapturedStderr(); + std::string error = capture.getCapturedStderr(); EXPECT_EQ(1u, bcsCsr->blitBufferCalled); EXPECT_EQ(BlitterConstants::BlitDirection::bufferToHostPtr, bcsCsr->receivedBlitProperties[0].blitDirection); diff --git a/level_zero/core/test/unit_tests/sources/kernel/test_kernel_2.cpp b/level_zero/core/test/unit_tests/sources/kernel/test_kernel_2.cpp index aaa9c95394..83f9253dc3 100644 --- a/level_zero/core/test/unit_tests/sources/kernel/test_kernel_2.cpp +++ b/level_zero/core/test/unit_tests/sources/kernel/test_kernel_2.cpp @@ -11,6 +11,7 @@ #include "shared/source/helpers/local_id_gen.h" #include "shared/source/helpers/simd_helper.h" #include "shared/test/common/helpers/raii_gfx_core_helper.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_bindless_heaps_helper.h" #include "shared/test/common/mocks/mock_device.h" #include "shared/test/common/mocks/mock_graphics_allocation.h" @@ -311,13 +312,14 @@ TEST_P(KernelImpSuggestGroupSize, WhenSlmSizeExceedsLocalMemorySizeAndSuggesting function.module = &module; uint32_t groupSize[3]; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); auto localMemSize = static_cast(device->getNEODevice()->getDeviceInfo().localMemSize); funcInfo.kernelDescriptor->kernelAttributes.slmInlineSize = localMemSize + 10u; EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY, function.KernelImp::suggestGroupSize(size, 1, 1, groupSize, groupSize + 1, groupSize + 2)); - auto output = testing::internal::GetCapturedStderr(); + auto output = capture.getCapturedStderr(); const auto &slmInlineSize = funcInfo.kernelDescriptor->kernelAttributes.slmInlineSize; std::string expectedOutput = "Size of SLM (" + std::to_string(slmInlineSize) + ") larger than available (" + std::to_string(localMemSize) + ")\n"; EXPECT_EQ(expectedOutput, output); diff --git a/level_zero/core/test/unit_tests/sources/module/test_module.cpp b/level_zero/core/test/unit_tests/sources/module/test_module.cpp index afc4fe5611..2c5f5bc66b 100644 --- a/level_zero/core/test/unit_tests/sources/module/test_module.cpp +++ b/level_zero/core/test/unit_tests/sources/module/test_module.cpp @@ -26,6 +26,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/implicit_args_test_helper.h" #include "shared/test/common/helpers/mock_file_io.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_compiler_product_helper.h" #include "shared/test/common/mocks/mock_compilers.h" @@ -4682,7 +4683,8 @@ TEST_F(ModuleTests, givenFullyLinkedModuleAndSlmSizeExceedingLocalMemorySizeWhen auto status = pModule->linkBinary(); EXPECT_TRUE(status); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); ze_kernel_handle_t kernelHandle; @@ -4693,7 +4695,7 @@ TEST_F(ModuleTests, givenFullyLinkedModuleAndSlmSizeExceedingLocalMemorySizeWhen EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY, res); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); const std::string expectedPart = "Size of SLM (" + std::to_string(slmInlineSizeCopy) + ") larger than available (" + std::to_string(localMemSize) + ")\n"; EXPECT_NE(std::string::npos, output.find(expectedPart)); } @@ -4723,7 +4725,8 @@ TEST_F(ModuleTests, givenFullyLinkedModuleWhenCreatingKernelThenDebugMsgOnPrivat auto status = pModule->linkBinary(); EXPECT_TRUE(status); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); ze_kernel_handle_t kernelHandle; @@ -4734,7 +4737,7 @@ TEST_F(ModuleTests, givenFullyLinkedModuleWhenCreatingKernelThenDebugMsgOnPrivat EXPECT_EQ(ZE_RESULT_SUCCESS, res); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); std::ostringstream expectedOutput; expectedOutput << "computeUnits for each thread: " << std::to_string(this->device->getDeviceInfo().computeUnitsUsedForScratch) << "\n" << "global memory size: " << std::to_string(this->device->getDeviceInfo().globalMemSize) << "\n" diff --git a/opencl/test/unit_test/api/cl_enqueue_nd_range_kernel_tests.inl b/opencl/test/unit_test/api/cl_enqueue_nd_range_kernel_tests.inl index 40be0b8c36..d370d1b928 100644 --- a/opencl/test/unit_test/api/cl_enqueue_nd_range_kernel_tests.inl +++ b/opencl/test/unit_test/api/cl_enqueue_nd_range_kernel_tests.inl @@ -1,10 +1,12 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "shared/test/common/helpers/stream_capture.h" + #include "opencl/source/command_queue/command_queue.h" #include "opencl/test/unit_test/mocks/mock_kernel.h" @@ -51,7 +53,8 @@ TEST_F(ClEnqueueNDRangeKernelTests, GivenKernelWithSlmSizeExceedingLocalMemorySi cl_event *eventWaitList = nullptr; cl_event *event = nullptr; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); auto localMemSize = static_cast(pDevice->getDevice().getDeviceInfo().localMemSize); @@ -69,10 +72,10 @@ TEST_F(ClEnqueueNDRangeKernelTests, GivenKernelWithSlmSizeExceedingLocalMemorySi EXPECT_EQ(CL_SUCCESS, retVal); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_EQ(std::string(""), output); - ::testing::internal::CaptureStderr(); + capture.captureStderr(); pKernel->setTotalSLMSize(localMemSize + 10u); retVal = clEnqueueNDRangeKernel( @@ -88,7 +91,7 @@ TEST_F(ClEnqueueNDRangeKernelTests, GivenKernelWithSlmSizeExceedingLocalMemorySi EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal); - output = testing::internal::GetCapturedStderr(); + output = capture.getCapturedStderr(); const auto &slmInlineSize = pKernel->getSlmTotalSize(); std::string expectedOutput = "Size of SLM (" + std::to_string(slmInlineSize) + ") larger than available (" + std::to_string(localMemSize) + ")\n"; EXPECT_EQ(expectedOutput, output); diff --git a/opencl/test/unit_test/command_queue/local_work_size_tests.cpp b/opencl/test/unit_test/command_queue/local_work_size_tests.cpp index b09e4f82b9..bbc1c1259f 100644 --- a/opencl/test/unit_test/command_queue/local_work_size_tests.cpp +++ b/opencl/test/unit_test/command_queue/local_work_size_tests.cpp @@ -8,6 +8,7 @@ #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/local_work_size.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_device.h" #include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/test_macros/hw_test.h" @@ -54,7 +55,8 @@ TEST_F(LocalWorkSizeTest, givenDisableEUFusionWhenCreatingWorkSizeInfoThenCorrec TEST_F(LocalWorkSizeTest, GivenSlmLargerThanLocalThenWarningIsReturned) { DebugManagerStateRestore dbgRestorer; debugManager.flags.PrintDebugMessages.set(true); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); EXPECT_THROW(WorkSizeInfo wsInfo(256, // maxWorkGroupSize 1u, // hasBariers @@ -69,14 +71,15 @@ TEST_F(LocalWorkSizeTest, GivenSlmLargerThanLocalThenWarningIsReturned) { ), std::exception); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_EQ(std::string("Size of SLM (128) larger than available (64)\n"), output); } TEST_F(LocalWorkSizeTest, GivenSlmSmallerThanLocalThenWarningIsNotReturned) { DebugManagerStateRestore dbgRestorer; debugManager.flags.PrintDebugMessages.set(true); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); WorkSizeInfo wsInfo(256, // maxWorkGroupSize 1u, // hasBariers @@ -90,7 +93,7 @@ TEST_F(LocalWorkSizeTest, GivenSlmSmallerThanLocalThenWarningIsNotReturned) { false // disableEUFusion ); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_EQ(std::string(""), output); } diff --git a/opencl/test/unit_test/kernel/kernel_tests.cpp b/opencl/test/unit_test/kernel/kernel_tests.cpp index 205cbec47c..7f4ecbebfe 100644 --- a/opencl/test/unit_test/kernel/kernel_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_tests.cpp @@ -23,6 +23,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/gtest_helpers.h" #include "shared/test/common/helpers/raii_gfx_core_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_allocation_properties.h" #include "shared/test/common/mocks/mock_bindless_heaps_helper.h" @@ -3630,7 +3631,8 @@ TEST(KernelInitializationTest, givenSlmSizeExceedingLocalMemorySizeWhenInitializ DebugManagerStateRestore dbgRestorer; debugManager.flags.PrintDebugMessages.set(true); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); MockContext context; MockProgram mockProgram(&context, false, context.getDevices()); @@ -3644,15 +3646,15 @@ TEST(KernelInitializationTest, givenSlmSizeExceedingLocalMemorySizeWhenInitializ mockKernelInfoExceedsSLM.kernelDescriptor.kernelAttributes.slmInlineSize = slmTotalSize; auto localMemSize = static_cast(clDevice->getDevice().getDeviceInfo().localMemSize); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); cl_int retVal{}; - ::testing::internal::CaptureStderr(); + capture.captureStderr(); std::unique_ptr kernelPtr(Kernel::create(&mockProgram, mockKernelInfoExceedsSLM, *clDevice, retVal)); EXPECT_EQ(nullptr, kernelPtr.get()); EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal); - output = testing::internal::GetCapturedStderr(); + output = capture.getCapturedStderr(); std::string expectedOutput = "Size of SLM (" + std::to_string(slmTotalSize) + ") larger than available (" + std::to_string(localMemSize) + ")\n"; EXPECT_EQ(expectedOutput, output); } diff --git a/opencl/test/unit_test/linux/main_linux_dll.cpp b/opencl/test/unit_test/linux/main_linux_dll.cpp index df13a3ee98..ecb0b7b874 100644 --- a/opencl/test/unit_test/linux/main_linux_dll.cpp +++ b/opencl/test/unit_test/linux/main_linux_dll.cpp @@ -524,12 +524,12 @@ TEST_F(DrmTests, GivenUnknownDeviceWhenCreatingDrmThenNullIsReturned) { deviceId = -1; revisionId = -1; - ::testing::internal::CaptureStderr(); StreamCapture capture; + capture.captureStderr(); capture.captureStdout(); auto drm = DrmWrap::createDrm(*mockRootDeviceEnvironment); EXPECT_EQ(drm, nullptr); - std::string errStr = ::testing::internal::GetCapturedStderr(); + std::string errStr = capture.getCapturedStderr(); EXPECT_TRUE(hasSubstr(errStr, std::string("FATAL: Unknown device: deviceId: ffff, revisionId: ffff"))); capture.getCapturedStdout(); } @@ -742,8 +742,8 @@ TEST_F(DrmTests, givenDebuggingEnabledWhenDrmIsCreatedThenPerContextVMIsTrueGetV TEST_F(DrmTests, givenEnabledDebuggingAndVmBindNotAvailableWhenDrmIsCreatedThenPerContextVMIsFalseVMsAreCreatedAndDebugMessageIsPrinted) { DebugManagerStateRestore restore; - ::testing::internal::CaptureStderr(); StreamCapture capture; + capture.captureStderr(); capture.captureStdout(); debugManager.flags.CreateMultipleSubDevices.set(2); @@ -757,7 +757,7 @@ TEST_F(DrmTests, givenEnabledDebuggingAndVmBindNotAvailableWhenDrmIsCreatedThenP if (drm->isPerContextVMRequired()) { capture.getCapturedStdout(); - ::testing::internal::GetCapturedStderr(); + capture.getCapturedStderr(); GTEST_SKIP(); } @@ -769,7 +769,7 @@ TEST_F(DrmTests, givenEnabledDebuggingAndVmBindNotAvailableWhenDrmIsCreatedThenP debugManager.flags.PrintDebugMessages.set(false); capture.getCapturedStdout(); - std::string errStr = ::testing::internal::GetCapturedStderr(); + std::string errStr = capture.getCapturedStderr(); auto &compilerProductHelper = drm->getRootDeviceEnvironment().getHelper(); bool heapless = compilerProductHelper.isHeaplessModeEnabled(*drm->getRootDeviceEnvironment().getHardwareInfo()); @@ -803,8 +803,8 @@ TEST_F(DrmTests, givenDrmIsCreatedWhenCreateVirtualMemoryFailsThenReturnVirtualM failOnVirtualMemoryCreate = -1; - ::testing::internal::CaptureStderr(); StreamCapture capture; + capture.captureStderr(); capture.captureStdout(); auto drm = DrmWrap::createDrm(*mockRootDeviceEnvironment); EXPECT_NE(drm, nullptr); @@ -812,7 +812,7 @@ TEST_F(DrmTests, givenDrmIsCreatedWhenCreateVirtualMemoryFailsThenReturnVirtualM EXPECT_EQ(0u, drm->getVirtualMemoryAddressSpace(0)); EXPECT_EQ(0u, static_cast(drm.get())->virtualMemoryIds.size()); - std::string errStr = ::testing::internal::GetCapturedStderr(); + std::string errStr = capture.getCapturedStderr(); if (!drm->isPerContextVMRequired()) { EXPECT_TRUE(hasSubstr(errStr, std::string("INFO: Device doesn't support GEM Virtual Memory"))); } @@ -996,15 +996,15 @@ TEST_F(DrmTests, whenDrmIsCreatedAndQueryEngineInfoFailsThenWarningIsReported) { VariableBackup backupFailOnFdSetParamEngineMap(&DrmQueryConfig::failOnQueryEngineInfo); DrmQueryConfig::failOnQueryEngineInfo = true; - ::testing::internal::CaptureStderr(); StreamCapture capture; + capture.captureStderr(); capture.captureStdout(); MockExecutionEnvironment mockExecutionEnvironment; auto drm = DrmWrap::createDrm(*mockExecutionEnvironment.rootDeviceEnvironments[0]); EXPECT_NE(drm, nullptr); - std::string errStr = ::testing::internal::GetCapturedStderr(); + std::string errStr = capture.getCapturedStderr(); EXPECT_TRUE(hasSubstr(errStr, std::string("WARNING: Failed to query engine info\n"))); capture.getCapturedStdout(); } @@ -1017,15 +1017,15 @@ TEST_F(DrmTests, whenDrmIsCreatedAndQueryMemoryInfoFailsThenWarningIsReported) { VariableBackup backupFailOnFdSetParamMemRegionMap(&DrmQueryConfig::failOnQueryMemoryInfo); DrmQueryConfig::failOnQueryMemoryInfo = true; - ::testing::internal::CaptureStderr(); StreamCapture capture; + capture.captureStderr(); capture.captureStdout(); MockExecutionEnvironment mockExecutionEnvironment; auto drm = DrmWrap::createDrm(*mockExecutionEnvironment.rootDeviceEnvironments[0]); EXPECT_NE(drm, nullptr); - std::string errStr = ::testing::internal::GetCapturedStderr(); + std::string errStr = capture.getCapturedStderr(); EXPECT_TRUE(hasSubstr(errStr, std::string("WARNING: Failed to query memory info\n"))); 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 2d59ad4578..2c069b574c 100644 --- a/opencl/test/unit_test/offline_compiler/ocloc_api_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/ocloc_api_tests.cpp @@ -1242,14 +1242,14 @@ struct OclocFallbackTests : ::testing::Test { StreamCapture capture; capture.captureStdout(); - testing::internal::CaptureStderr(); + capture.captureStderr(); auto retVal = oclocInvoke(argc, argv, 0, nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); capturedStdout = capture.getCapturedStdout(); - capturedStderr = testing::internal::GetCapturedStderr(); + capturedStderr = capture.getCapturedStderr(); return retVal; } } diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index 2e50a90aae..29dd5e69b8 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -2126,13 +2126,14 @@ TEST_F(ProgramTests, givenProgramFromGenBinaryWhenSLMSizeIsBiggerThenDeviceLimit program->buildInfos[rootDeviceIndex].unpackedDeviceBinary = makeCopy(patchtokensProgram.storage.data(), patchtokensProgram.storage.size()); program->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize = patchtokensProgram.storage.size(); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); auto retVal = program->processGenBinary(*pClDevice); EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); const auto &slmInlineSize = patchtokensProgram.slmMutable->TotalInlineLocalMemorySize; const auto &localMemSize = pDevice->getDeviceInfo().localMemSize; std::string expectedOutput = "Size of SLM (" + std::to_string(slmInlineSize) + ") larger than available (" + std::to_string(localMemSize) + ")\n"; @@ -2793,11 +2794,12 @@ TEST(CreateProgramFromBinaryTests, givenBinaryProgramBuiltInWhenKernelRebuildIsF EXPECT_EQ(CL_SUCCESS, retVal); pProgram->irBinarySize = 0x10; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); debugManager.flags.PrintDebugMessages.set(true); retVal = pProgram->createProgramFromBinary(programTokens.storage.data(), programTokens.storage.size(), *clDevice); debugManager.flags.PrintDebugMessages.set(false); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_FALSE(pProgram->requiresRebuild); EXPECT_EQ(CL_SUCCESS, retVal); std::string expectedOutput = "Skip rebuild binary. Lack of IR, rebuild impossible.\n"; diff --git a/shared/test/unit_test/assert_handler/assert_handler_tests.cpp b/shared/test/unit_test/assert_handler/assert_handler_tests.cpp index e6fa1bdf7f..4d7e7f62fb 100644 --- a/shared/test/unit_test/assert_handler/assert_handler_tests.cpp +++ b/shared/test/unit_test/assert_handler/assert_handler_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Intel Corporation + * Copyright (C) 2023-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -7,6 +7,7 @@ #include "shared/source/assert_handler/assert_handler.h" #include "shared/source/memory_manager/graphics_allocation.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_assert_handler.h" #include "shared/test/common/mocks/mock_device.h" @@ -51,10 +52,11 @@ TEST(AssertHandlerTests, GivenNoFlagSetWhenPrintAssertAndAbortCalledThenAbortIsN reinterpret_cast(assertHandler.getAssertBuffer()->getUnderlyingBuffer())->flags = 0; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); assertHandler.printAssertAndAbort(); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_STREQ("", output.c_str()); } @@ -80,9 +82,10 @@ TEST(AssertHandlerTests, GivenFlagSetWhenPrintAssertAndAbortCalledThenMessageIsP reinterpret_cast(assertHandler.getAssertBuffer()->getUnderlyingBuffer())->begin += sizeof(uint64_t); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); EXPECT_THROW(assertHandler.printAssertAndAbort(), std::exception); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_STREQ("AssertHandler::printMessage\nassert!", output.c_str()); } diff --git a/shared/test/unit_test/compiler_interface/windows/compiler_cache_tests_windows.cpp b/shared/test/unit_test/compiler_interface/windows/compiler_cache_tests_windows.cpp index 93da5cc073..149bd31a4f 100644 --- a/shared/test/unit_test/compiler_interface/windows/compiler_cache_tests_windows.cpp +++ b/shared/test/unit_test/compiler_interface/windows/compiler_cache_tests_windows.cpp @@ -14,6 +14,7 @@ #include "shared/source/utilities/stackvec.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/test_macros/test.h" @@ -297,9 +298,10 @@ TEST_F(CompilerCacheWindowsTest, givenEvictCacheWhenFileSearchFailedThenDebugMes uint64_t bytesEvicted{0u}; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); cache.evictCache(bytesEvicted); - auto capturedStderr = ::testing::internal::GetCapturedStderr(); + auto capturedStderr = capture.getCapturedStderr(); std::string expectedStderrSubstr("[Cache failure]: File search failed! error code:"); EXPECT_TRUE(hasSubstr(capturedStderr, expectedStderrSubstr)); @@ -348,9 +350,10 @@ TEST_F(CompilerCacheWindowsTest, givenLockConfigFileAndReadSizeWhenOpenExistingC UnifiedHandle configFileHandle{nullptr}; size_t directorySize = 0u; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); cache.lockConfigFileAndReadSize("somePath\\cl_cache\\config.file", configFileHandle, directorySize); - auto capturedStderr = ::testing::internal::GetCapturedStderr(); + auto capturedStderr = capture.getCapturedStderr(); std::string expectedStderrSubstr("[Cache failure]: Lock config file failed! error code:"); EXPECT_TRUE(hasSubstr(capturedStderr, expectedStderrSubstr)); @@ -379,9 +382,10 @@ TEST_F(CompilerCacheWindowsTest, givenLockConfigFileAndReadSizeWhenOpenExistingC UnifiedHandle configFileHandle{nullptr}; size_t directorySize = 0u; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); cache.lockConfigFileAndReadSize("somePath\\cl_cache\\config.file", configFileHandle, directorySize); - auto capturedStderr = ::testing::internal::GetCapturedStderr(); + auto capturedStderr = capture.getCapturedStderr(); std::string expectedStderrSubstr("[Cache failure]: File pointer move failed! error code:"); EXPECT_TRUE(hasSubstr(capturedStderr, expectedStderrSubstr)); @@ -415,9 +419,10 @@ TEST_F(CompilerCacheWindowsTest, givenLockConfigFileAndReadSizeWhenOpenExistingC UnifiedHandle configFileHandle{nullptr}; size_t directorySize = 0u; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); cache.lockConfigFileAndReadSize("somePath\\cl_cache\\config.file", configFileHandle, directorySize); - auto capturedStderr = ::testing::internal::GetCapturedStderr(); + auto capturedStderr = capture.getCapturedStderr(); std::string expectedStderrSubstr("[Cache failure]: Read config failed! error code:"); EXPECT_TRUE(hasSubstr(capturedStderr, expectedStderrSubstr)); @@ -518,9 +523,10 @@ TEST_F(CompilerCacheWindowsTest, givenLockConfigFileAndReadSizeWhenOpenExistingC UnifiedHandle configFileHandle{nullptr}; size_t directorySize = 0u; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); cache.lockConfigFileAndReadSize("somePath\\cl_cache\\config.file", configFileHandle, directorySize); - auto capturedStderr = ::testing::internal::GetCapturedStderr(); + auto capturedStderr = capture.getCapturedStderr(); std::string expectedStderrSubstr("[Cache failure]: Create config file failed! error code:"); @@ -574,9 +580,10 @@ TEST_F(CompilerCacheWindowsTest, givenLockConfigFileAndReadSizeWhenOpenExistingC UnifiedHandle configFileHandle{nullptr}; size_t directorySize = 0u; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); cache.lockConfigFileAndReadSize("somePath\\cl_cache\\config.file", configFileHandle, directorySize); - auto capturedStderr = ::testing::internal::GetCapturedStderr(); + auto capturedStderr = capture.getCapturedStderr(); std::string expectedStderrSubstr("[Cache failure]: Open config file failed! error code:"); @@ -621,10 +628,11 @@ TEST_F(CompilerCacheWindowsTest, givenCreateUniqueTempFileAndWriteDataWhenGetTem CompilerCacheMockWindows cache({true, ".cl_cache", "somePath\\cl_cache", cacheSize}); const char *binary = "12345"; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); char tmpFileName[] = "somePath\\cl_cache\\TMP.XXXXXX"; cache.createUniqueTempFileAndWriteData(tmpFileName, binary, strlen(binary)); - auto capturedStderr = ::testing::internal::GetCapturedStderr(); + auto capturedStderr = capture.getCapturedStderr(); std::string expectedStderrSubstr("[Cache failure]: Creating temporary file name failed! error code:"); EXPECT_TRUE(hasSubstr(capturedStderr, expectedStderrSubstr)); @@ -645,10 +653,11 @@ TEST_F(CompilerCacheWindowsTest, givenCreateUniqueTempFileAndWriteDataWhenCreate CompilerCacheMockWindows cache({true, ".cl_cache", "somePath\\cl_cache", cacheSize}); const char *binary = "12345"; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); char tmpFileName[] = "somePath\\cl_cache\\TMP.XXXXXX"; cache.createUniqueTempFileAndWriteData(tmpFileName, binary, strlen(binary)); - auto capturedStderr = ::testing::internal::GetCapturedStderr(); + auto capturedStderr = capture.getCapturedStderr(); std::string expectedStderrSubstr("[Cache failure]: Creating temporary file failed! error code:"); EXPECT_TRUE(hasSubstr(capturedStderr, expectedStderrSubstr)); @@ -670,10 +679,11 @@ TEST_F(CompilerCacheWindowsTest, givenCreateUniqueTempFileAndWriteDataWhenWriteF CompilerCacheMockWindows cache({true, ".cl_cache", "somePath\\cl_cache", cacheSize}); const char *binary = "12345"; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); char tmpFileName[] = "somePath\\cl_cache\\TMP.XXXXXX"; cache.createUniqueTempFileAndWriteData(tmpFileName, binary, strlen(binary)); - auto capturedStderr = ::testing::internal::GetCapturedStderr(); + auto capturedStderr = capture.getCapturedStderr(); std::string expectedStderrSubstr("[Cache failure]: Writing to temporary file failed! error code:"); EXPECT_TRUE(hasSubstr(capturedStderr, expectedStderrSubstr)); @@ -696,10 +706,11 @@ TEST_F(CompilerCacheWindowsTest, givenCreateUniqueTempFileAndWriteDataWhenWriteF const char *binary = "12345"; SysCalls::writeFileNumberOfBytesWritten = static_cast(strlen(binary)) - 1; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); char tmpFileName[] = "somePath\\cl_cache\\TMP.XXXXXX"; cache.createUniqueTempFileAndWriteData(tmpFileName, binary, strlen(binary)); - auto capturedStderr = ::testing::internal::GetCapturedStderr(); + auto capturedStderr = capture.getCapturedStderr(); std::stringstream expectedStderrSubstr; expectedStderrSubstr << "[Cache failure]: Writing to temporary file failed! Incorrect number of bytes written: "; @@ -821,9 +832,10 @@ TEST_F(CompilerCacheWindowsTest, givenCacheBinaryWhenWriteToConfigFileFailsThenE const size_t binarySize = strlen(binary); SysCalls::writeFileNumberOfBytesWritten = static_cast(sizeof(size_t)); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); auto result = cache.cacheBinary(kernelFileHash, binary, binarySize); - auto capturedStderr = ::testing::internal::GetCapturedStderr(); + auto capturedStderr = capture.getCapturedStderr(); std::string expectedStderrSubstr("[Cache failure]: Writing to config file failed! error code:"); @@ -862,9 +874,10 @@ TEST_F(CompilerCacheWindowsTest, givenCacheBinaryWhenWriteFileBytesWrittenMismat const size_t binarySize = strlen(binary); SysCalls::writeFileNumberOfBytesWritten = static_cast(sizeof(size_t)) - 1; - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); auto result = cache.cacheBinary(kernelFileHash, binary, binarySize); - auto capturedStderr = ::testing::internal::GetCapturedStderr(); + auto capturedStderr = capture.getCapturedStderr(); std::stringstream expectedStderrSubstr; expectedStderrSubstr << "[Cache failure]: Writing to config file failed! Incorrect number of bytes written: "; diff --git a/shared/test/unit_test/device/neo_device_tests.cpp b/shared/test/unit_test/device/neo_device_tests.cpp index ffbd31606e..c5dae262fc 100644 --- a/shared/test/unit_test/device/neo_device_tests.cpp +++ b/shared/test/unit_test/device/neo_device_tests.cpp @@ -24,6 +24,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/raii_product_helper.h" +#include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/helpers/ult_hw_config.h" #include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/libult/ult_command_stream_receiver.h" @@ -2479,9 +2480,10 @@ TEST_F(DeviceTests, givenDebuggerRequestedByUserAndNotAvailableWhenDeviceIsIniti executionEnvironment->setDebuggingMode(NEO::DebuggingMode::online); NEO::debugManager.flags.PrintDebugMessages.set(1); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); auto device = std::unique_ptr(MockDevice::createWithExecutionEnvironment(defaultHwInfo.get(), executionEnvironment, 0u)); - auto output = testing::internal::GetCapturedStderr(); + auto output = capture.getCapturedStderr(); EXPECT_EQ(std::string("Debug mode is not enabled in the system.\n"), output); EXPECT_EQ(nullptr, device); diff --git a/shared/test/unit_test/device_binary_format/patchtokens_decoder_tests.cpp b/shared/test/unit_test/device_binary_format/patchtokens_decoder_tests.cpp index 59c61404ef..6dc466eead 100644 --- a/shared/test/unit_test/device_binary_format/patchtokens_decoder_tests.cpp +++ b/shared/test/unit_test/device_binary_format/patchtokens_decoder_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -9,6 +9,7 @@ #include "shared/source/helpers/hash.h" #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/stream_capture.h" #include "shared/test/common/test_macros/test.h" #include @@ -1219,10 +1220,11 @@ TEST(ProgramDecoder, givenPatchTokenInterfaceDescriptorDataWhenFlagPrintDebugMes auto kernelHeader = reinterpret_cast(storage.data()); kernelHeader->PatchListSize = static_cast(storage.size() - patchListOffset); NEO::PatchTokenBinary::KernelFromPatchtokens decodedKernel; - testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); bool decodeSuccess = NEO::PatchTokenBinary::decodeKernelFromPatchtokensBlob(storage, decodedKernel); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_TRUE(decodeSuccess); EXPECT_EQ(NEO::DecodeError::success, decodedKernel.decodeStatus); EXPECT_EQ("Ignored kernel-scope Patch Token: 21\n", output); diff --git a/shared/test/unit_test/execution_environment/execution_environment_tests.cpp b/shared/test/unit_test/execution_environment/execution_environment_tests.cpp index a206932ccb..03f0115077 100644 --- a/shared/test/unit_test/execution_environment/execution_environment_tests.cpp +++ b/shared/test/unit_test/execution_environment/execution_environment_tests.cpp @@ -27,6 +27,7 @@ #include "shared/source/release_helper/release_helper.h" #include "shared/test/common/fixtures/mock_aub_center_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_ail_configuration.h" #include "shared/test/common/mocks/mock_device.h" #include "shared/test/common/mocks/mock_driver_model.h" @@ -132,7 +133,8 @@ class TestAubCenter : public AubCenter { } }; TEST(RootDeviceEnvironment, givenNullptrAubManagerWhenInitializeAubCenterIsCalledThenMessErrorIsPrintedAndAbortCalled) { - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); MockExecutionEnvironment executionEnvironment; executionEnvironment.rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get()); auto rootDeviceEnvironment = static_cast(executionEnvironment.rootDeviceEnvironments[0].get()); @@ -145,7 +147,7 @@ TEST(RootDeviceEnvironment, givenNullptrAubManagerWhenInitializeAubCenterIsCalle rootDeviceEnvironment->useMockAubCenter = false; EXPECT_THROW(rootDeviceEnvironment->initAubCenter(true, "test.aub", CommandStreamReceiverType::aub), std::runtime_error); - std::string output = ::testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_NE(output.find("ERROR: Simulation mode detected but Aubstream is not available.\n"), std::string::npos); } 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 f92bed4599..4302f1b51f 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 @@ -245,13 +245,13 @@ TEST_F(CcsModeTest, GivenValidCcsModeAndOpenSysCallFailsWithNoPermissionsWhenCon StreamCapture capture; capture.captureStdout(); - testing::internal::CaptureStderr(); + capture.captureStderr(); debugManager.flags.ZEX_NUMBER_OF_CCS.set("2"); executionEnvironment->configureCcsMode(); std::string stdOutString = capture.getCapturedStdout(); - std::string stdErrString = testing::internal::GetCapturedStderr(); + std::string stdErrString = capture.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"; EXPECT_EQ(1u, ccsMode); @@ -285,13 +285,13 @@ TEST_F(CcsModeTest, GivenValidCcsModeAndOpenSysCallFailsWithNoAccessWhenConfigur StreamCapture capture; capture.captureStdout(); - testing::internal::CaptureStderr(); + capture.captureStderr(); debugManager.flags.ZEX_NUMBER_OF_CCS.set("2"); executionEnvironment->configureCcsMode(); std::string stdOutString = capture.getCapturedStdout(); - std::string stdErrString = testing::internal::GetCapturedStderr(); + std::string stdErrString = capture.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"; EXPECT_EQ(1u, ccsMode); 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 f4898d8149..762641371e 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 @@ -593,24 +593,25 @@ TEST(DrmBufferObject, givenPrintBOBindingResultWhenBOBindAndUnbindFailsThenPrint auto osContext = engines[contextId].osContext; osContext->ensureContextInitialized(false); - testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); bo.bind(osContext, 0, false); EXPECT_FALSE(bo.bindInfo[contextId][0]); - std::string bindOutput = testing::internal::GetCapturedStderr(); + std::string bindOutput = capture.getCapturedStderr(); std::stringstream expected; expected << "bind BO-0 to VM " << drm->latestCreatedVmId << ", vmHandleId = 0" << ", range: 0 - 0, size: 0, result: -1, errno: 22\n"; EXPECT_TRUE(hasSubstr(expected.str(), expected.str())) << bindOutput; expected.str(""); - testing::internal::CaptureStderr(); + capture.captureStderr(); bo.bindInfo[contextId][0] = true; bo.unbind(osContext, 0); EXPECT_TRUE(bo.bindInfo[contextId][0]); - std::string unbindOutput = testing::internal::GetCapturedStderr(); + std::string unbindOutput = capture.getCapturedStderr(); expected << "unbind BO-0 from VM " << drm->latestCreatedVmId << ", vmHandleId = 0" << ", range: 0 - 0, size: 0, result: -1, errno: 22"; EXPECT_TRUE(hasSubstr(unbindOutput, expected.str())) << unbindOutput; diff --git a/shared/test/unit_test/os_interface/linux/drm_engine_info_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_engine_info_prelim_tests.cpp index 8b9f4d66ca..62940513fb 100644 --- a/shared/test/unit_test/os_interface/linux/drm_engine_info_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_engine_info_prelim_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Intel Corporation + * Copyright (C) 2022-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -14,6 +14,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/helpers/variable_backup.h" #include "shared/test/common/libult/linux/drm_mock_helper.h" #include "shared/test/common/libult/linux/drm_query_mock.h" @@ -116,12 +117,13 @@ TEST(DrmTest, givenEngineQueryOnIncorrectSetupWithZeroEnginesThenProperDebugMess auto ioctlHelper = std::make_unique(*drm); drm->ioctlHelper.reset(ioctlHelper.release()); - testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); drm->queryEngineInfo(); EXPECT_EQ(0u, drm->engineInfo.get()->getEngineInfos().size()); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); std::string expectedError = "FATAL: Engine info size is equal to 0.\n"; EXPECT_EQ(output, expectedError); 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 177553b13a..c9feb9aa3e 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 @@ -174,13 +174,14 @@ TEST_F(DrmVmTestTest, givenNewMemoryInfoQuerySupportedWhenCreatingVirtualMemoryF EXPECT_EQ(1u + tileCount, memoryInfo->getDrmRegionInfos().size()); drm->ioctlCount.reset(); - testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); bool ret = drm->createVirtualMemoryAddressSpace(tileCount); EXPECT_FALSE(ret); EXPECT_EQ(1, drm->ioctlCount.gemVmCreate.load()); EXPECT_NE(0ull, drm->receivedGemVmControl.extensions); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); auto pos = output.find("INFO: Cannot create Virtual Memory at memory bank"); EXPECT_NE(std::string::npos, pos); } 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 cf74c30baa..3ff667d83c 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 @@ -79,7 +79,7 @@ TEST(DrmSystemInfoTest, givenSetupHardwareInfoWhenQuerySystemInfoFalseThenSystem StreamCapture capture; capture.captureStdout(); - ::testing::internal::CaptureStderr(); + capture.captureStderr(); DebugManagerStateRestore restorer; debugManager.flags.PrintDebugMessages.set(true); @@ -89,7 +89,7 @@ TEST(DrmSystemInfoTest, givenSetupHardwareInfoWhenQuerySystemInfoFalseThenSystem EXPECT_EQ(nullptr, drm.getSystemInfo()); EXPECT_TRUE(isEmpty(capture.getCapturedStdout())); - EXPECT_FALSE(isEmpty(::testing::internal::GetCapturedStderr())); + EXPECT_FALSE(isEmpty(capture.getCapturedStderr())); } TEST(DrmSystemInfoTest, whenSetupHardwareInfoThenReleaseHelperContainsCorrectIpVersion) { @@ -237,7 +237,7 @@ TEST(DrmSystemInfoTest, givenSetupHardwareInfoWhenQuerySystemInfoFailsThenSystem StreamCapture capture; capture.captureStdout(); - ::testing::internal::CaptureStderr(); + capture.captureStderr(); DebugManagerStateRestore restorer; debugManager.flags.PrintDebugMessages.set(true); @@ -251,9 +251,9 @@ TEST(DrmSystemInfoTest, givenSetupHardwareInfoWhenQuerySystemInfoFailsThenSystem 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")); + EXPECT_TRUE(hasSubstr(capture.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")); } else { - EXPECT_FALSE(::testing::internal::GetCapturedStderr().empty()); + EXPECT_FALSE(capture.getCapturedStderr().empty()); } } 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 6ded6bd3d9..c60b06794b 100644 --- a/shared/test/unit_test/os_interface/linux/drm_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_tests.cpp @@ -170,9 +170,10 @@ TEST(DrmTest, givenSmallBarDetectedInMemoryInfoAndNotSupportedWhenSetupHardwareI drm.ioctlHelper.reset(mockIoctlHelper.release()); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); EXPECT_EQ(-1, drm.setupHardwareInfo(&device, false)); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_STREQ("WARNING: Small BAR detected for device 0000:ab:cd.e\n", output.c_str()); } @@ -189,9 +190,10 @@ TEST(DrmTest, givenSmallBarDetectedInMemoryInfoAndSupportedWhenSetupHardwareInfo drm.ioctlHelper.reset(mockIoctlHelper.release()); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); EXPECT_EQ(0, drm.setupHardwareInfo(&device, false)); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_STREQ("WARNING: Small BAR detected for device 0000:ab:cd.e\n", output.c_str()); } @@ -1563,11 +1565,11 @@ TEST(DrmDeathTest, GivenResetStatsWithValidFaultWhenIsGpuHangIsCalledThenProcess std::string expectedString = std::string(buf.get()); - ::testing::internal::CaptureStderr(); StreamCapture capture; + capture.captureStderr(); capture.captureStdout(); EXPECT_THROW(drm.isGpuHangDetected(mockOsContextLinux), std::runtime_error); - auto stderrString = ::testing::internal::GetCapturedStderr(); + auto stderrString = capture.getCapturedStderr(); 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 aa48afc04e..dfe8af1af6 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 @@ -979,12 +979,13 @@ TEST_F(IoctlHelperPrelimFixture, givenIoctlHelperWhenInvalidHwIpVersionSizeOnIni DebugManagerStateRestore restore; debugManager.flags.PrintDebugMessages.set(true); - testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); drm->returnInvalidHwIpVersionLength = true; drm->ioctlHelper->setupIpVersion(); debugManager.flags.PrintDebugMessages.set(false); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); std::string expectedOutput = "Size got from PRELIM_DRM_I915_QUERY_HW_IP_VERSION query does not match PrelimI915::prelim_drm_i915_query_hw_ip_version size\n"; EXPECT_STREQ(output.c_str(), expectedOutput.c_str()); @@ -994,12 +995,13 @@ TEST_F(IoctlHelperPrelimFixture, givenIoctlHelperWhenFailOnInitializationAndPlat DebugManagerStateRestore restore; debugManager.flags.PrintDebugMessages.set(true); - testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); drm->failRetHwIpVersion = true; drm->ioctlHelper->setupIpVersion(); debugManager.flags.PrintDebugMessages.set(false); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); auto &productHelper = executionEnvironment->rootDeviceEnvironments[0]->getHelper(); if (productHelper.isPlatformQuerySupported()) { 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 8c7161874f..1f6208c6ef 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 @@ -540,13 +540,13 @@ TEST_F(CcsModeXeTest, GivenXeDrmAndValidCcsModeAndOpenSysCallFailsWithNoPermissi StreamCapture capture; capture.captureStdout(); - testing::internal::CaptureStderr(); + capture.captureStderr(); debugManager.flags.ZEX_NUMBER_OF_CCS.set("2"); executionEnvironment->configureCcsMode(); std::string stdOutString = capture.getCapturedStdout(); - std::string stdErrString = testing::internal::GetCapturedStderr(); + std::string stdErrString = capture.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"; EXPECT_EQ(1u, ccsMode); @@ -626,13 +626,13 @@ TEST_F(CcsModeXeTest, GivenXeDrmAndValidCcsModeAndOpenSysCallFailsWithNoAccessWh StreamCapture capture; capture.captureStdout(); - testing::internal::CaptureStderr(); + capture.captureStderr(); debugManager.flags.ZEX_NUMBER_OF_CCS.set("2"); executionEnvironment->configureCcsMode(); std::string stdOutString = capture.getCapturedStdout(); - std::string stdErrString = testing::internal::GetCapturedStderr(); + std::string stdErrString = capture.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"; EXPECT_EQ(1u, ccsMode); diff --git a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp index 1242bb3287..351e1d57b0 100644 --- a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp @@ -12,6 +12,7 @@ #include "shared/source/unified_memory/usm_memory_support.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/mocks/linux/mock_drm_memory_manager.h" #include "shared/test/common/mocks/linux/mock_os_context_linux.h" #include "shared/test/common/mocks/linux/mock_os_time_linux.h" @@ -1943,13 +1944,14 @@ TEST_F(IoctlHelperXeTest, whenXeShowBindTableIsCalledThenBindLogsArePrinted) { mockBindInfo.addr = 3u; xeIoctlHelper->bindInfo.push_back(mockBindInfo); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); debugManager.flags.PrintXeLogs.set(true); xeIoctlHelper->xeShowBindTable(); debugManager.flags.PrintXeLogs.set(false); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); std::string expectedOutput1 = "show bind: ( )\n"; std::string expectedOutput2 = "0 x0000000000000002 x0000000000000003"; diff --git a/shared/test/unit_test/os_interface/windows/wddm_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm_tests.cpp index 6646fd20a8..1e394a7bbc 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_tests.cpp @@ -12,6 +12,7 @@ #include "shared/source/os_interface/windows/wddm/um_km_data_translator.h" #include "shared/source/os_interface/windows/wddm_allocation.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_gmm_client_context_base.h" #include "shared/test/common/mocks/mock_io_functions.h" #include "shared/test/common/mocks/mock_product_helper.h" @@ -597,20 +598,21 @@ TEST_F(WddmTests, givenCheckDeviceStateSetToTrueAndForceExecutionStateWhenSubmit VariableBackup pagingFenceBackup(&wddm->pagingFenceAddress, &pagingFenceValue); auto executionState = D3DKMT_DEVICEEXECUTION_ERROR_OUTOFMEMORY; setMockDeviceExecutionStateFcn(executionState); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); WddmSubmitArguments submitArguments{}; EXPECT_FALSE(wddm->submit(0, 0, nullptr, submitArguments)); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_EQ(std::string("Device execution error, out of memory " + std::to_string(executionState) + "\n"), output); setMockDeviceExecutionStateFcn(D3DKMT_DEVICEEXECUTION_ACTIVE); - ::testing::internal::CaptureStderr(); + capture.captureStderr(); COMMAND_BUFFER_HEADER commandBufferHeader{}; MonitoredFence monitoredFence{}; submitArguments.monitorFence = &monitoredFence; EXPECT_TRUE(wddm->submit(0, 0, &commandBufferHeader, submitArguments)); - output = testing::internal::GetCapturedStderr(); + output = capture.getCapturedStderr(); EXPECT_EQ(std::string(""), output); } @@ -622,16 +624,17 @@ TEST_F(WddmTests, givenCheckDeviceStateSetToTrueWhenCallGetDeviceStateAndForceEx auto executionState = D3DKMT_DEVICEEXECUTION_ERROR_OUTOFMEMORY; setMockDeviceExecutionStateFcn(executionState); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); EXPECT_FALSE(wddm->getDeviceState()); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_EQ(std::string("Device execution error, out of memory " + std::to_string(executionState) + "\n"), output); setMockDeviceExecutionStateFcn(D3DKMT_DEVICEEXECUTION_ACTIVE); - ::testing::internal::CaptureStderr(); + capture.captureStderr(); EXPECT_TRUE(wddm->getDeviceState()); - output = testing::internal::GetCapturedStderr(); + output = capture.getCapturedStderr(); EXPECT_EQ(std::string(""), output); } @@ -644,17 +647,18 @@ TEST_F(WddmTests, givenCheckDeviceStateSetToTrueWhenCallGetDeviceStateReturnsFai setMockDeviceExecutionStateFcn(executionState); setMockGetDeviceStateReturnValueFcn(STATUS_SUCCESS + 1, true); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); EXPECT_FALSE(wddm->getDeviceState()); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_EQ(std::string(""), output); setMockDeviceExecutionStateFcn(D3DKMT_DEVICEEXECUTION_ACTIVE); setMockGetDeviceStateReturnValueFcn(STATUS_SUCCESS, true); - ::testing::internal::CaptureStderr(); + capture.captureStderr(); EXPECT_TRUE(wddm->getDeviceState()); - output = testing::internal::GetCapturedStderr(); + output = capture.getCapturedStderr(); EXPECT_EQ(std::string(""), output); } @@ -666,16 +670,17 @@ TEST_F(WddmTests, givenCheckDeviceStateSetToFalseWhenCallGetDeviceStateAndForceE auto executionState = D3DKMT_DEVICEEXECUTION_ERROR_OUTOFMEMORY; setMockDeviceExecutionStateFcn(executionState); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); EXPECT_TRUE(wddm->getDeviceState()); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); EXPECT_EQ(std::string(""), output); setMockDeviceExecutionStateFcn(D3DKMT_DEVICEEXECUTION_ACTIVE); - ::testing::internal::CaptureStderr(); + capture.captureStderr(); EXPECT_TRUE(wddm->getDeviceState()); - output = testing::internal::GetCapturedStderr(); + output = capture.getCapturedStderr(); EXPECT_EQ(std::string(""), output); } @@ -770,17 +775,18 @@ TEST_F(WddmTests, givenCheckDeviceStateSetToTrueWhenCallGetDeviceStateReturnsPag wddm->checkDeviceState = true; setMockDeviceExecutionStateFcn(D3DKMT_DEVICEEXECUTION_ERROR_DMAPAGEFAULT); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); EXPECT_FALSE(wddm->getDeviceState()); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); std::string expected = "Device execution error, page fault\nfaulted gpuva 0xabc000, pipeline stage 0, bind table entry 2, flags 0x1, error code(is device) 1, error code 10\n"; EXPECT_EQ(expected, output); setMockDeviceExecutionStateFcn(D3DKMT_DEVICEEXECUTION_ACTIVE); - ::testing::internal::CaptureStderr(); + capture.captureStderr(); EXPECT_TRUE(wddm->getDeviceState()); - output = testing::internal::GetCapturedStderr(); + output = capture.getCapturedStderr(); EXPECT_EQ(std::string(""), output); } @@ -792,18 +798,19 @@ TEST_F(WddmTests, givenCheckDeviceStateSetToTrueWhenCallGetDeviceStateReturnsFai setMockDeviceExecutionStateFcn(D3DKMT_DEVICEEXECUTION_ERROR_DMAPAGEFAULT); setMockGetDeviceStateReturnValueFcn(STATUS_SUCCESS + 1, false); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); EXPECT_FALSE(wddm->getDeviceState()); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); std::string expected = "Device execution error, page fault\n"; EXPECT_EQ(expected, output); setMockDeviceExecutionStateFcn(D3DKMT_DEVICEEXECUTION_ACTIVE); setMockGetDeviceStateReturnValueFcn(STATUS_SUCCESS, false); - ::testing::internal::CaptureStderr(); + capture.captureStderr(); EXPECT_TRUE(wddm->getDeviceState()); - output = testing::internal::GetCapturedStderr(); + output = capture.getCapturedStderr(); EXPECT_EQ(std::string(""), output); } @@ -815,17 +822,18 @@ TEST_F(WddmTests, givenCheckDeviceStateSetToTrueWhenCallGetDeviceStateReturnsOth auto executionState = D3DKMT_DEVICEEXECUTION_RESET; setMockDeviceExecutionStateFcn(executionState); - ::testing::internal::CaptureStderr(); + StreamCapture capture; + capture.captureStderr(); EXPECT_FALSE(wddm->getDeviceState()); - std::string output = testing::internal::GetCapturedStderr(); + std::string output = capture.getCapturedStderr(); std::string expected = std::string("Device execution error " + std::to_string(executionState) + "\n"); EXPECT_EQ(expected, output); setMockDeviceExecutionStateFcn(D3DKMT_DEVICEEXECUTION_ACTIVE); - ::testing::internal::CaptureStderr(); + capture.captureStderr(); EXPECT_TRUE(wddm->getDeviceState()); - output = testing::internal::GetCapturedStderr(); + output = capture.getCapturedStderr(); EXPECT_EQ(std::string(""), output); }