All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: kvm@vger.kernel.org,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	David Hildenbrand <david@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Shuah Khan <shuah@kernel.org>,
	Janis Schoetterl-Glausch <scgl@linux.ibm.com>,
	linux-s390@vger.kernel.org
Subject: [PATCH v2 1/4] KVM: s390: selftests: Use TAP interface in the memop test
Date: Tue, 19 Apr 2022 20:58:54 +0200	[thread overview]
Message-ID: <20220419185857.128351-2-thuth@redhat.com> (raw)
In-Reply-To: <20220419185857.128351-1-thuth@redhat.com>

The memop test currently does not have any output (unless one of the
TEST_ASSERT statement fails), so it's hard to say for a user whether
a certain new sub-test has been included in the binary or not. Let's
make this a little bit more user-friendly and include some TAP output
via the kselftests.h interface.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tools/testing/selftests/kvm/s390x/memop.c | 90 ++++++++++++++++++-----
 1 file changed, 73 insertions(+), 17 deletions(-)

diff --git a/tools/testing/selftests/kvm/s390x/memop.c b/tools/testing/selftests/kvm/s390x/memop.c
index b04c2c1b3c30..ad9fe86c0592 100644
--- a/tools/testing/selftests/kvm/s390x/memop.c
+++ b/tools/testing/selftests/kvm/s390x/memop.c
@@ -12,6 +12,7 @@
 
 #include "test_util.h"
 #include "kvm_util.h"
+#include "kselftest.h"
 
 enum mop_target {
 	LOGICAL,
@@ -648,33 +649,88 @@ static void test_errors(void)
 	kvm_vm_free(t.kvm_vm);
 }
 
+struct testdef {
+	const char *name;
+	void (*test)(void);
+	int cap;
+} testlist[] = {
+	{
+		.name = "simple copy",
+		.test = test_copy,
+	},
+	{
+		.name = "generic error checks",
+		.test = test_errors,
+	},
+	{
+		.name = "copy with storage keys",
+		.test = test_copy_key,
+		.cap = KVM_CAP_S390_MEM_OP_EXTENSION,
+	},
+	{
+		.name = "copy with key storage protection override",
+		.test = test_copy_key_storage_prot_override,
+		.cap = KVM_CAP_S390_MEM_OP_EXTENSION,
+	},
+	{
+		.name = "copy with key fetch protection",
+		.test = test_copy_key_fetch_prot,
+		.cap = KVM_CAP_S390_MEM_OP_EXTENSION,
+	},
+	{
+		.name = "copy with key fetch protection override",
+		.test = test_copy_key_fetch_prot_override,
+		.cap = KVM_CAP_S390_MEM_OP_EXTENSION,
+	},
+	{
+		.name = "error checks with key",
+		.test = test_errors_key,
+		.cap = KVM_CAP_S390_MEM_OP_EXTENSION,
+	},
+	{
+		.name = "error checks with key storage protection override",
+		.test = test_errors_key_storage_prot_override,
+		.cap = KVM_CAP_S390_MEM_OP_EXTENSION,
+	},
+	{
+		.name = "error checks without key fetch prot override",
+		.test = test_errors_key_fetch_prot_override_not_enabled,
+		.cap = KVM_CAP_S390_MEM_OP_EXTENSION,
+	},
+	{
+		.name = "error checks with key fetch prot override",
+		.test = test_errors_key_fetch_prot_override_enabled,
+		.cap = KVM_CAP_S390_MEM_OP_EXTENSION,
+	},
+};
+
 int main(int argc, char *argv[])
 {
-	int memop_cap, extension_cap;
+	int memop_cap, extension_cap, idx;
 
 	setbuf(stdout, NULL);	/* Tell stdout not to buffer its content */
 
+	ksft_print_header();
+
 	memop_cap = kvm_check_cap(KVM_CAP_S390_MEM_OP);
 	extension_cap = kvm_check_cap(KVM_CAP_S390_MEM_OP_EXTENSION);
 	if (!memop_cap) {
-		print_skip("CAP_S390_MEM_OP not supported");
-		exit(KSFT_SKIP);
+		ksft_exit_skip("CAP_S390_MEM_OP not supported.\n");
 	}
 
-	test_copy();
-	if (extension_cap > 0) {
-		test_copy_key();
-		test_copy_key_storage_prot_override();
-		test_copy_key_fetch_prot();
-		test_copy_key_fetch_prot_override();
-		test_errors_key();
-		test_errors_key_storage_prot_override();
-		test_errors_key_fetch_prot_override_not_enabled();
-		test_errors_key_fetch_prot_override_enabled();
-	} else {
-		print_skip("storage key memop extension not supported");
+	ksft_set_plan(ARRAY_SIZE(testlist));
+
+	for (idx = 0; idx < ARRAY_SIZE(testlist); idx++) {
+		if (!testlist[idx].cap || (extension_cap &&
+		    testlist[idx].cap == KVM_CAP_S390_MEM_OP_EXTENSION)) {
+			testlist[idx].test();
+			ksft_test_result_pass("%s\n", testlist[idx].name);
+		} else {
+			ksft_test_result_skip("%s - capability %d not supported\n",
+					      testlist[idx].name,
+					      testlist[idx].cap);
+		}
 	}
-	test_errors();
 
-	return 0;
+	ksft_finished();
 }
-- 
2.27.0


  reply	other threads:[~2022-04-19 18:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-19 18:58 [PATCH v2 0/4] KVM: s390: selftests: Provide TAP output in tests Thomas Huth
2022-04-19 18:58 ` Thomas Huth [this message]
2022-04-20  9:21   ` [PATCH v2 1/4] KVM: s390: selftests: Use TAP interface in the memop test Janosch Frank
2022-04-19 18:58 ` [PATCH v2 2/4] KVM: s390: selftests: Use TAP interface in the sync_regs test Thomas Huth
2022-04-20  9:29   ` Janosch Frank
2022-04-19 18:58 ` [PATCH v2 3/4] KVM: s390: selftests: Use TAP interface in the tprot test Thomas Huth
2022-04-20 10:23   ` Janosch Frank
2022-04-20 11:38   ` Janis Schoetterl-Glausch
2022-04-20 11:46     ` Thomas Huth
2022-04-20 12:06       ` Janis Schoetterl-Glausch
2022-04-19 18:58 ` [PATCH v2 4/4] KVM: s390: selftests: Use TAP interface in the reset test Thomas Huth
2022-04-20 10:34   ` Janosch Frank
2022-04-29  6:21     ` Thomas Huth

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=20220419185857.128351-2-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=scgl@linux.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.