2024-04-03 16:42:57

by Raghavendra Rao Ananta

[permalink] [raw]
Subject: [PATCH v2] KVM: selftests: Fix build error due to assert in dirty_log_test

The commit e5ed6c922537 ("KVM: selftests: Fix a semaphore imbalance in
the dirty ring logging test") backported the fix from v6.8 to stable
v6.1. However, since the patch uses 'TEST_ASSERT_EQ()', which doesn't
exist on v6.1, the following build error is seen:

dirty_log_test.c:775:2: error: call to undeclared function
'TEST_ASSERT_EQ'; ISO C99 and later do not support implicit function
declarations [-Wimplicit-function-declaration]
TEST_ASSERT_EQ(sem_val, 0);
^
1 error generated.

Replace the macro with its equivalent, 'ASSERT_EQ()' to fix the issue.

Fixes: e5ed6c922537 ("KVM: selftests: Fix a semaphore imbalance in the dirty ring logging test")
Cc: <[email protected]>
Signed-off-by: Raghavendra Rao Ananta <[email protected]>
---
tools/testing/selftests/kvm/dirty_log_test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c
index ec40a33c29fd..711b9e4d86aa 100644
--- a/tools/testing/selftests/kvm/dirty_log_test.c
+++ b/tools/testing/selftests/kvm/dirty_log_test.c
@@ -772,9 +772,9 @@ static void run_test(enum vm_guest_mode mode, void *arg)
* verification of all iterations.
*/
sem_getvalue(&sem_vcpu_stop, &sem_val);
- TEST_ASSERT_EQ(sem_val, 0);
+ ASSERT_EQ(sem_val, 0);
sem_getvalue(&sem_vcpu_cont, &sem_val);
- TEST_ASSERT_EQ(sem_val, 0);
+ ASSERT_EQ(sem_val, 0);

pthread_create(&vcpu_thread, NULL, vcpu_worker, vcpu);


base-commit: e5cd595e23c1a075359a337c0e5c3a4f2dc28dd1
--
2.44.0.478.gd926399ef9-goog



2024-04-03 17:08:06

by Sean Christopherson

[permalink] [raw]
Subject: Re: [PATCH v2] KVM: selftests: Fix build error due to assert in dirty_log_test

On Wed, Apr 03, 2024, Raghavendra Rao Ananta wrote:
> The commit e5ed6c922537 ("KVM: selftests: Fix a semaphore imbalance in
> the dirty ring logging test") backported the fix from v6.8 to stable
> v6.1. However, since the patch uses 'TEST_ASSERT_EQ()', which doesn't
> exist on v6.1, the following build error is seen:
>
> dirty_log_test.c:775:2: error: call to undeclared function
> 'TEST_ASSERT_EQ'; ISO C99 and later do not support implicit function
> declarations [-Wimplicit-function-declaration]
> TEST_ASSERT_EQ(sem_val, 0);
> ^
> 1 error generated.
>
> Replace the macro with its equivalent, 'ASSERT_EQ()' to fix the issue.
>
> Fixes: e5ed6c922537 ("KVM: selftests: Fix a semaphore imbalance in the dirty ring logging test")
> Cc: <[email protected]>
> Signed-off-by: Raghavendra Rao Ananta <[email protected]>

Just to be super explicit, this is specifically for 6.1.y.

Acked-by: Sean Christopherson <[email protected]>

> ---
> tools/testing/selftests/kvm/dirty_log_test.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c
> index ec40a33c29fd..711b9e4d86aa 100644
> --- a/tools/testing/selftests/kvm/dirty_log_test.c
> +++ b/tools/testing/selftests/kvm/dirty_log_test.c
> @@ -772,9 +772,9 @@ static void run_test(enum vm_guest_mode mode, void *arg)
> * verification of all iterations.
> */
> sem_getvalue(&sem_vcpu_stop, &sem_val);
> - TEST_ASSERT_EQ(sem_val, 0);
> + ASSERT_EQ(sem_val, 0);
> sem_getvalue(&sem_vcpu_cont, &sem_val);
> - TEST_ASSERT_EQ(sem_val, 0);
> + ASSERT_EQ(sem_val, 0);
>
> pthread_create(&vcpu_thread, NULL, vcpu_worker, vcpu);
>
>
> base-commit: e5cd595e23c1a075359a337c0e5c3a4f2dc28dd1
> --
> 2.44.0.478.gd926399ef9-goog
>