mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 15:10:26 +01:00
Ignore test devices for libinput contexts not run from the test suite
Add a LIBINPUT_TEST_DEVICE udev parameter to test devices created by the test suite. When an application tries to add such a device to the path backend or when the udev backend discovers such a device, it will be ignored. Only the context when run via the test suite will actually handle these devices. Doing this will enable a user to run the libinput test suite on a system running libinput without having the test suite devices interfering with the actual system. Note that X.org users running an input device driver that is not the libinput X input driver will still need to manually configure the X server to ignore such devices (see test/50-litest.conf). Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
5cb1cb47f7
commit
091206c907
8 changed files with 35 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
5
udev/.gitignore
vendored
5
udev/.gitignore
vendored
|
|
@ -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
|
||||
|
|
|
|||
1
udev/80-libinput-test-device.rules
Normal file
1
udev/80-libinput-test-device.rules
Normal file
|
|
@ -0,0 +1 @@
|
|||
KERNELS=="*input*", ATTRS{name}=="litest *", ENV{LIBINPUT_TEST_DEVICE}="1"
|
||||
Loading…
Add table
Reference in a new issue