diff mbox series

[v1,3/4] KVM: selftests: Add checks for histogram stats parameters

Message ID 20210706180350.2838127-4-jingzhangos@google.com (mailing list archive)
State New, archived
Headers show
Series Linear and Logarithmic histogram statistics | expand

Commit Message

Jing Zhang July 6, 2021, 6:03 p.m. UTC
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 <jingzhangos@google.com>
---
 .../selftests/kvm/kvm_binary_stats_test.c       | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

David Matlack July 8, 2021, 9:26 p.m. UTC | #1
On Tue, Jul 06, 2021 at 06:03:49PM +0000, Jing Zhang wrote:
> 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 <jingzhangos@google.com>

Reviewed-by: David Matlack <dmatlack@google.com>

> ---
>  .../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
>
diff mbox series

Patch

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 */