Skip to content

Commit

Permalink
Add synaptics touchpad ioctl record and integration test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Pitt committed Feb 19, 2013
1 parent e2ddd25 commit 07977c9
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 11 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ tests_test_integration_LDADD = $(GLIB_LIBS)
tests_test_integration_VALAFLAGS = \ tests_test_integration_VALAFLAGS = \
--vapidir tests \ --vapidir tests \
--pkg glib-2.0 \ --pkg glib-2.0 \
--pkg posix \
$(NULL) $(NULL)


tests_test_umockdev_record_SOURCES = \ tests_test_umockdev_record_SOURCES = \
Expand Down
19 changes: 19 additions & 0 deletions devices/input/synaptics-touchpad.ioctl
Original file line number Original file line Diff line number Diff line change
@@ -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
90 changes: 79 additions & 11 deletions tests/test-integration.vala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


using Assertions; 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 static bool
have_program (string program) have_program (string program)
Expand All @@ -38,26 +38,35 @@ have_program (string program)
return exit == 0; return exit == 0;
} }


static void static bool
check_program_out (string program, string run_command, string expected_out, string expected_err = "") 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)) { if (!have_program (program)) {
stderr.printf ("[SKIP: %s not installed] ", 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 { 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) { } 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(); 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 (sout, Op.EQ, expected_out);
assert_cmpstr (serr, Op.EQ, expected_err); assert_cmpstr (serr, Op.EQ, expected_err);
assert_cmpint (exit, Op.EQ, 0); assert_cmpint (exit, Op.EQ, 0);
Expand Down Expand Up @@ -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 int
main (string[] args) main (string[] args)
Expand All @@ -121,5 +186,8 @@ main (string[] args)
Test.add_func ("/umockdev-integration/gphoto-folderlist", t_gphoto_folderlist); Test.add_func ("/umockdev-integration/gphoto-folderlist", t_gphoto_folderlist);
Test.add_func ("/umockdev-integration/gphoto-filelist", t_gphoto_filelist); 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(); return Test.run();
} }
4 changes: 4 additions & 0 deletions tests/xorg-dummy.conf
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,4 @@
Section "Device"
Identifier "test"
Driver "dummy"
EndSection

0 comments on commit 07977c9

Please sign in to comment.