selftests: avoid using SKIP(exit()) in harness fixure setup
Subsystems (9)
Jakub Kicinski
maintainerPATCH 1/1 selftests: avoid using SKIP(exit()) in harness fixure setup
selftest harness uses various exit codes to signal test results. Avoid calling exit() directly, otherwise tests may get broken by harness refactoring (like the commit under Fixes). SKIP() will instruct the harness that the test shouldn't run, it used to not be the case, but that has been fixed. So just return, no need to exit.
Note that for hmm-tests this actually changes the result from pass to skip. Which seems fair, the test is skipped, after all.
---
This needs to go to net-next because that's where the breaking patch was (mis?)-applied.
--- tools/testing/selftests/alsa/test-pcmtest-driver.c | 4 ++-- tools/testing/selftests/mm/hmm-tests.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/alsa/test-pcmtest-driver.c +2 -2
@@ -127,11 +127,11 @@ FIXTURE_SETUP(pcmtest) {int err;if (geteuid ()) -SKIP (exit (-1 ),"This test needs root to run!" ); +SKIP (return,"This test needs root to run!" ); err =read_patterns ();if (err) -SKIP (exit (-1 ),"Can't read patterns. Probably, module isn't loaded" ); +SKIP (return,"Can't read patterns. Probably, module isn't loaded" ); card_name =malloc (127 );ASSERT_NE (card_name,NULL );
tools/testing/selftests/mm/hmm-tests.c +2 -2
@@ -138,7 +138,7 @@ FIXTURE_SETUP(hmm) self->fd =hmm_open (variant->device_number);if (self->fd <0 &&hmm_is_coherent_type (variant->device_number)) -SKIP (exit (0 ),"DEVICE_COHERENT not available" ); +SKIP (return,"DEVICE_COHERENT not available" );ASSERT_GE (self->fd,0 ); }
@@ -149,7 +149,7 @@ FIXTURE_SETUP(hmm2) self->fd0 =hmm_open (variant->device_number0);if (self->fd0 <0 &&hmm_is_coherent_type (variant->device_number0)) -SKIP (exit (0 ),"DEVICE_COHERENT not available" ); +SKIP (return,"DEVICE_COHERENT not available" );ASSERT_GE (self->fd0,0 ); self->fd1 =hmm_open (variant->device_number1);ASSERT_GE (self->fd1,0 );
Signature · 1 line
2.44.0
Quoted 7 lines · Jakub Kicinski
selftest harness uses various exit codes to signal test results. Avoid calling
exit()directly, otherwise tests may get broken by harness refactoring (like the commit under Fixes).SKIP()will instruct the harness that the test shouldn't run, it used to not be the case, but that has been fixed. So just return, no need to exit.
Quoted 8 lines
Note that for hmm-tests this actually changes the result from pass to skip. Which seems fair, the test is skipped, after all.
Reported-by Mark Brown <[email protected]>Fixes a724707976b0 ("selftests: kselftest_harness: use KSFT_* exit codes")Signed-off-by Jakub Kicinski <[email protected]>
Signature · 1 line
Kees Cook
Quoted 10 lines · Jakub Kicinski
selftest harness uses various exit codes to signal test results. Avoid calling
exit()directly, otherwise tests may get broken by harness refactoring (like the commit under Fixes).SKIP()will instruct the harness that the test shouldn't run, it used to not be the case, but that has been fixed. So just return, no need to exit.Note that for hmm-tests this actually changes the result from pass to skip. Which seems fair, the test is skipped, after all.
This fixes at least the pcmtest-driver suite.
Quoted 7 lines · Jakub Kicinski
selftest harness uses various exit codes to signal test results. Avoid calling
exit()directly, otherwise tests may get broken by harness refactoring (like the commit under Fixes).SKIP()will instruct the harness that the test shouldn't run, it used to not be the case, but that has been fixed. So just return, no need to exit.
Quoted 7 lines
Note that for hmm-tests this actually changes the result from pass to skip. Which seems fair, the test is skipped, after all.
Reported-by Mark Brown <[email protected]>Fixes a724707976b0 ("selftests: kselftest_harness: use KSFT_* exit codes")
I believe that the next patch of the linked series is a culprit, but that does not mandate a next revision in my eyes
Quoted 53 lines
Signed-off-by Jakub Kicinski <[email protected]>---
This needs to go to net-next because that's where the breaking patch was (mis?)-applied.--- tools/testing/selftests/alsa/test-pcmtest-driver.c | 4 ++-- tools/testing/selftests/mm/hmm-tests.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)tools/testing/selftests/alsa/test-pcmtest-driver.c +2
-2@@ -127,11 +127,11 @@ FIXTURE_SETUP(pcmtest) {int err;if (geteuid ()) -SKIP (exit (-1 ),"This test needs root to run!" ); +SKIP (return,"This test needs root to run!" ); err =read_patterns ();if (err) -SKIP (exit (-1 ),"Can't read patterns. Probably, module isn't loaded" ); +SKIP (return,"Can't read patterns. Probably, module isn't loaded" ); card_name =malloc (127 );ASSERT_NE (card_name,NULL );tools/testing/selftests/mm/hmm-tests.c +1
-1@@ -138,7 +138,7 @@ FIXTURE_SETUP(hmm) self->fd =hmm_open (variant->device_number);if (self->fd <0 &&hmm_is_coherent_type (variant->device_number)) -SKIP (exit (0 ),"DEVICE_COHERENT not available" ); +SKIP (return,"DEVICE_COHERENT not available" );ASSERT_GE (self->fd,0 ); }
tools/testing/selftests/mm/hmm-tests.c FIXTURE_SETUP(hmm2) · line 155
Quoted 8 lines
tools/testing/selftests/mm/hmm-tests.c +1
-1@@ -149,7 +149,7 @@ FIXTURE_SETUP(hmm2) self->fd0 =hmm_open (variant->device_number0);if (self->fd0 <0 &&hmm_is_coherent_type (variant->device_number0)) -SKIP (exit (0 ),"DEVICE_COHERENT not available" ); +SKIP (return,"DEVICE_COHERENT not available" );ASSERT_GE (self->fd0,0 ); self->fd1 =hmm_open (variant->device_number1);ASSERT_GE (self->fd1,0 );
- that's totally what mandates vfork() introduced in recent refactor
(Sorry for pointing the same in the Link:-ed thread, it was just newer/higher in my email client)
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Mon, 4 Mar 2024 15:36:20 -0800 you wrote:
selftest harness uses various exit codes to signal test results. Avoid calling
exit()directly, otherwise tests may get broken by harness refactoring (like the commit under Fixes).SKIP()will instruct the harness that the test shouldn't run, it used to not be the case, but that has been fixed. So just return, no need to exit.[...]
Here is the summary with links:
- [net-next] selftests: avoid using SKIP(exit()) in harness fixure setup
https://git.kernel.org/netdev/net-next/c/e3350ba4a5b7
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html