From b43abaeacb5f795d1b71eb420998cd7a1341190c Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 31 Mar 2025 14:10:26 +1000 Subject: [PATCH] test: allow passing func/line up from litest_abort_msg() Part-of: --- test/litest.c | 7 ++++--- test/litest.h | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/test/litest.c b/test/litest.c index a604eebd..f34ab502 100644 --- a/test/litest.c +++ b/test/litest.c @@ -208,7 +208,7 @@ litest_fail_condition(const char *file, litest_log("%s\n", buf); } - litest_log("in %s() (%s:%d)\n", func, file, line); + litest_log("in %s() (%s:%d)\n", func, file ? file : "???", line); litest_backtrace(func); litest_runner_abort(); } @@ -3487,8 +3487,9 @@ _litest_wait_for_event_of_type(struct libinput *li, uint64_t now; now_in_us(&now); if (now > expiry) { - litest_abort_msg("Waited >%dms for events, but no events are pending", - timeout); + _litest_abort_msg(NULL, lineno, func, + "Waited >%dms for events, but no events are pending", + timeout); } } diff --git a/test/litest.h b/test/litest.h index 57e68b40..a2cd7155 100644 --- a/test/litest.h +++ b/test/litest.h @@ -162,11 +162,14 @@ litest_fail_comparison_str(const char *file, #cond, __VA_ARGS__); \ } while(0) -#define litest_abort_msg(...) {\ - litest_fail_condition(__FILE__, __LINE__, __func__, \ +#define _litest_abort_msg(file_, line_, func_, ...) do {\ + litest_fail_condition(file_, line_, func_, \ "aborting", __VA_ARGS__); \ abort(); \ -} +} while (0) + +#define litest_abort_msg(...) \ + _litest_abort_msg(__FILE__, __LINE__, __func__, __VA_ARGS__) #define litest_assert_notnull(cond) \ do { \