From: Yu Watanabe Date: Thu, 6 Mar 2025 03:11:43 +0000 (+0900) Subject: tests: introduce ASSERT_PTR_EQ() X-Git-Tag: v258-rc1~1101^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f0ebc0c5bfd5350e40a80ad9ea5a777bb3dfa695;p=thirdparty%2Fsystemd.git tests: introduce ASSERT_PTR_EQ() --- diff --git a/src/shared/tests.h b/src/shared/tests.h index 8d0e6a4bcf3..07c4eeefbdd 100644 --- a/src/shared/tests.h +++ b/src/shared/tests.h @@ -418,6 +418,16 @@ static inline int run_test_table(void) { } \ }) +#define ASSERT_PTR_EQ(expr1, expr2) \ + ({ \ + const void *_expr1 = (expr1), *_expr2 = (expr2); \ + if (_expr1 != _expr2) { \ + log_error("%s:%i: Assertion failed: expected \"%s == %s\", got \"0x%p != 0x%p\"", \ + PROJECT_FILE, __LINE__, #expr1, #expr2, _expr1, _expr2); \ + abort(); \ + } \ + }) + /* DECIMAL_STR_FMT() uses _Generic which cannot be used in string concatenation so we have to format the * input into strings first and then format those into the final assertion message. */