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@xxxxxxxxxx> --- tools/testing/selftests/kvm/x86_64/emulator_error_test.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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); /* -- 2.38.0.rc1.362.ged0d419d3c-goog