Skip to content

Commit

Permalink
KVM: s390: selftests: Use TAP interface in the reset test
Browse files Browse the repository at this point in the history
Let's standardize the s390x KVM selftest output to the TAP output
generated via the kselftests.h interface.

Reviewed-by: Janosch Frank <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Christian Borntraeger <[email protected]>
  • Loading branch information
huth authored and borntraeger committed Jun 1, 2022
1 parent 0c07322 commit b1edf7f
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions tools/testing/selftests/kvm/s390x/resets.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "test_util.h"
#include "kvm_util.h"
#include "kselftest.h"

#define VCPU_ID 3
#define LOCAL_IRQS 32
Expand Down Expand Up @@ -202,7 +203,7 @@ static void inject_irq(int cpu_id)

static void test_normal(void)
{
pr_info("Testing normal reset\n");
ksft_print_msg("Testing normal reset\n");
/* Create VM */
vm = vm_create_default(VCPU_ID, 0, guest_code_initial);
run = vcpu_state(vm, VCPU_ID);
Expand All @@ -225,7 +226,7 @@ static void test_normal(void)

static void test_initial(void)
{
pr_info("Testing initial reset\n");
ksft_print_msg("Testing initial reset\n");
vm = vm_create_default(VCPU_ID, 0, guest_code_initial);
run = vcpu_state(vm, VCPU_ID);
sync_regs = &run->s.regs;
Expand All @@ -247,7 +248,7 @@ static void test_initial(void)

static void test_clear(void)
{
pr_info("Testing clear reset\n");
ksft_print_msg("Testing clear reset\n");
vm = vm_create_default(VCPU_ID, 0, guest_code_initial);
run = vcpu_state(vm, VCPU_ID);
sync_regs = &run->s.regs;
Expand All @@ -266,14 +267,35 @@ static void test_clear(void)
kvm_vm_free(vm);
}

struct testdef {
const char *name;
void (*test)(void);
bool needs_cap;
} testlist[] = {
{ "initial", test_initial, false },
{ "normal", test_normal, true },
{ "clear", test_clear, true },
};

int main(int argc, char *argv[])
{
bool has_s390_vcpu_resets = kvm_check_cap(KVM_CAP_S390_VCPU_RESETS);
int idx;

setbuf(stdout, NULL); /* Tell stdout not to buffer its content */

test_initial();
if (kvm_check_cap(KVM_CAP_S390_VCPU_RESETS)) {
test_normal();
test_clear();
ksft_print_header();
ksft_set_plan(ARRAY_SIZE(testlist));

for (idx = 0; idx < ARRAY_SIZE(testlist); idx++) {
if (!testlist[idx].needs_cap || has_s390_vcpu_resets) {
testlist[idx].test();
ksft_test_result_pass("%s\n", testlist[idx].name);
} else {
ksft_test_result_skip("%s - no VCPU_RESETS capability\n",
testlist[idx].name);
}
}
return 0;

ksft_finished(); /* Print results and exit() accordingly */
}

0 comments on commit b1edf7f

Please sign in to comment.