From: Sun Jian <sun.jian.kdev@gmail.com>
To: shuah@kernel.org
Cc: linux-kselftest@vger.kernel.org, kees@kernel.org,
linux-kernel@vger.kernel.org, linux@weissschuh.net,
Sun Jian <sun.jian.kdev@gmail.com>,
Bjoern Doebel <doebel@amazon.de>
Subject: [PATCH v3] selftests/harness: harness-selftest: cover XFAIL_ADD ctor ordering
Date: Thu, 30 Apr 2026 12:02:07 +0800 [thread overview]
Message-ID: <20260430040207.296136-1-sun.jian.kdev@gmail.com> (raw)
Add a fixture-based test with a single variant and mark it with
XFAIL_ADD(). The test intentionally fails and is expected to be
accounted as XFAIL, covering the constructor ordering dependency
between TEST_F() registration and XFAIL_ADD() registration.
Suggested-by: Thomas Weißschuh <linux@weissschuh.net>
Tested-by: Bjoern Doebel <doebel@amazon.de>
Signed-off-by: Sun Jian <sun.jian.kdev@gmail.com>
---
v3:
- Rebase on kselftest/fixes.
- Refresh harness-selftest.expected after commit 465b05bae5ac
("selftests: harness: Restore order of test functions").
- Add Tested-by from Bjoern Doebel.
v2:
- update Suggested-by address
- update harness-selftest.expected
- verify with 'make run_tests'
.../kselftest_harness/harness-selftest.c | 23 +++++++++++++++++++
.../harness-selftest.expected | 13 +++++++----
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/kselftest_harness/harness-selftest.c b/tools/testing/selftests/kselftest_harness/harness-selftest.c
index 3e3033d2745a..93b5a5bbf10a 100644
--- a/tools/testing/selftests/kselftest_harness/harness-selftest.c
+++ b/tools/testing/selftests/kselftest_harness/harness-selftest.c
@@ -158,6 +158,29 @@ TEST(test_result_skip) {
ksft_test_result_skip("");
}
+FIXTURE(xfail_ctor_ordering) {
+};
+
+FIXTURE_SETUP(xfail_ctor_ordering) {
+}
+
+FIXTURE_TEARDOWN(xfail_ctor_ordering) {
+}
+
+FIXTURE_VARIANT(xfail_ctor_ordering) {
+ int dummy;
+};
+
+FIXTURE_VARIANT_ADD(xfail_ctor_ordering, only) {
+ .dummy = 0,
+};
+
+TEST_F(xfail_ctor_ordering, expected_fail) {
+ ASSERT_EQ(1, 0);
+}
+
+XFAIL_ADD(xfail_ctor_ordering, only, expected_fail);
+
int main(int argc, char **argv)
{
/*
diff --git a/tools/testing/selftests/kselftest_harness/harness-selftest.expected b/tools/testing/selftests/kselftest_harness/harness-selftest.expected
index c0a68ec124f8..f8b7cb2812b6 100644
--- a/tools/testing/selftests/kselftest_harness/harness-selftest.expected
+++ b/tools/testing/selftests/kselftest_harness/harness-selftest.expected
@@ -1,6 +1,6 @@
TAP version 13
-1..19
-# Starting 19 tests from 4 test cases.
+1..20
+# Starting 20 tests from 5 test cases.
# RUN global.standalone_pass ...
# harness-selftest.c:19:standalone_pass:before
# harness-selftest.c:23:standalone_pass:after
@@ -93,6 +93,11 @@ ok 18 fixture_parent.pass
# pass: Test terminated by assertion
# FAIL fixture_setup_failure.pass
not ok 19 fixture_setup_failure.pass
-# FAILED: 12 / 19 tests passed.
+# RUN xfail_ctor_ordering.only.expected_fail ...
+# harness-selftest.c:179:expected_fail:Expected 1 (1) == 0 (0)
+# expected_fail: Test terminated by assertion
+# FAIL xfail_ctor_ordering.only.expected_fail
+ok 20 xfail_ctor_ordering.only.expected_fail # XFAIL unknown
+# FAILED: 13 / 20 tests passed.
# 1 skipped test(s) detected. Consider enabling relevant config options to improve coverage.
-# Totals: pass:9 fail:7 xfail:1 xpass:1 skip:1 error:0
+# Totals: pass:9 fail:7 xfail:2 xpass:1 skip:1 error:0
--
2.43.0
reply other threads:[~2026-04-30 4:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260430040207.296136-1-sun.jian.kdev@gmail.com \
--to=sun.jian.kdev@gmail.com \
--cc=doebel@amazon.de \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux@weissschuh.net \
--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