From: John Kacur <jkacur@redhat.com>
To: Daniel Wagner <dwagner@suse.de>
Cc: Clark Williams <williams@redhat.com>, linux-rt-users@vger.kernel.org
Subject: Re: [rt-tests v1 07/12] ptsematest: Add quiet command line option
Date: Tue, 1 Dec 2020 02:09:02 -0500 (EST) [thread overview]
Message-ID: <af10cfde-f6e1-e1ce-302b-9a7cdcb1132@redhat.com> (raw)
In-Reply-To: <20201118190642.16006-8-dwagner@suse.de>
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/ptsematest/ptsematest.8 | 5 ++++-
> src/ptsematest/ptsematest.c | 20 ++++++++++++++++----
> 2 files changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/src/ptsematest/ptsematest.8 b/src/ptsematest/ptsematest.8
> index 05a0cdfd3657..a435e7a6221c 100644
> --- a/src/ptsematest/ptsematest.8
> +++ b/src/ptsematest/ptsematest.8
> @@ -4,7 +4,7 @@
> \fBptsematest\fR \- Start two threads and measure the latency of interprocess communication with POSIX mutex.
> .SH "SYNOPSIS"
> .LP
> -ptsematest [-a|--affinity [PROC]] [-b|--breaktrace USEC] [-d|--distance DIST] [-D|--duration TIME] [-h|--help] [-i|--interval INTV] [-l|--loops LOOPS] [-p|--prio PRIO] [-S|--smp] [-t|--threads [NUM]]
> +ptsematest [-a|--affinity [PROC]] [-b|--breaktrace USEC] [-d|--distance DIST] [-D|--duration TIME] [-h|--help] [-i|--interval INTV] [-l|--loops LOOPS] [-p|--prio PRIO] [-q|--quiet] [-S|--smp] [-t|--threads [NUM]]
> .br
> .SH "DESCRIPTION"
> .LP
> @@ -38,6 +38,9 @@ Set the number of loops. The default is 0 (endless). This option is useful for a
> .B \-p, \-\-prio=PRIO
> Set the priority of the process.
> .TP
> +.B \-q, \-\-quiet
> +Print a summary only on exit. Useful for automated tests, where only the summary output needs to be captured.
> +.TP
> .B \-S, \-\-smp
> SMP testing: options -a -t and same priority
> .TP
> diff --git a/src/ptsematest/ptsematest.c b/src/ptsematest/ptsematest.c
> index 69b4e1221361..2e392299fdc4 100644
> --- a/src/ptsematest/ptsematest.c
> +++ b/src/ptsematest/ptsematest.c
> @@ -156,6 +156,7 @@ static void display_help(int error)
> "-i INTV --interval=INTV base interval of thread in us default=1000\n"
> "-l LOOPS --loops=LOOPS number of loops: default=0(endless)\n"
> "-p PRIO --prio=PRIO priority\n"
> + "-q --quiet print a summary only on exit\n"
> "-S --smp SMP testing: options -a -t and same priority\n"
> " of all threads\n"
> "-t --threads one thread per available processor\n"
> @@ -178,6 +179,7 @@ static int interval = 1000;
> static int distance = 500;
> static int smp;
> static int sameprio;
> +static int quiet;
>
> static void process_options(int argc, char *argv[])
> {
> @@ -196,11 +198,12 @@ static void process_options(int argc, char *argv[])
> {"interval", required_argument, NULL, 'i'},
> {"loops", required_argument, NULL, 'l'},
> {"priority", required_argument, NULL, 'p'},
> + {"quiet", no_argument , NULL, 'q'},
> {"smp", no_argument, NULL, 'S'},
> {"threads", optional_argument, NULL, 't'},
> {NULL, 0, NULL, 0}
> };
> - int c = getopt_long (argc, argv, "a::b:d:i:l:D:p:St::h",
> + int c = getopt_long (argc, argv, "a::b:d:i:l:D:p:qSt::h",
> long_options, &option_index);
> if (c == -1)
> break;
> @@ -228,6 +231,7 @@ static void process_options(int argc, char *argv[])
> case 'h': display_help(0); break;
> case 'l': max_cycles = atoi(optarg); break;
> case 'p': priority = atoi(optarg); break;
> + case 'q': quiet = 1; break;
> case 'S':
> smp = 1;
> num_threads = max_cpus;
> @@ -293,6 +297,9 @@ static void print_stat(FILE *fp, struct params *receiver, struct params *sender,
> {
> int i;
>
> + if (quiet)
> + return;
> +
> for (i = 0; i < num_threads; i++) {
> printf("#%1d: ID%d, P%d, CPU%d, I%ld; #%1d: ID%d, P%d, CPU%d, Cycles %d\n",
> i*2, receiver[i].tid, receiver[i].priority, receiver[i].cpu,
> @@ -391,8 +398,9 @@ int main(int argc, char *argv[])
> shutdown |= receiver[i].shutdown | sender[i].shutdown;
>
> if (receiver[0].samples > oldsamples || shutdown) {
> - print_stat(stdout, receiver, sender, 0, 0);
> - printf("\033[%dA", num_threads*2);
> + print_stat(stdout, receiver, sender, 0, quiet);
> + if (!quiet)
> + printf("\033[%dA", num_threads*2);
> }
>
> sigemptyset(&sigset);
> @@ -405,7 +413,11 @@ int main(int argc, char *argv[])
> sigemptyset(&sigset);
> pthread_sigmask(SIG_SETMASK, &sigset, NULL);
> }
> - printf("\033[%dB", num_threads*2 + 2);
> +
> + if (!quiet)
> + printf("\033[%dB", num_threads*2 + 2);
> + else
> + print_stat(stdout, receiver, sender, 0, 0);
>
> for (i = 0; i < num_threads; i++) {
> receiver[i].shutdown = 1;
> --
> 2.29.2
>
>
Signed-off-by: John Kacur <jkacur@redhat.com>
next prev parent reply other threads:[~2020-12-01 7:09 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 19:06 [rt-tests v1 00/12] Add quiet command line option Daniel Wagner
2020-11-18 19:06 ` [rt-tests v1 01/12] cyclicdeadline: Remove dead code Daniel Wagner
2020-11-19 6:54 ` Punit Agrawal
2020-11-19 8:19 ` Daniel Wagner
2020-12-01 6:30 ` John Kacur
2020-12-01 8:21 ` Daniel Wagner
2020-11-18 19:06 ` [rt-tests v1 02/12] cyclicdeadline: Use common error handlers Daniel Wagner
2020-12-01 6:57 ` John Kacur
2020-11-18 19:06 ` [rt-tests v1 03/12] cyclicdeadline: Add quiet command line option Daniel Wagner
2020-12-01 7:00 ` John Kacur
2020-11-18 19:06 ` [rt-tests v1 04/12] pmqtest: Move statictic output into print_stat() Daniel Wagner
2020-12-01 7:02 ` John Kacur
2020-11-18 19:06 ` [rt-tests v1 05/12] pmqtest: Add quiet command line option Daniel Wagner
2020-12-01 7:04 ` John Kacur
2020-11-18 19:06 ` [rt-tests v1 06/12] ptsematest: Move statictic output into print_stat() Daniel Wagner
2020-12-01 7:06 ` John Kacur
2020-11-18 19:06 ` [rt-tests v1 07/12] ptsematest: Add quiet command line option Daniel Wagner
2020-12-01 7:09 ` John Kacur [this message]
2020-11-18 19:06 ` [rt-tests v1 08/12] svsematest: Move statictic output into print_stat() Daniel Wagner
2020-12-01 7:11 ` John Kacur
2020-11-18 19:06 ` [rt-tests v1 09/12] svsematest: Add quiet command line option Daniel Wagner
2020-12-01 7:12 ` John Kacur
2020-11-18 19:06 ` [rt-tests v1 10/12] sigwaittest: Move statictic output into print_stat() Daniel Wagner
2020-12-01 7:14 ` John Kacur
2020-11-18 19:06 ` [rt-tests v1 11/12] sigwaittest: Add quiet command line option Daniel Wagner
2020-12-01 7:16 ` John Kacur
2020-11-18 19:06 ` [rt-tests v1 12/12] rt-migrate-test: " Daniel Wagner
2020-12-01 7:17 ` John Kacur
2020-11-20 16:33 ` [rt-tests v1 00/12] " Daniel Wagner
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=af10cfde-f6e1-e1ce-302b-9a7cdcb1132@redhat.com \
--to=jkacur@redhat.com \
--cc=dwagner@suse.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox