All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: selftests: Use TAP in the steal_time test
@ 2023-10-19  9:59 Thomas Huth
  2023-10-19 13:13 ` Andrew Jones
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Thomas Huth @ 2023-10-19  9:59 UTC (permalink / raw)
  To: Paolo Bonzini, kvm; +Cc: Shuah Khan, linux-kselftest, linux-kernel

For easier use of the tests in automation and for having some
status information for the user while the test is running, let's
provide some TAP output in this test.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 NB: This patch does not use the interface from kselftest_harness.h
     since it is not very suitable for the for-loop in this patch.

 tools/testing/selftests/kvm/steal_time.c | 46 ++++++++++++------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/tools/testing/selftests/kvm/steal_time.c b/tools/testing/selftests/kvm/steal_time.c
index 171adfb2a6cb..aa6149eb9ea1 100644
--- a/tools/testing/selftests/kvm/steal_time.c
+++ b/tools/testing/selftests/kvm/steal_time.c
@@ -81,20 +81,18 @@ static void steal_time_init(struct kvm_vcpu *vcpu, uint32_t i)
 static void steal_time_dump(struct kvm_vm *vm, uint32_t vcpu_idx)
 {
 	struct kvm_steal_time *st = addr_gva2hva(vm, (ulong)st_gva[vcpu_idx]);
-	int i;
 
-	pr_info("VCPU%d:\n", vcpu_idx);
-	pr_info("    steal:     %lld\n", st->steal);
-	pr_info("    version:   %d\n", st->version);
-	pr_info("    flags:     %d\n", st->flags);
-	pr_info("    preempted: %d\n", st->preempted);
-	pr_info("    u8_pad:    ");
-	for (i = 0; i < 3; ++i)
-		pr_info("%d", st->u8_pad[i]);
-	pr_info("\n    pad:       ");
-	for (i = 0; i < 11; ++i)
-		pr_info("%d", st->pad[i]);
-	pr_info("\n");
+	ksft_print_msg("VCPU%d:\n", vcpu_idx);
+	ksft_print_msg("    steal:     %lld\n", st->steal);
+	ksft_print_msg("    version:   %d\n", st->version);
+	ksft_print_msg("    flags:     %d\n", st->flags);
+	ksft_print_msg("    preempted: %d\n", st->preempted);
+	ksft_print_msg("    u8_pad:    %d %d %d\n",
+			st->u8_pad[0], st->u8_pad[1], st->u8_pad[2]);
+	ksft_print_msg("    pad:       %d %d %d %d %d %d %d %d %d %d %d\n",
+			st->pad[0], st->pad[1], st->pad[2], st->pad[3],
+			st->pad[4], st->pad[5], st->pad[6], st->pad[7],
+			st->pad[8], st->pad[9], st->pad[10]);
 }
 
 #elif defined(__aarch64__)
@@ -197,10 +195,10 @@ static void steal_time_dump(struct kvm_vm *vm, uint32_t vcpu_idx)
 {
 	struct st_time *st = addr_gva2hva(vm, (ulong)st_gva[vcpu_idx]);
 
-	pr_info("VCPU%d:\n", vcpu_idx);
-	pr_info("    rev:     %d\n", st->rev);
-	pr_info("    attr:    %d\n", st->attr);
-	pr_info("    st_time: %ld\n", st->st_time);
+	ksft_print_msg("VCPU%d:\n", vcpu_idx);
+	ksft_print_msg("    rev:     %d\n", st->rev);
+	ksft_print_msg("    attr:    %d\n", st->attr);
+	ksft_print_msg("    st_time: %ld\n", st->st_time);
 }
 
 #endif
@@ -267,7 +265,9 @@ int main(int ac, char **av)
 	vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS, ST_GPA_BASE, 1, gpages, 0);
 	virt_map(vm, ST_GPA_BASE, ST_GPA_BASE, gpages);
 
+	ksft_print_header();
 	TEST_REQUIRE(is_steal_time_supported(vcpus[0]));
+	ksft_set_plan(NR_VCPUS);
 
 	/* Run test on each VCPU */
 	for (i = 0; i < NR_VCPUS; ++i) {
@@ -308,14 +308,14 @@ int main(int ac, char **av)
 			    run_delay, stolen_time);
 
 		if (verbose) {
-			pr_info("VCPU%d: total-stolen-time=%ld test-stolen-time=%ld", i,
-				guest_stolen_time[i], stolen_time);
-			if (stolen_time == run_delay)
-				pr_info(" (BONUS: guest test-stolen-time even exactly matches test-run_delay)");
-			pr_info("\n");
+			ksft_print_msg("VCPU%d: total-stolen-time=%ld test-stolen-time=%ld%s\n",
+				       i, guest_stolen_time[i], stolen_time,
+				       stolen_time == run_delay ?
+				       " (BONUS: guest test-stolen-time even exactly matches test-run_delay)" : "");
 			steal_time_dump(vm, i);
 		}
+		ksft_test_result_pass("vcpu%d\n", i);
 	}
 
-	return 0;
+	ksft_finished();        /* Print results and exit() accordingly */
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] KVM: selftests: Use TAP in the steal_time test
  2023-10-19  9:59 [PATCH] KVM: selftests: Use TAP in the steal_time test Thomas Huth
@ 2023-10-19 13:13 ` Andrew Jones
  2023-12-11  9:39   ` Thomas Huth
  2024-03-26  8:30 ` Zhao Liu
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Andrew Jones @ 2023-10-19 13:13 UTC (permalink / raw)
  To: Thomas Huth; +Cc: Paolo Bonzini, kvm, Shuah Khan, linux-kselftest, linux-kernel

