All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Upton <oliver.upton@linux.dev>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, seanjc@google.com, Oliver Upton <oupton@google.com>
Subject: [PATCH 3/3] selftests: KVM: Add exponent check for boolean stats
Date: Tue, 19 Jul 2022 14:31:34 +0000	[thread overview]
Message-ID: <20220719143134.3246798-4-oliver.upton@linux.dev> (raw)
In-Reply-To: <20220719143134.3246798-1-oliver.upton@linux.dev>

From: Oliver Upton <oupton@google.com>

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>
---
 tools/testing/selftests/kvm/kvm_binary_stats_test.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/kvm/kvm_binary_stats_test.c b/tools/testing/selftests/kvm/kvm_binary_stats_test.c
index 3237c7c94bf0..0b45ac593387 100644
--- a/tools/testing/selftests/kvm/kvm_binary_stats_test.c
+++ b/tools/testing/selftests/kvm/kvm_binary_stats_test.c
@@ -96,6 +96,7 @@ static void stats_test(int stats_fd)
 		 * Exponent for unit seconds should be less than or equal to 0
 		 * Exponent for unit clock cycles should be greater than or
 		 * equal to 0
+		 * Exponent for unit boolean should be 0
 		 */
 		switch (pdesc->flags & KVM_STATS_UNIT_MASK) {
 		case KVM_STATS_UNIT_NONE:
@@ -110,6 +111,11 @@ static void stats_test(int stats_fd)
 				    "Unsupported KVM stats (%s) exponent: %i",
 				    pdesc->name, pdesc->exponent);
 			break;
+		case KVM_STATS_UNIT_BOOLEAN:
+			TEST_ASSERT(pdesc->exponent == 0,
+				    "Unsupported KVM stats (%s) exponent: %d",
+				    pdesc->name, pdesc->exponent);
+			break;
 		}
 
 		/* Check size field, which should not be zero */
-- 
2.37.0.170.g444d1eabd0-goog


  parent reply	other threads:[~2022-07-19 14:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19 14:31 [PATCH 0/3] selftests: KVM: Improvements to binary stats test Oliver Upton
2022-07-19 14:31 ` [PATCH 1/3] selftests: KVM: Check stat name before other fields Oliver Upton
2022-07-19 14:31 ` [PATCH 2/3] selftests: KVM: Provide descriptive assertions in kvm_binary_stats_test Oliver Upton
2022-07-19 14:31 ` Oliver Upton [this message]
2022-07-19 16:09 ` [PATCH 0/3] selftests: KVM: Improvements to binary stats test Andrew Jones
2022-07-19 17:53   ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220719143134.3246798-4-oliver.upton@linux.dev \
    --to=oliver.upton@linux.dev \
    --cc=kvm@vger.kernel.org \
    --cc=oupton@google.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.