diff mbox series

[v2,4/4] KVM: s390: selftests: Use TAP interface in the reset test

Message ID 20220419185857.128351-5-thuth@redhat.com (mailing list archive)
State New
Headers show
Series KVM: s390: selftests: Provide TAP output in tests | expand

Commit Message

Thomas Huth April 19, 2022, 6:58 p.m. UTC
Let's standardize the s390x KVM selftest output to the TAP output
generated via the kselftests.h interface.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tools/testing/selftests/kvm/s390x/resets.c | 38 +++++++++++++++++-----
 1 file changed, 30 insertions(+), 8 deletions(-)

Comments

Janosch Frank April 20, 2022, 10:34 a.m. UTC | #1
On 4/19/22 20:58, Thomas Huth wrote:
> Let's standardize the s390x KVM selftest output to the TAP output
> generated via the kselftests.h interface.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---

Reviewed-by: Janosch Frank <frankja@linux.ibm.com>

[...]
> -	return 0;
> +
> +	ksft_finished();

main() is still int so it looks really weird, that we remove the return 
here. After reading the ksft_finished() code I know that we never return 
because we do an exit() but I'd like to have a comment, change to void 
or noreturn tag to make this clearer.

I'd guess that's true for all 4 patches.

>   }
Thomas Huth April 29, 2022, 6:21 a.m. UTC | #2
On 20/04/2022 12.34, Janosch Frank wrote:
> On 4/19/22 20:58, Thomas Huth wrote:
>> Let's standardize the s390x KVM selftest output to the TAP output
>> generated via the kselftests.h interface.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
> 
> Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
> 
> [...]
>> -    return 0;
>> +
>> +    ksft_finished();
> 
> main() is still int so it looks really weird, that we remove the return 
> here. After reading the ksft_finished() code I know that we never return 
> because we do an exit() but I'd like to have a comment, change to void or 
> noreturn tag to make this clearer.

Changing the return type of main() to void causes a compiler warning here, 
so I'll go with the comment.

  Thomas
diff mbox series

Patch

diff --git a/tools/testing/selftests/kvm/s390x/resets.c b/tools/testing/selftests/kvm/s390x/resets.c
index b143db6d8693..1d649ec77260 100644
--- a/tools/testing/selftests/kvm/s390x/resets.c
+++ b/tools/testing/selftests/kvm/s390x/resets.c
@@ -12,6 +12,7 @@ 
 
 #include "test_util.h"
 #include "kvm_util.h"
+#include "kselftest.h"
 
 #define VCPU_ID 3
 #define LOCAL_IRQS 32
@@ -202,7 +203,7 @@  static void inject_irq(int cpu_id)
 
 static void test_normal(void)
 {
-	pr_info("Testing normal reset\n");
+	ksft_print_msg("Testing normal reset\n");
 	/* Create VM */
 	vm = vm_create_default(VCPU_ID, 0, guest_code_initial);
 	run = vcpu_state(vm, VCPU_ID);
@@ -225,7 +226,7 @@  static void test_normal(void)
 
 static void test_initial(void)
 {
-	pr_info("Testing initial reset\n");
+	ksft_print_msg("Testing initial reset\n");
 	vm = vm_create_default(VCPU_ID, 0, guest_code_initial);
 	run = vcpu_state(vm, VCPU_ID);
 	sync_regs = &run->s.regs;
@@ -247,7 +248,7 @@  static void test_initial(void)
 
 static void test_clear(void)
 {
-	pr_info("Testing clear reset\n");
+	ksft_print_msg("Testing clear reset\n");
 	vm = vm_create_default(VCPU_ID, 0, guest_code_initial);
 	run = vcpu_state(vm, VCPU_ID);
 	sync_regs = &run->s.regs;
@@ -266,14 +267,35 @@  static void test_clear(void)
 	kvm_vm_free(vm);
 }
 
+struct testdef {
+	const char *name;
+	void (*test)(void);
+	bool needs_cap;
+} testlist[] = {
+	{ "initial", test_initial, false },
+	{ "normal", test_normal, true },
+	{ "clear", test_clear, true },
+};
+
 int main(int argc, char *argv[])
 {
+	bool has_s390_vcpu_resets = kvm_check_cap(KVM_CAP_S390_VCPU_RESETS);
+	int idx;
+
 	setbuf(stdout, NULL);	/* Tell stdout not to buffer its content */
 
-	test_initial();
-	if (kvm_check_cap(KVM_CAP_S390_VCPU_RESETS)) {
-		test_normal();
-		test_clear();
+	ksft_print_header();
+	ksft_set_plan(ARRAY_SIZE(testlist));
+
+	for (idx = 0; idx < ARRAY_SIZE(testlist); idx++) {
+		if (!testlist[idx].needs_cap || has_s390_vcpu_resets) {
+			testlist[idx].test();
+			ksft_test_result_pass("%s\n", testlist[idx].name);
+		} else {
+			ksft_test_result_skip("%s - no VCPU_RESETS capability\n",
+					      testlist[idx].name);
+		}
 	}
-	return 0;
+
+	ksft_finished();
 }