aboutsummaryrefslogtreecommitdiff
path: root/tests/CxxoptsUtils.hpp
diff options
context:
space:
mode:
authorJames Ward <james.ward@arm.com>2020-10-12 14:17:36 +0100
committerJames Ward <james.ward@arm.com>2020-10-14 12:41:58 +0000
commitc89829f1f47855227f9a842c979f3a43800ea826 (patch)
tree40d58dfa85ff4f8ebf03f5b594ace1775fae2c22 /tests/CxxoptsUtils.hpp
parentf9f33a04626756b73e6fd5c89092fd4bcb504b16 (diff)
downloadarmnn-c89829f1f47855227f9a842c979f3a43800ea826.tar.gz
IVGCVSW-5280 Switch tests/InferenceTest and derived tests over to cxxopts
* refactor AddCommandLineOptions() functions to allow checking of required options * add CxxoptsUtils.hpp file for convenience functions !referencetests:268500 Signed-off-by: James Ward <james.ward@arm.com> Change-Id: Ica954b210b2981b7cd10995f0d75fcb2a2f7b443
Diffstat (limited to 'tests/CxxoptsUtils.hpp')
-rw-r--r--tests/CxxoptsUtils.hpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/CxxoptsUtils.hpp b/tests/CxxoptsUtils.hpp
new file mode 100644
index 0000000000..518fc1be67
--- /dev/null
+++ b/tests/CxxoptsUtils.hpp
@@ -0,0 +1,27 @@
+//
+// Copyright © 2020 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <cxxopts/cxxopts.hpp>
+
+/**
+ * Ensure all mandatory command-line parameters have been passed to cxxopts.
+ * @param result returned from the cxxopts parse(argc, argv) call
+ * @param required vector of strings listing the mandatory parameters to be input from the command-line
+ * @return boolean value - true if all required parameters satisfied, false otherwise
+ * */
+inline bool CheckRequiredOptions(const cxxopts::ParseResult& result, const std::vector<std::string>& required)
+{
+ for(const std::string& str : required)
+ {
+ if(result.count(str) == 0)
+ {
+ std::cerr << "--" << str << " parameter is mandatory" << std::endl;
+ return false;
+ }
+ }
+ return true;
+}