diff mbox series

[rt-tests,v1,03/12] cyclicdeadline: Add quiet command line option

Message ID 20201118190642.16006-4-dwagner@suse.de
State New
Headers show
Series Add quiet command line option | expand

Commit Message

Daniel Wagner Nov. 18, 2020, 7:06 p.m. UTC
The quiet option is useful for automated test setups where
only the final result of the run is interesting. This avoids
to fill up the logs.

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

Comments

John Kacur Dec. 1, 2020, 7 a.m. UTC | #1
On Wed, 18 Nov 2020, Daniel Wagner wrote:

> The quiet option is useful for automated test setups where

> only the final result of the run is interesting. This avoids

> to fill up the logs.

> 

> Signed-off-by: Daniel Wagner <dwagner@suse.de>

> ---

>  src/sched_deadline/cyclicdeadline.8 |  6 +++++-

>  src/sched_deadline/cyclicdeadline.c | 22 +++++++++++++++++-----

>  2 files changed, 22 insertions(+), 6 deletions(-)

> 

> diff --git a/src/sched_deadline/cyclicdeadline.8 b/src/sched_deadline/cyclicdeadline.8

> index def42f77044a..59b60ca7bd31 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 "[-a [CPUSET]] [-D TIME] [-h]  [-i INTV] [-s STEP] [-t NUM]"

> +.RI "[-a [CPUSET]] [-D TIME] [-h]  [-i INTV] [-s STEP] [-t NUM] [-q]"

>  .PP

>  .SH DESCRIPTION

>  .B cyclicdeadline

> @@ -43,6 +43,10 @@ The amount to increase the deadline for each task in us. (default 500us)

>  .TP

>  .B \-t \-\-threads NUM

>  The number of threads to run as deadline (default 1)

> +.TP

> +.B \-q, \-\-quiet

> +Print a summary only on exit. Useful for automated tests, where only

> +the summary output needs to be captured.

>  .br

>  .SH AUTHOR

>  cyclicdeadline was written by Steven Rostedt <rostedt@goodmis.org>

> diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c

> index 7adc91465f44..40b514c5e7e0 100644

> --- a/src/sched_deadline/cyclicdeadline.c

> +++ b/src/sched_deadline/cyclicdeadline.c

> @@ -108,6 +108,8 @@ static int use_nsecs;

>  

>  static int mark_fd;

>  

> +static int quiet;

> +

>  static int find_mount(const char *mount, char *debugfs)

>  {

>  	char type[100];

> @@ -627,6 +629,7 @@ static void usage(int error)

>  	       "-s STEP     --step         The amount to increase the deadline for each task in us\n"

>  	       "                           (default 500us).\n"

>  	       "-t NUM      --threads      The number of threads to run as deadline (default 1).\n"

> +	       "-q          --quiet        print a summary only on exit\n"

>  	       );

>  	exit(error);

>  }

> @@ -966,13 +969,18 @@ static void loop(struct sched_data *sched_data, int nr_threads)

>  

>  	while (!shutdown) {

>  		for (i = 0; i < nr_threads; i++)

> -			print_stat(stdout, &sched_data[i], i, 0, 0);

> +			print_stat(stdout, &sched_data[i], i, 0, quiet);

>  		usleep(10000);

> -		printf("\033[%dA", nr_threads);

> +		if (!quiet)

> +			printf("\033[%dA", nr_threads);

>  	}

>  	usleep(10000);

> -	for (i = 0; i < nr_threads; i++)

> -		printf("\n");

> +	if (!quiet) {

> +		printf("\033[%dB", nr_threads + 2);

> +	} else {

> +		for (i = 0; i < nr_threads; ++i)

> +			print_stat(stdout, &sched_data[i], i, 0, 0);

> +	}

>  }

>  

>  int main(int argc, char **argv)

> @@ -1006,9 +1014,10 @@ int main(int argc, char **argv)

>  			{ "help",	no_argument,		NULL,	'h' },

>  			{ "interval",	required_argument,	NULL,	'i' },

>  			{ "threads",	required_argument,	NULL,	't' },

> +			{ "quiet",	no_argument,		NULL,	'q' },

