Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: selftests: Use consistent message for test skipping

Signed-off-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Andrew Jones and committed by
Paolo Bonzini
d0aac332 d9eaf19e

+37 -25
+2 -2
tools/testing/selftests/kvm/demand_paging_test.c
··· 660 660 661 661 int main(void) 662 662 { 663 - printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n"); 664 - return KSFT_SKIP; 663 + print_skip("__NR_userfaultfd must be present for userfaultfd test"); 664 + return KSFT_SKIP; 665 665 } 666 666 667 667 #endif /* __NR_userfaultfd */
+1 -2
tools/testing/selftests/kvm/dirty_log_test.c
··· 437 437 dirty_log_manual_caps = 438 438 kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2); 439 439 if (!dirty_log_manual_caps) { 440 - fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not available, " 441 - "skipping tests\n"); 440 + print_skip("KVM_CLEAR_DIRTY_LOG not available"); 442 441 exit(KSFT_SKIP); 443 442 } 444 443 dirty_log_manual_caps &= (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE |
+2
tools/testing/selftests/kvm/include/test_util.h
··· 32 32 #define pr_info(...) _no_printf(__VA_ARGS__) 33 33 #endif 34 34 35 + void print_skip(const char *fmt, ...) __attribute__((format(printf, 1, 2))); 36 + 35 37 ssize_t test_write(int fd, const void *buf, size_t count); 36 38 ssize_t test_read(int fd, void *buf, size_t count); 37 39 int test_seq_read(const char *path, char **bufp, size_t *sizep);
+4 -2
tools/testing/selftests/kvm/lib/assert.c
··· 82 82 } 83 83 va_end(ap); 84 84 85 - if (errno == EACCES) 86 - ksft_exit_skip("Access denied - Exiting.\n"); 85 + if (errno == EACCES) { 86 + print_skip("Access denied - Exiting"); 87 + exit(KSFT_SKIP); 88 + } 87 89 exit(254); 88 90 } 89 91
+1 -1
tools/testing/selftests/kvm/lib/kvm_util.c
··· 92 92 exit(KSFT_SKIP); 93 93 94 94 if (!kvm_check_cap(KVM_CAP_IMMEDIATE_EXIT)) { 95 - fprintf(stderr, "immediate_exit not available, skipping test\n"); 95 + print_skip("immediate_exit not available"); 96 96 exit(KSFT_SKIP); 97 97 } 98 98
+12
tools/testing/selftests/kvm/lib/test_util.c
··· 7 7 #include <stdlib.h> 8 8 #include <ctype.h> 9 9 #include <limits.h> 10 + #include <assert.h> 10 11 #include "test_util.h" 11 12 12 13 /* ··· 69 68 } 70 69 71 70 return temp; 71 + } 72 + 73 + void print_skip(const char *fmt, ...) 74 + { 75 + va_list ap; 76 + 77 + assert(fmt); 78 + va_start(ap, fmt); 79 + vprintf(fmt, ap); 80 + va_end(ap); 81 + puts(", skipping test"); 72 82 }
+1 -1
tools/testing/selftests/kvm/lib/x86_64/svm.c
··· 154 154 kvm_get_supported_cpuid_entry(0x80000001); 155 155 156 156 if (!(entry->ecx & CPUID_SVM)) { 157 - fprintf(stderr, "nested SVM not enabled, skipping test\n"); 157 + print_skip("nested SVM not enabled"); 158 158 exit(KSFT_SKIP); 159 159 } 160 160 }
+1 -1
tools/testing/selftests/kvm/lib/x86_64/vmx.c
··· 381 381 struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1); 382 382 383 383 if (!(entry->ecx & CPUID_VMX)) { 384 - fprintf(stderr, "nested VMX not enabled, skipping test\n"); 384 + print_skip("nested VMX not enabled"); 385 385 exit(KSFT_SKIP); 386 386 } 387 387 }
+1 -1
tools/testing/selftests/kvm/s390x/memop.c
··· 40 40 41 41 maxsize = kvm_check_cap(KVM_CAP_S390_MEM_OP); 42 42 if (!maxsize) { 43 - fprintf(stderr, "CAP_S390_MEM_OP not supported -> skip test\n"); 43 + print_skip("CAP_S390_MEM_OP not supported"); 44 44 exit(KSFT_SKIP); 45 45 } 46 46 if (maxsize > sizeof(mem1))
+1 -1
tools/testing/selftests/kvm/s390x/sync_regs_test.c
··· 86 86 87 87 cap = kvm_check_cap(KVM_CAP_SYNC_REGS); 88 88 if (!cap) { 89 - fprintf(stderr, "CAP_SYNC_REGS not supported, skipping test\n"); 89 + print_skip("CAP_SYNC_REGS not supported"); 90 90 exit(KSFT_SKIP); 91 91 } 92 92
+1 -1
tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c
··· 72 72 73 73 entry = kvm_get_supported_cpuid_entry(1); 74 74 if (!(entry->ecx & X86_FEATURE_XSAVE)) { 75 - printf("XSAVE feature not supported, skipping test\n"); 75 + print_skip("XSAVE feature not supported"); 76 76 return 0; 77 77 } 78 78
+1 -1
tools/testing/selftests/kvm/x86_64/evmcs_test.c
··· 87 87 88 88 if (!kvm_check_cap(KVM_CAP_NESTED_STATE) || 89 89 !kvm_check_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS)) { 90 - printf("capabilities not available, skipping test\n"); 90 + print_skip("capabilities not available"); 91 91 exit(KSFT_SKIP); 92 92 } 93 93
+2 -4
tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
··· 141 141 142 142 rv = kvm_check_cap(KVM_CAP_HYPERV_CPUID); 143 143 if (!rv) { 144 - fprintf(stderr, 145 - "KVM_CAP_HYPERV_CPUID not supported, skip test\n"); 144 + print_skip("KVM_CAP_HYPERV_CPUID not supported"); 146 145 exit(KSFT_SKIP); 147 146 } 148 147 ··· 159 160 free(hv_cpuid_entries); 160 161 161 162 if (!kvm_check_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS)) { 162 - fprintf(stderr, 163 - "Enlightened VMCS is unsupported, skip related test\n"); 163 + print_skip("Enlightened VMCS is unsupported"); 164 164 goto vm_free; 165 165 } 166 166
+2 -2
tools/testing/selftests/kvm/x86_64/mmio_warning_test.c
··· 93 93 int warnings_before, warnings_after; 94 94 95 95 if (!is_intel_cpu()) { 96 - printf("Must be run on an Intel CPU, skipping test\n"); 96 + print_skip("Must be run on an Intel CPU"); 97 97 exit(KSFT_SKIP); 98 98 } 99 99 100 100 if (vm_is_unrestricted_guest(NULL)) { 101 - printf("Unrestricted guest must be disabled, skipping test\n"); 101 + print_skip("Unrestricted guest must be disabled"); 102 102 exit(KSFT_SKIP); 103 103 } 104 104
+1 -2
tools/testing/selftests/kvm/x86_64/platform_info_test.c
··· 88 88 89 89 rv = kvm_check_cap(KVM_CAP_MSR_PLATFORM_INFO); 90 90 if (!rv) { 91 - fprintf(stderr, 92 - "KVM_CAP_MSR_PLATFORM_INFO not supported, skip test\n"); 91 + print_skip("KVM_CAP_MSR_PLATFORM_INFO not supported"); 93 92 exit(KSFT_SKIP); 94 93 } 95 94
+2 -2
tools/testing/selftests/kvm/x86_64/sync_regs_test.c
··· 91 91 92 92 cap = kvm_check_cap(KVM_CAP_SYNC_REGS); 93 93 if ((cap & TEST_SYNC_FIELDS) != TEST_SYNC_FIELDS) { 94 - fprintf(stderr, "KVM_CAP_SYNC_REGS not supported, skipping test\n"); 94 + print_skip("KVM_CAP_SYNC_REGS not supported"); 95 95 exit(KSFT_SKIP); 96 96 } 97 97 if ((cap & INVALID_SYNC_FIELD) != 0) { 98 - fprintf(stderr, "The \"invalid\" field is not invalid, skipping test\n"); 98 + print_skip("The \"invalid\" field is not invalid"); 99 99 exit(KSFT_SKIP); 100 100 } 101 101
+1 -1
tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c
··· 228 228 have_evmcs = kvm_check_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS); 229 229 230 230 if (!kvm_check_cap(KVM_CAP_NESTED_STATE)) { 231 - printf("KVM_CAP_NESTED_STATE not available, skipping test\n"); 231 + print_skip("KVM_CAP_NESTED_STATE not available"); 232 232 exit(KSFT_SKIP); 233 233 } 234 234
+1 -1
tools/testing/selftests/kvm/x86_64/xss_msr_test.c
··· 51 51 xss_supported = entry && !!(entry->eax & X86_FEATURE_XSAVES); 52 52 } 53 53 if (!xss_supported) { 54 - printf("IA32_XSS is not supported by the vCPU, skipping test\n"); 54 + print_skip("IA32_XSS is not supported by the vCPU"); 55 55 exit(KSFT_SKIP); 56 56 } 57 57