diff mbox series

[3/4] KVM: selftests: Skip emulator_error_test if KVM_CAP_EXIT_ON_EMULATION_FAILURE not available

Message ID 20220929204708.2548375-4-dmatlack@google.com (mailing list archive)
State New, archived
Headers show
Series KVM: selftests: Fix and clean up emulator_error_test | expand

Commit Message

David Matlack Sept. 29, 2022, 8:47 p.m. UTC
Skip emulator_error_test if KVM_CAP_EXIT_ON_EMULATION_FAILURE is not
available rather than failing. This makes emulator_error_test skip on
older kernels and also deletes a net 2 lines of code from the test.

Signed-off-by: David Matlack <dmatlack@google.com>
---
 tools/testing/selftests/kvm/x86_64/emulator_error_test.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/tools/testing/selftests/kvm/x86_64/emulator_error_test.c b/tools/testing/selftests/kvm/x86_64/emulator_error_test.c
index 52ff1eb772e9..4b06c9eefe7d 100644
--- a/tools/testing/selftests/kvm/x86_64/emulator_error_test.c
+++ b/tools/testing/selftests/kvm/x86_64/emulator_error_test.c
@@ -103,15 +103,13 @@  int main(int argc, char *argv[])
 {
 	struct kvm_vcpu *vcpu;
 	struct kvm_vm *vm;
-	int rc;
 
 	/* Tell stdout not to buffer its content */
 	setbuf(stdout, NULL);
 
-	vm = vm_create_with_one_vcpu(&vcpu, guest_code);
+	TEST_REQUIRE(kvm_has_cap(KVM_CAP_EXIT_ON_EMULATION_FAILURE));
 
-	rc = kvm_check_cap(KVM_CAP_EXIT_ON_EMULATION_FAILURE);
-	TEST_ASSERT(rc, "KVM_CAP_EXIT_ON_EMULATION_FAILURE is unavailable");
+	vm = vm_create_with_one_vcpu(&vcpu, guest_code);
 	vm_enable_cap(vm, KVM_CAP_EXIT_ON_EMULATION_FAILURE, 1);
 
 	/*