linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests: timers: improve adjtick output readability
@ 2025-07-28 16:03 Vishal Parmar
  2025-07-29  0:33 ` John Stultz
  0 siblings, 1 reply; 4+ messages in thread
From: Vishal Parmar @ 2025-07-28 16:03 UTC (permalink / raw)
  To: shuah
  Cc: anna-maria, frederic, tglx, jstultz, sboyd, linux-kernel,
	linux-kselftest, Vishal Parmar

Reformat the output of the `adjtick` test in tools/testing/selftests/timers/
to display results in a clean tabular format.

Previously, the output was printed in a free-form manner like this:

  Each iteration takes about 15 seconds
  Estimating tick (act: 9000 usec, -100000 ppm): 9000 usec, -100000 ppm [OK]

This format made it hard to visually compare values across iterations or parse
results in scripts.

The new output is aligned in a table with clearly labeled columns:

  Each iteration takes about 15 seconds
   ---------------------------------------------------------------
   | Requested (usec) | Expected (ppm) | Measured (ppm) | Result  |
   |------------------|----------------|----------------|---------|
   | 9000             | -100000        | -100001        | [ OK ]  |
   | 9250             | -75000         | -75000         | [ OK ]  |
   ...
   ---------------------------------------------------------------

This improves readability, consistency, and log usability for automated tooling.

Signed-off-by: Vishal Parmar <vishistriker@gmail.com>
---
 tools/testing/selftests/timers/adjtick.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/timers/adjtick.c b/tools/testing/selftests/timers/adjtick.c
index 777d9494b683..b6b3de04d6ae 100644
--- a/tools/testing/selftests/timers/adjtick.c
+++ b/tools/testing/selftests/timers/adjtick.c
@@ -128,18 +128,18 @@ int check_tick_adj(long tickval)
 	sleep(1);
 
 	ppm = ((long long)tickval * MILLION)/systick - MILLION;
-	printf("Estimating tick (act: %ld usec, %lld ppm): ", tickval, ppm);
+	printf(" | %-16ld | %-14lld |", tickval, ppm);
 
 	eppm = get_ppm_drift();
-	printf("%lld usec, %lld ppm", systick + (systick * eppm / MILLION), eppm);
+	printf(" %-14lld |", eppm);
 	fflush(stdout);
 
 	tx1.modes = 0;
 	adjtimex(&tx1);
 
 	if (tx1.offset || tx1.freq || tx1.tick != tickval) {
-		printf("	[ERROR]\n");
-		printf("\tUnexpected adjtimex return values, make sure ntpd is not running.\n");
+		printf(" [ERROR]  |\n");
+		printf("   Unexpected adjtimex return values, make sure ntpd is not running.\n");
 		return -1;
 	}
 
@@ -153,10 +153,10 @@ int check_tick_adj(long tickval)
 	 * room for interruptions during the measurement.
 	 */
 	if (llabs(eppm - ppm) > 100) {
-		printf("	[FAILED]\n");
+		printf(" [FAILED]\n");
 		return -1;
 	}
-	printf("	[OK]\n");
+	printf(" [ OK ]  |\n");
 
 	return  0;
 }
@@ -175,7 +175,10 @@ int main(int argc, char **argv)
 		return -1;
 	}
 
-	printf("Each iteration takes about 15 seconds\n");
+	printf("\n Each iteration takes about 15 seconds\n");
+	printf(" ---------------------------------------------------------------\n");
+	printf(" | Requested (usec) | Expected (ppm) | Measured (ppm) | Result  |\n");
+	printf(" |------------------|----------------|----------------|---------|\n");
 
 	systick = sysconf(_SC_CLK_TCK);
 	systick = USEC_PER_SEC/sysconf(_SC_CLK_TCK);
@@ -188,6 +191,7 @@ int main(int argc, char **argv)
 			break;
 		}
 	}
+	printf(" ---------------------------------------------------------------\n");
 
 	/* Reset things to zero */
 	tx1.modes	 = ADJ_TICK;
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests: timers: improve adjtick output readability
  2025-07-28 16:03 [PATCH] selftests: timers: improve adjtick output readability Vishal Parmar
@ 2025-07-29  0:33 ` John Stultz
       [not found]   ` <CAEOVoRwsHdAmn1d_SekD+ddWeUDJCooNsK_wDHxEyvtqkDXQZw@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: John Stultz @ 2025-07-29  0:33 UTC (permalink / raw)
  To: Vishal Parmar
  Cc: shuah, anna-maria, frederic, tglx, sboyd, linux-kernel,
	linux-kselftest

On Mon, Jul 28, 2025 at 9:03 AM Vishal Parmar <vishistriker@gmail.com> wrote:
>
> Reformat the output of the `adjtick` test in tools/testing/selftests/timers/
> to display results in a clean tabular format.
>
> Previously, the output was printed in a free-form manner like this:
>
>   Each iteration takes about 15 seconds
>   Estimating tick (act: 9000 usec, -100000 ppm): 9000 usec, -100000 ppm [OK]
>
> This format made it hard to visually compare values across iterations or parse
> results in scripts.
>
> The new output is aligned in a table with clearly labeled columns:
>
>   Each iteration takes about 15 seconds
>    ---------------------------------------------------------------
>    | Requested (usec) | Expected (ppm) | Measured (ppm) | Result  |
>    |------------------|----------------|----------------|---------|
>    | 9000             | -100000        | -100001        | [ OK ]  |
>    | 9250             | -75000         | -75000         | [ OK ]  |
>    ...
>    ---------------------------------------------------------------
>
> This improves readability, consistency, and log usability for automated tooling.

No major objection from me, but also I've not followed too closely if
the kselftest output formatting has been formalized further (I know it
was moving towards TAP), but it seems this test hasn't been converted
yet, so it probably isn't negatively impacting things.

So it might be worth looking into getting the output to be happy with
TAP while you're tweaking things here.

Otherwise,
Acked-by: John Stultz <jstultz@google.com>

thanks
-john

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests: timers: improve adjtick output readability
       [not found]   ` <CAEOVoRwsHdAmn1d_SekD+ddWeUDJCooNsK_wDHxEyvtqkDXQZw@mail.gmail.com>
