Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Oliver Upton and committed by
Paolo Bonzini
dd4d1c3b 7eebae78

+6
+6
tools/testing/selftests/kvm/kvm_binary_stats_test.c
··· 96 96 * Exponent for unit seconds should be less than or equal to 0 97 97 * Exponent for unit clock cycles should be greater than or 98 98 * equal to 0 99 + * Exponent for unit boolean should be 0 99 100 */ 100 101 switch (pdesc->flags & KVM_STATS_UNIT_MASK) { 101 102 case KVM_STATS_UNIT_NONE: ··· 109 108 case KVM_STATS_UNIT_SECONDS: 110 109 TEST_ASSERT(pdesc->exponent <= 0, 111 110 "Unsupported KVM stats (%s) exponent: %i", 111 + pdesc->name, pdesc->exponent); 112 + break; 113 + case KVM_STATS_UNIT_BOOLEAN: 114 + TEST_ASSERT(pdesc->exponent == 0, 115 + "Unsupported KVM stats (%s) exponent: %d", 112 116 pdesc->name, pdesc->exponent); 113 117 break; 114 118 }