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 5fc79cdc31f44dad14c1c5b492a45e3782ab459e..d27ebbc3572022f79e5b23f26411f0154e85482b 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 7b035d30a6abe598d9d8c90152ccbe4c9c8c3146..a7787bc4eaefd1b9f5c50d14483e5271ac6aa5cc 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 bf10ea832cfaceef2c9c667ba5a09e2836600d9e..436e8ecb0c0f51ec98629d75a108b0466b298693 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));