Skip to content

Commit e3350ba

Browse files
committed
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. Reported-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/all/05f7bf89-04a5-4b65-bf59-c19456aeb1f0@sirena.org.uk Fixes: a724707 ("selftests: kselftest_harness: use KSFT_* exit codes") Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Mark Brown <broonie@kernel.org> Tested-by: Mark Brown <broonie@kernel.org> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Link: https://lore.kernel.org/r/20240304233621.646054-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 6d0f77a commit e3350ba

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tools/testing/selftests/alsa/test-pcmtest-driver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ FIXTURE_SETUP(pcmtest) {
127127
int err;
128128

129129
if (geteuid())
130-
SKIP(exit(-1), "This test needs root to run!");
130+
SKIP(return, "This test needs root to run!");
131131

132132
err = read_patterns();
133133
if (err)
134-
SKIP(exit(-1), "Can't read patterns. Probably, module isn't loaded");
134+
SKIP(return, "Can't read patterns. Probably, module isn't loaded");
135135

136136
card_name = malloc(127);
137137
ASSERT_NE(card_name, NULL);

tools/testing/selftests/mm/hmm-tests.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ FIXTURE_SETUP(hmm)
138138

139139
self->fd = hmm_open(variant->device_number);
140140
if (self->fd < 0 && hmm_is_coherent_type(variant->device_number))
141-
SKIP(exit(0), "DEVICE_COHERENT not available");
141+
SKIP(return, "DEVICE_COHERENT not available");
142142
ASSERT_GE(self->fd, 0);
143143
}
144144

@@ -149,7 +149,7 @@ FIXTURE_SETUP(hmm2)
149149

150150
self->fd0 = hmm_open(variant->device_number0);
151151
if (self->fd0 < 0 && hmm_is_coherent_type(variant->device_number0))
152-
SKIP(exit(0), "DEVICE_COHERENT not available");
152+
SKIP(return, "DEVICE_COHERENT not available");
153153
ASSERT_GE(self->fd0, 0);
154154
self->fd1 = hmm_open(variant->device_number1);
155155
ASSERT_GE(self->fd1, 0);

0 commit comments

Comments
 (0)