Skip to content

Commit

Permalink
KVM: selftests: Add checks for histogram stats bucket_size field
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jing Zhang authored and Paolo Bonzini committed Aug 20, 2021
1 parent 0176ec5 commit d49b11f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tools/testing/selftests/kvm/kvm_binary_stats_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ static void stats_test(int stats_fd)
/* Check size field, which should not be zero */
TEST_ASSERT(pdesc->size, "KVM descriptor(%s) with size of 0",
pdesc->name);
/* Check bucket_size field */
switch (pdesc->flags & KVM_STATS_TYPE_MASK) {
case KVM_STATS_TYPE_LINEAR_HIST:
TEST_ASSERT(pdesc->bucket_size,
"Bucket size of Linear Histogram stats (%s) is zero",
pdesc->name);
break;
default:
TEST_ASSERT(!pdesc->bucket_size,
"Bucket size of stats (%s) is not zero",
pdesc->name);
}
size_data += pdesc->size * sizeof(*stats_data);
}
/* Check overlap */
Expand Down

0 comments on commit d49b11f

Please sign in to comment.