From cdd4e30dfcaba706120df340c0c8757d56e48b7a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 19 Sep 2020 18:49:27 -0600 Subject: 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 --- include/test/ut.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include') 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); \ -- cgit