Skip to content

Commit c140e93

Browse files
suomilewissean-jc
authored andcommitted
KVM: selftests: Print detailed info in PMU event filter asserts
Provide the actual vs. expected count in the PMU event filter test's asserts instead of relying on pr_info() to provide the context, e.g. so that all information needed to triage a failure is readily available even if the environment in which the test is run captures only the assert itself. Signed-off-by: Aaron Lewis <aaronlewis@google.com> [sean: rewrite changelog] Link: https://lore.kernel.org/r/20230407233254.957013-4-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent fa32233 commit c140e93

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,18 +246,17 @@ static struct kvm_pmu_event_filter *remove_event(struct kvm_pmu_event_filter *f,
246246

247247
#define ASSERT_PMC_COUNTING_INSTRUCTIONS(count) \
248248
do { \
249-
if (count != NUM_BRANCHES) \
249+
if (count && count != NUM_BRANCHES) \
250250
pr_info("%s: Branch instructions retired = %lu (expected %u)\n", \
251251
__func__, count, NUM_BRANCHES); \
252-
TEST_ASSERT(count, "Allowed PMU event is not counting."); \
252+
TEST_ASSERT(count, "%s: Branch instructions retired = %lu (expected > 0)", \
253+
__func__, count); \
253254
} while (0)
254255

255256
#define ASSERT_PMC_NOT_COUNTING_INSTRUCTIONS(count) \
256257
do { \
257-
if (count) \
258-
pr_info("%s: Branch instructions retired = %lu (expected 0)\n", \
259-
__func__, count); \
260-
TEST_ASSERT(!count, "Disallowed PMU Event is counting"); \
258+
TEST_ASSERT(!count, "%s: Branch instructions retired = %lu (expected 0)", \
259+
__func__, count); \
261260
} while (0)
262261

263262
static void test_without_filter(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)