Skip to content

Commit

Permalink
test: don't leak test warnings to stdout
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  • Loading branch information
whot committed Jun 2, 2017
1 parent b5e3fd0 commit dcbf2c2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions test/test-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ START_TEST(log_axisrange_warning)
/* Expect only one message per 5 min */
ck_assert_int_eq(axisrange_log_handler_called, 1);

libinput_log_set_priority(li, LIBINPUT_LOG_PRIORITY_ERROR);
litest_restore_log_handler(li);
axisrange_log_handler_called = 0;
}
Expand Down
14 changes: 2 additions & 12 deletions test/test-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ START_TEST(event_conversion_device_notify)
EV_KEY, BTN_LEFT,
-1, -1);
li = libinput_path_create_context(&simple_interface, NULL);
litest_restore_log_handler(li); /* use the default litest handler */
libinput_path_add_device(li, libevdev_uinput_get_devnode(uinput));

libinput_dispatch(li);
Expand Down Expand Up @@ -1202,16 +1203,6 @@ const struct libinput_interface leak_interface = {
.close_restricted = close_restricted_leak,
};

LIBINPUT_ATTRIBUTE_PRINTF(3, 0)
static void
simple_log_handler(struct libinput *libinput,
enum libinput_log_priority priority,
const char *format,
va_list args)
{
vfprintf(stderr, format, args);
}

START_TEST(fd_no_event_leak)
{
struct libevdev_uinput *uinput;
Expand All @@ -1234,8 +1225,7 @@ START_TEST(fd_no_event_leak)
ck_assert_int_gt(fd, -1);

li = libinput_path_create_context(&leak_interface, &fd);
libinput_log_set_priority(li, LIBINPUT_LOG_PRIORITY_DEBUG);
libinput_log_set_handler(li, simple_log_handler);
litest_restore_log_handler(li); /* use the default litest handler */

/* Add the device, trigger an event, then remove it again.
* Without it, we get a SYN_DROPPED immediately and no events.
Expand Down
14 changes: 14 additions & 0 deletions test/test-path.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,16 @@ START_TEST(path_create_invalid)

li = libinput_path_create_context(&simple_interface, NULL);
ck_assert(li != NULL);

litest_disable_log_handler(li);

device = libinput_path_add_device(li, path);
ck_assert(device == NULL);

ck_assert_int_eq(open_func_count, 0);
ck_assert_int_eq(close_func_count, 0);

litest_restore_log_handler(li);
libinput_unref(li);
ck_assert_int_eq(close_func_count, 0);

Expand All @@ -111,12 +115,16 @@ START_TEST(path_create_invalid_kerneldev)

li = libinput_path_create_context(&simple_interface, NULL);
ck_assert(li != NULL);

litest_disable_log_handler(li);

device = libinput_path_add_device(li, path);
ck_assert(device == NULL);

ck_assert_int_eq(open_func_count, 1);
ck_assert_int_eq(close_func_count, 1);

litest_restore_log_handler(li);
libinput_unref(li);
ck_assert_int_eq(close_func_count, 1);

Expand All @@ -143,13 +151,16 @@ START_TEST(path_create_invalid_file)
li = libinput_path_create_context(&simple_interface, NULL);
unlink(path);

litest_disable_log_handler(li);

ck_assert(li != NULL);
device = libinput_path_add_device(li, path);
ck_assert(device == NULL);

ck_assert_int_eq(open_func_count, 0);
ck_assert_int_eq(close_func_count, 0);

litest_restore_log_handler(li);
libinput_unref(li);
ck_assert_int_eq(close_func_count, 0);

Expand All @@ -175,6 +186,9 @@ START_TEST(path_create_destroy)

li = libinput_path_create_context(&simple_interface, userdata);
ck_assert(li != NULL);

litest_disable_log_handler(li);

ck_assert(libinput_get_user_data(li) == userdata);

device = libinput_path_add_device(li,
Expand Down
4 changes: 2 additions & 2 deletions test/test-touch.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,15 @@ START_TEST(touch_double_touch_down_up)
dev = litest_current_device();
libinput = dev->libinput;

litest_disable_log_handler(libinput);
/* note: this test is a false negative, libevdev will filter
* tracking IDs re-used in the same slot. */

litest_touch_down(dev, 0, 0, 0);
litest_touch_down(dev, 0, 0, 0);
litest_touch_up(dev, 0);
litest_touch_up(dev, 0);

libinput_dispatch(libinput);
litest_restore_log_handler(libinput);

while ((ev = libinput_get_event(libinput))) {
switch (libinput_event_get_type(ev)) {
Expand Down

0 comments on commit dcbf2c2

Please sign in to comment.