From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>,
Kan Liang <kan.liang@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org
Subject: [PATCH] perf test: Print test description first
Date: Fri, 28 Jun 2024 14:57:50 -0700 [thread overview]
Message-ID: <20240628215751.1512250-1-namhyung@kernel.org> (raw)
Currently perf test prints the description of the test when it finishes
to run the test. But sometimes it runs long and users want to see which
test it is running. Change it to print the info in start_test() so that
we can see it right after the test.
No functional changes intended.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/tests/builtin-test.c | 54 ++++++++++++++++++---------------
1 file changed, 30 insertions(+), 24 deletions(-)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index c3d84b67ca8e..33defd3b7185 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -243,12 +243,17 @@ static int run_test_child(struct child_process *process)
static int print_test_result(struct test_suite *t, int i, int subtest, int result, int width)
{
- if (has_subtests(t)) {
- int subw = width > 2 ? width - 2 : width;
+ /* If it printed other messages, print the header again. */
+ if (verbose > 1 || (verbose == 1 && result == TEST_FAIL)) {
+ if (has_subtests(t)) {
+ int subw = width > 2 ? width - 2 : width;
- pr_info("%3d.%1d: %-*s:", i + 1, subtest + 1, subw, test_description(t, subtest));
- } else
- pr_info("%3d: %-*s:", i + 1, width, test_description(t, subtest));
+ pr_info("%3d.%1d: %-*s:", i + 1, subtest + 1, subw,
+ test_description(t, subtest));
+ } else {
+ pr_info("%3d: %-*s:", i + 1, width, test_description(t, -1));
+ }
+ }
switch (result) {
case TEST_OK:
@@ -282,25 +287,12 @@ static int finish_test(struct child_test *child_test, int width)
struct strbuf err_output = STRBUF_INIT;
int ret;
- /*
- * For test suites with subtests, display the suite name ahead of the
- * sub test names.
- */
- if (has_subtests(t) && subi == 0)
- pr_info("%3d: %-*s:\n", i + 1, width, test_description(t, -1));
-
/*
* Busy loop reading from the child's stdout/stderr that are set to be
* non-blocking until EOF.
*/
if (!err_done)
fcntl(err, F_SETFL, O_NONBLOCK);
- if (verbose > 1) {
- if (has_subtests(t))
- pr_info("%3d.%1d: %s:\n", i + 1, subi + 1, test_description(t, subi));
- else
- pr_info("%3d: %s:\n", i + 1, test_description(t, -1));
- }
while (!err_done) {
struct pollfd pfds[1] = {
{ .fd = err,
@@ -330,12 +322,8 @@ static int finish_test(struct child_test *child_test, int width)
/* Clean up child process. */
ret = finish_command(&child_test->process);
if (verbose == 1 && ret == TEST_FAIL) {
- /* Add header for test that was skipped above. */
- if (has_subtests(t))
- pr_info("%3d.%1d: %s:\n", i + 1, subi + 1, test_description(t, subi));
- else
- pr_info("%3d: %s:\n", i + 1, test_description(t, -1));
- fprintf(stderr, "%s", err_output.buf);
+ /* It printed the header first, print messages in a new line */
+ fprintf(stderr, "\n%s", err_output.buf);
}
strbuf_release(&err_output);
print_test_result(t, i, subi, ret, width);
@@ -376,6 +364,24 @@ static int start_test(struct test_suite *test, int i, int subi, struct child_tes
(*child)->process.err = -1;
}
(*child)->process.no_exec_cmd = run_test_child;
+
+ if (has_subtests(test)) {
+ int subw = width > 2 ? width - 2 : width;
+
+ /*
+ * For test suites with subtests, display the suite name ahead of the
+ * sub test names.
+ */
+ if (has_subtests(test) && subi == 0)
+ pr_info("%3d: %-*s:\n", i + 1, width, test_description(test, -1));
+
+ pr_info("%3d.%1d: %-*s:", i + 1, subi + 1, subw, test_description(test, subi));
+ } else
+ pr_info("%3d: %-*s:", i + 1, width, test_description(test, -1));
+
+ if (verbose > 1)
+ pr_info("\n");
+
err = start_command(&(*child)->process);
if (err || !sequential)
return err;
--
2.45.2.803.g4e1b14247a-goog
next reply other threads:[~2024-06-28 21:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-28 21:57 Namhyung Kim [this message]
2024-06-28 22:20 ` [PATCH] perf test: Print test description first Ian Rogers
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=20240628215751.1512250-1-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
/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