Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Ackerley Tng <ackerleytng@google.com>
To: Kees Cook <kees@kernel.org>,
	Andy Lutomirski <luto@amacapital.net>,
	Will Drewry <wad@chromium.org>,  Shuah Khan <shuah@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	 Sean Christopherson <seanjc@google.com>,
	thomas.weissschuh@linutronix.de, linux@weissschuh.net
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	 kvm@vger.kernel.org, Ackerley Tng <ackerleytng@google.com>
Subject: [PATCH RFC 4/4] HACK: Show that the teardown function is called from KVM selftests
Date: Tue, 14 Apr 2026 11:07:51 -0700	[thread overview]
Message-ID: <20260414-selftest-global-metadata-v1-4-fd223922bc57@google.com> (raw)
In-Reply-To: <20260414-selftest-global-metadata-v1-0-fd223922bc57@google.com>

Running the selftest tools/testing/selftests/kvm/kvm_test_harness_selftest
gets me this:

$ tools/testing/selftests/kvm/kvm_test_harness_selftest
Random seed: 0x6b8b4567
TAP version 13
1..2
setup
teardown
ok 1 my_fixture.my_test_pass
setup
==== Test Assertion Failure ====
  kvm_test_harness_selftest.c:28: false
  pid=73044 tid=73044 errno=0 - Success
     1  0x0000000000402c04: my_fixture_my_test_assert at kvm_test_harness_selftest.c:28
     2   (inlined by) wrapper_my_fixture_my_test_assert at kvm_test_harness_selftest.c:26
     3  0x0000000000403497: __run_test at kselftest_harness.h:1185
     4  0x0000000000402340: test_harness_run at kselftest_harness.h:1256
     5   (inlined by) main at kvm_test_harness_selftest.c:33
     6  0x000000000041ef10: __libc_start_call_main at libc-start.o:?
     7  0x000000000042108c: __libc_start_main_impl at ??:?
     8  0x00000000004026e0: _start at ??:?
  foobar
teardown
not ok 2 my_fixture.my_test_assert

Signed-off-by: Ackerley Tng <ackerleytng@google.com>
---
 tools/testing/selftests/kvm/Makefile.kvm           |  1 +
 .../selftests/kvm/kvm_test_harness_selftest.c      | 34 ++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm
index 6471fa214a9f9..d32045f7d9396 100644
--- a/tools/testing/selftests/kvm/Makefile.kvm
+++ b/tools/testing/selftests/kvm/Makefile.kvm
@@ -64,6 +64,7 @@ TEST_GEN_PROGS_COMMON += kvm_binary_stats_test
 TEST_GEN_PROGS_COMMON += kvm_create_max_vcpus
 TEST_GEN_PROGS_COMMON += kvm_page_table_test
 TEST_GEN_PROGS_COMMON += set_memory_region_test
+TEST_GEN_PROGS_COMMON += kvm_test_harness_selftest
 
 # Compiled test targets
 TEST_GEN_PROGS_x86 = $(TEST_GEN_PROGS_COMMON)
diff --git a/tools/testing/selftests/kvm/kvm_test_harness_selftest.c b/tools/testing/selftests/kvm/kvm_test_harness_selftest.c
new file mode 100644
index 0000000000000..36ce14226fdb7
--- /dev/null
+++ b/tools/testing/selftests/kvm/kvm_test_harness_selftest.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+
+#include "kselftest_harness.h"
+#include "test_util.h"
+
+FIXTURE(my_fixture)
+{
+
+};
+
+FIXTURE_SETUP(my_fixture)
+{
+	pr_info("setup\n");
+}
+
+FIXTURE_TEARDOWN(my_fixture)
+{
+	pr_info("teardown\n");
+}
+
+TEST_F(my_fixture, my_test_pass)
+{
+	TEST_ASSERT(true, "foobar");
+}
+
+TEST_F(my_fixture, my_test_assert)
+{
+	TEST_ASSERT(false, "foobar");
+}
+
+int main(int argc, char **argv)
+{
+	return test_harness_run(argc, argv);
+}

-- 
2.54.0.rc0.605.g598a273b03-goog


  parent reply	other threads:[~2026-04-14 18:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-14 18:07 [PATCH RFC 0/4] selftests: harness: Provide global metadata pointer to allow clean teardown from selftest libraries Ackerley Tng
2026-04-14 18:07 ` [PATCH RFC 1/4] selftests: harness: Move metadata structs to separate header file Ackerley Tng
2026-04-14 18:07 ` [PATCH RFC 2/4] selftests: harness: Set global current_test_metadata for each test run Ackerley Tng
2026-04-14 18:07 ` [PATCH RFC 3/4] KVM: selftests: Do teardown from kselftest harness if kselftest_harness is used Ackerley Tng
2026-04-14 18:07 ` Ackerley Tng [this message]
2026-05-12 20:24 ` [PATCH RFC 0/4] selftests: harness: Provide global metadata pointer to allow clean teardown from selftest libraries Sean Christopherson
2026-05-13  1:01 ` Kees Cook

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=20260414-selftest-global-metadata-v1-4-fd223922bc57@google.com \
    --to=ackerleytng@google.com \
    --cc=kees@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=luto@amacapital.net \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=shuah@kernel.org \
    --cc=thomas.weissschuh@linutronix.de \
    --cc=wad@chromium.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