Skip to content

Commit dd4d1c3

Browse files
ouptonbonzini
authored andcommitted
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>
1 parent 7eebae7 commit dd4d1c3

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tools/testing/selftests/kvm/kvm_binary_stats_test.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ static void stats_test(int stats_fd)
9696
* Exponent for unit seconds should be less than or equal to 0
9797
* Exponent for unit clock cycles should be greater than or
9898
* equal to 0
99+
* Exponent for unit boolean should be 0
99100
*/
100101
switch (pdesc->flags & KVM_STATS_UNIT_MASK) {
101102
case KVM_STATS_UNIT_NONE:
@@ -110,6 +111,11 @@ static void stats_test(int stats_fd)
110111
"Unsupported KVM stats (%s) exponent: %i",
111112
pdesc->name, pdesc->exponent);
112113
break;
114+
case KVM_STATS_UNIT_BOOLEAN:
115+
TEST_ASSERT(pdesc->exponent == 0,
116+
"Unsupported KVM stats (%s) exponent: %d",
117+
pdesc->name, pdesc->exponent);
118+
break;
113119
}
114120

115121
/* Check size field, which should not be zero */

0 commit comments

Comments
 (0)