All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix the processing of optional options for cyclictest
@ 2008-06-27  8:10 John Kacur
  2008-06-27 14:34 ` Leon Woestenberg
  0 siblings, 1 reply; 6+ messages in thread
From: John Kacur @ 2008-06-27  8:10 UTC (permalink / raw)
  To: linux-rt-users, Thomas Gleixner, Steven Rostedt, Leon Woestenberg

Problem: when running cyclic test, short options are not parsing
optional arguments correctly when followed by a space.
"-t3" works, but "-t 3" does not.

The following patch fixes the parsing for -a (affinity) and -t
(threads) whether there is a space or no space after the optional
argument, and of course it does the right thing if there is no
argument.

Please apply, because there is the possibility that people are not
testing what they think, especially if tests are automated.

Thanks

Author: John Kacur <jkacur@gmail.com>  2008-06-27 09:47:56
Committer: John Kacur <jkacur@gmail.com>  2008-06-27 09:47:56
Parent: 7a052daef09a5af77815e21fbff84ef580110dee (rt-tests/Makefile:
Import an updated version number into RPM spec file)
Branch: master
Follows: v0.22
Precedes:

    -Fix the processing of options with optional parameters, so that the user
    can write -tNUM or -t NUM and it will work as expected. This was done
    for the -t and -a options
    - Modify the usage messages to correspond with the way the program makes use
    of the options.

------------------------- src/cyclictest/cyclictest.c -------------------------
index d3f545f..bf60f09 100644
@@ -571,7 +571,8 @@ static void display_help(void)
 	printf("cyclictest V %1.2f\n", VERSION_STRING);
 	printf("Usage:\n"
 	       "cyclictest <options>\n\n"
-	       "-a       --affinity        run thread #N on processor #N, if
possible\n"
+	       "-a [NUM] --affinity        run thread #N on processor #N, if
possible\n"
+	       "                           with NUM restricts it to the
first NUM processors\n"
 	       "-a PROC  --affinity=PROC   run all threads on processor #PROC\n"
 	       "-b USEC  --breaktrace=USEC send break trace command when
latency > USEC\n"
 	       "-B       --preemptirqs     both preempt and irqsoff tracing
(used with -b)\n"
@@ -591,7 +592,9 @@ static void display_help(void)
 	       "-r       --relative        use relative timer instead of absolute\n"
 	       "-s       --system          use sys_nanosleep and sys_setitimer\n"
 	       "-t       --threads         one thread per available processor\n"
-	       "-t NUM   --threads=NUM     number of threads: without -t default=1\n"
+	       "-t [NUM] --threads=NUM     number of threads:\n"
+	       "                           without NUM, threads = max_cpus\n"
+	       "                           without -t default = 1\n"
 	       "-v       --verbose         output values on stdout for statistics\n"
 	       "                           format: n:c:v n=tasknum c=count
v=value in us\n");
 	exit(0);
@@ -661,8 +664,12 @@ static void process_options (int argc, char *argv[])
 			if (optarg != NULL) {
 				affinity = atoi(optarg);
 				setaffinity = AFFINITY_SPECIFIED;
-			} else
+			} else if (optind<argc && atoi(argv[optind])) {
+				affinity = atoi(argv[optind]);
+				setaffinity = AFFINITY_SPECIFIED;
+			} else {
 				setaffinity = AFFINITY_USEALL;
+			}
 			break;
 		case 'b': tracelimit = atoi(optarg); break;
 		case 'B': tracetype = IRQPREEMPTOFF; break;
@@ -682,6 +689,8 @@ static void process_options (int argc, char *argv[])
 		case 't':
 			if (optarg != NULL)
 				num_threads = atoi(optarg);
+			else if (optind<argc && atoi(argv[optind]))
+				num_threads = atoi(argv[optind]);
 			else
 				num_threads = max_cpus;
 			break;

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-07-06 17:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-27  8:10 [PATCH] Fix the processing of optional options for cyclictest John Kacur
2008-06-27 14:34 ` Leon Woestenberg
2008-06-27 15:59   ` Steven Rostedt
2008-06-27 16:06     ` Clark Williams
2008-06-27 19:22       ` John Kacur
2008-07-06 17:33         ` Thomas Gleixner

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.