So we have them available per litest device and check in tests for certain
quirks to be present.

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 test/litest.c | 28 ++++++++++++++++++++++++++++
 test/litest.h |  2 ++
 2 files changed, 30 insertions(+)

diff --git a/test/litest.c b/test/litest.c
index 8a4b5335..7222d798 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -55,6 +55,7 @@
 #include "litest.h"
 #include "litest-int.h"
 #include "libinput-util.h"
+#include "quirks.h"
 
 #include <linux/kd.h>
 
@@ -76,6 +77,7 @@ static int verbose = 0;
 const char *filter_test = NULL;
 const char *filter_device = NULL;
 const char *filter_group = NULL;
+static struct quirks_context *quirks_context;
 
 struct created_file {
        struct list link;
@@ -790,6 +792,19 @@ litest_free_test_list(struct list *tests)
        }
 }
 
+LIBINPUT_ATTRIBUTE_PRINTF(3, 0)
+static inline void
+quirk_log_handler(struct libinput *unused,
+                 enum libinput_log_priority priority,
+                 const char *format,
+                 va_list args)
+{
+       if (priority < LIBINPUT_LOG_PRIORITY_ERROR)
+               return;
+
+       vfprintf(stderr, format, args);
+}
+
 static int
 litest_run_suite(struct list *tests, int which, int max, int error_fd)
 {
@@ -805,6 +820,12 @@ litest_run_suite(struct list *tests, int which, int max, 
int error_fd)
        struct name *n, *tmp;
        struct list testnames;
 
+       quirks_context = quirks_init_subsystem(getenv("LIBINPUT_DATA_DIR"),
+                                              NULL,
+                                              quirk_log_handler,
+                                              NULL,
+                                              QLOG_LIBINPUT_LOGGING);
+
        /* Check just takes the suite/test name pointers but doesn't strdup
         * them - we have to keep them around */
        list_init(&testnames);
@@ -889,6 +910,8 @@ out:
                free(n);
        }
 
+       quirks_context_unref(quirks_context);
+
        return failed;
 }
 
@@ -1494,6 +1517,9 @@ litest_add_device_with_overrides(struct libinput 
*libinput,
 
        d->libinput = libinput;
        d->libinput_device = libinput_path_add_device(d->libinput, path);
+       d->quirks = quirks_fetch_for_device(quirks_context,
+                                           
libinput_device_get_udev_device(d->libinput_device));
+
        litest_assert(d->libinput_device != NULL);
        libinput_device_ref(d->libinput_device);
 
@@ -1617,6 +1643,8 @@ litest_delete_device(struct litest_device *d)
 
        litest_assert_int_eq(d->skip_ev_syn, 0);
 
+       quirks_unref(d->quirks);
+
        if (d->libinput_device) {
                libinput_path_remove_device(d->libinput_device);
                libinput_device_unref(d->libinput_device);
diff --git a/test/litest.h b/test/litest.h
index 2315764b..def06f0b 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -35,6 +35,7 @@
 #include <math.h>
 
 #include "libinput-util.h"
+#include "quirks.h"
 
 struct test_device {
        const char *name;
@@ -345,6 +346,7 @@ struct litest_device {
        struct libevdev *evdev;
        struct libevdev_uinput *uinput;
        struct libinput *libinput;
+       struct quirks *quirks;
        bool owns_context;
        struct libinput_device *libinput_device;
        struct litest_device_interface *interface;
-- 
2.14.3

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to