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>
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)