Skip to content

Commit 9f92c06

Browse files
huthsean-jc
authored andcommitted
KVM: selftests: Use TAP in the steal_time test
For easier use of the tests in automation and for having some status information for the user while the test is running, let's provide some TAP output in this test. Signed-off-by: Thomas Huth <[email protected]> Reviewed-by: Muhammad Usama Anjum <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Zhao Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 0cba644 commit 9f92c06

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

tools/testing/selftests/kvm/steal_time.c

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,18 @@ static void steal_time_init(struct kvm_vcpu *vcpu, uint32_t i)
8383
static void steal_time_dump(struct kvm_vm *vm, uint32_t vcpu_idx)
8484
{
8585
struct kvm_steal_time *st = addr_gva2hva(vm, (ulong)st_gva[vcpu_idx]);
86-
int i;
8786

88-
pr_info("VCPU%d:\n", vcpu_idx);
89-
pr_info(" steal: %lld\n", st->steal);
90-
pr_info(" version: %d\n", st->version);
91-
pr_info(" flags: %d\n", st->flags);
92-
pr_info(" preempted: %d\n", st->preempted);
93-
pr_info(" u8_pad: ");
94-
for (i = 0; i < 3; ++i)
95-
pr_info("%d", st->u8_pad[i]);
96-
pr_info("\n pad: ");
97-
for (i = 0; i < 11; ++i)
98-
pr_info("%d", st->pad[i]);
99-
pr_info("\n");
87+
ksft_print_msg("VCPU%d:\n", vcpu_idx);
88+
ksft_print_msg(" steal: %lld\n", st->steal);
89+
ksft_print_msg(" version: %d\n", st->version);
90+
ksft_print_msg(" flags: %d\n", st->flags);
91+
ksft_print_msg(" preempted: %d\n", st->preempted);
92+
ksft_print_msg(" u8_pad: %d %d %d\n",
93+
st->u8_pad[0], st->u8_pad[1], st->u8_pad[2]);
94+
ksft_print_msg(" pad: %d %d %d %d %d %d %d %d %d %d %d\n",
95+
st->pad[0], st->pad[1], st->pad[2], st->pad[3],
96+
st->pad[4], st->pad[5], st->pad[6], st->pad[7],
97+
st->pad[8], st->pad[9], st->pad[10]);
10098
}
10199

102100
#elif defined(__aarch64__)
@@ -199,10 +197,10 @@ static void steal_time_dump(struct kvm_vm *vm, uint32_t vcpu_idx)
199197
{
200198
struct st_time *st = addr_gva2hva(vm, (ulong)st_gva[vcpu_idx]);
201199

202-
pr_info("VCPU%d:\n", vcpu_idx);
203-
pr_info(" rev: %d\n", st->rev);
204-
pr_info(" attr: %d\n", st->attr);
205-
pr_info(" st_time: %ld\n", st->st_time);
200+
ksft_print_msg("VCPU%d:\n", vcpu_idx);
201+
ksft_print_msg(" rev: %d\n", st->rev);
202+
ksft_print_msg(" attr: %d\n", st->attr);
203+
ksft_print_msg(" st_time: %ld\n", st->st_time);
206204
}
207205

208206
#elif defined(__riscv)
@@ -366,7 +364,9 @@ int main(int ac, char **av)
366364
vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS, ST_GPA_BASE, 1, gpages, 0);
367365
virt_map(vm, ST_GPA_BASE, ST_GPA_BASE, gpages);
368366

367+
ksft_print_header();
369368
TEST_REQUIRE(is_steal_time_supported(vcpus[0]));
369+
ksft_set_plan(NR_VCPUS);
370370

371371
/* Run test on each VCPU */
372372
for (i = 0; i < NR_VCPUS; ++i) {
@@ -407,14 +407,15 @@ int main(int ac, char **av)
407407
run_delay, stolen_time);
408408

409409
if (verbose) {
410-
pr_info("VCPU%d: total-stolen-time=%ld test-stolen-time=%ld", i,
411-
guest_stolen_time[i], stolen_time);
412-
if (stolen_time == run_delay)
413-
pr_info(" (BONUS: guest test-stolen-time even exactly matches test-run_delay)");
414-
pr_info("\n");
410+
ksft_print_msg("VCPU%d: total-stolen-time=%ld test-stolen-time=%ld%s\n",
411+
i, guest_stolen_time[i], stolen_time,
412+
stolen_time == run_delay ?
413+
" (BONUS: guest test-stolen-time even exactly matches test-run_delay)" : "");
415414
steal_time_dump(vm, i);
416415
}
416+
ksft_test_result_pass("vcpu%d\n", i);
417417
}
418418

419-
return 0;
419+
/* Print results and exit() accordingly */
420+
ksft_finished();
420421
}

0 commit comments

Comments
 (0)