Re: [PATCH v9 2/2] perf test: Truncate printed test descriptions dynamically to avoid terminal wrapping

From: Ian Rogers

Date: Thu Jun 04 2026 - 16:48:13 EST


On Thu, Jun 4, 2026 at 1:26 PM Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> wrote:
>
> On Thu, Jun 04, 2026 at 09:36:27AM -0700, Ian Rogers wrote:
> > When test descriptions are extremely long (e.g., the truncated perf.data
> > graceful handling test is 103 characters long), they wrap across terminal
> > boundaries.
> >
> > Because the ANSI escape code to delete the line (PERF_COLOR_DELETE_LINE)
> > only clears a single terminal line, visual wrapping leaves orphan
> > wrapped lines on the screen, which results in the test description being
> > printed multiple times.
>
> CC /tmp/build/perf-tools-next/util/bpf_lock_contention.o
> tests/builtin-test.c: In function ‘print_test_result.isra’:
> tests/builtin-test.c:427:40: error: ‘%-*s’ directive output may be truncated writing between 20 and 65507 bytes into a region of size 256 [-Werror=format-truncation=]
> 427 | snprintf(buf, buf_sz, "%-*s", width, desc);
> | ^~~~
> In file included from /usr/include/stdio.h:974,
> from /home/acme/git/perf-tools-next/tools/include/linux/panic.h:6,
> from /home/acme/git/perf-tools-next/tools/include/linux/kernel.h:11,
> from /home/acme/git/perf-tools-next/tools/include/linux/list.h:7,
> from /home/acme/git/perf-tools-next/tools/perf/util/config.h:6,
> from tests/builtin-test.c:26:
> In function ‘snprintf’,
> inlined from ‘format_test_description’ at tests/builtin-test.c:427:3,
> inlined from ‘print_test_result.isra’ at tests/builtin-test.c:473:3:
> /usr/include/bits/stdio2.h:68:10: note: ‘__builtin___snprintf_chk’ output between 21 and 65508 bytes into a destination of size 256
> 68 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 69 | __glibc_objsize (__s), __fmt,
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 70 | __va_arg_pack ());
> | ~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> make[4]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:95: /tmp/build/perf-tools-next/tests/builtin-test.o] Error 1
> make[3]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:158: tests] Error 2
> make[2]: *** [Makefile.perf:566: /tmp/build/perf-tools-next/perf-test-in.o] Error 2
> make[2]: *** Waiting for unfinished jobs....
> LD /tmp/build/perf-tools-next/util/perf-util-in.o
> LD /tmp/build/perf-tools-next/perf-util-in.o
> make[1]: *** [Makefile.perf:288: sub-make] Error 2
> make: *** [Makefile:122: install-bin] Error 2
> make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'
> ⬢ [acme@toolbx perf-tools-next]$
>
>
> I thought you had fixed this one?

I thought so too with the clipped local variable. Let me look again,
sorry for the churn.

Thanks,
Ian

> The first patch is applied, testing with it now.
>
> - Arnaldo