diff options
author | Sadik Armagan <sadik.armagan@arm.com> | 2019-09-26 23:13:31 +0100 |
---|---|---|
committer | Kevin May <kevin.may@arm.com> | 2019-09-27 07:01:48 +0000 |
commit | bd9e2c546d83fa654d8e764ef755b1ded0cd1ff8 (patch) | |
tree | 3633ea36e376f1df14f2368068dfc6b22265b565 /src | |
parent | 404b27569523f4cdd49752e7ae1633e359ba2190 (diff) | |
download | armnn-bd9e2c546d83fa654d8e764ef755b1ded0cd1ff8.tar.gz |
IVGCVSW-3557 Return IProfilingConnection from ProfilingConnectionFactory
* Remove WaitingForAck test, test std::cerr instead
Signed-off-by: Kevin May <kevin.may@arm.com>
Signed-off-by: Sadik Armagan <sadik.armagan@arm.com>
Change-Id: I968c53dc005ff078ed08faf8818c83cb2a41528a
Diffstat (limited to 'src')
-rw-r--r-- | src/profiling/ProfilingConnectionFactory.cpp | 3 | ||||
-rw-r--r-- | src/profiling/ProfilingService.cpp | 13 | ||||
-rw-r--r-- | src/profiling/test/ProfilingTests.cpp | 29 |
3 files changed, 35 insertions, 10 deletions
diff --git a/src/profiling/ProfilingConnectionFactory.cpp b/src/profiling/ProfilingConnectionFactory.cpp index 1b4924df72..faecea7526 100644 --- a/src/profiling/ProfilingConnectionFactory.cpp +++ b/src/profiling/ProfilingConnectionFactory.cpp @@ -4,6 +4,7 @@ // #include "ProfilingConnectionFactory.hpp" +#include "SocketProfilingConnection.hpp" namespace armnn { @@ -14,7 +15,7 @@ namespace profiling std::unique_ptr<IProfilingConnection> ProfilingConnectionFactory::GetProfilingConnection( const Runtime::CreationOptions::ExternalProfilingOptions& options) const { - return nullptr; + return std::make_unique<SocketProfilingConnection>(); } } // namespace profiling diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp index 9f5978888d..786bfae12e 100644 --- a/src/profiling/ProfilingService.cpp +++ b/src/profiling/ProfilingService.cpp @@ -57,14 +57,17 @@ void ProfilingService::Run() { if (m_State.GetCurrentState() == ProfilingState::NotConnected) { - // Since GetProfilingConnection is not implemented, if !NULL, - // then change to WaitingForAck. This will need to change once there is implementation - // for the IProfilingConnection - if (!m_Factory.GetProfilingConnection(m_Options)) + try { + m_Factory.GetProfilingConnection(m_Options); m_State.TransitionToState(ProfilingState::WaitingForAck); } - } else if (m_State.GetCurrentState() == ProfilingState::Uninitialised && m_Options.m_EnableProfiling == true) + catch (const armnn::Exception& e) + { + std::cerr << e.what() << std::endl; + } + } + else if (m_State.GetCurrentState() == ProfilingState::Uninitialised && m_Options.m_EnableProfiling == true) { Initialise(); } diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp index a474c309e8..5ef9811b2c 100644 --- a/src/profiling/test/ProfilingTests.cpp +++ b/src/profiling/test/ProfilingTests.cpp @@ -27,11 +27,13 @@ #include <armnn/Conversion.hpp> -#include <boost/test/unit_test.hpp> +#include <boost/algorithm/string.hpp> #include <boost/numeric/conversion/cast.hpp> +#include <boost/test/unit_test.hpp> #include <cstdint> #include <cstring> +#include <iostream> #include <limits> #include <map> #include <random> @@ -663,17 +665,32 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceDisabled) BOOST_CHECK(service.GetCurrentState() == ProfilingState::Uninitialised); } +struct cerr_redirect { + cerr_redirect(std::streambuf* new_buffer) + : old( std::cerr.rdbuf(new_buffer)) {} + + ~cerr_redirect( ) { + std::cerr.rdbuf(old); + } + +private: + std::streambuf* old; +}; + BOOST_AUTO_TEST_CASE(CheckProfilingServiceEnabled) { armnn::Runtime::CreationOptions::ExternalProfilingOptions options; options.m_EnableProfiling = true; ProfilingService service(options); BOOST_CHECK(service.GetCurrentState() == ProfilingState::NotConnected); + + // As there is no daemon running a connection cannot be made so expect a std::cerr to console + std::stringstream ss; + cerr_redirect guard(ss.rdbuf()); service.Run(); - BOOST_CHECK(service.GetCurrentState() == ProfilingState::WaitingForAck); + BOOST_CHECK(boost::contains(ss.str(), "Cannot connect to stream socket: Connection refused")); } - BOOST_AUTO_TEST_CASE(CheckProfilingServiceEnabledRuntime) { armnn::Runtime::CreationOptions::ExternalProfilingOptions options; @@ -684,8 +701,12 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceEnabledRuntime) options.m_EnableProfiling = true; service.ResetExternalProfilingOptions(options); BOOST_CHECK(service.GetCurrentState() == ProfilingState::NotConnected); + + // As there is no daemon running a connection cannot be made so expect a std::cerr to console + std::stringstream ss; + cerr_redirect guard(ss.rdbuf()); service.Run(); - BOOST_CHECK(service.GetCurrentState() == ProfilingState::WaitingForAck); + BOOST_CHECK(boost::contains(ss.str(), "Cannot connect to stream socket: Connection refused")); } BOOST_AUTO_TEST_CASE(CheckProfilingServiceCounterDirectory) |