summaryrefslogtreecommitdiff
path: root/include/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-09-20 03:49:27 +0300
committerSimon Glass <sjg@chromium.org>2020-10-06 18:07:54 +0300
commitcdd4e30dfcaba706120df340c0c8757d56e48b7a (patch)
treea3e8de88ec394d7c628527a1d54c698c1ccf5b34 /include/test
parent4aed22762303755f8f26d14f0ad2608d63550e72 (diff)
downloadu-boot-cdd4e30dfcaba706120df340c0c8757d56e48b7a.tar.xz
bloblist: Compare addresses rather than pointers in tests
When running these tests on sandbox any failures result in very large or long pointer values which are a pain to work with. Map them to an address so it is easier to diagnose failures. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/test')
-rw-r--r--include/test/ut.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/test/ut.h b/include/test/ut.h
index 3295cd4e54..3f2ee7514b 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -224,6 +224,19 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
} \
}
+/* Assert that two addresses (converted from pointers) are equal */
+#define ut_asserteq_addr(expr1, expr2) { \
+ ulong _val1 = map_to_sysmem(expr1); \
+ ulong _val2 = map_to_sysmem(expr2); \
+ \
+ if (_val1 != _val2) { \
+ ut_failf(uts, __FILE__, __LINE__, __func__, \
+ #expr1 " = " #expr2, \
+ "Expected %lx, got %lx", _val1, _val2); \
+ return CMD_RET_FAILURE; \
+ } \
+}
+
/* Assert that a pointer is NULL */
#define ut_assertnull(expr) { \
const void *_val = (expr); \