diff mbox series

[12/20] KVM: selftests: Use continue to handle all "pass" scenarios in dirty_log_test

Message ID 20241214010721.2356923-13-seanjc@google.com (mailing list archive)
State New
Headers show
Series [01/20] KVM: selftests: Support multiple write retires in dirty_log_test | expand

Commit Message

Sean Christopherson Dec. 14, 2024, 1:07 a.m. UTC
When verifying pages in dirty_log_test, immediately continue on all "pass"
scenarios to make the logic consistent in how it handles pass vs. fail.

No functional change intended.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 tools/testing/selftests/kvm/dirty_log_test.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Maxim Levitsky Dec. 18, 2024, 12:01 a.m. UTC | #1
On Fri, 2024-12-13 at 17:07 -0800, Sean Christopherson wrote:
> When verifying pages in dirty_log_test, immediately continue on all "pass"
> scenarios to make the logic consistent in how it handles pass vs. fail.
> 
> No functional change intended.
> 
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
>  tools/testing/selftests/kvm/dirty_log_test.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c
> index 8544e8425f9c..d7cf1840bd80 100644
> --- a/tools/testing/selftests/kvm/dirty_log_test.c
> +++ b/tools/testing/selftests/kvm/dirty_log_test.c
> @@ -510,8 +510,6 @@ static void vm_dirty_log_verify(enum vm_guest_mode mode, unsigned long *bmap)
>  		}
>  
>  		if (__test_and_clear_bit_le(page, bmap)) {
> -			bool matched;
> -
>  			nr_dirty_pages++;
>  
>  			/*
> @@ -519,9 +517,10 @@ static void vm_dirty_log_verify(enum vm_guest_mode mode, unsigned long *bmap)
>  			 * the corresponding page should be either the
>  			 * previous iteration number or the current one.
>  			 */
> -			matched = (val == iteration || val == iteration - 1);
> +			if (val == iteration || val == iteration - 1)
> +				continue;
>  
> -			if (host_log_mode == LOG_MODE_DIRTY_RING && !matched) {
> +			if (host_log_mode == LOG_MODE_DIRTY_RING) {
>  				if (val == iteration - 2 && min_iter <= iteration - 2) {
>  					/*
>  					 * Short answer: this case is special
> @@ -567,10 +566,8 @@ static void vm_dirty_log_verify(enum vm_guest_mode mode, unsigned long *bmap)
>  				}
>  			}
>  
> -			TEST_ASSERT(matched,
> -				    "Set page %"PRIu64" value %"PRIu64
> -				    " incorrect (iteration=%"PRIu64")",
> -				    page, val, iteration);
> +			TEST_FAIL("Dirty page %lu value (%lu) != iteration (%lu)",
> +				  page, val, iteration);
>  		} else {
>  			nr_clean_pages++;
>  			/*

Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>

Best regards,
	Maxim Levitsky
diff mbox series

Patch

diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c
index 8544e8425f9c..d7cf1840bd80 100644
--- a/tools/testing/selftests/kvm/dirty_log_test.c
+++ b/tools/testing/selftests/kvm/dirty_log_test.c
@@ -510,8 +510,6 @@  static void vm_dirty_log_verify(enum vm_guest_mode mode, unsigned long *bmap)
 		}
 
 		if (__test_and_clear_bit_le(page, bmap)) {
-			bool matched;
-
 			nr_dirty_pages++;
 
 			/*
@@ -519,9 +517,10 @@  static void vm_dirty_log_verify(enum vm_guest_mode mode, unsigned long *bmap)
 			 * the corresponding page should be either the
 			 * previous iteration number or the current one.
 			 */
-			matched = (val == iteration || val == iteration - 1);
+			if (val == iteration || val == iteration - 1)
+				continue;
 
-			if (host_log_mode == LOG_MODE_DIRTY_RING && !matched) {
+			if (host_log_mode == LOG_MODE_DIRTY_RING) {
 				if (val == iteration - 2 && min_iter <= iteration - 2) {
 					/*
 					 * Short answer: this case is special
@@ -567,10 +566,8 @@  static void vm_dirty_log_verify(enum vm_guest_mode mode, unsigned long *bmap)
 				}
 			}
 
-			TEST_ASSERT(matched,
-				    "Set page %"PRIu64" value %"PRIu64
-				    " incorrect (iteration=%"PRIu64")",
-				    page, val, iteration);
+			TEST_FAIL("Dirty page %lu value (%lu) != iteration (%lu)",
+				  page, val, iteration);
 		} else {
 			nr_clean_pages++;
 			/*