diff options
author | Sean Christopherson <seanjc@google.com> | 2025-01-11 03:50:43 +0300 |
---|---|---|
committer | Sean Christopherson <seanjc@google.com> | 2025-02-14 18:01:27 +0300 |
commit | eead13d493af0c2d3b8025da4acb2a9ef854a26a (patch) | |
tree | 5e31611043cfa8ce9d4e840f665ff5829febea91 | |
parent | f7f232a01f3d26a5bd67a4309ea54640f625dbe5 (diff) | |
download | linux-eead13d493af0c2d3b8025da4acb2a9ef854a26a.tar.xz |
KVM: selftests: Assert that __vm_get_stat() actually finds a stat
Fail the test if it attempts to read a stat that doesn't exist, e.g. due
to a typo (hooray, strings), or because the test tried to get a stat for
the wrong scope. As is, there's no indiciation of failure and @data is
left untouched, e.g. holds '0' or random stack data in most cases.
Fixes: 8448ec5993be ("KVM: selftests: Add NX huge pages test")
Link: https://lore.kernel.org/r/20250111005049.1247555-4-seanjc@google.com
[sean: fixup spelling mistake, courtesy of Colin Ian King]
Signed-off-by: Sean Christopherson <seanjc@google.com>
-rw-r--r-- | tools/testing/selftests/kvm/lib/kvm_util.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 9138801ecb60..e3cb3ee74491 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -2238,9 +2238,10 @@ void __vm_get_stat(struct kvm_vm *vm, const char *stat_name, uint64_t *data, read_stat_data(vm->stats_fd, &vm->stats_header, desc, data, max_elements); - - break; + return; } + + TEST_FAIL("Unable to find stat '%s'", stat_name); } __weak void kvm_arch_vm_post_create(struct kvm_vm *vm) |