aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/test
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
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')
-rw-r--r--src/profiling/test/ProfilingTestUtils.hpp40
-rw-r--r--src/profiling/test/ProfilingTests.cpp39
-rw-r--r--src/profiling/test/ProfilingTests.hpp43
-rw-r--r--src/profiling/test/SendTimelinePacketTests.cpp5
4 files changed, 68 insertions, 59 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
diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp
index 43938cff7f..9c3007b017 100644
--- a/src/profiling/test/ProfilingTests.cpp
+++ b/src/profiling/test/ProfilingTests.cpp
@@ -139,6 +139,8 @@ TEST_CASE("CheckPacketKeyComparisons")
TEST_CASE("CheckCommandHandler")
{
+ LogLevelSwapper logLevelSwapper(arm::pipe::LogSeverity::Fatal);
+
arm::pipe::PacketVersionResolver packetVersionResolver;
ProfilingStateMachine profilingStateMachine;
@@ -3153,7 +3155,12 @@ TEST_CASE("CheckConfigureProfilingServiceOff")
TEST_CASE("CheckProfilingServiceEnabled")
{
// Locally reduce log level to "Warning", as this test needs to parse a warning message from the standard output
- LogLevelSwapper logLevelSwapper(armnn::LogSeverity::Warning);
+ LogLevelSwapper logLevelSwapper(arm::pipe::LogSeverity::Warning);
+
+ // Redirect the output to a local stream so that we can parse the warning message
+ std::stringstream ss;
+ StreamRedirector streamRedirector(std::cout, ss.rdbuf());
+
ProfilingOptions options;
options.m_EnableProfiling = true;
armnn::ArmNNProfilingServiceInitialiser initialiser;
@@ -3163,9 +3170,6 @@ TEST_CASE("CheckProfilingServiceEnabled")
profilingService.Update();
CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected);
- // Redirect the output to a local stream so that we can parse the warning message
- std::stringstream ss;
- StreamRedirector streamRedirector(std::cout, ss.rdbuf());
profilingService.Update();
// Reset the profiling service to stop any running thread
@@ -3185,7 +3189,12 @@ TEST_CASE("CheckProfilingServiceEnabled")
TEST_CASE("CheckProfilingServiceEnabledRuntime")
{
// Locally reduce log level to "Warning", as this test needs to parse a warning message from the standard output
- LogLevelSwapper logLevelSwapper(armnn::LogSeverity::Warning);
+ LogLevelSwapper logLevelSwapper(arm::pipe::LogSeverity::Warning);
+
+ // Redirect the output to a local stream so that we can parse the warning message
+ std::stringstream ss;
+ StreamRedirector streamRedirector(std::cout, ss.rdbuf());
+
ProfilingOptions options;
armnn::ArmNNProfilingServiceInitialiser initialiser;
ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER, initialiser);
@@ -3199,9 +3208,6 @@ TEST_CASE("CheckProfilingServiceEnabledRuntime")
profilingService.Update();
CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected);
- // Redirect the output to a local stream so that we can parse the warning message
- std::stringstream ss;
- StreamRedirector streamRedirector(std::cout, ss.rdbuf());
profilingService.Update();
// Reset the profiling service to stop any running thread
@@ -3221,8 +3227,7 @@ TEST_CASE("CheckProfilingServiceEnabledRuntime")
TEST_CASE("CheckProfilingServiceBadConnectionAcknowledgedPacket")
{
// Locally reduce log level to "Warning", as this test needs to parse a warning message from the standard output
- LogLevelSwapper logLevelSwapper(armnn::LogSeverity::Warning);
-
+ LogLevelSwapper logLevelSwapper(arm::pipe::LogSeverity::Warning);
// Redirect the standard output to a local stream so that we can parse the warning message
std::stringstream ss;
@@ -3285,7 +3290,7 @@ TEST_CASE("CheckProfilingServiceBadConnectionAcknowledgedPacket")
TEST_CASE("CheckProfilingServiceBadRequestCounterDirectoryPacket")
{
// Locally reduce log level to "Warning", as this test needs to parse a warning message from the standard output
- LogLevelSwapper logLevelSwapper(armnn::LogSeverity::Warning);
+ LogLevelSwapper logLevelSwapper(arm::pipe::LogSeverity::Warning);
// Redirect the standard output to a local stream so that we can parse the warning message
std::stringstream ss;
@@ -3350,7 +3355,7 @@ TEST_CASE("CheckProfilingServiceBadRequestCounterDirectoryPacket")
TEST_CASE("CheckProfilingServiceBadPeriodicCounterSelectionPacket")
{
// Locally reduce log level to "Warning", as this test needs to parse a warning message from the standard output
- LogLevelSwapper logLevelSwapper(armnn::LogSeverity::Warning);
+ LogLevelSwapper logLevelSwapper(arm::pipe::LogSeverity::Warning);
// Redirect the standard output to a local stream so that we can parse the warning message
std::stringstream ss;
@@ -3707,7 +3712,11 @@ TEST_CASE("CheckRegisterCounters")
TEST_CASE("CheckFileFormat") {
// Locally reduce log level to "Warning", as this test needs to parse a warning message from the standard output
- LogLevelSwapper logLevelSwapper(armnn::LogSeverity::Warning);
+ LogLevelSwapper logLevelSwapper(arm::pipe::LogSeverity::Warning);
+
+ // Redirect the output to a local stream so that we can parse the warning message
+ std::stringstream ss;
+ StreamRedirector streamRedirector(std::cout, ss.rdbuf());
// Create profiling options.
ProfilingOptions options;
@@ -3725,10 +3734,6 @@ TEST_CASE("CheckFileFormat") {
profilingService.Update();
CHECK(profilingService.GetCurrentState()==ProfilingState::NotConnected);
- // Redirect the output to a local stream so that we can parse the warning message
- std::stringstream ss;
- StreamRedirector streamRedirector(std::cout, ss.rdbuf());
-
// When Update is called and the current state is ProfilingState::NotConnected
// an exception will be raised from GetProfilingConnection and displayed as warning in the output local stream
profilingService.Update();
diff --git a/src/profiling/test/ProfilingTests.hpp b/src/profiling/test/ProfilingTests.hpp
index 70bf6138cf..e55117bbc7 100644
--- a/src/profiling/test/ProfilingTests.hpp
+++ b/src/profiling/test/ProfilingTests.hpp
@@ -7,14 +7,13 @@
#include "ProfilingMocks.hpp"
-#include <armnn/Logging.hpp>
#include <armnn/utility/PolymorphicDowncast.hpp>
#include <IProfilingConnection.hpp>
#include <ProfilingService.hpp>
#include <common/include/CommandHandlerFunctor.hpp>
-
+#include <common/include/Logging.hpp>
#include <doctest/doctest.h>
@@ -27,46 +26,6 @@ namespace arm
namespace pipe
{
-struct LogLevelSwapper
-{
-public:
- LogLevelSwapper(armnn::LogSeverity severity)
- {
- // Set the new log level
- armnn::ConfigureLogging(true, true, severity);
- }
- ~LogLevelSwapper()
- {
- // The default log level for unit tests is "Fatal"
- armnn::ConfigureLogging(true, true, armnn::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;
-};
-
class TestProfilingConnectionBase : public IProfilingConnection
{
public:
diff --git a/src/profiling/test/SendTimelinePacketTests.cpp b/src/profiling/test/SendTimelinePacketTests.cpp
index eb6a2627b4..7f2421dbec 100644
--- a/src/profiling/test/SendTimelinePacketTests.cpp
+++ b/src/profiling/test/SendTimelinePacketTests.cpp
@@ -4,6 +4,7 @@
//
#include "ProfilingMocks.hpp"
+#include "ProfilingTestUtils.hpp"
#include <ArmNNProfilingServiceInitialiser.hpp>
#include <BufferManager.hpp>
@@ -428,6 +429,8 @@ TEST_CASE("SendTimelinePacketTests3")
TEST_CASE("GetGuidsFromProfilingService")
{
+ LogLevelSwapper logLevelSwapper(arm::pipe::LogSeverity::Fatal);
+
armnn::IRuntime::CreationOptions options;
options.m_ProfilingOptions.m_EnableProfiling = true;
armnn::RuntimeImpl runtime(options);
@@ -451,6 +454,8 @@ TEST_CASE("GetGuidsFromProfilingService")
TEST_CASE("GetTimelinePackerWriterFromProfilingService")
{
+ LogLevelSwapper logLevelSwapper(arm::pipe::LogSeverity::Fatal);
+
ProfilingOptions options;
options.m_EnableProfiling = true;
armnn::ArmNNProfilingServiceInitialiser initialiser;