rt-tests/SOURCES/rt-tests-queuelat-Fixes-to-...

81 lines
2.6 KiB
Diff

From d823298c8b09b9cc406b272ea91cc2b5d697cc08 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Thu, 23 Jan 2020 19:17:21 +0100
Subject: [PATCH 7/8] rt-tests: queuelat: Fixes to man page and display_help
- Make sure that help is displayed and not just the message
"Unknown option" when the options are incorrect.
- Add -q to the man page and to the print_help()
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/queuelat/queuelat.8 | 4 +++-
src/queuelat/queuelat.c | 22 +++++++++++++---------
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/queuelat/queuelat.8 b/src/queuelat/queuelat.8
index d68beb98bff7..f67a0bb7556e 100644
--- a/src/queuelat/queuelat.8
+++ b/src/queuelat/queuelat.8
@@ -52,7 +52,9 @@ TSC frequency in MHz.
.TP
.B \-t timeout
Timeout in seconds to quit the program.
-
+.TP
+.B \-q min_queue_len_to_print_trace
+Minimum queue length to print in the trace
.SH AUTHOR
queuelat was written by Marcelo Tosatti <mtosatti@redhat.com>
diff --git a/src/queuelat/queuelat.c b/src/queuelat/queuelat.c
index 98346f346f82..7e5e35768a8b 100644
--- a/src/queuelat/queuelat.c
+++ b/src/queuelat/queuelat.c
@@ -571,6 +571,7 @@ void print_help(void)
printf("-p million-packet-per-sec (million packets per second) (float)\n");
printf("-f tsc-freq-mhz (TSC frequency in MHz) (float)\n");
printf("-t timeout (timeout, in seconds) (int)\n");
+ printf("-q min_queue_len_to_print_trace (int)\n");
}
int main(int argc, char **argv)
@@ -616,22 +617,25 @@ int main(int argc, char **argv)
return 0;
case '?':
if (optopt == 'm' || optopt == 'c' || optopt == 'p' ||
- optopt == 'f' || optopt == 't' || optopt == 'q')
+ optopt == 'f' || optopt == 't' || optopt == 'q') {
printf ("Option -%c requires an argument.\n", optopt);
- else if (isprint (optopt))
+ } else if (isprint (optopt)) {
printf ("Unknown option `-%c'.\n", optopt);
- else
- printf ( "Unknown option character `\\x%x'.\n",
-
-optopt);
+ print_help();
+ return 1;
+ } else {
+ printf ( "Unknown option character `\\x%x'.\n", optopt);
+ print_help();
return 1;
- default:
- abort ();
+ }
+ break;
+ default:
+ abort ();
}
if (mvalue == NULL || cvalue == NULL || pvalue == NULL ||
fvalue == NULL) {
- printf("options -m, -c, -p and -f required.\n");
+ printf("options -m, -c, -p and -f are required.\n");
printf("usage: %s -m maxlatency -c cycles_per_packet -p mpps(million-packet-per-sec) -f tsc_freq_mhz [-t timeout (in secs)] [-q min_queue_len_to_print_trace]\n", argv[0]);
return 1;
}
--
2.20.1