aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/armnn/test')
-rw-r--r--src/armnn/test/ModelAccuracyCheckerTest.cpp1
-rw-r--r--src/armnn/test/UnitTests.cpp56
-rw-r--r--src/armnn/test/UnitTests.hpp3
3 files changed, 56 insertions, 4 deletions
diff --git a/src/armnn/test/ModelAccuracyCheckerTest.cpp b/src/armnn/test/ModelAccuracyCheckerTest.cpp
index e1618512eb..8bbe3d9f41 100644
--- a/src/armnn/test/ModelAccuracyCheckerTest.cpp
+++ b/src/armnn/test/ModelAccuracyCheckerTest.cpp
@@ -8,7 +8,6 @@
#include <boost/test/unit_test.hpp>
#include <boost/filesystem.hpp>
-#include <boost/log/core/core.hpp>
#include <boost/optional.hpp>
#include <boost/variant.hpp>
#include <iostream>
diff --git a/src/armnn/test/UnitTests.cpp b/src/armnn/test/UnitTests.cpp
index c08b705506..7d171a8d88 100644
--- a/src/armnn/test/UnitTests.cpp
+++ b/src/armnn/test/UnitTests.cpp
@@ -6,6 +6,9 @@
#include <boost/test/unit_test.hpp>
#include "UnitTests.hpp"
+#include <armnn/Logging.hpp>
+
+#include <boost/algorithm/string.hpp>
struct ConfigureLoggingFixture
{
@@ -57,4 +60,55 @@ private:
BOOST_GLOBAL_FIXTURE(SetupDebugOutput);
-#endif // defined(_MSC_VER) \ No newline at end of file
+#endif // defined(_MSC_VER)
+
+
+BOOST_AUTO_TEST_SUITE(LoggerSuite)
+
+BOOST_AUTO_TEST_CASE(LoggerTest)
+{
+ std::stringstream ss;
+
+ {
+ struct StreamRedirector
+ {
+ public:
+ StreamRedirector(std::ostream& stream, std::streambuf* newStreamBuffer)
+ : m_Stream(stream)
+ , m_BackupBuffer(m_Stream.rdbuf(newStreamBuffer))
+ {}
+ ~StreamRedirector() { m_Stream.rdbuf(m_BackupBuffer); }
+
+ private:
+ std::ostream& m_Stream;
+ std::streambuf* m_BackupBuffer;
+ };
+
+
+ StreamRedirector redirect(std::cout, ss.rdbuf());
+
+ using namespace armnn;
+ SetLogFilter(LogSeverity::Trace);
+ SetAllLoggingSinks(true, false, false);
+
+
+ ARMNN_LOG(trace) << "My trace message; " << -2;
+ ARMNN_LOG(debug) << "My debug message; " << -1;
+ ARMNN_LOG(info) << "My info message; " << 0;
+ ARMNN_LOG(warning) << "My warning message; " << 1;
+ ARMNN_LOG(error) << "My error message; " << 2;
+ ARMNN_LOG(fatal) << "My fatal message; " << 3;
+
+ SetLogFilter(LogSeverity::Fatal);
+
+ }
+
+ BOOST_CHECK(boost::contains(ss.str(), "Trace: My trace message; -2"));
+ BOOST_CHECK(boost::contains(ss.str(), "Debug: My debug message; -1"));
+ BOOST_CHECK(boost::contains(ss.str(), "Info: My info message; 0"));
+ BOOST_CHECK(boost::contains(ss.str(), "Warning: My warning message; 1"));
+ BOOST_CHECK(boost::contains(ss.str(), "Error: My error message; 2"));
+ BOOST_CHECK(boost::contains(ss.str(), "Fatal: My fatal message; 3"));
+}
+
+BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnn/test/UnitTests.hpp b/src/armnn/test/UnitTests.hpp
index dc97f90ba9..60d191f97d 100644
--- a/src/armnn/test/UnitTests.hpp
+++ b/src/armnn/test/UnitTests.hpp
@@ -4,7 +4,7 @@
//
#pragma once
-#include <Logging.hpp>
+#include <armnn/Logging.hpp>
#include <armnn/Utils.hpp>
#include <reference/RefWorkloadFactory.hpp>
#include <backendsCommon/test/LayerTests.hpp>
@@ -16,7 +16,6 @@ inline void ConfigureLoggingTest()
{
// Configures logging for both the ARMNN library and this test program.
armnn::ConfigureLogging(true, true, armnn::LogSeverity::Fatal);
- armnnUtils::ConfigureLogging(boost::log::core::get().get(), true, true, armnn::LogSeverity::Fatal);
}
// The following macros require the caller to have defined FactoryType, with one of the following using statements: