Permalink
Browse files

Add synaptics touchpad ioctl record and integration test case

  • Loading branch information...
1 parent e2ddd25 commit 07977c99569ba3700067f619b6499faad184efb6 Martin Pitt committed Feb 19, 2013
Showing with 103 additions and 11 deletions.
  1. +1 −0 Makefile.am
  2. +19 −0 devices/input/synaptics-touchpad.ioctl
  3. +79 −11 tests/test-integration.vala
  4. +4 −0 tests/xorg-dummy.conf
View
@@ -269,6 +269,7 @@ tests_test_integration_LDADD = $(GLIB_LIBS)
tests_test_integration_VALAFLAGS = \
--vapidir tests \
--pkg glib-2.0 \
+ --pkg posix \
$(NULL)
tests_test_umockdev_record_SOURCES = \
@@ -0,0 +1,19 @@
+EVIOCGBIT(0) 8 0B00000000000000
+EVIOCGBIT(3) 8 0300001100806002
+EVIOCGBIT(1) 96 000000000000000000000000000000000000000000000000000000000000000000000300000000002064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+EVIOCGPROP(0) 1 09
+EVIOCGABS(47) 0 000000000000000001000000000000000000000000000000
+EVIOCGABS(53) 0 00000000C005000000170000000000000000000061000000
+EVIOCGABS(54) 0 0000000080050000CA1200000000000000000000BC000000
+EVIOCGABS(57) 0 0000000000000000FFFF0000000000000000000000000000
+EVIOCGABS(24) 0 0000000000000000FF000000000000000000000000000000
+EVIOCGMTSLOTS(0) 0 350000000000000000000000427F0000604C1E8D427F00000000000000000000D037EADAFF7F00003113FE8C427F0000D037EADAFF7F0000950BFE8C000000005C6AD28D427F000058451880000000000000000000000000C003D38D427F00001038EADAFF7F00005E15FE8C427F000000000000000000005C6AD28D427F000058451880
+EVIOCGMTSLOTS(0) 0 360000000000000000000000427F0000604C1E8D427F00000000000000000000D037EADAFF7F00003113FE8C427F0000D037EADAFF7F0000950BFE8C000000005C6AD28D427F000058451880000000000000000000000000C003D38D427F00001038EADAFF7F00005E15FE8C427F000000000000000000005C6AD28D427F000058451880
+EVIOCGMTSLOTS(0) 0 39000000FFFFFFFFFFFFFFFF427F0000604C1E8D427F00000000000000000000D037EADAFF7F00003113FE8C427F0000D037EADAFF7F0000950BFE8C000000005C6AD28D427F000058451880000000000000000000000000C003D38D427F00001038EADAFF7F00005E15FE8C427F000000000000000000005C6AD28D427F000058451880
+EVIOCGABS 0 00000000C005000000170000000000000000000061000000
+EVIOCGABS(1) 0 0000000080050000CA1200000000000000000000BC000000
+EVIOCGABS(28) 0 00000000000000000F000000000000000000000000000000
+EVIOCGID 0 110002000700B101
+EVIOCGMTSLOTS(0) 0 350000000000000000000000427F0000604C1E8D427F0000C003D38D427F0000D036EADAFF7F00003113FE8C427F0000D036EADAFF7F0000950BFE8C000000002CD4D28D427F000058451880000000000000000000000000D0D5D28D427F00001037EADAFF7F00005E15FE8C427F000000000000000000002CD4D28D427F000058451880
+EVIOCGMTSLOTS(0) 0 360000000000000000000000427F0000604C1E8D427F0000C003D38D427F0000D036EADAFF7F00003113FE8C427F0000D036EADAFF7F0000950BFE8C000000002CD4D28D427F000058451880000000000000000000000000D0D5D28D427F00001037EADAFF7F00005E15FE8C427F000000000000000000002CD4D28D427F000058451880
+EVIOCGMTSLOTS(0) 0 39000000FFFFFFFFFFFFFFFF427F0000604C1E8D427F0000C003D38D427F0000D036EADAFF7F00003113FE8C427F0000D036EADAFF7F0000950BFE8C000000002CD4D28D427F000058451880000000000000000000000000D0D5D28D427F00001037EADAFF7F00005E15FE8C427F000000000000000000002CD4D28D427F000058451880
@@ -20,7 +20,7 @@
using Assertions;
-//string run_cmd = "LC_ALL=C LD_LIBRARY_PATH=.libs src/umockdev-run";
+const string umockdev_run_command = "env LC_ALL=C LD_LIBRARY_PATH=.libs src/umockdev-run ";
static bool
have_program (string program)
@@ -38,26 +38,35 @@ have_program (string program)
return exit == 0;
}
-static void
-check_program_out (string program, string run_command, string expected_out, string expected_err = "")
+static bool
+get_program_out (string program, string command, out string sout,
+ out string serr, out int exit)
{
- string sout;
- string serr;
- int exit;
-
if (!have_program (program)) {
stderr.printf ("[SKIP: %s not installed] ", program);
- return;
+ return false;
}
- string cmd = "env LC_ALL=C LD_LIBRARY_PATH=.libs src/umockdev-run " + run_command;
try {
- Process.spawn_command_line_sync (cmd, out sout, out serr, out exit);
+ Process.spawn_command_line_sync (command, out sout, out serr, out exit);
} catch (SpawnError e) {
- stderr.printf ("cannot call %s: %s\n", cmd, e.message);
+ stderr.printf ("cannot call %s: %s\n", command, e.message);
Process.abort();
}
+ return true;
+}
+
+static void
+check_program_out (string program, string run_command, string expected_out, string expected_err = "")
+{
+ string sout;
+ string serr;
+ int exit;
+
+ if (!get_program_out (program, umockdev_run_command + run_command, out sout, out serr, out exit))
+ return;
+
assert_cmpstr (sout, Op.EQ, expected_out);
assert_cmpstr (serr, Op.EQ, expected_err);
assert_cmpint (exit, Op.EQ, 0);
@@ -110,6 +119,62 @@ There are 9 files in folder '/store_00010001/DCIM/100CANON'.
""");
}
+static void
+t_input_touchpad ()
+{
+ if (!have_program ("Xorg")) {
+ stderr.printf ("[SKIP: Xorg not installed] ");
+ return;
+ }
+
+ Pid xorg_pid;
+ try {
+ Process.spawn_async (null, {"env", "LD_LIBRARY_PATH=.libs", "src/umockdev-run",
+ "-l", "devices/input/synaptics-touchpad.umockdev",
+ "-i", "/dev/input/event12=devices/input/synaptics-touchpad.ioctl",
+ "--", "Xorg", "-config", "tests/xorg-dummy.conf", "-logfile", "/dev/null", ":5"},
+ null, SpawnFlags.SEARCH_PATH | SpawnFlags.STDERR_TO_DEV_NULL, null, out xorg_pid);
+ } catch (SpawnError e) {
+ stderr.printf ("cannot call Xorg: %s\n", e.message);
+ Process.abort();
+ }
+
+ /* wait until X socket is available */
+ int timeout = 50;
+ while (timeout > 0) {
+ timeout -= 1;
+ Posix.usleep (100000);
+ if (FileUtils.test ("/tmp/.X11-unix/X5", FileTest.EXISTS))
+ break;
+ }
+ if (timeout <= 0) {
+ stderr.printf ("Xorg failed to start up\n");
+ Process.abort();
+ }
+
+ /* call xinput */
+ string sout;
+ string serr;
+ int exit;
+ assert (get_program_out ("xinput", "env DISPLAY=:5 xinput", out sout, out serr, out exit));
+ assert_cmpstr (serr, Op.EQ, "");
+ assert_cmpint (exit, Op.EQ, 0);
+ assert (sout.contains ("SynPS/2 Synaptics TouchPad"));
+
+ assert (get_program_out ("xinput", "env DISPLAY=:5 xinput --list-props 'SynPS/2 Synaptics TouchPad'",
+ out sout, out serr, out exit));
+ assert_cmpstr (serr, Op.EQ, "");
+ assert_cmpint (exit, Op.EQ, 0);
+ assert (sout.contains ("Synaptics Two-Finger Scrolling"));
+ assert (sout.contains ("/dev/input/event12"));
+
+ /* shut down X */
+ Posix.kill (xorg_pid, Posix.SIGTERM);
+ int status;
+ Posix.waitpid (xorg_pid, out status, 0);
+ Process.close_pid (xorg_pid);
+}
+
int
main (string[] args)
@@ -121,5 +186,8 @@ main (string[] args)
Test.add_func ("/umockdev-integration/gphoto-folderlist", t_gphoto_folderlist);
Test.add_func ("/umockdev-integration/gphoto-filelist", t_gphoto_filelist);
+ // input devices
+ Test.add_func ("/umockdev-integration/input-touchpad", t_input_touchpad);
+
return Test.run();
}
View
@@ -0,0 +1,4 @@
+Section "Device"
+ Identifier "test"
+ Driver "dummy"
+EndSection

0 comments on commit 07977c9

Please sign in to comment.