test: init the quirks once per test suite run

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2018-05-24 16:52:42 +10:00
parent 5e4dee22fd
commit a50e13d50f
2 changed files with 30 additions and 0 deletions

View file

@ -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);

View file

@ -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;