selftests: kselftest: fix wrong test number in ksft_exit_skip
PATCH 1/1 selftests: kselftest: fix wrong test number in ksft_exit_skip
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.
--- tools/testing/selftests/kselftest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kselftest.h +1 -1
@@ -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 " ); }
Signature · 1 line
2.39.5
Shuah Khan
maintainerQuoted 8 lines · Sarthak Sharma
ksft_exit_skip()incrementsksft_xskipbefore 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?
Quoted 12 lines
Fixes b85d387c9b09 ("kselftest: fix TAP output for skipped tests")Signed-off-by Sarthak Sharma <[email protected]>--- tools/testing/selftests/kselftest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/kselftest.h +0
-0
tools/testing/selftests/kselftest.h static inline __noreturn __printf(1, 2) void ksft_exit_skip(const char *msg, ... · line 455
Quoted 8 lines
tools/testing/selftests/kselftest.h +1
-1@@ -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
Hi Shuah!
Quoted 8 lines · Shuah Khan
Quoted 7 lines · Sarthak Sharma
ksft_exit_skip()incrementsksft_xskipbefore 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.
Quoted 8 lines
Quoted 1 line
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.
Quoted 26 lines
Quoted 15 lines
Fixes b85d387c9b09 ("kselftest: fix TAP output for skipped tests")Signed-off-by Sarthak Sharma <[email protected]>---
tools/testing/selftests/kselftest.h| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/ renamed from tools/testing/selftests/kselftest.h +0
-0
selftests/kselftest.h
indexafbcf8412ae5..827b47cf4df8100644tools/testing/selftests/kselftest.h +0
-0@@ -449,7 +449,7 @@ static inline __noreturn __printf(1, 2) voidksft_exit_skip(const char *msg, ...
Quoted 8 lines
*/
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
Shuah Khan
maintainerQuoted 45 lines · Sarthak Sharma
Hi Shuah!
Quoted 8 lines · Shuah Khan
Quoted 7 lines · Sarthak Sharma
ksft_exit_skip()incrementsksft_xskipbefore 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.Quoted 8 lines
Quoted 1 line
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_syscalltest. 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:0where 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
Quoted 4 lines
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