Commit d0aac332 authored by Andrew Jones's avatar Andrew Jones Committed by Paolo Bonzini

KVM: selftests: Use consistent message for test skipping

Signed-off-by: default avatarAndrew Jones <drjones@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent d9eaf19e
......@@ -660,7 +660,7 @@ int main(int argc, char *argv[])
int main(void)
{
printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n");
print_skip("__NR_userfaultfd must be present for userfaultfd test");
return KSFT_SKIP;
}
......
......@@ -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 |
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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");
}
......@@ -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);
}
}
......
......@@ -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);
}
}
......
......@@ -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))
......
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment