[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <apcrmtprcj7uqqkozjdd7t7lrlef5y7et4if7gfdupu6oopvu6@7v7umuew3zjp>
Date: Thu, 20 Nov 2025 23:46:39 +0000
From: Yosry Ahmed <yosry.ahmed@...ux.dev>
To: Sean Christopherson <seanjc@...gle.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>, Jim Mattson <jmattson@...gle.com>,
kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 01/23] KVM: selftests: Minor improvements to asserts
in test_vmx_nested_state()
On Thu, Nov 20, 2025 at 03:40:35PM -0800, Sean Christopherson wrote:
> On Tue, Oct 21, 2025, Yosry Ahmed wrote:
> > Display the address as hex if the asserts for the vmxon_pa and vmcs12_pa
> > fail, and assert that the flags are 0 as expected.
> >
> > Reviewed-by: Jim Mattson <jmattson@...gle.com>
> > Signed-off-by: Yosry Ahmed <yosry.ahmed@...ux.dev>
> > ---
> > .../selftests/kvm/x86/vmx_set_nested_state_test.c | 10 ++++++++--
> > 1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/testing/selftests/kvm/x86/vmx_set_nested_state_test.c b/tools/testing/selftests/kvm/x86/vmx_set_nested_state_test.c
> > index 67a62a5a88951..c4c400d2824c1 100644
> > --- a/tools/testing/selftests/kvm/x86/vmx_set_nested_state_test.c
> > +++ b/tools/testing/selftests/kvm/x86/vmx_set_nested_state_test.c
> > @@ -241,8 +241,14 @@ void test_vmx_nested_state(struct kvm_vcpu *vcpu)
> > TEST_ASSERT(state->size >= sizeof(*state) && state->size <= state_sz,
> > "Size must be between %ld and %d. The size returned was %d.",
> > sizeof(*state), state_sz, state->size);
> > - TEST_ASSERT(state->hdr.vmx.vmxon_pa == -1ull, "vmxon_pa must be -1ull.");
> > - TEST_ASSERT(state->hdr.vmx.vmcs12_pa == -1ull, "vmcs_pa must be -1ull.");
> > + TEST_ASSERT(state->hdr.vmx.vmxon_pa == -1ull,
> > + "vmxon_pa must be 0x%llx, but was 0x%llx",
> > + -1ull, state->hdr.vmx.vmxon_pa);
> > + TEST_ASSERT(state->hdr.vmx.vmcs12_pa == -1ull,
> > + "vmcs12_pa must be 0x%llx, but was 0x%llx",
> > + -1llu, state->hdr.vmx.vmcs12_pa);
> > + TEST_ASSERT(state->flags == 0,
> > + "Flags must be equal to 0, but was 0x%hx", state->flags);
>
> The error messages aren't adding a whole lot, why not just use TEST_ASSERT_EQ()?
I hadn't discovered TEST_ASSERT_EQ() at that point in my life, not until
later while working on that series :D
Seems like TEST_ASSERT_EQ() already prints in hex, so that's nice. I can
switch to TEST_ASSERT_EQ() if/when I respin.
Powered by blists - more mailing lists