aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/test/ProfilingTestUtils.hpp
diff options
context:
space:
mode:
authorJim Flynn <jim.flynn@arm.com>2022-03-10 23:13:01 +0000
committerJim Flynn <jim.flynn@arm.com>2022-03-12 15:14:48 +0000
commit6c9f17dc5fe58e23db0ba591302168766b38ab2a (patch)
tree50b302f1bdfcce997a2b8330a8142d6858c672d5 /src/profiling/test/ProfilingTestUtils.hpp
parent6730fe9cbc195f054d697b25daba8516d70658e0 (diff)
downloadarmnn-6c9f17dc5fe58e23db0ba591302168766b38ab2a.tar.gz
IVGCVSW-6843 replace armnn::Logging with arm::pipe::Logging in profiling code
Change-Id: I9c3af46ca02c5685e06657b8af0e4658d71891d4 Signed-off-by: Jim Flynn <jim.flynn@arm.com>
Diffstat (limited to 'src/profiling/test/ProfilingTestUtils.hpp')
-rw-r--r--src/profiling/test/ProfilingTestUtils.hpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/profiling/test/ProfilingTestUtils.hpp b/src/profiling/test/ProfilingTestUtils.hpp
index 323a762918..32db72a19d 100644
--- a/src/profiling/test/ProfilingTestUtils.hpp
+++ b/src/profiling/test/ProfilingTestUtils.hpp
@@ -89,6 +89,46 @@ public:
}
};
+struct LogLevelSwapper
+{
+public:
+ LogLevelSwapper(arm::pipe::LogSeverity severity)
+ {
+ // Set the new log level
+ arm::pipe::ConfigureLogging(true, true, severity);
+ }
+ ~LogLevelSwapper()
+ {
+ // The default log level for unit tests is "Fatal"
+ arm::pipe::ConfigureLogging(true, true, arm::pipe::LogSeverity::Fatal);
+ }
+};
+
+struct StreamRedirector
+{
+public:
+ StreamRedirector(std::ostream& stream, std::streambuf* newStreamBuffer)
+ : m_Stream(stream)
+ , m_BackupBuffer(m_Stream.rdbuf(newStreamBuffer))
+ {}
+
+ ~StreamRedirector() { CancelRedirect(); }
+
+ void CancelRedirect()
+ {
+ // Only cancel the redirect once.
+ if (m_BackupBuffer != nullptr )
+ {
+ m_Stream.rdbuf(m_BackupBuffer);
+ m_BackupBuffer = nullptr;
+ }
+ }
+
+private:
+ std::ostream& m_Stream;
+ std::streambuf* m_BackupBuffer;
+};
+
} // namespace pipe
} // namespace arm