On Thu, Oct 19, 2023 at 11:59:00AM +0200, Thomas Huth wrote:
> For easier use of the tests in automation and for having some
> status information for the user while the test is running, let's
> provide some TAP output in this test.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  NB: This patch does not use the interface from kselftest_harness.h
>      since it is not very suitable for the for-loop in this patch.
> 
>  tools/testing/selftests/kvm/steal_time.c | 46 ++++++++++++------------
>  1 file changed, 23 insertions(+), 23 deletions(-)
>

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] KVM: selftests: Use TAP in the steal_time test
  2023-10-19 13:13 ` Andrew Jones
@ 2023-12-11  9:39   ` Thomas Huth
  2024-03-15  7:03     ` Thomas Huth
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Huth @ 2023-12-11  9:39 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: kvm, Shuah Khan, linux-kselftest, linux-kernel, Andrew Jones

On 19/10/2023 15.13, Andrew Jones wrote:
> On Thu, Oct 19, 2023 at 11:59:00AM +0200, Thomas Huth wrote:
>> For easier use of the tests in automation and for having some
>> status information for the user while the test is running, let's
>> provide some TAP output in this test.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>   NB: This patch does not use the interface from kselftest_harness.h
>>       since it is not very suitable for the for-loop in this patch.
>>
>>   tools/testing/selftests/kvm/steal_time.c | 46 ++++++++++++------------
>>   1 file changed, 23 insertions(+), 23 deletions(-)
>>
> 
> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>

Thanks Andrew!

Paolo, if there are no other concerns, could you maybe pick it up for kvm/next ?

  Thanks,
   Thomas


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] KVM: selftests: Use TAP in the steal_time test
  2023-12-11  9:39   ` Thomas Huth
@ 2024-03-15  7:03     ` Thomas Huth
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Huth @ 2024-03-15  7:03 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: kvm, Shuah Khan, linux-kselftest, linux-kernel, Andrew Jones

On 11/12/2023 10.39, Thomas Huth wrote:
> On 19/10/2023 15.13, Andrew Jones wrote:
>> On Thu, Oct 19, 2023 at 11:59:00AM +0200, Thomas Huth wrote:
>>> For easier use of the tests in automation and for having some
>>> status information for the user while the test is running, let's
>>> provide some TAP output in this test.
>>>
>>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>>> ---
>>>   NB: This patch does not use the interface from kselftest_harness.h
>>>       since it is not very suitable for the for-loop in this patch.
>>>
>>>   tools/testing/selftests/kvm/steal_time.c | 46 ++++++++++++------------
>>>   1 file changed, 23 insertions(+), 23 deletions(-)
>>>
>>
>> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> 
> Thanks Andrew!
> 
> Paolo, if there are no other concerns, could you maybe pick it up for 
> kvm/next ?

Ping?

  Thomas



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] KVM: selftests: Use TAP in the steal_time test
  2023-10-19  9:59 [PATCH] KVM: selftests: Use TAP in the steal_time test Thomas Huth
  2023-10-19 13:13 ` Andrew Jones
