test: add helper function to install a "bug expected" log handler

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2017-01-13 11:44:28 +10:00
parent 50dfd52cd7
commit fcddfc6b11
2 changed files with 21 additions and 0 deletions

View file

@ -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,

View file

@ -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__)