aboutsummaryrefslogtreecommitdiff
path: root/tests/profiling/gatordmock/CommandFileParser.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/CommandFileParser.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/CommandFileParser.cpp')
-rw-r--r--tests/profiling/gatordmock/CommandFileParser.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/profiling/gatordmock/CommandFileParser.cpp b/tests/profiling/gatordmock/CommandFileParser.cpp
new file mode 100644
index 0000000000..e86763b55f
--- /dev/null
+++ b/tests/profiling/gatordmock/CommandFileParser.cpp
@@ -0,0 +1,76 @@
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "CommandFileParser.hpp"
+
+#include <algorithm>
+#include <fstream>
+#include <iostream>
+#include <iterator>
+
+namespace armnn
+{
+
+namespace gatordmock
+{
+
+void CommandFileParser::ParseFile(std::string CommandFile, GatordMockService& mockService)
+{
+ std::ifstream infile(CommandFile);
+ std::string line;
+
+ std::cout << "Parsing command file: " << CommandFile << std::endl;
+
+ while (std::getline(infile, line))
+ {
+ std::istringstream iss(line);
+
+ std::vector<std::string> tokens;
+
+ std::copy(std::istream_iterator<std::string>(iss), std::istream_iterator<std::string>(),
+ std::back_inserter(tokens));
+
+ std::string command = tokens[0];
+
+ if (command == "SET")
+ {
+ // Expected format for the SET command
+ //
+ // SET 500000 1 2 5 10
+ //
+ // This breaks down to:
+ // SET command
+ // 500000 polling period in micro seconds
+ // 1 2 5 10 counter list
+
+ uint period = static_cast<uint>(std::stoul(tokens[1]));
+
+ std::vector<uint16_t> counters;
+
+ std::transform(tokens.begin() + 2, tokens.end(), std::back_inserter(counters),
+ [](const std::string& str) { return static_cast<uint16_t>(std::stoul(str)); });
+
+ mockService.SendPeriodicCounterSelectionList(period, counters);
+ }
+ else if (command == "WAIT")
+ {
+ // Expected format for the SET command
+ //
+ // WAIT 11000000
+ //
+ // This breaks down to:
+ // WAIT command
+ // 11000000 timeout period in micro seconds
+
+ uint timeout = static_cast<uint>(std::stoul(tokens[1]));
+
+ mockService.WaitCommand(timeout);
+ }
+ }
+}
+
+} // namespace gatordmock
+
+} // namespace armnn