summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/kvm/s390x
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2022-05-27 16:24:02 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2022-06-11 11:47:29 -0400
commit7ed397d107d461a53e350e5025d68ec3c4a8934d (patch)
treead575aa65d292978ad352451b1e5ad8662ff07ce /tools/testing/selftests/kvm/s390x
parent3ea9b809650b4eda5d4ae18ed7bb080e499af154 (diff)
downloadlinux-stable-7ed397d107d461a53e350e5025d68ec3c4a8934d.tar.gz
linux-stable-7ed397d107d461a53e350e5025d68ec3c4a8934d.tar.bz2
linux-stable-7ed397d107d461a53e350e5025d68ec3c4a8934d.zip
KVM: selftests: Add TEST_REQUIRE macros to reduce skipping copy+paste
Add TEST_REQUIRE() and __TEST_REQUIRE() to replace the myriad open coded instances of selftests exiting with KSFT_SKIP after printing an informational message. In addition to reducing the amount of boilerplate code in selftests, the UPPERCASE macro names make it easier to visually identify a test's requirements. Convert usage that erroneously uses something other than print_skip() and/or "exits" with '0' or some other non-KSFT_SKIP value. Intentionally drop a kvm_vm_free() in aarch64/debug-exceptions.c as part of the conversion. All memory and file descriptors are freed on process exit, so the explicit free is superfluous. Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm/s390x')
-rw-r--r--tools/testing/selftests/kvm/s390x/memop.c11
-rw-r--r--tools/testing/selftests/kvm/s390x/sync_regs_test.c5
2 files changed, 6 insertions, 10 deletions
diff --git a/tools/testing/selftests/kvm/s390x/memop.c b/tools/testing/selftests/kvm/s390x/memop.c
index 22b0bb785591..a8f9b74b9144 100644
--- a/tools/testing/selftests/kvm/s390x/memop.c
+++ b/tools/testing/selftests/kvm/s390x/memop.c
@@ -756,20 +756,17 @@ struct testdef {
int main(int argc, char *argv[])
{
- int memop_cap, extension_cap, idx;
+ int extension_cap, idx;
+
+ TEST_REQUIRE(kvm_has_cap(KVM_CAP_S390_MEM_OP));
setbuf(stdout, NULL); /* Tell stdout not to buffer its content */
ksft_print_header();
- memop_cap = kvm_check_cap(KVM_CAP_S390_MEM_OP);
- extension_cap = kvm_check_cap(KVM_CAP_S390_MEM_OP_EXTENSION);
- if (!memop_cap) {
- ksft_exit_skip("CAP_S390_MEM_OP not supported.\n");
- }
-
ksft_set_plan(ARRAY_SIZE(testlist));
+ extension_cap = kvm_check_cap(KVM_CAP_S390_MEM_OP_EXTENSION);
for (idx = 0; idx < ARRAY_SIZE(testlist); idx++) {
if (testlist[idx].extension >= extension_cap) {
testlist[idx].test();
diff --git a/tools/testing/selftests/kvm/s390x/sync_regs_test.c b/tools/testing/selftests/kvm/s390x/sync_regs_test.c
index 4b2eb5edde5e..b69710822c47 100644
--- a/tools/testing/selftests/kvm/s390x/sync_regs_test.c
+++ b/tools/testing/selftests/kvm/s390x/sync_regs_test.c
@@ -229,14 +229,13 @@ int main(int argc, char *argv[])
struct kvm_vm *vm;
int idx;
+ TEST_REQUIRE(kvm_check_cap(KVM_CAP_SYNC_REGS));
+
/* Tell stdout not to buffer its content */
setbuf(stdout, NULL);
ksft_print_header();
- if (!kvm_check_cap(KVM_CAP_SYNC_REGS))
- ksft_exit_skip("CAP_SYNC_REGS not supported");
-
ksft_set_plan(ARRAY_SIZE(testlist));
/* Create VM */