>  			{ NULL,		0,			NULL,	0   },

>  		};

> -		c = getopt_long(argc, argv, "a::c:D:hi:t:", options, NULL);

> +		c = getopt_long(argc, argv, "a::c:D:hi:t:q", options, NULL);

>  		if (c == -1)

>  			break;

>  		switch (c) {

> @@ -1035,6 +1044,9 @@ int main(int argc, char **argv)

>  		case 'D':

>  			duration = parse_time_string(optarg);

>  			break;

> +		case 'q':

> +			quiet = 1;

> +			break;

>  		case 'h':

>  			usage(0);

>  			break;

> -- 

> 2.29.2

> 

> 

Signed-off-by: John Kacur <jkacur@redhat.com>
diff mbox series

Patch

diff --git a/src/sched_deadline/cyclicdeadline.8 b/src/sched_deadline/cyclicdeadline.8
index def42f77044a..59b60ca7bd31 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 "[-a [CPUSET]] [-D TIME] [-h]  [-i INTV] [-s STEP] [-t NUM]"
+.RI "[-a [CPUSET]] [-D TIME] [-h]  [-i INTV] [-s STEP] [-t NUM] [-q]"
 .PP
 .SH DESCRIPTION
 .B cyclicdeadline
@@ -43,6 +43,10 @@  The amount to increase the deadline for each task in us. (default 500us)
 .TP
 .B \-t \-\-threads NUM
 The number of threads to run as deadline (default 1)
+.TP
+.B \-q, \-\-quiet
+Print a summary only on exit. Useful for automated tests, where only
+the summary output needs to be captured.
 .br
 .SH AUTHOR
 cyclicdeadline was written by Steven Rostedt <rostedt@goodmis.org>
diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 7adc91465f44..40b514c5e7e0 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -108,6 +108,8 @@  static int use_nsecs;
 
 static int mark_fd;
 
+static int quiet;
+
 static int find_mount(const char *mount, char *debugfs)
 {
 	char type[100];
@@ -627,6 +629,7 @@  static void usage(int error)
 	       "-s STEP     --step         The amount to increase the deadline for each task in us\n"
 	       "                           (default 500us).\n"
 	       "-t NUM      --threads      The number of threads to run as deadline (default 1).\n"
+	       "-q          --quiet        print a summary only on exit\n"
 	       );
 	exit(error);
 }
@@ -966,13 +969,18 @@  static void loop(struct sched_data *sched_data, int nr_threads)
 
 	while (!shutdown) {
 		for (i = 0; i < nr_threads; i++)
-			print_stat(stdout, &sched_data[i], i, 0, 0);
+			print_stat(stdout, &sched_data[i], i, 0, quiet);
 		usleep(10000);
-		printf("\033[%dA", nr_threads);
+		if (!quiet)
+			printf("\033[%dA", nr_threads);
 	}
 	usleep(10000);
-	for (i = 0; i < nr_threads; i++)
-		printf("\n");
+	if (!quiet) {
+		printf("\033[%dB", nr_threads + 2);
+	} else {
+		for (i = 0; i < nr_threads; ++i)
+			print_stat(stdout, &sched_data[i], i, 0, 0);
+	}
 }
 
 int main(int argc, char **argv)
@@ -1006,9 +1014,10 @@  int main(int argc, char **argv)
 			{ "help",	no_argument,		NULL,	'h' },
 			{ "interval",	required_argument,	NULL,	'i' },
 			{ "threads",	required_argument,	NULL,	't' },
+			{ "quiet",	no_argument,		NULL,	'q' },
 			{ NULL,		0,			NULL,	0   },
 		};
-		c = getopt_long(argc, argv, "a::c:D:hi:t:", options, NULL);
+		c = getopt_long(argc, argv, "a::c:D:hi:t:q", options, NULL);
 		if (c == -1)
 			break;
 		switch (c) {
@@ -1035,6 +1044,9 @@  int main(int argc, char **argv)
 		case 'D':
 			duration = parse_time_string(optarg);
 			break;
+		case 'q':
+			quiet = 1;
+			break;
 		case 'h':
 			usage(0);
 			break;