From b10e08180dc1576fbe0f838a9f0277ab4b3f40f4 Mon Sep 17 00:00:00 2001 From: Keith Davis Date: Thu, 17 Oct 2019 09:52:50 +0100 Subject: Fix for bug where ProfilingConnectionDumpToFactory is not used in profiling service Signed-off-by: Keith Davis Change-Id: I962093766a79fefc8fb91b9bc3d5bd8f28c35114 --- ...ProfilingConnectionDumpToFileDecoratorTests.cpp | 61 ++++++++++------------ 1 file changed, 29 insertions(+), 32 deletions(-) (limited to 'src/profiling/test') diff --git a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp index a7acdd63cc..c42891d9bf 100644 --- a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp +++ b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp @@ -4,6 +4,7 @@ // #include "../ProfilingConnectionDumpToFileDecorator.hpp" +#include #include #include @@ -80,36 +81,22 @@ std::vector ReadDumpFile(const std::string& dumpFileName) BOOST_AUTO_TEST_SUITE(ProfilingConnectionDumpToFileDecoratorTests) -BOOST_AUTO_TEST_CASE(CheckSettings) -{ - ProfilingConnectionDumpToFileDecoratorSettings settings0("", ""); - BOOST_CHECK(settings0.m_DumpIncoming == false); - BOOST_CHECK(settings0.m_DumpOutgoing == false); - - ProfilingConnectionDumpToFileDecoratorSettings settings1("incomingDumpFile.dat", ""); - BOOST_CHECK(settings1.m_DumpIncoming == true); - BOOST_CHECK(settings1.m_DumpOutgoing == false); - - ProfilingConnectionDumpToFileDecoratorSettings settings2("", "outgoingDumpFile.dat"); - BOOST_CHECK(settings2.m_DumpIncoming == false); - BOOST_CHECK(settings2.m_DumpOutgoing == true); - - ProfilingConnectionDumpToFileDecoratorSettings settings3("incomingDumpFile.dat", "outgoingDumpFile.dat"); - BOOST_CHECK(settings3.m_DumpIncoming == true); - BOOST_CHECK(settings3.m_DumpOutgoing == true); -} BOOST_AUTO_TEST_CASE(DumpIncomingInvalidFile) { - ProfilingConnectionDumpToFileDecoratorSettings settings("/", "", false); - ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), settings); + armnn::Runtime::CreationOptions::ExternalProfilingOptions options; + options.m_IncomingCaptureFile = "/"; + options.m_OutgoingCaptureFile = ""; + ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), options, false); BOOST_CHECK_THROW(decorator.ReadPacket(0), armnn::RuntimeException); } BOOST_AUTO_TEST_CASE(DumpIncomingInvalidFileIgnoreErrors) { - ProfilingConnectionDumpToFileDecoratorSettings settings("/", "", true); - ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), settings); + armnn::Runtime::CreationOptions::ExternalProfilingOptions options; + options.m_IncomingCaptureFile = "/"; + options.m_OutgoingCaptureFile = ""; + ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), options, true); BOOST_CHECK_NO_THROW(decorator.ReadPacket(0)); } @@ -117,9 +104,11 @@ BOOST_AUTO_TEST_CASE(DumpIncomingValidFile) { std::stringstream fileName; fileName << ARMNN_PROFILING_CONNECTION_TEST_DUMP_DIR << "/test_dump_file_incoming.dat"; + armnn::Runtime::CreationOptions::ExternalProfilingOptions options; + options.m_IncomingCaptureFile = fileName.str(); + options.m_OutgoingCaptureFile = ""; - ProfilingConnectionDumpToFileDecoratorSettings settings(fileName.str(), "", false); - ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), settings); + ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), options, false); // NOTE: unique_ptr is needed here because operator=() is deleted for Packet std::unique_ptr packet; @@ -127,7 +116,7 @@ BOOST_AUTO_TEST_CASE(DumpIncomingValidFile) decorator.Close(); - std::vector data = ReadDumpFile(settings.m_IncomingDumpFileName); + std::vector data = ReadDumpFile(options.m_IncomingCaptureFile); const char* packetData = reinterpret_cast(packet->GetData()); // check if the data read back from the dump file matches the original @@ -138,15 +127,20 @@ BOOST_AUTO_TEST_CASE(DumpIncomingValidFile) BOOST_AUTO_TEST_CASE(DumpOutgoingInvalidFile) { - ProfilingConnectionDumpToFileDecoratorSettings settings("", "/", false); - ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), settings); + armnn::Runtime::CreationOptions::ExternalProfilingOptions options; + options.m_IncomingCaptureFile = ""; + options.m_OutgoingCaptureFile = "/"; + ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), options, false); BOOST_CHECK_THROW(decorator.WritePacket(g_DataPtr, g_DataLength), armnn::RuntimeException); } BOOST_AUTO_TEST_CASE(DumpOutgoingInvalidFileIgnoreErrors) { - ProfilingConnectionDumpToFileDecoratorSettings settings("", "/", true); - ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), settings); + armnn::Runtime::CreationOptions::ExternalProfilingOptions options; + options.m_IncomingCaptureFile = ""; + options.m_OutgoingCaptureFile = "/"; + + ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), options, true); BOOST_CHECK_NO_THROW(decorator.WritePacket(g_DataPtr, g_DataLength)); bool success = decorator.WritePacket(g_DataPtr, g_DataLength); @@ -158,8 +152,11 @@ BOOST_AUTO_TEST_CASE(DumpOutgoingValidFile) std::stringstream fileName; fileName << ARMNN_PROFILING_CONNECTION_TEST_DUMP_DIR << "/test_dump_file.dat"; - ProfilingConnectionDumpToFileDecoratorSettings settings("", fileName.str(), false); - ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), settings); + armnn::Runtime::CreationOptions::ExternalProfilingOptions options; + options.m_IncomingCaptureFile = ""; + options.m_OutgoingCaptureFile = fileName.str(); + + ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), options, false); bool success = false; BOOST_CHECK_NO_THROW(success = decorator.WritePacket(g_DataPtr, g_DataLength)); @@ -167,7 +164,7 @@ BOOST_AUTO_TEST_CASE(DumpOutgoingValidFile) decorator.Close(); - std::vector data = ReadDumpFile(settings.m_OutgoingDumpFileName); + std::vector data = ReadDumpFile(options.m_OutgoingCaptureFile); // check if the data read back from the dump file matches the original int diff = std::strncmp(data.data(), g_Data.data(), g_DataLength); -- cgit v1.2.1