All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 02/12] perf test: Truncate test description to fit terminal width
Date: Tue, 16 Jun 2026 01:38:06 +0000	[thread overview]
Message-ID: <20260616013807.073841F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260616012744.4049193-3-irogers@google.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Subtest descriptions are unnecessarily truncated because the alignment padding width (`subw`) is incorrectly used as the maximum string precision.
- [Medium] Test descriptions are unconditionally truncated to 45 characters when the output is redirected to a file or pipe, degrading standard log outputs.
--

commit 4e5040303fa86a90233f1836bc00692228c7e994
Author: Ian Rogers <irogers@google.com>

perf test: Truncate test description to fit terminal width

This commit dynamically queries the terminal width to truncate printed test
descriptions. This prevents long names from wrapping around the terminal
and corrupting the parallel test harness's progress lines.

> diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
> index afc06cec49546..51484e84d7c15 100644
> --- a/tools/perf/tests/builtin-test.c
> +++ b/tools/perf/tests/builtin-test.c
[ ... ]
> @@ -413,19 +417,52 @@ static char *xml_escape(const char *str)
>  	return res ? res : strdup("");
>  }
>  
> +static int get_max_desc_width(int width)
> +{
> +	struct winsize ws;
> +	int cols = 80;
> +	int max_desc_width;
> +
> +	get_term_dimensions(&ws);
> +	if (ws.ws_col > 0)
> +		cols = ws.ws_col;
> +
> +	/*
> +	 * Limit description width to fit on a single line. We subtract 35
> +	 * columns of headroom to allocate space for:
> +	 * - The suite index prefix: e.g. " 10.100:" (9 characters).
> +	 * - The colon separator and spaces: " : " (3 characters).
> +	 * - The longest status results: e.g. "Skip (some metrics failed)" (26 characters)
> +	 *   or "Running (XX active)" (20 characters).
> +	 *
> +	 * A minimum description width of 10 is enforced to ensure names are
> +	 * legible even on very narrow consoles.
> +	 */
> +	max_desc_width = cols - 35;
> +	if (max_desc_width < 10)
> +		max_desc_width = 10;
> +
> +	return width > max_desc_width ? max_desc_width : width;
> +}
> +
>  static int print_test_result(struct test_suite *t, int curr_suite, int curr_test_case,
>  			     int result, int width, int running,
>  			     const char *err_output, double elapsed)
>  {
> +	width = get_max_desc_width(width);

[Severity: Medium]
Will this unconditionally truncate test descriptions to 45 characters when
output is redirected to a file or pipe?

When a TTY isn't present, get_term_dimensions() fails and cols defaults to
80, making max_desc_width evaluate to 45. Is it intended to enforce this
truncation on non-interactive text logs where line wrapping isn't an issue?

> +
>  	if (test_suite__num_test_cases(t) > 1) {
>  		char prefix[32];
>  		int len = snprintf(prefix, sizeof(prefix), "%3d.%1d:",
>  				   curr_suite + 1, curr_test_case + 1);
>  		int subw = len >= 4 ? width + 4 - len : width;
>  
> -		pr_info("%s %-*s:", prefix, subw, test_description(t, curr_test_case));
> -	} else
> -		pr_info("%3d: %-*s:", curr_suite + 1, width, test_description(t, curr_test_case));
> +		pr_info("%s %-*.*s:", prefix, subw, subw,
> +			test_description(t, curr_test_case));

[Severity: Medium]
Does using subw as the string precision here cause subtest descriptions to
be unnecessarily truncated?

subw is calculated as width + 4 - len, which makes it slightly smaller than
the global width to accommodate the longer subtest prefix. If a subtest
description length is close to the maximum test description length, it
appears this format will forcefully chop off the end of the description,
even on wide terminals where plenty of space exists.

> +	} else {
> +		pr_info("%3d: %-*.*s:", curr_suite + 1, width, width,
> +			test_description(t, curr_test_case));
> +	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260616012744.4049193-1-irogers@google.com?part=2

  reply	other threads:[~2026-06-16  1:38 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16  1:27 [PATCH v1 00/12] perf tests: Enhancements, speedups, and flakiness fixes Ian Rogers
2026-06-16  1:27 ` [PATCH v1 01/12] perf parse-events: Restrict core PMU bypass to --cputype option Ian Rogers
2026-06-16  1:44   ` sashiko-bot
2026-06-16  1:27 ` [PATCH v1 02/12] perf test: Truncate test description to fit terminal width Ian Rogers
2026-06-16  1:38   ` sashiko-bot [this message]
2026-06-16  1:27 ` [PATCH v1 03/12] perf tests workloads: Support sub-second durations in noploop and thloop Ian Rogers
2026-06-16  1:35   ` sashiko-bot
2026-06-16  1:27 ` [PATCH v1 04/12] perf tests: Add robust record retry helper and use subsecond workloads Ian Rogers
2026-06-16  1:38   ` sashiko-bot
2026-06-16  1:27 ` [PATCH v1 05/12] perf tests: Skip metrics validation if system-wide recording lacks permission Ian Rogers
2026-06-16  1:41   ` sashiko-bot
2026-06-16  1:27 ` [PATCH v1 06/12] perf tests: Fix Python JIT dump profiling test failure Ian Rogers
2026-06-16  1:39   ` sashiko-bot
2026-06-16  1:27 ` [PATCH v1 07/12] perf tests: Fix flakiness in trace record and replay test Ian Rogers
2026-06-16  1:42   ` sashiko-bot
2026-06-16  1:27 ` [PATCH v1 08/12] perf tests: Fix flakiness in BPF counters test on hybrid systems Ian Rogers
2026-06-16  1:35   ` sashiko-bot
2026-06-16  1:27 ` [PATCH v1 09/12] perf tests: Fix flakiness in branch stack sampling tests Ian Rogers
2026-06-16  1:27 ` [PATCH v1 10/12] perf tests: Speed up off-cpu profiling tests Ian Rogers
2026-06-16  1:41   ` sashiko-bot
2026-06-16  1:27 ` [PATCH v1 11/12] perf tests: Speed up lock contention analysis shell test Ian Rogers
2026-06-16  1:27 ` [PATCH v1 12/12] perf tests: Speed up metrics checking shell tests Ian Rogers
2026-06-16  6:13 ` [PATCH v2 00/12] perf tests: Enhance robustness, speed up execution, and fix flakiness Ian Rogers
2026-06-16  6:13   ` [PATCH v2 01/12] perf parse-events: Restrict core PMU bypass to --cputype option Ian Rogers
2026-06-16  6:31     ` sashiko-bot
2026-06-16  6:13   ` [PATCH v2 02/12] perf test: Truncate test description to fit terminal width Ian Rogers
2026-06-16  6:24     ` sashiko-bot
2026-06-16  6:13   ` [PATCH v2 03/12] perf tests workloads: Support sub-second durations in noploop and thloop Ian Rogers
2026-06-16  6:22     ` sashiko-bot
2026-06-16  6:13   ` [PATCH v2 04/12] perf tests: Add robust record retry helper and use subsecond workloads Ian Rogers
2026-06-16  6:27     ` sashiko-bot
2026-06-16  6:13   ` [PATCH v2 05/12] perf tests: Skip metrics validation if system-wide recording lacks permission Ian Rogers
2026-06-16  6:13   ` [PATCH v2 06/12] perf tests: Fix Python JIT dump profiling test failure Ian Rogers
2026-06-16  6:27     ` sashiko-bot
2026-06-16  6:13   ` [PATCH v2 07/12] perf tests: Fix flakiness in trace record and replay test Ian Rogers
2026-06-16  6:27     ` sashiko-bot
2026-06-16  6:14   ` [PATCH v2 08/12] perf tests: Fix flakiness in BPF counters test on hybrid systems Ian Rogers
2026-06-16  6:14   ` [PATCH v2 09/12] perf tests: Fix flakiness in branch stack sampling tests Ian Rogers
2026-06-16  6:14   ` [PATCH v2 10/12] perf tests: Speed up off-cpu profiling tests Ian Rogers
2026-06-16  6:25     ` sashiko-bot
2026-06-16  6:14   ` [PATCH v2 11/12] perf tests: Speed up lock contention analysis shell test Ian Rogers
2026-06-16  6:14   ` [PATCH v2 12/12] perf tests: Speed up metrics checking shell tests Ian Rogers
  -- strict thread matches above, loose matches on Subject: below --
2026-06-16  1:25 [PATCH v1 00/12] perf tests: Enhancements, speedups, and flakiness fixes Ian Rogers
2026-06-16  1:25 ` [PATCH v1 02/12] perf test: Truncate test description to fit terminal width 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=20260616013807.073841F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=irogers@google.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.