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 <[email protected]>
Signed-off-by: Sun Jian <[email protected]>
---
 .../kselftest_harness/harness-selftest.c      | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tools/testing/selftests/kselftest_harness/harness-selftest.c 
b/tools/testing/selftests/kselftest_harness/harness-selftest.c
index 7820bb5d0e6d..9920ef7e4385 100644
--- a/tools/testing/selftests/kselftest_harness/harness-selftest.c
+++ b/tools/testing/selftests/kselftest_harness/harness-selftest.c
@@ -118,6 +118,29 @@ TEST_F(fixture_setup_failure, pass) {
        TH_LOG("after");
 }
 
+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)
 {
        /*

base-commit: 1f318b96cc84d7c2ab792fcc0bfd42a7ca890681
-- 
2.43.0


Reply via email to