aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Milard <christophe.milard@linaro.org>2016-04-14 19:21:35 +0200
committerMaxim Uvarov <maxim.uvarov@linaro.org>2016-05-23 15:07:00 +0300
commit3e6d2cf0b1ac2ef5cfddb779abe7e8b04a286355 (patch)
tree155ebb1090a106216d5aac2a6a1fd1d6ea031773
parent92c5d1182f7a298a60311d439beb559ef6b629e5 (diff)
example: timer: adding helper cmd line parsing
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> Reviewed-by: Brian Brooks <brian.brooks@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rw-r--r--example/timer/odp_timer_test.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index 2a33085f9..cb58dfe4c 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -259,7 +259,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'},
@@ -270,6 +270,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;
@@ -278,9 +283,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 */