All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Wagner <dwagner@suse.de>
To: Clark Williams <williams@redhat.com>, John Kacur <jkacur@redhat.com>
Cc: linux-rt-users@vger.kernel.org, Daniel Wagner <dwagner@suse.de>
Subject: [rt-tests v2 04/18] cyclicdeadline: Add long command line options
Date: Wed,  7 Oct 2020 10:56:39 +0200	[thread overview]
Message-ID: <20201007085653.11961-5-dwagner@suse.de> (raw)
In-Reply-To: <20201007085653.11961-1-dwagner@suse.de>

Use getopt_long to parse long version of the commands.

Change the 'a/affinity' option to handle all cases including what '-c'
did. We still keep '-c' silently supported to avoid breaking existing
users.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/sched_deadline/cyclicdeadline.8 | 17 +++++-------
 src/sched_deadline/cyclicdeadline.c | 42 ++++++++++++++++++++---------
 2 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/src/sched_deadline/cyclicdeadline.8 b/src/sched_deadline/cyclicdeadline.8
index 6df7faf445f9..def42f77044a 100644
--- a/src/sched_deadline/cyclicdeadline.8
+++ b/src/sched_deadline/cyclicdeadline.8
@@ -17,7 +17,7 @@ cyclicdeadline \- This program is used to test the deadline scheduler (SCHED_DEA
 .PP
 .SH SYNOPSIS
 .B cyclicdeadline
-.RI "[-ha] [-c CPUSET] [-D TIME] [-i INTV] [-s STEP] [-t NUM]"
+.RI "[-a [CPUSET]] [-D TIME] [-h]  [-i INTV] [-s STEP] [-t NUM]"
 .PP
 .SH DESCRIPTION
 .B cyclicdeadline
@@ -25,26 +25,23 @@ is a cyclictest style program for testing the deadline scheduler
 .PP
 .SH OPTIONS
 .TP
-.B \-a
-Use all CPUs
-.TP
-.B \-c CPUSET
+.B \-a \-\-affinity [CPUSET]
 Comma / hypen separated list of CPUs to run deadline tasks on
 .TP
-.B \-D TIME
+.B \-D \-\-duration TIME
 Specify a length for the test to run
 Append 'm', 'h', or 'd' to specify minutes, hours, or days
 .TP
-.B \-h
+.B \-h \-\-help
 Show this help menu
 .TP
-.B \-i INTV
+.B \-i \-\-interval INTV
 The shortest deadline for the tasks in us. (default 1000us)
 .TP
-.B \-s STEP
+.B \-s \-\-step STEP
 The amount to increase the deadline for each task in us. (default 500us)
 .TP
-.B \-t NUM
+.B \-t \-\-threads NUM
 The number of threads to run as deadline (default 1)
 .br
 .SH AUTHOR
diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 310880805553..5f5cdfa08f14 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -17,6 +17,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <signal.h>
+#include <getopt.h>
 
 #include <sys/syscall.h>
 #include <sys/types.h>
@@ -635,18 +636,19 @@ static void usage(int error)
 	printf("cyclicdeadline V %1.2f\n", VERSION);
 	printf("Usage:\n"
 	       "cyclicdeadline <options>\n\n"
-	       "-a                         Use all CPUs\n"
-	       "-c CPUSET                  Comma/hyphen separated list of CPUs to run deadline\n"
-	       "                           tasks on.\n"
-	       "-D TIME                    Specify a length for the test run.\n"
+	       "-a [CPUSET] --affinity     Comma/hyphen separated list of CPUs to run deadline\n"
+	       "                           tasks on. An empty CPUSET runs on all CPUs a deadline\n"
+	       "                           task.\n"
+	       "                           on CPU 4, and thread #5 on CPU 5.\n"
+	       "-D TIME     --duration     Specify a length for the test run.\n"
 	       "                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
 	       "                           days\n"
-	       "-h                         Show this help menu.\n"
-	       "-i INTV                    The shortest deadline for the tasks in us\n"
+	       "-h          --help         Show this help menu.\n"
+	       "-i INTV     --interval     The shortest deadline for the tasks in us\n"
 	       "                           (default 1000us).\n"
-	       "-s STEP                    The amount to increase the deadline for each task in us\n"
+	       "-s STEP     --step         The amount to increase the deadline for each task in us\n"
 	       "                           (default 500us).\n"
-	       "-t NUM                     The number of threads to run as deadline (default 1).\n"
+	       "-t NUM      --threads      The number of threads to run as deadline (default 1).\n"
 	       );
 	exit(error);
 }
