* [PATCH] selftests: kselftest: fix wrong test number in ksft_exit_skip
@ 2026-04-27 11:24 Sarthak Sharma
2026-04-27 17:44 ` Shuah Khan
0 siblings, 1 reply; 4+ messages in thread
From: Sarthak Sharma @ 2026-04-27 11:24 UTC (permalink / raw)
To: shuah; +Cc: pbonzini, linux-kselftest, linux-kernel, Sarthak Sharma
ksft_exit_skip() increments ksft_xskip before printing the KTAP
result. As a result, ksft_test_num() already includes the skipped
test.
Adding 1 to ksft_test_num() increments the printed test number
again, producing an incorrect test number and wrong KTAP output.
Drop the extra increment and print ksft_test_num() directly.
Fixes: b85d387c9b09 ("kselftest: fix TAP output for skipped tests")
Signed-off-by: Sarthak Sharma <sarthak.sharma@arm.com>
---
tools/testing/selftests/kselftest.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
index afbcf8412ae5..827b47cf4df8 100644
--- a/tools/testing/selftests/kselftest.h
+++ b/tools/testing/selftests/kselftest.h
@@ -449,7 +449,7 @@ static inline __noreturn __printf(1, 2) void ksft_exit_skip(const char *msg, ...
*/
if (ksft_plan || ksft_test_num()) {
ksft_cnt.ksft_xskip++;
- printf("ok %u # SKIP ", 1 + ksft_test_num());
+ printf("ok %u # SKIP ", ksft_test_num());
} else {
printf("1..0 # SKIP ");
}
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] selftests: kselftest: fix wrong test number in ksft_exit_skip
2026-04-27 11:24 [PATCH] selftests: kselftest: fix wrong test number in ksft_exit_skip Sarthak Sharma
@ 2026-04-27 17:44 ` Shuah Khan
2026-04-28 5:10 ` Sarthak Sharma
0 siblings, 1 reply; 4+ messages in thread
From: Shuah Khan @ 2026-04-27 17:44 UTC (permalink / raw)
To: Sarthak Sharma, shuah; +Cc: pbonzini, linux-kselftest, linux-kernel, Shuah Khan
On 4/27/26 05:24, Sarthak Sharma wrote:
> ksft_exit_skip() increments ksft_xskip before printing the KTAP
> result. As a result, ksft_test_num() already includes the skipped
> test.
>
> Adding 1 to ksft_test_num() increments the printed test number
> again, producing an incorrect test number and wrong KTAP output.
>
> Drop the extra increment and print ksft_test_num() directly.
I applied this patch to linux-kselftest fixes branch.
I ran a few tests and couldn't really see the problem this patch
fixes with and without the patch.
Can you send me before and after for mm or timers test runs?
>
> Fixes: b85d387c9b09 ("kselftest: fix TAP output for skipped tests")
> Signed-off-by: Sarthak Sharma <sarthak.sharma@arm.com>
> ---
> tools/testing/selftests/kselftest.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
> index afbcf8412ae5..827b47cf4df8 100644
> --- a/tools/testing/selftests/kselftest.h
> +++ b/tools/testing/selftests/kselftest.h
> @@ -449,7 +449,7 @@ static inline __noreturn __printf(1, 2) void ksft_exit_skip(const char *msg, ...
> */
> if (ksft_plan || ksft_test_num()) {
> ksft_cnt.ksft_xskip++;
> - printf("ok %u # SKIP ", 1 + ksft_test_num());
> + printf("ok %u # SKIP ", ksft_test_num());
> } else {
> printf("1..0 # SKIP ");
> }
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] selftests: kselftest: fix wrong test number in ksft_exit_skip
2026-04-27 17:44 ` Shuah Khan
@ 2026-04-28 5:10 ` Sarthak Sharma
2026-05-04 17:58 ` Shuah Khan
0 siblings, 1 reply; 4+ messages in thread
From: Sarthak Sharma @ 2026-04-28 5:10 UTC (permalink / raw)
To: Shuah Khan, shuah; +Cc: pbonzini, linux-kselftest, linux-kernel
Hi Shuah!
On 4/27/26 11:14 PM, Shuah Khan wrote:
> On 4/27/26 05:24, Sarthak Sharma wrote:
>> ksft_exit_skip() increments ksft_xskip before printing the KTAP
>> result. As a result, ksft_test_num() already includes the skipped
>> test.
>>
>> Adding 1 to ksft_test_num() increments the printed test number
>> again, producing an incorrect test number and wrong KTAP output.
>>
>> Drop the extra increment and print ksft_test_num() directly.
>
> I applied this patch to linux-kselftest fixes branch.
>
> I ran a few tests and couldn't really see the problem this patch
> fixes with and without the patch.
>
> Can you send me before and after for mm or timers test runs?
Sure, this will affect the output whenever a ksft_exit_skip() is called
after a ksft plan has been printed.
Let us look at acct_syscall test. When I run the test without root, I
get the following output before applying the patch:
TAP version 13
1..1
ok 2 # SKIP This test needs root to run!
# 1 skipped test(s) detected. Consider enabling relevant config options
to improve coverage.
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0
where we should have observed ok 1 instead of ok 2.
When I run the test without root, after applying the patch, I get the
corrected output:
TAP version 13
1..1
ok 1 # SKIP This test needs root to run!
# 1 skipped test(s) detected. Consider enabling relevant config options
to improve coverage.
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0
Since a lot of selftests are being formatted to give KTAP output right
now, this patch is expected to fix a larger number of tests once that
gets merged.
>
>>
>> Fixes: b85d387c9b09 ("kselftest: fix TAP output for skipped tests")
>> Signed-off-by: Sarthak Sharma <sarthak.sharma@arm.com>
>> ---
>> tools/testing/selftests/kselftest.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/
>> selftests/kselftest.h
>> index afbcf8412ae5..827b47cf4df8 100644
>> --- a/tools/testing/selftests/kselftest.h
>> +++ b/tools/testing/selftests/kselftest.h
>> @@ -449,7 +449,7 @@ static inline __noreturn __printf(1, 2) void
>> ksft_exit_skip(const char *msg, ...
>> */
>> if (ksft_plan || ksft_test_num()) {
>> ksft_cnt.ksft_xskip++;
>> - printf("ok %u # SKIP ", 1 + ksft_test_num());
>> + printf("ok %u # SKIP ", ksft_test_num());
>> } else {
>> printf("1..0 # SKIP ");
>> }
>
> thanks,
> -- Shuah
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] selftests: kselftest: fix wrong test number in ksft_exit_skip
2026-04-28 5:10 ` Sarthak Sharma
@ 2026-05-04 17:58 ` Shuah Khan
0 siblings, 0 replies; 4+ messages in thread
From: Shuah Khan @ 2026-05-04 17:58 UTC (permalink / raw)
To: Sarthak Sharma, shuah; +Cc: pbonzini, linux-kselftest, linux-kernel
On 4/27/26 23:10, Sarthak Sharma wrote:
> Hi Shuah!
>
> On 4/27/26 11:14 PM, Shuah Khan wrote:
>> On 4/27/26 05:24, Sarthak Sharma wrote:
>>> ksft_exit_skip() increments ksft_xskip before printing the KTAP
>>> result. As a result, ksft_test_num() already includes the skipped
>>> test.
>>>
>>> Adding 1 to ksft_test_num() increments the printed test number
>>> again, producing an incorrect test number and wrong KTAP output.
>>>
>>> Drop the extra increment and print ksft_test_num() directly.
>>
>> I applied this patch to linux-kselftest fixes branch.
>>
>> I ran a few tests and couldn't really see the problem this patch
>> fixes with and without the patch.
>>
>> Can you send me before and after for mm or timers test runs?
>
> Sure, this will affect the output whenever a ksft_exit_skip() is called
> after a ksft plan has been printed.
>
> Let us look at acct_syscall test. When I run the test without root, I
> get the following output before applying the patch:
>
> TAP version 13
> 1..1
> ok 2 # SKIP This test needs root to run!
> # 1 skipped test(s) detected. Consider enabling relevant config options
> to improve coverage.
> # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0
>
> where we should have observed ok 1 instead of ok 2.
>
> When I run the test without root, after applying the patch, I get the
> corrected output:
>
> TAP version 13
> 1..1
> ok 1 # SKIP This test needs root to run!
> # 1 skipped test(s) detected. Consider enabling relevant config options
> to improve coverage.
> # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0
>
> Since a lot of selftests are being formatted to give KTAP output right
> now, this patch is expected to fix a larger number of tests once that
> gets merged.
>
Sounds good.
Thanks.
-- Shuah
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-04 17:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 11:24 [PATCH] selftests: kselftest: fix wrong test number in ksft_exit_skip Sarthak Sharma
2026-04-27 17:44 ` Shuah Khan
2026-04-28 5:10 ` Sarthak Sharma
2026-05-04 17:58 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox