Skip to content

Commit 372b304

Browse files
magalilemeskuba-moo
authored andcommitted
selftests/harness: allow tests to be skipped during setup
Before executing each test from a fixture, FIXTURE_SETUP is run once. When SKIP is used in FIXTURE_SETUP, the setup function returns early but the test still proceeds to run, unless another SKIP macro is used within the test definition, leading to some code repetition. Therefore, allow tests to be skipped directly from the setup function. Suggested-by: Jakub Kicinski <[email protected]> Signed-off-by: Magali Lemes <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 40f71e7 commit 372b304

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/testing/selftests/kselftest_harness.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@
249249

250250
/**
251251
* FIXTURE_SETUP() - Prepares the setup function for the fixture.
252-
* *_metadata* is included so that EXPECT_* and ASSERT_* work correctly.
252+
* *_metadata* is included so that EXPECT_*, ASSERT_* etc. work correctly.
253253
*
254254
* @fixture_name: fixture name
255255
*
@@ -275,7 +275,7 @@
275275

276276
/**
277277
* FIXTURE_TEARDOWN()
278-
* *_metadata* is included so that EXPECT_* and ASSERT_* work correctly.
278+
* *_metadata* is included so that EXPECT_*, ASSERT_* etc. work correctly.
279279
*
280280
* @fixture_name: fixture name
281281
*
@@ -388,7 +388,7 @@
388388
if (setjmp(_metadata->env) == 0) { \
389389
fixture_name##_setup(_metadata, &self, variant->data); \
390390
/* Let setup failure terminate early. */ \
391-
if (!_metadata->passed) \
391+
if (!_metadata->passed || _metadata->skip) \
392392
return; \
393393
_metadata->setup_completed = true; \
394394
fixture_name##_##test_name(_metadata, &self, variant->data); \

0 commit comments

Comments
 (0)