@ 2024-03-26  8:30 ` Zhao Liu
  2024-03-26  9:24 ` Muhammad Usama Anjum
  2024-04-10  0:19 ` Sean Christopherson
  3 siblings, 0 replies; 7+ messages in thread
From: Zhao Liu @ 2024-03-26  8:30 UTC (permalink / raw)
  To: Thomas Huth; +Cc: Paolo Bonzini, kvm, Shuah Khan, linux-kselftest, linux-kernel

On Thu, Oct 19, 2023 at 11:59:00AM +0200, Thomas Huth wrote:
> Date:   Thu, 19 Oct 2023 11:59:00 +0200
> From: Thomas Huth <thuth@redhat.com>
> Subject: [PATCH] KVM: selftests: Use TAP in the steal_time test
> 
> For easier use of the tests in automation and for having some
> status information for the user while the test is running, let's
> provide some TAP output in this test.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  NB: This patch does not use the interface from kselftest_harness.h
>      since it is not very suitable for the for-loop in this patch.
> 
>  tools/testing/selftests/kvm/steal_time.c | 46 ++++++++++++------------
>  1 file changed, 23 insertions(+), 23 deletions(-)
>

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] KVM: selftests: Use TAP in the steal_time test
  2023-10-19  9:59 [PATCH] KVM: selftests: Use TAP in the steal_time test Thomas Huth
  2023-10-19 13:13 ` Andrew Jones
  2024-03-26  8:30 ` Zhao Liu
@ 2024-03-26  9:24 ` Muhammad Usama Anjum
  2024-04-10  0:19 ` Sean Christopherson
  3 siblings, 0 replies; 7+ messages in thread
From: Muhammad Usama Anjum @ 2024-03-26  9:24 UTC (permalink / raw)
  To: Thomas Huth, Paolo Bonzini, kvm
  Cc: Muhammad Usama Anjum, Shuah Khan, linux-kselftest, linux-kernel

On 10/19/23 2:59 PM, Thomas Huth wrote:
> For easier use of the tests in automation and for having some
> status information for the user while the test is running, let's
> provide some TAP output in this test.
LGTM. I was thinking why kselftest.h hasn't been included. I found out that
test_util.h includes kselftest.h.

> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>

> ---
>  NB: This patch does not use the interface from kselftest_harness.h
>      since it is not very suitable for the for-loop in this patch.
> 
>  tools/testing/selftests/kvm/steal_time.c | 46 ++++++++++++------------
>  1 file changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/steal_time.c b/tools/testing/selftests/kvm/steal_time.c
> index 171adfb2a6cb..aa6149eb9ea1 100644
> --- a/tools/testing/selftests/kvm/steal_time.c
> +++ b/tools/testing/selftests/kvm/steal_time.c
> @@ -81,20 +81,18 @@ static void steal_time_init(struct kvm_vcpu *vcpu, uint32_t i)
>  static void steal_time_dump(struct kvm_vm *vm, uint32_t vcpu_idx)
>  {
>  	struct kvm_steal_time *st = addr_gva2hva(vm, (ulong)st_gva[vcpu_idx]);
> -	int i;
>  
> -	pr_info("VCPU%d:\n", vcpu_idx);
> -	pr_info("    steal:     %lld\n", st->steal);
> -	pr_info("    version:   %d\n", st->version);
> -	pr_info("    flags:     %d\n", st->flags);
> -	pr_info("    preempted: %d\n", st->preempted);
> -	pr_info("    u8_pad:    ");
> -	for (i = 0; i < 3; ++i)
> -		pr_info("%d", st->u8_pad[i]);
> -	pr_info("\n    pad:       ");
> -	for (i = 0; i < 11; ++i)
> -		pr_info("%d", st->pad[i]);
> -	pr_info("\n");
> +	ksft_print_msg("VCPU%d:\n", vcpu_idx);
> +	ksft_print_msg("    steal:     %lld\n", st->steal);
> +	ksft_print_msg("    version:   %d\n", st->version);
> +	ksft_print_msg("    flags:     %d\n", st->flags);
> +	ksft_print_msg("    preempted: %d\n", st->preempted);
> +	ksft_print_msg("    u8_pad:    %d %d %d\n",
> +			st->u8_pad[0], st->u8_pad[1], st->u8_pad[2]);
> +	ksft_print_msg("    pad:       %d %d %d %d %d %d %d %d %d %d %d\n",
> +			st->pad[0], st->pad[1], st->pad[2], st->pad[3],
> +			st->pad[4], st->pad[5], st->pad[6], st->pad[7],
> +			st->pad[8], st->pad[9], st->pad[10]);
>  }
>  
>  #elif defined(__aarch64__)
> @@ -197,10 +195,10 @@ static void steal_time_dump(struct kvm_vm *vm, uint32_t vcpu_idx)
>  {
>  	struct st_time *st = addr_gva2hva(vm, (ulong)st_gva[vcpu_idx]);
>  
> -	pr_info("VCPU%d:\n", vcpu_idx);
> -	pr_info("    rev:     %d\n", st->rev);
> -	pr_info("    attr:    %d\n", st->attr);
> -	pr_info("    st_time: %ld\n", st->st_time);
> +	ksft_print_msg("VCPU%d:\n", vcpu_idx);
> +	ksft_print_msg("    rev:     %d\n", st->rev);
> +	ksft_print_msg("    attr:    %d\n", st->attr);
> +	ksft_print_msg("    st_time: %ld\n", st->st_time);
>  }
>  
>  #endif
> @@ -267,7 +265,9 @@ int main(int ac, char **av)
>  	vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS, ST_GPA_BASE, 1, gpages, 0);
>  	virt_map(vm, ST_GPA_BASE, ST_GPA_BASE, gpages);
>  
> +	ksft_print_header();
>  	TEST_REQUIRE(is_steal_time_supported(vcpus[0]));
> +	ksft_set_plan(NR_VCPUS);
>  
>  	/* Run test on each VCPU */
>  	for (i = 0; i < NR_VCPUS; ++i) {
> @@ -308,14 +308,14 @@ int main(int ac, char **av)
>  			    run_delay, stolen_time);
>  
>  		if (verbose) {
> -			pr_info("VCPU%d: total-stolen-time=%ld test-stolen-time=%ld", i,
> -				guest_stolen_time[i], stolen_time);
> -			if (stolen_time == run_delay)
> -				pr_info(" (BONUS: guest test-stolen-time even exactly matches test-run_delay)");
> -			pr_info("\n");
> +			ksft_print_msg("VCPU%d: total-stolen-time=%ld test-stolen-time=%ld%s\n",
> +				       i, guest_stolen_time[i], stolen_time,
> +				       stolen_time == run_delay ?
> +				       " (BONUS: guest test-stolen-time even exactly matches test-run_delay)" : "");
>  			steal_time_dump(vm, i);
>  		}
> +		ksft_test_result_pass("vcpu%d\n", i);
>  	}
>  
> -	return 0;
> +	ksft_finished();        /* Print results and exit() accordingly */
>  }

-- 
BR,
Muhammad Usama Anjum

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] KVM: selftests: Use TAP in the steal_time test
  2023-10-19  9:59 [PATCH] KVM: selftests: Use TAP in the steal_time test Thomas Huth
                   ` (2 preceding siblings ...)
  2024-03-26  9:24 ` Muhammad Usama Anjum
@ 2024-04-10  0:19 ` Sean Christopherson
  3 siblings, 0 replies; 7+ messages in thread
From: Sean Christopherson @ 2024-04-10  0:19 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini, kvm, Thomas Huth
  Cc: Shuah Khan, linux-kselftest, linux-kernel

On Thu, 19 Oct 2023 11:59:00 +0200, Thomas Huth wrote:
> For easier use of the tests in automation and for having some
> status information for the user while the test is running, let's
> provide some TAP output in this test.

Applied to kvm-x86 selftests, though I was mildly tempted to see how many
reviews it could accumulate before someone picked it up. ;-)  Thanks!

[1/1] KVM: selftests: Use TAP in the steal_time test
      https://github.com/kvm-x86/linux/commit/9f92c06e1840

--
https://github.com/kvm-x86/linux/tree/next

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-04-10  0:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-19  9:59 [PATCH] KVM: selftests: Use TAP in the steal_time test Thomas Huth
2023-10-19 13:13 ` Andrew Jones
2023-12-11  9:39   ` Thomas Huth
2024-03-15  7:03     ` Thomas Huth
2024-03-26  8:30 ` Zhao Liu
2024-03-26  9:24 ` Muhammad Usama Anjum
2024-04-10  0:19 ` Sean Christopherson

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.