[PATCH v1 2/2] perf tests: Use TEST_ASSERT_EQUAL for all watchpoint tests

From: Tiezhu Yang

Date: Fri Nov 06 2026 - 04:28:52 EST


Currently, WP_TEST_ASSERT_VAL uses TEST_ASSERT_VAL which only prints
the failure message but drops the actual and expected counters. This
makes debugging hard when a watchpoint test fails due to arch-specific
hardware behavior or counter mismatches.

Rename WP_TEST_ASSERT_VAL to WP_TEST_ASSERT_EQUAL and use the built-in
TEST_ASSERT_EQUAL macro. This ensures that both the expected and actual
counter values are automatically printed upon failure.

Here is the log when executing "./perf test -v 'Read Only Watchpoint'".

Before:
FAILED tests/wp.c:90 RO watchpoint

After:
FAILED tests/wp.c:90 RO watchpoint (2 != 1)

Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
---
tools/perf/tests/wp.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c
index f0b829b82f2b..253e551f10d2 100644
--- a/tools/perf/tests/wp.c
+++ b/tools/perf/tests/wp.c
@@ -13,11 +13,11 @@
#include "cloexec.h"
#include "../perf-sys.h"

-#define WP_TEST_ASSERT_VAL(fd, text, val) \
-do { \
- long long count; \
- wp_read(fd, &count, sizeof(long long)); \
- TEST_ASSERT_VAL(text, count == val); \
+#define WP_TEST_ASSERT_EQUAL(fd, text, val) \
+do { \
+ long long count; \
+ wp_read(fd, &count, sizeof(long long)); \
+ TEST_ASSERT_EQUAL(text, (int)count, (int)val); \
} while (0)

#ifdef __i386__
@@ -87,10 +87,10 @@ static int test__wp_ro(struct test_suite *test __maybe_unused,
return fd == -ENODEV ? TEST_SKIP : -1;

tmp = data1;
- WP_TEST_ASSERT_VAL(fd, "RO watchpoint", 1);
+ WP_TEST_ASSERT_EQUAL(fd, "RO watchpoint", 1);

data1 = tmp1 + tmp;
- WP_TEST_ASSERT_VAL(fd, "RO watchpoint", 1);
+ WP_TEST_ASSERT_EQUAL(fd, "RO watchpoint", 1);

close(fd);
return 0;
@@ -111,10 +111,10 @@ static int test__wp_wo(struct test_suite *test __maybe_unused,
return fd == -ENODEV ? TEST_SKIP : -1;

tmp = data1;
- WP_TEST_ASSERT_VAL(fd, "WO watchpoint", 0);
+ WP_TEST_ASSERT_EQUAL(fd, "WO watchpoint", 0);

data1 = tmp1 + tmp;
- WP_TEST_ASSERT_VAL(fd, "WO watchpoint", 1);
+ WP_TEST_ASSERT_EQUAL(fd, "WO watchpoint", 1);

close(fd);
return 0;
@@ -136,10 +136,10 @@ static int test__wp_rw(struct test_suite *test __maybe_unused,
return fd == -ENODEV ? TEST_SKIP : -1;

tmp = data1;
- WP_TEST_ASSERT_VAL(fd, "RW watchpoint", 1);
+ WP_TEST_ASSERT_EQUAL(fd, "RW watchpoint", 1);

data1 = tmp1 + tmp;
- WP_TEST_ASSERT_VAL(fd, "RW watchpoint", 2);
+ WP_TEST_ASSERT_EQUAL(fd, "RW watchpoint", 2);

close(fd);
return 0;
@@ -160,7 +160,7 @@ static int test__wp_modify(struct test_suite *test __maybe_unused, int subtest _
return fd == -ENODEV ? TEST_SKIP : -1;

data1 = tmp;
- WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 1);
+ WP_TEST_ASSERT_EQUAL(fd, "Modify watchpoint", 1);

/* Modify watchpoint with disabled = 1 */
get__perf_event_attr(&new_attr, HW_BREAKPOINT_W, (void *)&data2[0],
@@ -179,7 +179,7 @@ static int test__wp_modify(struct test_suite *test __maybe_unused, int subtest _
}

data2[1] = tmp; /* Not Counted */
- WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 1);
+ WP_TEST_ASSERT_EQUAL(fd, "Modify watchpoint", 1);

/* Enable the event */
ret = ioctl(fd, PERF_EVENT_IOC_ENABLE, 0);
@@ -190,10 +190,10 @@ static int test__wp_modify(struct test_suite *test __maybe_unused, int subtest _
}

data2[1] = tmp; /* Counted */
- WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 2);
+ WP_TEST_ASSERT_EQUAL(fd, "Modify watchpoint", 2);

data2[2] = tmp; /* Not Counted */
- WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 2);
+ WP_TEST_ASSERT_EQUAL(fd, "Modify watchpoint", 2);

close(fd);
return 0;
--
2.42.0