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

KVM: selftests: Add checks for histogram stats bucket_size field

The bucket_size field should be non-zero for linear histogram stats and
should be zero for other stats types.

Reviewed-by: David Matlack <dmatlack@google.com>
Signed-off-by: Jing Zhang <jingzhangos@google.com>
Message-Id: <20210802165633.1866976-4-jingzhangos@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Jing Zhang and committed by
Paolo Bonzini
d49b11f0 0176ec51

+12
+12
tools/testing/selftests/kvm/kvm_binary_stats_test.c
··· 109 109 /* Check size field, which should not be zero */ 110 110 TEST_ASSERT(pdesc->size, "KVM descriptor(%s) with size of 0", 111 111 pdesc->name); 112 + /* Check bucket_size field */ 113 + switch (pdesc->flags & KVM_STATS_TYPE_MASK) { 114 + case KVM_STATS_TYPE_LINEAR_HIST: 115 + TEST_ASSERT(pdesc->bucket_size, 116 + "Bucket size of Linear Histogram stats (%s) is zero", 117 + pdesc->name); 118 + break; 119 + default: 120 + TEST_ASSERT(!pdesc->bucket_size, 121 + "Bucket size of stats (%s) is not zero", 122 + pdesc->name); 123 + } 112 124 size_data += pdesc->size * sizeof(*stats_data); 113 125 } 114 126 /* Check overlap */