diff --git a/src/libinput-private.h b/src/libinput-private.h index e0ba51b5..5d0826d0 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -292,6 +292,9 @@ open_restricted(struct libinput *libinput, void close_restricted(struct libinput *libinput, int fd); +bool +ignore_litest_test_suite_device(struct udev_device *device); + void libinput_seat_init(struct libinput_seat *seat, struct libinput *libinput, diff --git a/src/libinput.c b/src/libinput.c index 69a6aef2..7d017e38 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -1020,6 +1020,16 @@ close_restricted(struct libinput *libinput, int fd) return libinput->interface->close_restricted(fd, libinput->user_data); } +bool +ignore_litest_test_suite_device(struct udev_device *device) +{ + if (!getenv("LIBINPUT_RUNNING_TEST_SUITE") && + udev_device_get_property_value(device, "LIBINPUT_TEST_DEVICE")) + return true; + + return false; +} + void libinput_seat_init(struct libinput_seat *seat, struct libinput *libinput, diff --git a/src/path.c b/src/path.c index 04c703c1..b14d8b67 100644 --- a/src/path.c +++ b/src/path.c @@ -343,6 +343,11 @@ libinput_path_add_device(struct libinput *libinput, return NULL; } + if (ignore_litest_test_suite_device(udev_device)) { + udev_device_unref(udev_device); + return NULL; + } + device = path_create_device(libinput, udev_device, NULL); udev_device_unref(udev_device); return device; diff --git a/src/udev-seat.c b/src/udev-seat.c index 6b019da2..6bf85de9 100644 --- a/src/udev-seat.c +++ b/src/udev-seat.c @@ -62,6 +62,9 @@ device_added(struct udev_device *udev_device, if (!streq(device_seat, input->seat_id)) return 0; + if (ignore_litest_test_suite_device(udev_device)) + return 0; + devnode = udev_device_get_devnode(udev_device); /* Search for matching logical seat */ diff --git a/test/Makefile.am b/test/Makefile.am index a9ddc85a..cde93b36 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -46,7 +46,8 @@ liblitest_la_SOURCES = \ liblitest_la_LIBADD = $(top_builddir)/src/libinput-util.la liblitest_la_CFLAGS = $(AM_CFLAGS) \ -DLIBINPUT_MODEL_QUIRKS_UDEV_RULES_FILE="\"$(abs_top_builddir)/udev/90-libinput-model-quirks-litest.rules\"" \ - -DLIBINPUT_MODEL_QUIRKS_UDEV_HWDB_FILE="\"$(abs_top_srcdir)/udev/90-libinput-model-quirks.hwdb\"" + -DLIBINPUT_MODEL_QUIRKS_UDEV_HWDB_FILE="\"$(abs_top_srcdir)/udev/90-libinput-model-quirks.hwdb\"" \ + -DLIBINPUT_TEST_DEVICE_RULES_FILE="\"$(abs_top_srcdir)/udev/80-libinput-test-device.rules\"" if HAVE_LIBUNWIND liblitest_la_LIBADD += $(LIBUNWIND_LIBS) -ldl liblitest_la_CFLAGS += $(LIBUNWIND_CFLAGS) diff --git a/test/litest.c b/test/litest.c index 45dabaaf..676485ed 100644 --- a/test/litest.c +++ b/test/litest.c @@ -57,6 +57,8 @@ "/91-litest-model-quirks-REMOVEME.rules" #define UDEV_MODEL_QUIRKS_HWDB_FILE UDEV_HWDB_D \ "/91-litest-model-quirks-REMOVEME.hwdb" +#define UDEV_TEST_DEVICE_RULE_FILE UDEV_RULES_D \ + "/91-litest-test-device-REMOVEME.rules" static int in_debugger = -1; static int verbose = 0; @@ -955,6 +957,9 @@ litest_install_model_quirks(void) litest_copy_file(UDEV_MODEL_QUIRKS_HWDB_FILE, LIBINPUT_MODEL_QUIRKS_UDEV_HWDB_FILE, warning); + litest_copy_file(UDEV_TEST_DEVICE_RULE_FILE, + LIBINPUT_TEST_DEVICE_RULES_FILE, + warning); } static inline void @@ -962,6 +967,7 @@ litest_remove_model_quirks(void) { unlink(UDEV_MODEL_QUIRKS_RULE_FILE); unlink(UDEV_MODEL_QUIRKS_HWDB_FILE); + unlink(UDEV_TEST_DEVICE_RULE_FILE); } static void @@ -2551,6 +2557,7 @@ main(int argc, char **argv) list_init(&all_tests); setenv("CK_DEFAULT_TIMEOUT", "10", 0); + setenv("LIBINPUT_RUNNING_TEST_SUITE", "1", 1); mode = litest_parse_argv(argc, argv); if (mode == LITEST_MODE_ERROR) diff --git a/udev/.gitignore b/udev/.gitignore index 2fdaedcf..cad377a8 100644 --- a/udev/.gitignore +++ b/udev/.gitignore @@ -1,3 +1,6 @@ libinput-device-group libinput-model-quirks -*.rules +80-libinput-device-groups-litest.rules +80-libinput-device-groups.rules +90-libinput-model-quirks-litest.rules +90-libinput-model-quirks.rules diff --git a/udev/80-libinput-test-device.rules b/udev/80-libinput-test-device.rules new file mode 100644 index 00000000..d37b2abe --- /dev/null +++ b/udev/80-libinput-test-device.rules @@ -0,0 +1 @@ +KERNELS=="*input*", ATTRS{name}=="litest *", ENV{LIBINPUT_TEST_DEVICE}="1"