aboutsummaryrefslogtreecommitdiff
path: root/tests/profiling/gatordmock/GatordMockMain.cpp
diff options
context:
space:
mode:
authorColm Donelan <Colm.Donelan@arm.com>2019-10-11 13:09:49 +0100
committerColm Donelan <Colm.Donelan@arm.com>2019-10-11 13:12:37 +0100
commita21620d32a8a0a8d527c061e2a22d51009d75877 (patch)
treeb08ffee4cddb1bb3b1d206c67ea80bc2093d7bf5 /tests/profiling/gatordmock/GatordMockMain.cpp
parent67ef2a52c3cdcc37538d77711bbcea2f0e5655e5 (diff)
downloadarmnn-a21620d32a8a0a8d527c061e2a22d51009d75877.tar.gz
IVGCVSW-3721 Add support for startup sequence (Mock Gatord service).
* Receive and process the stream metadata from the client. * Send the connection ack packet. * Wait in a receiving thread and print the packets. * GatordMockTest and Impl for PeriodicCounterCapture CommandHandler * CaptureData class to retain packet data * MockUtils * Update SocketProfilingConnection to fix non blocking receipt of packets. * Restructure directory layout following review comments. * Extract the mock service into a static library in the cmake files. Signed-off-by: Colm Donelan <Colm.Donelan@arm.com> Signed-off-by: Keith Davis <keith.davis@arm.com> Signed-off-by: Mike Kelly <mike.kelly@arm.com> Signed-off-by: Finn Williams <Finn.Williams@arm.com> Signed-off-by: Kevin May <kevin.may@arm.com> Change-Id: I33c1c9f93976708c9315f71290d42cff53b8c075
Diffstat (limited to 'tests/profiling/gatordmock/GatordMockMain.cpp')
-rw-r--r--tests/profiling/gatordmock/GatordMockMain.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/profiling/gatordmock/GatordMockMain.cpp b/tests/profiling/gatordmock/GatordMockMain.cpp
new file mode 100644
index 0000000000..500b016669
--- /dev/null
+++ b/tests/profiling/gatordmock/GatordMockMain.cpp
@@ -0,0 +1,71 @@
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "CommandFileParser.hpp"
+#include "CommandLineProcessor.hpp"
+#include "GatordMockService.hpp"
+#include "MockUtils.hpp"
+#include "PeriodicCounterCaptureCommandHandler.hpp"
+
+#include <string>
+
+int main(int argc, char *argv[])
+{
+ // Process command line arguments
+ armnn::gatordmock::CommandLineProcessor cmdLine;
+ if (!cmdLine.ProcessCommandLine(argc, argv))
+ {
+ return EXIT_FAILURE;
+ }
+
+ // Initialise functors and register into the CommandHandlerRegistry
+ uint32_t version = 1;
+
+ // Create headers
+ uint32_t counterCaptureCommandHeader = armnn::gatordmock::ConstructHeader(1,0,0);
+
+ // Create the Command Handler Registry
+ armnn::profiling::CommandHandlerRegistry registry;
+
+ // Update with derived functors
+ armnn::gatordmock::PeriodicCounterCaptureCommandHandler counterCaptureCommandHandler(counterCaptureCommandHeader,
+ version,
+ cmdLine.IsEchoEnabled());
+
+ // Register different derived functors
+ registry.RegisterFunctor(&counterCaptureCommandHandler);
+
+ armnn::gatordmock::GatordMockService mockService(registry, cmdLine.IsEchoEnabled());
+
+ if (!mockService.OpenListeningSocket(cmdLine.GetUdsNamespace()))
+ {
+ return EXIT_FAILURE;
+ }
+
+ // Wait for a single connection.
+ if (-1 == mockService.BlockForOneClient())
+ {
+ return EXIT_FAILURE;
+ }
+
+ // Send receive the strweam metadata and send connection ack.
+ if (!mockService.WaitForStreamMetaData())
+ {
+ return EXIT_FAILURE;
+ }
+ mockService.SendConnectionAck();
+
+ // Prepare to receive data.
+ mockService.LaunchReceivingThread();
+
+ // Process the SET and WAIT command from the file.
+ armnn::gatordmock::CommandFileParser commandLineParser;
+ commandLineParser.ParseFile(cmdLine.GetCommandFile(), mockService);
+
+ // Once we've finished processing the file wait for the receiving thread to close.
+ mockService.WaitForReceivingThread();
+
+ return EXIT_SUCCESS;
+}