Skip to content

Commit 06b651d

Browse files
committed
KVM: selftests: Convert x86's CPUID test to printf style GUEST_ASSERT
Convert x86's CPUID test to use printf-based GUEST_ASSERT_EQ() so that the test prints out debug information. Note, the test previously used REPORT_GUEST_ASSERT_2(), but that was pointless because none of the guest-side code passed any parameters to the assert. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 3d9bd83 commit 06b651d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tools/testing/selftests/kvm/x86_64/cpuid_test.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*
55
* Generic tests for KVM CPUID set/get ioctls
66
*/
7+
#define USE_GUEST_ASSERT_PRINTF 1
8+
79
#include <asm/kvm_para.h>
810
#include <linux/kvm_para.h>
911
#include <stdint.h>
@@ -35,10 +37,10 @@ static void test_guest_cpuids(struct kvm_cpuid2 *guest_cpuid)
3537
guest_cpuid->entries[i].index,
3638
&eax, &ebx, &ecx, &edx);
3739

38-
GUEST_ASSERT(eax == guest_cpuid->entries[i].eax &&
39-
ebx == guest_cpuid->entries[i].ebx &&
40-
ecx == guest_cpuid->entries[i].ecx &&
41-
edx == guest_cpuid->entries[i].edx);
40+
GUEST_ASSERT_EQ(eax, guest_cpuid->entries[i].eax);
41+
GUEST_ASSERT_EQ(ebx, guest_cpuid->entries[i].ebx);
42+
GUEST_ASSERT_EQ(ecx, guest_cpuid->entries[i].ecx);
43+
GUEST_ASSERT_EQ(edx, guest_cpuid->entries[i].edx);
4244
}
4345

4446
}
@@ -51,7 +53,7 @@ static void guest_main(struct kvm_cpuid2 *guest_cpuid)
5153

5254
GUEST_SYNC(2);
5355

54-
GUEST_ASSERT(this_cpu_property(X86_PROPERTY_MAX_KVM_LEAF) == 0x40000001);
56+
GUEST_ASSERT_EQ(this_cpu_property(X86_PROPERTY_MAX_KVM_LEAF), 0x40000001);
5557

5658
GUEST_DONE();
5759
}
@@ -116,7 +118,7 @@ static void run_vcpu(struct kvm_vcpu *vcpu, int stage)
116118
case UCALL_DONE:
117119
return;
118120
case UCALL_ABORT:
119-
REPORT_GUEST_ASSERT_2(uc, "values: %#lx, %#lx");
121+
REPORT_GUEST_ASSERT(uc);
120122
default:
121123
TEST_ASSERT(false, "Unexpected exit: %s",
122124
exit_reason_str(vcpu->run->exit_reason));

0 commit comments

Comments
 (0)