test: don't leak test warnings to stdout
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 1 Jun 2017 05:00:27 +0000 (15:00 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 2 Jun 2017 00:53:50 +0000 (10:53 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
test/test-log.c
test/test-misc.c
test/test-path.c
test/test-touch.c

index 99882670bbe278ebfc23670037a8db5d8d344d82..c07e6bd57b7068dc82cc2a3ffc38a349d8bcb60c 100644 (file)
@@ -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;
 }
index 5101dcffa5ee45ce32383d1296c40b247a25b430..e55daed4290a473b28e590c159b2c3ca87ce80d2 100644 (file)
@@ -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);
@@ -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;
@@ -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.
index 4f49d2b03dae0ad89c3c3db6a1f5de42a78a0f97..16b4daabe6a7a074f445c267333483ea21b586c1 100644 (file)
@@ -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);
 
@@ -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);
 
@@ -143,6 +151,8 @@ 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);
@@ -150,6 +160,7 @@ START_TEST(path_create_invalid_file)
        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);
 
@@ -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,
index a7dc41111eda602f67c155bd54ed2ab7945d9ca9..c9f78d11d7bd8f1620aaf72d991ad323ccc6b9e4 100644 (file)
@@ -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)) {