@ 2025-07-31 13:58     ` Thomas Gleixner
  2025-07-31 16:12       ` Vishal Parmar
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2025-07-31 13:58 UTC (permalink / raw)
  To: Vishal Parmar, John Stultz
  Cc: shuah, anna-maria, frederic, sboyd, linux-kernel, linux-kselftest

Vishal!

On Wed, Jul 30 2025 at 23:35, Vishal Parmar wrote:

Please do not top-post and trim your replies.

> The intent behind this change is to make output useful as is.
> for example, to provide a performance report in case of regression.

The point John was making:

>> So it might be worth looking into getting the output to be happy with
>> TAP while you're tweaking things here.

The kernel selftests are converting over to standardized TAP output
format, which is intended to aid automated testing.

So if we change the outpot format of this test, then we switch it over to
TAP format and do not invent yet another randomized output scheme.

> CSV format is also a good alternative if the maintainer prefers that.

The most important information is whether the test succeeded or not and
CSV format is not helping either to conform with the test output
standards.

For the success case, the actual numbers are uninteresting. In the
failure case it's sufficient to emit:

        ksft_test_result_fail("Req: NNNN, Exp: $MMMM, Res: $LLLL\n", ...);

In case of regressions (fail), a report providing this output is good
enough for the relevant maintainer/developer to start investigating.

No?

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests: timers: improve adjtick output readability
  2025-07-31 13:58     ` Thomas Gleixner
@ 2025-07-31 16:12       ` Vishal Parmar
  0 siblings, 0 replies; 4+ messages in thread
From: Vishal Parmar @ 2025-07-31 16:12 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: John Stultz, shuah, anna-maria, frederic, sboyd, linux-kernel,
	linux-kselftest

hi Thomas,

> Please do not top-post and trim your replies.
Thanks, I learned about this netiquette today.
I hope this reply is in the correct format.

> The point John was making:
>
> >> So it might be worth looking into getting the output to be happy with
> >> TAP while you're tweaking things here.
>
> The kernel selftests are converting over to standardized TAP output
> format, which is intended to aid automated testing.
>
> So if we change the outpot format of this test, then we switch it over to
> TAP format and do not invent yet another randomized output scheme.

oh okay, please ignore this patch. no need to review it further.

> For the success case, the actual numbers are uninteresting. In the
> failure case it's sufficient to emit:
>
>         ksft_test_result_fail("Req: NNNN, Exp: $MMMM, Res: $LLLL\n", ...);
>
> In case of regressions (fail), a report providing this output is good
> enough for the relevant maintainer/developer to start investigating
> No?

yes understood, thanks for the explanation.

Thanks,
Vishal

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-07-31 16:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-28 16:03 [PATCH] selftests: timers: improve adjtick output readability Vishal Parmar
2025-07-29  0:33 ` John Stultz
     [not found]   ` <CAEOVoRwsHdAmn1d_SekD+ddWeUDJCooNsK_wDHxEyvtqkDXQZw@mail.gmail.com>
2025-07-31 13:58     ` Thomas Gleixner
2025-07-31 16:12       ` Vishal Parmar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).