summaryrefslogtreecommitdiff
path: root/tools/testing
diff options
context:
space:
mode:
authorOliver Upton <oupton@google.com>2022-07-19 17:31:34 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2022-08-01 15:01:23 +0300
commitdd4d1c3bb3f1cd91a7a67ed3d73299ecb273ff92 (patch)
tree78d7f9e0953f104a899ee4d9c5ef0794722734c3 /tools/testing
parent7eebae78bc9754564779927976f37d04c2c01b64 (diff)
downloadlinux-dd4d1c3bb3f1cd91a7a67ed3d73299ecb273ff92.tar.xz
selftests: KVM: Add exponent check for boolean stats
The only sensible exponent for a boolean stat is 0. Add a test assertion requiring all boolean statistics to have an exponent of 0. Signed-off-by: Oliver Upton <oupton@google.com> Reviewed-by: Andrew Jones <andrew.jones@linux.dev> Message-Id: <20220719143134.3246798-4-oliver.upton@linux.dev> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/kvm/kvm_binary_stats_test.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/kvm_binary_stats_test.c b/tools/testing/selftests/kvm/kvm_binary_stats_test.c
index 3237c7c94bf0..0b45ac593387 100644
--- a/tools/testing/selftests/kvm/kvm_binary_stats_test.c
+++ b/tools/testing/selftests/kvm/kvm_binary_stats_test.c
@@ -96,6 +96,7 @@ static void stats_test(int stats_fd)
* Exponent for unit seconds should be less than or equal to 0
* Exponent for unit clock cycles should be greater than or
* equal to 0
+ * Exponent for unit boolean should be 0
*/
switch (pdesc->flags & KVM_STATS_UNIT_MASK) {
case KVM_STATS_UNIT_NONE:
@@ -110,6 +111,11 @@ static void stats_test(int stats_fd)
"Unsupported KVM stats (%s) exponent: %i",
pdesc->name, pdesc->exponent);
break;
+ case KVM_STATS_UNIT_BOOLEAN:
+ TEST_ASSERT(pdesc->exponent == 0,
+ "Unsupported KVM stats (%s) exponent: %d",
+ pdesc->name, pdesc->exponent);
+ break;
}
/* Check size field, which should not be zero */