From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jing Zhang Date: Tue, 06 Jul 2021 18:03:49 +0000 Subject: [PATCH v1 3/4] KVM: selftests: Add checks for histogram stats parameters Message-Id: <20210706180350.2838127-4-jingzhangos@google.com> List-Id: References: <20210706180350.2838127-1-jingzhangos@google.com> In-Reply-To: <20210706180350.2838127-1-jingzhangos@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: KVM , KVMPPC , Paolo Bonzini , Sean Christopherson , Jim Mattson , Peter Shier , Oliver Upton , David Rientjes , David Matlack Cc: Jing Zhang The hist_param field should be zero for simple stats and 2 for logarithmic histogram. It shouldbe non-zero for linear histogram stats. Signed-off-by: Jing Zhang --- .../selftests/kvm/kvm_binary_stats_test.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/testing/selftests/kvm/kvm_binary_stats_test.c b/tools/testing/selftests/kvm/kvm_binary_stats_test.c index 5906bbc08483..03c7842fcb26 100644 --- a/tools/testing/selftests/kvm/kvm_binary_stats_test.c +++ b/tools/testing/selftests/kvm/kvm_binary_stats_test.c @@ -109,6 +109,23 @@ 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 hist_param field */ + switch (pdesc->flags & KVM_STATS_TYPE_MASK) { + case KVM_STATS_TYPE_LINEAR_HIST: + TEST_ASSERT(pdesc->hist_param, + "Bucket size of Linear Histogram stats (%s) is zero", + pdesc->name); + break; + case KVM_STATS_TYPE_LOG_HIST: + TEST_ASSERT(pdesc->hist_param = 2, + "Base of Log Histogram stats (%s) is not 2", + pdesc->name); + break; + default: + TEST_ASSERT(!pdesc->hist_param, + "Simple stats (%s) with hist_param of nonzero", + pdesc->name); + } size_data += pdesc->size * sizeof(*stats_data); } /* Check overlap */ -- 2.32.0.93.g670b81a890-goog