[PATCH libinput 1/9] udev: make sure the udev callout path is valid for a test run

Peter Hutterer peter.hutterer at who-t.net
Tue Jun 30 23:08:45 PDT 2015


udev requires callout binaries to sit in /lib/udev or otherwise provide an
absolute path. The test suite should work without installing everything first,
so create two rule files - one to install, one with the path to the
$builddir/test

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 configure.ac                            | 10 +++++++++-
 test/Makefile.am                        |  2 +-
 udev/.gitignore                         |  1 +
 udev/80-libinput-device-groups.rules    |  8 --------
 udev/80-libinput-device-groups.rules.in |  8 ++++++++
 udev/90-libinput-model-quirks.rules     | 28 ----------------------------
 udev/90-libinput-model-quirks.rules.in  | 28 ++++++++++++++++++++++++++++
 udev/Makefile.am                        | 12 ++++++++++++
 8 files changed, 59 insertions(+), 38 deletions(-)
 delete mode 100644 udev/80-libinput-device-groups.rules
 create mode 100644 udev/80-libinput-device-groups.rules.in
 delete mode 100644 udev/90-libinput-model-quirks.rules
 create mode 100644 udev/90-libinput-model-quirks.rules.in

diff --git a/configure.ac b/configure.ac
index 314b0d4..7cf4b73 100644
--- a/configure.ac
+++ b/configure.ac
@@ -184,6 +184,12 @@ AM_CONDITIONAL(HAVE_VALGRIND, [test "x$VALGRIND" != "x"])
 AM_CONDITIONAL(BUILD_TESTS, [test "x$build_tests" = "xyes"])
 AM_CONDITIONAL(BUILD_DOCS, [test "x$build_documentation" = "xyes"])
 
+# Used by the udev rules so we can use callouts during testing without
+# installing everything first. Default is the empty string so the installed
+# rule will use udev's default path. Override is in udev/Makefile.am
+AC_SUBST(UDEV_TEST_PATH, "")
+AC_PATH_PROG(SED, [sed])
+
 AC_CONFIG_FILES([Makefile
 		 doc/Makefile
 		 doc/libinput.doxygen
@@ -192,7 +198,9 @@ AC_CONFIG_FILES([Makefile
 		 src/libinput-version.h
 		 test/Makefile
 		 tools/Makefile
-		 udev/Makefile])
+		 udev/Makefile
+		 udev/80-libinput-device-groups.rules
+		 udev/90-libinput-model-quirks.rules])
 AC_CONFIG_FILES([test/symbols-leak-test],
 		[chmod +x test/symbols-leak-test])
 AC_OUTPUT
diff --git a/test/Makefile.am b/test/Makefile.am
index 6a55c7f..ebb853a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -40,7 +40,7 @@ liblitest_la_SOURCES = \
 	litest.c
 liblitest_la_LIBADD = $(top_builddir)/src/libinput-util.la
 liblitest_la_CFLAGS = $(AM_CFLAGS) \
-	      -DLIBINPUT_UDEV_RULES_FILE="\"$(abs_top_srcdir)/udev/90-libinput-model-quirks.rules\"" \
+	      -DLIBINPUT_UDEV_RULES_FILE="\"$(abs_top_srcdir)/udev/90-libinput-model-quirks-litest.rules\"" \
 	      -DLIBINPUT_UDEV_HWDB_FILE="\"$(abs_top_srcdir)/udev/90-libinput-model-quirks.hwdb\""
 if HAVE_LIBUNWIND
 liblitest_la_LIBADD += $(LIBUNWIND_LIBS) -ldl
diff --git a/udev/.gitignore b/udev/.gitignore
index d8e1456..72c77a0 100644
--- a/udev/.gitignore
+++ b/udev/.gitignore
@@ -1 +1,2 @@
 libinput-device-group
