From 366023fcb63d0ade5bd742ede2fc27899296877c Mon Sep 17 00:00:00 2001 From: Colm Donelan Date: Thu, 5 Sep 2019 10:03:56 +0100 Subject: IVGCVSW-3719 Create test program executable. Introduce a new test utility that simulates the Gatord service. This will be used to test the external profiling features. Change-Id: Ib7c75c1302650e140945cd66d272c23af3aac760 Signed-off-by: Colm Donelan --- tests/profiling/CommandLineProcessor.cpp | 59 ++++++++++++++++++++++++++++++++ tests/profiling/CommandLineProcessor.hpp | 25 ++++++++++++++ tests/profiling/GatordMockMain.cpp | 18 ++++++++++ 3 files changed, 102 insertions(+) create mode 100644 tests/profiling/CommandLineProcessor.cpp create mode 100644 tests/profiling/CommandLineProcessor.hpp create mode 100644 tests/profiling/GatordMockMain.cpp (limited to 'tests') diff --git a/tests/profiling/CommandLineProcessor.cpp b/tests/profiling/CommandLineProcessor.cpp new file mode 100644 index 0000000000..6affbbe2b8 --- /dev/null +++ b/tests/profiling/CommandLineProcessor.cpp @@ -0,0 +1,59 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "CommandLineProcessor.hpp" + +#include + +#include + +namespace armnn +{ +namespace gatordmock +{ + +bool CommandLineProcessor::ProcessCommandLine(int argc, char *argv[]) +{ + namespace po = boost::program_options; + + po::options_description desc("Options"); + try + { + desc.add_options()("help,h", "Display help messages"); + } + catch (const std::exception& e) + { + std::cerr << "Fatal internal error: [" << e.what() << "]" << std::endl; + return false; + } + + po::variables_map vm; + try + { + po::store(po::parse_command_line(argc, argv, desc), vm); + + if (vm.count("help") || argc <= 1) + { + std::cout << "Simulate a Gatord server to interact with ArmNN external profiling." << std::endl; + std::cout << std::endl; + std::cout << desc << std::endl; + return false; + } + + po::notify(vm); + } + catch (const po::error& e) + { + std::cerr << e.what() << std::endl << std::endl; + std::cerr << desc << std::endl; + return false; + } + + return true; +} + +} // namespace gatordmock + +} // namespace armnn \ No newline at end of file diff --git a/tests/profiling/CommandLineProcessor.hpp b/tests/profiling/CommandLineProcessor.hpp new file mode 100644 index 0000000000..441d7cddd9 --- /dev/null +++ b/tests/profiling/CommandLineProcessor.hpp @@ -0,0 +1,25 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// +#pragma once + +namespace armnn +{ + +namespace gatordmock +{ + +// Parses the command line to extract: +// + +class CommandLineProcessor +{ +public: + bool ProcessCommandLine(int argc, char *argv[]); + +}; + +} // namespace gatordmock + +} // namespace armnn diff --git a/tests/profiling/GatordMockMain.cpp b/tests/profiling/GatordMockMain.cpp new file mode 100644 index 0000000000..91fa907795 --- /dev/null +++ b/tests/profiling/GatordMockMain.cpp @@ -0,0 +1,18 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "CommandLineProcessor.hpp" + +#include + +int main(int argc, char *argv[]) +{ + armnn::gatordmock::CommandLineProcessor cmdline; + if (!cmdline.ProcessCommandLine(argc, argv)) + { + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} -- cgit v1.2.1