From f7017cb58b25f6047f2fa90cdb5cb06f77217089 Mon Sep 17 00:00:00 2001 From: Matthew Sloyan Date: Wed, 30 Sep 2020 13:07:51 +0100 Subject: IVGCVSW-5283 Switch tests/profiling/gatordmock over to cxxopts Signed-off-by: Matthew Sloyan Change-Id: I4f06a414d6bd5f18c2ced882ac518052ed371cfc --- .../profiling/gatordmock/CommandLineProcessor.cpp | 57 ++++++++++++---------- 1 file changed, 31 insertions(+), 26 deletions(-) (limited to 'tests') diff --git a/tests/profiling/gatordmock/CommandLineProcessor.cpp b/tests/profiling/gatordmock/CommandLineProcessor.cpp index 2903dbbfe3..c1b6a6b2b3 100644 --- a/tests/profiling/gatordmock/CommandLineProcessor.cpp +++ b/tests/profiling/gatordmock/CommandLineProcessor.cpp @@ -5,7 +5,7 @@ #include "CommandLineProcessor.hpp" -#include +#include #include namespace armnn @@ -15,19 +15,24 @@ namespace gatordmock bool CommandLineProcessor::ProcessCommandLine(int argc, char *argv[]) { - namespace po = boost::program_options; - po::options_description desc("Options"); + cxxopts::Options options("GatordMock", + "Simulate a Gatord server to interact with ArmNN external profiling."); + try { - desc.add_options() - ("help,h", "Display help messages") - ("file,f", po::value(&m_File), - "The path to the file that contains instructions for the mock gatord") - ("namespace,n", po::value(&m_UdsNamespace)->default_value("gatord_namespace"), - "The Unix domain socket namespace this server will bind to.\n" - "This will always be prepended with \\0 to use the abstract namespace") - ("echo,e", po::bool_switch(&m_Echo)->default_value(false), - "Echo packets sent and received to stdout. Disabled by default.\n"); + options.add_options() + ("h,help", "Display help messages") + ("f,file", + "The path to the file that contains instructions for the mock gatord.", + cxxopts::value(m_File)) + ("n,namespace", + "The Unix domain socket namespace this server will bind to.\n" + "This will always be prepended with \\0 to use the abstract namespace", + cxxopts::value(m_UdsNamespace)->default_value("gatord_namespace")) + ("e,echo", + "Echo packets sent and received to stdout. Disabled by default. " + "Default value = false.", + cxxopts::value(m_Echo)->default_value("false")); } catch (const std::exception& e) { @@ -35,32 +40,32 @@ bool CommandLineProcessor::ProcessCommandLine(int argc, char *argv[]) return false; } - po::variables_map vm; try { - po::store(po::parse_command_line(argc, argv, desc), vm); + auto result = options.parse(argc, argv); - if (vm.count("help")) + if (result.count("help")) { - std::cout << "Simulate a Gatord server to interact with ArmNN external profiling." << std::endl; - std::cout << std::endl; - std::cout << desc << std::endl; + std::cout << options.help() << std::endl; return false; } + // Currently the file parameter is mandatory. - if (!vm.count("file")) + if (!result.count("file")) { - std::cout << std::endl << "*** Expected --file or -f parameter." << std::endl; - std::cout << std::endl; - std::cout << desc << std::endl; + std::cout << "-f/--file parameter is mandatory." << std::endl; return false; } - po::notify(vm); + + // Sets bool value correctly. + if (result.count("echo")) + { + m_Echo = true; + } } - catch (const po::error& e) + catch (const cxxopts::OptionException& e) { - std::cerr << e.what() << std::endl << std::endl; - std::cerr << desc << std::endl; + std::cerr << e.what() << std::endl; return false; } -- cgit v1.2.1