From fcddfc6b11dcb59775ad7309ef4e6894086a7a86 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 13 Jan 2017 11:44:28 +1000 Subject: [PATCH] test: add helper function to install a "bug expected" log handler Signed-off-by: Peter Hutterer --- test/litest.c | 20 ++++++++++++++++++++ test/litest.h | 1 + 2 files changed, 21 insertions(+) diff --git a/test/litest.c b/test/litest.c index 24baf816..d3598f4e 100644 --- a/test/litest.c +++ b/test/litest.c @@ -1265,6 +1265,26 @@ litest_restore_log_handler(struct libinput *libinput) libinput_log_set_handler(libinput, litest_log_handler); } +LIBINPUT_ATTRIBUTE_PRINTF(3, 0) +static void +litest_bug_log_handler(struct libinput *libinput, + enum libinput_log_priority pri, + const char *format, + va_list args) +{ + if (strstr(format, "client bug: ") || + strstr(format, "libinput bug: ")) + return; + + litest_abort_msg("Expected bug statement in log msg, aborting.\n"); +} + +void +litest_set_log_handler_bug(struct libinput *libinput) +{ + libinput_log_set_handler(libinput, litest_bug_log_handler); +} + struct litest_device * litest_add_device_with_overrides(struct libinput *libinput, enum litest_device_type which, diff --git a/test/litest.h b/test/litest.h index 38e3a833..ccda9a42 100644 --- a/test/litest.h +++ b/test/litest.h @@ -307,6 +307,7 @@ struct range { struct libinput *litest_create_context(void); void litest_disable_log_handler(struct libinput *libinput); void litest_restore_log_handler(struct libinput *libinput); +void litest_set_log_handler_bug(struct libinput *libinput); #define litest_add(name_, func_, ...) \ _litest_add(name_, #func_, func_, __VA_ARGS__)