test: use context creation helper in the log tests
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 3 Jul 2020 00:49:32 +0000 (10:49 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 7 Jul 2020 08:51:33 +0000 (18:51 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
test/test-device.c
test/test-log.c
test/test-misc.c

index 5fc79cd..d27ebbc 100644 (file)
@@ -799,22 +799,6 @@ START_TEST(device_user_data)
 }
 END_TEST
 
-static int open_restricted(const char *path, int flags, void *data)
-{
-       int fd;
-       fd = open(path, flags);
-       return fd < 0 ? -errno : fd;
-}
-static void close_restricted(int fd, void *data)
-{
-       close(fd);
-}
-
-const struct libinput_interface simple_interface = {
-       .open_restricted = open_restricted,
-       .close_restricted = close_restricted,
-};
-
 START_TEST(device_group_get)
 {
        struct litest_device *dev = litest_current_device();
@@ -877,7 +861,7 @@ START_TEST(device_group_leak)
                                             EV_REL, REL_Y,
                                             -1);
 
-       li = libinput_path_create_context(&simple_interface, NULL);
+       li = litest_create_context();
        device = libinput_path_add_device(li,
                                          libevdev_uinput_get_devnode(uinput));
 
index 7b035d3..a7787bc 100644 (file)
 static int log_handler_called;
 static struct libinput *log_handler_context;
 
-static int open_restricted(const char *path, int flags, void *data)
-{
-       int fd;
-       fd = open(path, flags);
-       return fd < 0 ? -errno : fd;
-}
-static void close_restricted(int fd, void *data)
-{
-       close(fd);
-}
-
-static const struct libinput_interface simple_interface = {
-       .open_restricted = open_restricted,
-       .close_restricted = close_restricted,
-};
-
 static void
 simple_log_handler(struct libinput *libinput,
                   enum libinput_log_priority priority,
@@ -68,7 +52,7 @@ START_TEST(log_default_priority)
        enum libinput_log_priority pri;
        struct libinput *li;
 
-       li = libinput_path_create_context(&simple_interface, NULL);
+       li = litest_create_context();
        pri = libinput_log_get_priority(li);
 
        ck_assert_int_eq(pri, LIBINPUT_LOG_PRIORITY_ERROR);
@@ -84,7 +68,7 @@ START_TEST(log_handler_invoked)
        log_handler_context = NULL;
        log_handler_called = 0;
 
-       li = libinput_path_create_context(&simple_interface, NULL);
+       li = litest_create_context();
 
        libinput_log_set_priority(li, LIBINPUT_LOG_PRIORITY_DEBUG);
        libinput_log_set_handler(li, simple_log_handler);
@@ -107,7 +91,7 @@ START_TEST(log_handler_NULL)
 
        log_handler_called = 0;
 
-       li = libinput_path_create_context(&simple_interface, NULL);
+       li = litest_create_context();
        libinput_log_set_priority(li, LIBINPUT_LOG_PRIORITY_DEBUG);
        libinput_log_set_handler(li, NULL);
 
@@ -128,7 +112,7 @@ START_TEST(log_priority)
        log_handler_context = NULL;
        log_handler_called = 0;
 
-       li = libinput_path_create_context(&simple_interface, NULL);
+       li = litest_create_context();
        libinput_log_set_priority(li, LIBINPUT_LOG_PRIORITY_ERROR);
        libinput_log_set_handler(li, simple_log_handler);
        log_handler_context = li;
index bf10ea8..436e8ec 100644 (file)
@@ -105,7 +105,7 @@ START_TEST(event_conversion_device_notify)
                                           EV_KEY, BTN_MIDDLE,
                                           EV_KEY, BTN_LEFT,
                                           -1, -1);
-       li = libinput_path_create_context(&simple_interface, NULL);
+       li = litest_create_context();
        litest_restore_log_handler(li); /* use the default litest handler */
        libinput_path_add_device(li, libevdev_uinput_get_devnode(uinput));