diff mbox

[PATCHv6,33/38] example: timer: adding helper cmd line parsing

Message ID 1462984942-53326-34-git-send-email-christophe.milard@linaro.org
State Superseded
Headers show

Commit Message

Christophe Milard May 11, 2016, 4:42 p.m. UTC
timer_test now calls the helper command line parsing so that helper
can collect its options. Hence enabling process mode run.

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>
---
 example/timer/odp_timer_test.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index 87690ab..5c86555 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -257,7 +257,7 @@  static void parse_args(int argc, char *argv[], test_args_t *args)
 	int opt;
 	int long_index;
 
-	static struct option longopts[] = {
+	static const struct option longopts[] = {
 		{"count",      required_argument, NULL, 'c'},
 		{"resolution", required_argument, NULL, 'r'},
 		{"min",        required_argument, NULL, 'm'},
@@ -268,6 +268,11 @@  static void parse_args(int argc, char *argv[], test_args_t *args)
 		{NULL, 0, NULL, 0}
 	};
 
+	static const char *shortopts = "+c:r:m:x:p:t:h";
+
+	/* let helper collect its own arguments (e.g. --odph_proc) */
+	odph_parse_options(argc, argv, shortopts, longopts);
+
 	/* defaults */
 	args->cpu_count     = 0; /* all CPU's */
 	args->resolution_us = 10000;
@@ -276,9 +281,10 @@  static void parse_args(int argc, char *argv[], test_args_t *args)
 	args->period_us     = 1000000;
 	args->tmo_count     = 30;
 
+	opterr = 0; /* do not issue errors on helper options */
+
 	while (1) {
-		opt = getopt_long(argc, argv, "+c:r:m:x:p:t:h",
-				  longopts, &long_index);
+		opt = getopt_long(argc, argv, shortopts, longopts, &long_index);
 
 		if (opt == -1)
 			break;	/* No more options */