Skip to content

Commit

Permalink
selftests: KVM: Add exponent check for boolean stats
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Oliver Upton authored and Paolo Bonzini committed Aug 1, 2022
1 parent 7eebae7 commit dd4d1c3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tools/testing/selftests/kvm/kvm_binary_stats_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 */
Expand Down

0 comments on commit dd4d1c3

Please sign in to comment.