aboutsummaryrefslogtreecommitdiff
path: root/tests/profiling/gatordmock/tests
diff options
context:
space:
mode:
authorFinn Williams <Finn.Williams@arm.com>2020-02-27 16:21:41 +0000
committerJim Flynn <jim.flynn@arm.com>2020-03-18 12:59:19 +0000
commite6a2ccd09060ba93203ddc5a7f79260cedf2c147 (patch)
treec542464311f16acde42fbe01df9f4d8a78feff64 /tests/profiling/gatordmock/tests
parenteba482e691bb314e1379d29f267ec3b46a082d01 (diff)
downloadarmnn-e6a2ccd09060ba93203ddc5a7f79260cedf2c147.tar.gz
IVGCVSW-4161 Provide for per model call back registration
!armnn:2810 Signed-off-by: Finn Williams <Finn.Williams@arm.com> Change-Id: Idf56d42bd767baa5df0059a2f489f75281f8ac71
Diffstat (limited to 'tests/profiling/gatordmock/tests')
-rw-r--r--tests/profiling/gatordmock/tests/GatordMockTests.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/tests/profiling/gatordmock/tests/GatordMockTests.cpp b/tests/profiling/gatordmock/tests/GatordMockTests.cpp
index 78c6f117ac..bba848588e 100644
--- a/tests/profiling/gatordmock/tests/GatordMockTests.cpp
+++ b/tests/profiling/gatordmock/tests/GatordMockTests.cpp
@@ -11,6 +11,7 @@
#include <StreamMetadataCommandHandler.hpp>
#include <TimelineDirectoryCaptureCommandHandler.hpp>
+#include <TimelineDecoder.hpp>
#include <test/ProfilingMocks.hpp>
@@ -21,7 +22,7 @@
BOOST_AUTO_TEST_SUITE(GatordMockTests)
using namespace armnn;
-using namespace std::this_thread; // sleep_for, sleep_until
+using namespace std::this_thread;
using namespace std::chrono_literals;
BOOST_AUTO_TEST_CASE(CounterCaptureHandlingTest)
@@ -118,6 +119,9 @@ BOOST_AUTO_TEST_CASE(GatorDMockEndToEnd)
// Create the Command Handler Registry
profiling::CommandHandlerRegistry registry;
+ timelinedecoder::TimelineDecoder timelineDecoder;
+ timelineDecoder.SetDefaultCallbacks();
+
// Update with derived functors
gatordmock::StreamMetadataCommandHandler streamMetadataCommandHandler(
0, 0, packetVersionResolver.ResolvePacketVersion(0, 0).GetEncodedValue(), true);
@@ -128,18 +132,29 @@ BOOST_AUTO_TEST_CASE(GatorDMockEndToEnd)
profiling::DirectoryCaptureCommandHandler directoryCaptureCommandHandler(
0, 2, packetVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue(), true);
+ timelinedecoder::TimelineCaptureCommandHandler timelineCaptureCommandHandler(
+ 1, 1, packetVersionResolver.ResolvePacketVersion(1, 1).GetEncodedValue(), timelineDecoder);
+
timelinedecoder::TimelineDirectoryCaptureCommandHandler timelineDirectoryCaptureCommandHandler(
- 1, 0, packetVersionResolver.ResolvePacketVersion(1, 0).GetEncodedValue(), true);
+ 1, 0, packetVersionResolver.ResolvePacketVersion(1, 0).GetEncodedValue(),
+ timelineCaptureCommandHandler, true);
// Register different derived functors
registry.RegisterFunctor(&streamMetadataCommandHandler);
registry.RegisterFunctor(&counterCaptureCommandHandler);
registry.RegisterFunctor(&directoryCaptureCommandHandler);
registry.RegisterFunctor(&timelineDirectoryCaptureCommandHandler);
+
// Setup the mock service to bind to the UDS.
std::string udsNamespace = "gatord_namespace";
- gatordmock::GatordMockService mockService(registry, false);
- mockService.OpenListeningSocket(udsNamespace);
+
+ armnnUtils::Sockets::Initialize();
+ armnnUtils::Sockets::Socket listeningSocket = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+
+ if (!gatordmock::GatordMockService::OpenListeningSocket(listeningSocket, udsNamespace))
+ {
+ BOOST_FAIL("Failed to open Listening Socket");
+ }
// Enable the profiling service.
armnn::IRuntime::CreationOptions::ExternalProfilingOptions options;
@@ -154,12 +169,15 @@ BOOST_AUTO_TEST_CASE(GatorDMockEndToEnd)
profilingService.Update();
// Connect the profiling service to the mock Gatord.
- int clientFd = mockService.BlockForOneClient();
- if (-1 == clientFd)
+ armnnUtils::Sockets::Socket clientSocket =
+ armnnUtils::Sockets::Accept(listeningSocket, nullptr, nullptr, SOCK_CLOEXEC);
+ if (-1 == clientSocket)
{
BOOST_FAIL("Failed to connect client");
}
+ gatordmock::GatordMockService mockService(clientSocket, registry, false);
+
// Give the profiling service sending thread time start executing and send the stream metadata.
while (profilingService.GetCurrentState() != profiling::ProfilingState::WaitingForAck)
{
@@ -286,7 +304,7 @@ BOOST_AUTO_TEST_CASE(GatorDMockEndToEnd)
mockService.WaitForReceivingThread();
options.m_EnableProfiling = false;
profilingService.ResetExternalProfilingOptions(options, true);
-
+ armnnUtils::Sockets::Close(listeningSocket);
// Future tests here will add counters to the ProfilingService, increment values and examine
// PeriodicCounterCapture data received. These are yet to be integrated.
}