Skip to content

Commit f694f30

Browse files
pratiksampatsean-jc
authored andcommitted
KVM: selftests: Replace assert() with TEST_ASSERT_EQ()
For SEV tests, assert() failures on VM type or fd do not provide sufficient error reporting. Replace assert() with TEST_ASSERT_EQ() to obtain more detailed information on the assertion condition failure, including the call stack. Signed-off-by: Pratik R. Sampat <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent acf0643 commit f694f30

File tree

1 file changed

+4
-4
lines changed
  • tools/testing/selftests/kvm/lib/x86

1 file changed

+4
-4
lines changed

tools/testing/selftests/kvm/lib/x86/sev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,25 @@ static void encrypt_region(struct kvm_vm *vm, struct userspace_mem_region *regio
3737
void sev_vm_init(struct kvm_vm *vm)
3838
{
3939
if (vm->type == KVM_X86_DEFAULT_VM) {
40-
assert(vm->arch.sev_fd == -1);
40+
TEST_ASSERT_EQ(vm->arch.sev_fd, -1);
4141
vm->arch.sev_fd = open_sev_dev_path_or_exit();
4242
vm_sev_ioctl(vm, KVM_SEV_INIT, NULL);
4343
} else {
4444
struct kvm_sev_init init = { 0 };
45-
assert(vm->type == KVM_X86_SEV_VM);
45+
TEST_ASSERT_EQ(vm->type, KVM_X86_SEV_VM);
4646
vm_sev_ioctl(vm, KVM_SEV_INIT2, &init);
4747
}
4848
}
4949

5050
void sev_es_vm_init(struct kvm_vm *vm)
5151
{
5252
if (vm->type == KVM_X86_DEFAULT_VM) {
53-
assert(vm->arch.sev_fd == -1);
53+
TEST_ASSERT_EQ(vm->arch.sev_fd, -1);
5454
vm->arch.sev_fd = open_sev_dev_path_or_exit();
5555
vm_sev_ioctl(vm, KVM_SEV_ES_INIT, NULL);
5656
} else {
5757
struct kvm_sev_init init = { 0 };
58-
assert(vm->type == KVM_X86_SEV_ES_VM);
58+
TEST_ASSERT_EQ(vm->type, KVM_X86_SEV_ES_VM);
5959
vm_sev_ioctl(vm, KVM_SEV_INIT2, &init);
6060
}
6161
}

0 commit comments

Comments
 (0)