Files
compute-runtime/opencl/test/unit_test/offline_compiler/stdout_capturer.h
Patryk Wrobel a8680c0b82 Implement ULTs for IgaWrapper
This change:
- implements mock for functions from IGA DLL
- implements ULTs for IgaWrapper
- implements RAII wrapper for GTEST's capture of stdout
- adds ASAN and TSAN flags to ocloc_tests

Related-To: NEO-6834
Signed-off-by: Patryk Wrobel <patryk.wrobel@intel.com>
2022-04-19 12:26:36 +02:00

42 lines
864 B
C++

/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "gtest/gtest.h"
#include <string>
namespace NEO {
/*
* This class is a RAII wrapper for GTEST's mechanism, which allows capturing stdout.
* We must ensure that GetCapturedStdout() is called after CaptureStdout().
* If it is not invoked, then next call to CaptureStdout() will cause abort of the test application.
*/
class StdoutCapturer {
public:
StdoutCapturer() {
::testing::internal::CaptureStdout();
}
~StdoutCapturer() {
if (!outputAcquired) {
::testing::internal::GetCapturedStdout();
}
}
std::string acquireOutput() {
outputAcquired = true;
return ::testing::internal::GetCapturedStdout();
}
private:
bool outputAcquired{false};
};
} // namespace NEO