KVM: selftests: Use consistent message for test skipping

Signed-off-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Andrew Jones 2020-03-10 10:15:56 +01:00 committed by Paolo Bonzini
parent d9eaf19ecc
commit d0aac3320d
18 changed files with 37 additions and 25 deletions

View File

@ -660,8 +660,8 @@ int main(int argc, char *argv[])
int main(void)
{
printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n");
return KSFT_SKIP;
print_skip("__NR_userfaultfd must be present for userfaultfd test");
return KSFT_SKIP;
}
#endif /* __NR_userfaultfd */

View File

@ -437,8 +437,7 @@ int main(int argc, char *argv[])
dirty_log_manual_caps =
kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
if (!dirty_log_manual_caps) {
fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not available, "
"skipping tests\n");
print_skip("KVM_CLEAR_DIRTY_LOG not available");
exit(KSFT_SKIP);
}
dirty_log_manual_caps &= (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE |

View File

@ -32,6 +32,8 @@ static inline int _no_printf(const char *format, ...) { return 0; }
#define pr_info(...) _no_printf(__VA_ARGS__)
#endif
void print_skip(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
ssize_t test_write(int fd, const void *buf, size_t count);
ssize_t test_read(int fd, void *buf, size_t count);
int test_seq_read(const char *path, char **bufp, size_t *sizep);

View File

@ -82,8 +82,10 @@ test_assert(bool exp, const char *exp_str,
}
va_end(ap);
if (errno == EACCES)
ksft_exit_skip("Access denied - Exiting.\n");
if (errno == EACCES) {
print_skip("Access denied - Exiting");
exit(KSFT_SKIP);
}
exit(254);
}

View File

@ -92,7 +92,7 @@ static void vm_open(struct kvm_vm *vm, int perm)
exit(KSFT_SKIP);
if (!kvm_check_cap(KVM_CAP_IMMEDIATE_EXIT)) {
fprintf(stderr, "immediate_exit not available, skipping test\n");
print_skip("immediate_exit not available");
exit(KSFT_SKIP);
}

View File

@ -7,6 +7,7 @@
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include <assert.h>
#include "test_util.h"
/*
@ -69,3 +70,14 @@ struct timespec timespec_diff(struct timespec start, struct timespec end)
return temp;
}
void print_skip(const char *fmt, ...)
{
va_list ap;
assert(fmt);
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
puts(", skipping test");
}

View File

@ -154,7 +154,7 @@ void nested_svm_check_supported(void)
kvm_get_supported_cpuid_entry(0x80000001);
if (!(entry->ecx & CPUID_SVM)) {
fprintf(stderr, "nested SVM not enabled, skipping test\n");
print_skip("nested SVM not enabled");
exit(KSFT_SKIP);
}
}

View File

@ -381,7 +381,7 @@ void nested_vmx_check_supported(void)
struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1);
if (!(entry->ecx & CPUID_VMX)) {
fprintf(stderr, "nested VMX not enabled, skipping test\n");
print_skip("nested VMX not enabled");
exit(KSFT_SKIP);
}
}

View File

@ -40,7 +40,7 @@ int main(int argc, char *argv[])
maxsize = kvm_check_cap(KVM_CAP_S390_MEM_OP);
if (!maxsize) {
fprintf(stderr, "CAP_S390_MEM_OP not supported -> skip test\n");
print_skip("CAP_S390_MEM_OP not supported");
exit(KSFT_SKIP);
}
if (maxsize > sizeof(mem1))

View File

@ -86,7 +86,7 @@ int main(int argc, char *argv[])
cap = kvm_check_cap(KVM_CAP_SYNC_REGS);
if (!cap) {
fprintf(stderr, "CAP_SYNC_REGS not supported, skipping test\n");
print_skip("CAP_SYNC_REGS not supported");
exit(KSFT_SKIP);
}

View File

@ -72,7 +72,7 @@ int main(int argc, char *argv[])
entry = kvm_get_supported_cpuid_entry(1);
if (!(entry->ecx & X86_FEATURE_XSAVE)) {
printf("XSAVE feature not supported, skipping test\n");
print_skip("XSAVE feature not supported");
return 0;
}

View File

@ -87,7 +87,7 @@ int main(int argc, char *argv[])
if (!kvm_check_cap(KVM_CAP_NESTED_STATE) ||
!kvm_check_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS)) {
printf("capabilities not available, skipping test\n");
print_skip("capabilities not available");
exit(KSFT_SKIP);
}

View File

@ -141,8 +141,7 @@ int main(int argc, char *argv[])
rv = kvm_check_cap(KVM_CAP_HYPERV_CPUID);
if (!rv) {
fprintf(stderr,
"KVM_CAP_HYPERV_CPUID not supported, skip test\n");
print_skip("KVM_CAP_HYPERV_CPUID not supported");
exit(KSFT_SKIP);
}
@ -160,8 +159,7 @@ int main(int argc, char *argv[])
free(hv_cpuid_entries);
if (!kvm_check_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS)) {
fprintf(stderr,
"Enlightened VMCS is unsupported, skip related test\n");
print_skip("Enlightened VMCS is unsupported");
goto vm_free;
}

View File

@ -93,12 +93,12 @@ int main(void)
int warnings_before, warnings_after;
if (!is_intel_cpu()) {
printf("Must be run on an Intel CPU, skipping test\n");
print_skip("Must be run on an Intel CPU");
exit(KSFT_SKIP);
}
if (vm_is_unrestricted_guest(NULL)) {
printf("Unrestricted guest must be disabled, skipping test\n");
print_skip("Unrestricted guest must be disabled");
exit(KSFT_SKIP);
}

View File

@ -88,8 +88,7 @@ int main(int argc, char *argv[])
rv = kvm_check_cap(KVM_CAP_MSR_PLATFORM_INFO);
if (!rv) {
fprintf(stderr,
"KVM_CAP_MSR_PLATFORM_INFO not supported, skip test\n");
print_skip("KVM_CAP_MSR_PLATFORM_INFO not supported");
exit(KSFT_SKIP);
}

View File

@ -91,11 +91,11 @@ int main(int argc, char *argv[])
cap = kvm_check_cap(KVM_CAP_SYNC_REGS);
if ((cap & TEST_SYNC_FIELDS) != TEST_SYNC_FIELDS) {
fprintf(stderr, "KVM_CAP_SYNC_REGS not supported, skipping test\n");
print_skip("KVM_CAP_SYNC_REGS not supported");
exit(KSFT_SKIP);
}
if ((cap & INVALID_SYNC_FIELD) != 0) {
fprintf(stderr, "The \"invalid\" field is not invalid, skipping test\n");
print_skip("The \"invalid\" field is not invalid");
exit(KSFT_SKIP);
}

View File

@ -228,7 +228,7 @@ int main(int argc, char *argv[])
have_evmcs = kvm_check_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS);
if (!kvm_check_cap(KVM_CAP_NESTED_STATE)) {
printf("KVM_CAP_NESTED_STATE not available, skipping test\n");
print_skip("KVM_CAP_NESTED_STATE not available");
exit(KSFT_SKIP);
}

View File

@ -51,7 +51,7 @@ int main(int argc, char *argv[])
xss_supported = entry && !!(entry->eax & X86_FEATURE_XSAVES);
}
if (!xss_supported) {
printf("IA32_XSS is not supported by the vCPU, skipping test\n");
print_skip("IA32_XSS is not supported by the vCPU");
exit(KSFT_SKIP);
}