From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
shuah@kernel.org, linux-kselftest@vger.kernel.org,
mic@digikod.net, linux-security-module@vger.kernel.org,
keescook@chromium.org, jakub@cloudflare.com,
Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH v4 06/12] selftests: kselftest_harness: use exit code to store skip
Date: Wed, 28 Feb 2024 16:59:13 -0800 [thread overview]
Message-ID: <20240229005920.2407409-7-kuba@kernel.org> (raw)
In-Reply-To: <20240229005920.2407409-1-kuba@kernel.org>
We always use skip in combination with exit_code being 0
(KSFT_PASS). This are basic KSFT / KTAP semantics.
Store the right KSFT_* code in exit_code directly.
This makes it easier to support tests reporting other
extended KSFT_* codes like XFAIL / XPASS.
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
tools/testing/selftests/kselftest_harness.h | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index d90d4a9039ee..5a48177c8c00 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -128,8 +128,7 @@
fprintf(TH_LOG_STREAM, "# SKIP %s\n", \
_metadata->results->reason); \
} \
- _metadata->exit_code = KSFT_PASS; \
- _metadata->skip = 1; \
+ _metadata->exit_code = KSFT_SKIP; \
_metadata->trigger = 0; \
statement; \
} while (0)
@@ -387,7 +386,7 @@
if (setjmp(_metadata->env) == 0) { \
fixture_name##_setup(_metadata, &self, variant->data); \
/* Let setup failure terminate early. */ \
- if (!__test_passed(_metadata) || _metadata->skip) \
+ if (_metadata->exit_code) \
return; \
_metadata->setup_completed = true; \
/* Use the same _metadata. */ \
@@ -837,7 +836,6 @@ struct __test_metadata {
struct __fixture_metadata *fixture;
int termsig;
int exit_code;
- int skip; /* did SKIP get used? */
int trigger; /* extra handler after the evaluation */
int timeout; /* seconds to wait for test timeout */
bool timed_out; /* did this test timeout instead of exiting? */
@@ -944,9 +942,7 @@ void __wait_for_test(struct __test_metadata *t)
"# %s: Test terminated by timeout\n", t->name);
} else if (WIFEXITED(status)) {
if (WEXITSTATUS(status) == KSFT_SKIP) {
- /* SKIP */
- t->exit_code = KSFT_PASS;
- t->skip = 1;
+ t->exit_code = WEXITSTATUS(status);
} else if (t->termsig != -1) {
t->exit_code = KSFT_FAIL;
fprintf(TH_LOG_STREAM,
@@ -1118,7 +1114,6 @@ void __run_test(struct __fixture_metadata *f,
/* reset test struct */
t->exit_code = KSFT_PASS;
- t->skip = 0;
t->trigger = 0;
memset(t->results->reason, 0, sizeof(t->results->reason));
@@ -1138,18 +1133,14 @@ void __run_test(struct __fixture_metadata *f,
} else if (t->pid == 0) {
setpgrp();
t->fn(t, variant);
- if (t->skip)
- _exit(KSFT_SKIP);
- if (__test_passed(t))
- _exit(KSFT_PASS);
- _exit(KSFT_FAIL);
+ _exit(t->exit_code);
} else {
__wait_for_test(t);
}
ksft_print_msg(" %4s %s\n",
__test_passed(t) ? "OK" : "FAIL", test_name);
- if (t->skip)
+ if (t->exit_code == KSFT_SKIP)
ksft_test_result_skip("%s\n", t->results->reason[0] ?
t->results->reason : "unknown");
else
--
2.43.2
next prev parent reply other threads:[~2024-02-29 0:59 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-29 0:59 [PATCH v4 00/12] selftests: kselftest_harness: support using xfail Jakub Kicinski
2024-02-29 0:59 ` [PATCH v4 01/12] selftests/landlock: Redefine TEST_F() as TEST_F_FORK() Jakub Kicinski
2024-02-29 0:59 ` [PATCH v4 02/12] selftests/harness: Merge TEST_F_FORK() into TEST_F() Jakub Kicinski
2024-03-04 19:27 ` Mickaël Salaün
2024-03-04 19:31 ` Mickaël Salaün
2024-03-05 15:47 ` Mickaël Salaün
2024-03-05 15:56 ` [PATCH v1 0/2] " Mickaël Salaün
2024-03-05 15:56 ` [PATCH v1 1/2] selftests/landlock: Redefine TEST_F() as TEST_F_FORK() Mickaël Salaün
2024-03-05 15:56 ` [PATCH v1 2/2] selftests/harness: Merge TEST_F_FORK() into TEST_F() Mickaël Salaün
2024-02-29 0:59 ` [PATCH v4 03/12] selftests: kselftest_harness: use KSFT_* exit codes Jakub Kicinski
2024-02-29 0:59 ` [PATCH v4 04/12] selftests: kselftest_harness: generate test name once Jakub Kicinski
2024-02-29 0:59 ` [PATCH v4 05/12] selftests: kselftest_harness: save full exit code in metadata Jakub Kicinski
2024-02-29 0:59 ` Jakub Kicinski [this message]
2024-02-29 0:59 ` [PATCH v4 07/12] selftests: kselftest: add ksft_test_result_code(), handling all exit codes Jakub Kicinski
2024-02-29 0:59 ` [PATCH v4 08/12] selftests: kselftest_harness: print test name for SKIP Jakub Kicinski
2024-02-29 0:59 ` [PATCH v4 09/12] selftests: kselftest_harness: separate diagnostic message with # in ksft_test_result_code() Jakub Kicinski
2024-02-29 0:59 ` [PATCH v4 10/12] selftests: kselftest_harness: let PASS / FAIL provide diagnostic Jakub Kicinski
2024-04-16 14:11 ` Muhammad Usama Anjum
2024-02-29 0:59 ` [PATCH v4 11/12] selftests: kselftest_harness: support using xfail Jakub Kicinski
2024-02-29 0:59 ` [PATCH v4 12/12] selftests: ip_local_port_range: use XFAIL instead of SKIP Jakub Kicinski
2024-02-29 20:19 ` Jakub Sitnicki
2024-02-29 23:25 ` Xin Long
2024-03-01 10:40 ` Jakub Sitnicki
2024-03-01 10:40 ` [PATCH v4 00/12] selftests: kselftest_harness: support using xfail patchwork-bot+netdevbpf
2024-03-04 22:20 ` Mark Brown
2024-03-04 23:04 ` Jakub Kicinski
2024-03-04 23:14 ` Kees Cook
2024-03-04 23:39 ` Jakub Kicinski
2024-03-05 9:43 ` Kees Cook
2024-03-05 16:05 ` Mickaël Salaün
2024-03-05 18:06 ` Jakub Kicinski
2024-03-05 19:14 ` Mickaël Salaün
2024-03-05 20:10 ` [PATCH] selftests/harness: Fix TEST_F()'s vfork handling Mickaël Salaün
2024-03-05 20:25 ` Jakub Kicinski
2024-03-06 7:25 ` Mickaël Salaün
2024-03-06 7:32 ` Mickaël Salaün
2024-03-05 20:31 ` Kees Cook
2024-03-06 13:25 ` Mark Brown
2024-03-07 4:40 ` patchwork-bot+netdevbpf
2024-05-02 18:42 ` [PATCH v4 00/12] selftests: kselftest_harness: support using xfail Sean Christopherson
2024-05-02 21:07 ` Mickaël Salaün
2024-03-05 15:48 ` Przemek Kitszel
2024-03-05 16:00 ` Mickaël Salaün
2024-03-05 16:39 ` Mickaël Salaün
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240229005920.2407409-7-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jakub@cloudflare.com \
--cc=keescook@chromium.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mic@digikod.net \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).