summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2020-07-03 10:49:32 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2020-07-07 18:51:33 +1000
commitd78d6629280878a64a506d72fbbaf9a4e8ece328 (patch)
tree1c95042cbe2cdfee0ab3217098d8869b293cb29a
parent9bb81334860b5415fc644ac86ca4dbe0102fead3 (diff)
test: use context creation helper in the log tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--test/test-device.c18
-rw-r--r--test/test-log.c24
-rw-r--r--test/test-misc.c2
3 files changed, 6 insertions, 38 deletions
diff --git a/test/test-device.c b/test/test-device.c
index 5fc79cdc..d27ebbc3 100644
--- a/test/test-device.c
+++ b/test/test-device.c
@@ -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));
diff --git a/test/test-log.c b/test/test-log.c
index 7b035d30..a7787bc4 100644
--- a/test/test-log.c
+++ b/test/test-log.c
@@ -35,22 +35,6 @@
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;
diff --git a/test/test-misc.c b/test/test-misc.c
index bf10ea83..436e8ecb 100644
--- a/test/test-misc.c
+++ b/test/test-misc.c
@@ -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));