@@ -1033,15 +1035,29 @@ int main (int argc, char **argv)
 		exit(-1);
 	}
 
-	while ((c = getopt(argc, argv, "+hac:i:s:t:D:")) >= 0) {
+	for (;;) {
+		static struct option options[] = {
+			{ "affinity",	optional_argument,	NULL,	'a' },
+			{ "duration",	required_argument,	NULL,	'D' },
+			{ "help",	no_argument,		NULL,	'h' },
+			{ "interval",	required_argument,	NULL,	'i' },
+			{ "threads",	required_argument,	NULL,	't' },
+			{ NULL,		0,			NULL,	0   },
+		};
+		c = getopt_long(argc, argv, "a::c:D:hi:t:", options, NULL);
+		if (c == -1)
+			break;
 		switch (c) {
 		case 'a':
-			all_cpus = 1;
+		case 'c':
 			if (!nr_threads)
 				nr_threads = cpu_count;
-			break;
-		case 'c':
-			setcpu = optarg;
+			if (optarg)
+				setcpu = optarg;
+			else if (optind < argc)
+				setcpu = argv[optind];
+			else
+				all_cpus = 1;
 			break;
 		case 'i':
 			interval = atoi(optarg);
-- 
2.28.0


  parent reply	other threads:[~2020-10-07  8:57 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
2020-10-07  8:56 ` [rt-tests v2 01/18] rt-util: Move parse_cpumask from cyclictest Daniel Wagner
2020-10-23 15:46   ` John Kacur
2020-10-26 18:34     ` Daniel Wagner
2020-10-29 15:45       ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 02/18] cyclictest: Use numa library helpers in get_available_cpus() Daniel Wagner
2020-10-23 15:55   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 03/18] cyclicdeadline: Streamline usage output and man page Daniel Wagner
2020-10-23 16:01   ` John Kacur
2020-10-07  8:56 ` Daniel Wagner [this message]
2020-10-23 16:07   ` [rt-tests v2 04/18] cyclicdeadline: Add long command line options John Kacur
2020-10-27  8:07     ` Daniel Wagner
2020-10-07  8:56 ` [rt-tests v2 05/18] deadline_test: Streamline usage output and man page Daniel Wagner
2020-10-23 16:10   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 06/18] oslat: " Daniel Wagner
2020-10-23 17:19   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 07/18] oslat: Use string parser utilies Daniel Wagner
2020-10-23 17:25   ` John Kacur
2020-10-27  8:09     ` Daniel Wagner
2020-10-07  8:56 ` [rt-tests v2 08/18] pip_stress: Add command line parser Daniel Wagner
2020-10-23 17:33   ` John Kacur
2020-10-27  8:09     ` Daniel Wagner
2020-10-07  8:56 ` [rt-tests v2 09/18] pi_stress: Streamline usage output and man page Daniel Wagner
2020-10-07  8:56 ` [rt-tests v2 10/18] pmqtest: " Daniel Wagner
2020-10-23 18:18   ` John Kacur
2020-10-23 18:23   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 11/18] ptsematest: " Daniel Wagner
2020-10-23 18:25   ` John Kacur
2021-02-10 16:08   ` Peter Xu
2021-02-10 16:25     ` Peter Xu
2021-02-10 16:30       ` Daniel Wagner
2021-02-10 16:33         ` Peter Xu
2021-02-10 16:35         ` Daniel Wagner
2021-02-10 17:00           ` Peter Xu
2021-02-10 17:24             ` Daniel Wagner
2020-10-07  8:56 ` [rt-tests v2 12/18] queuelat: Streamline usage " Daniel Wagner
2020-10-23 18:40   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 13/18] rt-migrate-test: " Daniel Wagner
2020-10-23 18:47   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 14/18] signaltest: " Daniel Wagner
2020-10-23 18:50   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 15/18] sigwaittest: " Daniel Wagner
2020-10-23 18:51   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 16/18] ssdd: " Daniel Wagner
2020-10-23 18:57   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 17/18] svsematest: " Daniel Wagner
2020-10-23 18:59   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 18/18] hackbench: " Daniel Wagner
2020-10-23 19:03   ` John Kacur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201007085653.11961-5-dwagner@suse.de \
    --to=dwagner@suse.de \
    --cc=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.