提交 372b304c 编写于 作者: M Magali Lemes 提交者: Jakub Kicinski

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: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NMagali Lemes <magali.lemes@canonical.com>
Signed-off-by: NJakub Kicinski <kuba@kernel.org>
上级 40f71e7c
...@@ -249,7 +249,7 @@ ...@@ -249,7 +249,7 @@
/** /**
* FIXTURE_SETUP() - Prepares the setup function for the fixture. * FIXTURE_SETUP() - Prepares the setup function for the fixture.
* *_metadata* is included so that EXPECT_* and ASSERT_* work correctly. * *_metadata* is included so that EXPECT_*, ASSERT_* etc. work correctly.
* *
* @fixture_name: fixture name * @fixture_name: fixture name
* *
...@@ -275,7 +275,7 @@ ...@@ -275,7 +275,7 @@
/** /**
* FIXTURE_TEARDOWN() * FIXTURE_TEARDOWN()
* *_metadata* is included so that EXPECT_* and ASSERT_* work correctly. * *_metadata* is included so that EXPECT_*, ASSERT_* etc. work correctly.
* *
* @fixture_name: fixture name * @fixture_name: fixture name
* *
...@@ -388,7 +388,7 @@ ...@@ -388,7 +388,7 @@
if (setjmp(_metadata->env) == 0) { \ if (setjmp(_metadata->env) == 0) { \
fixture_name##_setup(_metadata, &self, variant->data); \ fixture_name##_setup(_metadata, &self, variant->data); \
/* Let setup failure terminate early. */ \ /* Let setup failure terminate early. */ \
if (!_metadata->passed) \ if (!_metadata->passed || _metadata->skip) \
return; \ return; \
_metadata->setup_completed = true; \ _metadata->setup_completed = true; \
fixture_name##_##test_name(_metadata, &self, variant->data); \ fixture_name##_##test_name(_metadata, &self, variant->data); \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册