From 08446976e3b6ce0e02f22b391b37aacaad181e1a Mon Sep 17 00:00:00 2001 From: Derek Lamberti Date: Tue, 26 Nov 2019 16:38:31 +0000 Subject: Replace boost logging with simple logger !referencetests:214319 * Reduces arm nn binary size ~15% * Also fixed test logging black hole issues Change-Id: Iba27db304d9a8088fa46aeb0b52225d93bb56bc8 Signed-off-by: Derek Lamberti --- src/armnn/test/ModelAccuracyCheckerTest.cpp | 1 - src/armnn/test/UnitTests.cpp | 56 ++++++++++++++++++++++++++++- src/armnn/test/UnitTests.hpp | 3 +- 3 files changed, 56 insertions(+), 4 deletions(-) (limited to 'src/armnn/test') 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 #include -#include #include #include #include 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 #include "UnitTests.hpp" +#include + +#include 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 +#include #include #include #include @@ -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: -- cgit v1.2.1