+*.rules
diff --git a/udev/80-libinput-device-groups.rules b/udev/80-libinput-device-groups.rules
deleted file mode 100644
index f826bec..0000000
--- a/udev/80-libinput-device-groups.rules
+++ /dev/null
@@ -1,8 +0,0 @@
-ACTION!="add|change", GOTO="libinput_device_group_end"
-KERNEL!="event[0-9]*", GOTO="libinput_device_group_end"
-
-ATTRS{phys}=="?*", \
-	PROGRAM="libinput-device-group %S%p", \
-	ENV{LIBINPUT_DEVICE_GROUP}="%c"
-
-LABEL="libinput_device_group_end"
diff --git a/udev/80-libinput-device-groups.rules.in b/udev/80-libinput-device-groups.rules.in
new file mode 100644
index 0000000..c2af0ce
--- /dev/null
+++ b/udev/80-libinput-device-groups.rules.in
@@ -0,0 +1,8 @@
+ACTION!="add|change", GOTO="libinput_device_group_end"
+KERNEL!="event[0-9]*", GOTO="libinput_device_group_end"
+
+ATTRS{phys}=="?*", \
+	PROGRAM="@UDEV_TEST_PATH at libinput-device-group %S%p", \
+	ENV{LIBINPUT_DEVICE_GROUP}="%c"
+
+LABEL="libinput_device_group_end"
diff --git a/udev/90-libinput-model-quirks.rules b/udev/90-libinput-model-quirks.rules
deleted file mode 100644
index 43674f5..0000000
--- a/udev/90-libinput-model-quirks.rules
+++ /dev/null
@@ -1,28 +0,0 @@
-# Do not edit this file, it will be overwritten on update
-#
-# This file contains lookup rules for libinput model-specific quirks.
-# The contents of this file are a contract between libinput, udev rules and
-# the hwdb.
-# IT IS NOT A STABLE API AND SUBJECT TO CHANGE AT ANY TIME
-#
-# The hwdb database is in:
-#	90-libinput-model-quirks.hwdb
-
-ACTION!="add|change", GOTO="libinput_model_quirks_end"
-KERNEL!="event*", GOTO="libinput_model_quirks_end"
-
-# Matches below are exclusive, if one matches we skip the rest
-# hwdb matches:
-# 
-# libinput:touchpad:<modalias>
-ENV{ID_INPUT_TOUCHPAD}=="1", \
-  IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:touchpad:", \
-  GOTO="libinput_model_quirks_end"
-
-# libinput:name:<name>:dmi:<dmi string>
-KERNELS=="input*", \
-  IMPORT{builtin}="hwdb 'libinput:name:$attr{name}:$attr{[dmi/id]modalias}'", \
-  GOTO="libinput_model_quirks_end"
-
-
-LABEL="libinput_model_quirks_end"
diff --git a/udev/90-libinput-model-quirks.rules.in b/udev/90-libinput-model-quirks.rules.in
new file mode 100644
index 0000000..43674f5
--- /dev/null
+++ b/udev/90-libinput-model-quirks.rules.in
@@ -0,0 +1,28 @@
+# Do not edit this file, it will be overwritten on update
+#
+# This file contains lookup rules for libinput model-specific quirks.
+# The contents of this file are a contract between libinput, udev rules and
+# the hwdb.
+# IT IS NOT A STABLE API AND SUBJECT TO CHANGE AT ANY TIME
+#
+# The hwdb database is in:
+#	90-libinput-model-quirks.hwdb
+
+ACTION!="add|change", GOTO="libinput_model_quirks_end"
+KERNEL!="event*", GOTO="libinput_model_quirks_end"
+
+# Matches below are exclusive, if one matches we skip the rest
+# hwdb matches:
+# 
+# libinput:touchpad:<modalias>
+ENV{ID_INPUT_TOUCHPAD}=="1", \
+  IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:touchpad:", \
+  GOTO="libinput_model_quirks_end"
+
+# libinput:name:<name>:dmi:<dmi string>
+KERNELS=="input*", \
+  IMPORT{builtin}="hwdb 'libinput:name:$attr{name}:$attr{[dmi/id]modalias}'", \
+  GOTO="libinput_model_quirks_end"
+
+
+LABEL="libinput_model_quirks_end"
diff --git a/udev/Makefile.am b/udev/Makefile.am
index 7d19809..e5cf95c 100644
--- a/udev/Makefile.am
+++ b/udev/Makefile.am
@@ -1,6 +1,10 @@
 udevdir=$(UDEV_DIR)
 udev_PROGRAMS = libinput-device-group
 
+litest_rules = 80-libinput-device-groups-litest.rules \
+	       90-libinput-model-quirks-litest.rules
+udev_SCRIPTS = $(litest_rules)
+
 libinput_device_group_SOURCES = libinput-device-group.c
 libinput_device_group_CFLAGS = $(LIBUDEV_CFLAGS) $(GCC_CFLAGS)
 libinput_device_group_LDADD = $(LIBUDEV_LIBS)
@@ -13,3 +17,11 @@ dist_udev_rules_DATA = \
 udev_hwdbdir=$(UDEV_DIR)/hwdb.d
 dist_udev_hwdb_DATA = \
 	90-libinput-model-quirks.hwdb
+
+%-litest.rules: %.rules.in
+	$(SED) -e "s|\@UDEV_TEST_PATH\@|$(abs_builddir)/|" < $^ > $@
+
+CLEANFILES = $(litest_rules)
+DISTCLEANFILES = \
+		 80-libinput-device-groups.rules \
+		 90-libinput-model-quirks.rules 
-- 
2.4.3



More information about the wayland-devel mailing list