Commit graph

368 commits

Author SHA1 Message Date
Hans de Goede
b8a2e5bc5f touchpad: Add an API for touchpad gesture events
For touchscreens we always send raw touch events to the compositor, and the
compositor or application toolkits do gesture recognition. This makes sense
because on a touchscreen which window / widget the touches are over is
important context to know to interpret gestures.

On touchpads however we never send raw events since a touchpad is an absolute
device which primary function is to send pointer motion delta-s, so we always
need to do processing (and a lot of it) on the raw events.

Moreover there is nothing underneath the finger which influences how to
interpret gestures, and there is a lot of touchpad and libinput configuration
specific context necessary for gesture recognition. E.g. is this a clickpad,
and if so are softbuttons or clickfinger used? What is the size of the
softbuttons? Is this a true multi-touch touchpad or a semi multi-touch touchpad
which only gives us a bounding box enclosing the fingers? Etc.

So for touchpads it is better to do gesture processing in libinput, this commit
adds an initial implementation of a Gesture event API which only supports swipe
gestures, other gestures will be added later following the same model wrt,
having clear start and stop events and the number of fingers involved being
fixed once a gesture sequence starts.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
2015-07-06 14:08:54 +10:00
Peter Hutterer
772d69751b Merge branch 'master' into tablet-support 2015-07-06 13:52:57 +10:00
Peter Hutterer
cd6326aa22 test: initialize syspath
When the condition with continue was hit, syspath was still compared in the
loop condition, leading to crashes when strcmp()-ing a random string.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-07-06 11:38:39 +10:00
Peter Hutterer
676be4b944 test: use poll instead of a busy wait
Drop the busy loop we had waiting for an event to appear and just call poll on
the libinput fd.

This actually makes the tests more correct, if we now time out where we didn't
before it means we're not setting the timers correctly.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-07-02 16:10:41 +10:00
Peter Hutterer
97f447d670 test: up the default test timeout to 10s
3s is too easy to hit on congested systems. 10s is overkill, but it's still
better to pass a test late than having to restart the whole test-suite again.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-07-02 16:09:13 +10:00
Peter Hutterer
79b7707d76 test: wait for the uinput_monitor on test devices
Set up a udev_monitor before each device creation and wait for the monitor to
notify us of the newly created device. This should take the place of the
various sleep loops  we currently have sprinkled around the code and provide a
reliability when testing.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-07-02 16:08:56 +10:00
Peter Hutterer
67ebcc3b8a Merge branch 'drop-pointer-normalization' 2015-07-02 13:06:18 +10:00
Peter Hutterer
92e415eadd test: add a low-dpi mouse test device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-07-02 13:03:43 +10:00
Peter Hutterer
a851415c61 test: add the warning to the rules file too
The rules file in /run may be left over after an unclean exit and mess with
things.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-07-01 11:13:46 +10:00
Peter Hutterer
c0ef2a172a test: increase the udev init timeout
Hitting this limit too often on congested VMs, so let's increase the sleep
sleep (so the system can get done what needs to be done) and get the whole
timeout from 600ms to 2000ms.

Note: if we really hit 2000ms we may still fail on some tests with the check's
default 3 second timeout.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-07-01 08:56:54 +10:00
Peter Hutterer
ac009c2c20 test: add a waltop tablet test device
Quite similar to wacom tablets but the evdev protocol differs - no serials for
example and only two tools. The device has a wheel, but it's not apparently
part of the stylus like on the wacom tablets. And it has a bunch of keys.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-06-29 15:39:50 +10:00
Peter Hutterer
9b174fc9d8 test: use the litest macros in the tablet button check
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-06-29 15:24:49 +10:00
Peter Hutterer
0d322c69d0 Merge branch 'master' into tablet-support 2015-06-22 15:20:01 +10:00
Peter Hutterer
56660494ae test: add ALPS DualPoint device
Same as the existing GlidePoint semi-mt device, but this one has a x/y
resolution.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-06-22 08:08:44 +10:00
Peter Hutterer
aaed6ad8e8 test: fix missing range value when the first test case is a ranged one
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-06-18 13:36:18 +10:00
Peter Hutterer
b1e7e6fd29 test: replace two asserts with litest_asserts
Having a backtrace is nice

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-06-18 10:34:11 +10:00
Peter Hutterer
bc9f16b40e COPYING: Update boilerplate from MIT X11 to MIT Expat license
To quote Bryce Harrington from [1]:
"MIT has released software under several slightly different licenses,
including the old 'X11 License' or 'MIT License'.  Some code under this
license was in fact included in X.org's Xserver in the past.  However,
X.org now prefers the MIT Expat License as the standard (which,
confusingly, is also referred to as the 'MIT License').  See
http://cgit.freedesktop.org/xorg/xserver/tree/COPYING

When Wayland started, it was Kristian Høgsberg's intent to license it
compatibly with X.org.  "I wanted Wayland to be usable (license-wise)
whereever X was usable."  But, the text of the older X11 License was
taken for Wayland, rather than X11's current standard.  This patch
corrects this by swapping in the intended text."

libinput is a fork of weston and thus inherited the original license intent
and the license boilerplate itself.

See this thread on wayland-devel here for a discussion:
http://lists.freedesktop.org/archives/wayland-devel/2015-May/022301.html

[1] http://lists.freedesktop.org/archives/wayland-devel/2015-June/022552.html

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Acked-by: Jonas Ådahl <jadahl@gmail.com>
2015-06-16 14:36:04 +10:00
Peter Hutterer
2b99363a1f Merge branch 'master' into tablet-support 2015-06-16 13:52:02 +10:00
Peter Hutterer
96face60c2 test: always install our own udev rule/hwdb files for tests
We can't rely on the system having these files installed, at least not in the
latest version that we'd like.
Copy them over from the source directory into the /run/ and /etc/ directories
for each test and update udev and the hwdb. This ensures the tags we set in
the hwdb file are always set, regardless of the system configuration.

Note that the /run/udev/* files need to have a different filename to the ones
we ship to avoid getting overridden by local configuration.

systemd does not have support for /run/udev/hwdb.d [1]. So our hwdb.d file
is in /etc/udev/hwdb.d instead and marked them with a REMOVEME and a comment
that if that file is left after the tests, it should be removed by the user.

[1] https://github.com/systemd/systemd/issues/127

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-06-12 08:51:57 +10:00
Peter Hutterer
36753fae8f test: fix litest_log() when libunwind is missing
Previous expansion had side-effects when litest_log was called in an if
condition without {}

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-06-05 11:41:59 +10:00
Peter Hutterer
bd4f129a2a test: replace a strncmp call with strneq
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-06-05 11:31:33 +10:00
Peter Hutterer
99aa1f5dc3 Merge branch 'master' into tablet-support 2015-06-04 12:49:18 +10:00
Jon A. Cruz
edb69067ef test: check getcwd() and system() return values in litest
Added code to check for errors in getcwd() and system() that
were previously ignored and silently dropped.

Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-06-02 11:19:12 +10:00
Jon A. Cruz
96d4fa0364 Add xasprintf to avoid use of undefined pointer values
If asprintf fails for any reason, the contents of the pointer
are undefined. While some platforms set it to NULL, there is no
guarantee that all will.

This change adds a simple wrapper to ensure proper NULL results
on failure.

Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>

Added LIBINPUT_PRINTF attribute and the required declaration for it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-06-01 08:47:14 +10:00
Peter Hutterer
742b5ccbfb test: add another wait loop for udev
Wait after deleting a device so udev can catch up with everything and the
various hooks to make sure it's happy with any newly created devices after
this.

The sleep is in the delete path to also cover the tests where we manually
create uinput devices rather than using the litest hooks.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-05-29 12:23:05 +10:00
Peter Hutterer
887895c1c1 test: don't abort if the device filter filtered all devices
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-28 13:33:54 +10:00
Peter Hutterer
00c75a2667 test: add disable-while-typing tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-05-27 17:38:25 +10:00
Peter Hutterer
753cb25abb test: add an extra loop for slow udev initialization
On slower machines, e.g. VMs, udev isn't fast enough to get the properties set
up by the time we're trying to get the device going. This fails when we try to
add the device with libinput_path_add_device().

We know that all litest devices will have ID_INPUT set, so check for that
before we continue.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-05-27 17:38:24 +10:00
Peter Hutterer
21e3d416ee Merge branch 'master' into tablet-support 2015-05-26 10:39:04 +10:00
Peter Hutterer
0ca29c6ddc Add streq() helper to use instead of strcmp() == 0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-26 08:46:05 +10:00
Peter Hutterer
c4be027b90 test: fix coverity complaint about unbounded loop
buffer tainted (from fgets()) so tighten the loop conditions a bit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-25 17:30:08 +10:00
Peter Hutterer
d9f702918c test: fail if fgets() from addr2line returns NULL
Found by Coverity

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-25 17:30:08 +10:00
Peter Hutterer
2507828f3f test: pclose the popened stream
Found by Coverity

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-25 17:30:08 +10:00
Peter Hutterer
f2c44ac9cd test: move litest_log/vlog up outside of HAVE_LIBUNWIND
Well, the patch looks like the HAVE_LIBUNWIND bit was moved down, which is the
same thing.

litest_log and litest_vlog are called from independent paths, we have a
compiler error otherwise.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-25 16:38:12 +10:00
Peter Hutterer
602bca6977 test: fix --list for the tests
The argument worked, but the test list was empty since b2fd428f96.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-25 08:56:53 +10:00
Peter Hutterer
8bb67c2550 test: fail if the filter leaves us with zero tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-22 17:18:05 +10:00
Peter Hutterer
a1075070a4 test: add missing filter for function names
Was added to other places, missing from here so some tests passed the filter
despite not being selected by it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-22 17:18:03 +10:00
Peter Hutterer
087d25a54e Merge branch 'master' into tablet-support 2015-05-22 14:21:21 +10:00
Peter Hutterer
a6be43990c Merge branch 'litest-filter-tests'
The litest-selftest has its own main method and compiles litest.c with special
flags. Use that to ifdef out the litest.c main function, and inline the
litest_run/litest_parse_args functions so gcc doesn't complain about unused
functions.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-22 09:15:15 +10:00
Peter Hutterer
f3947c0eb9 test: add --filter-group argument to match test groups (suites)
Same as CK_RUN_SUITE, but supports fnmatch-like globs

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-22 08:45:35 +10:00
Peter Hutterer
538e98d46f test: add --filter-device argument
Similar to the CK_RUN_CASE environment variable, but it does support
fnmatch()-style wildcards, e.g.

	./test/test-touchpad --filter-device="synaptics*"

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-22 08:45:35 +10:00
Peter Hutterer
f3d37d9653 test: add filtering to litest framework
Complementary to CK_RUN_SUITE and CK_RUN_CASE, this filters on actual test
function names with a simple fnmatch.

./test/test-touchpad --filter-test="*1fg_tap*"

Most of this patch is renaming litest_add_* to _litest_add_* so we can use the
macros to get at the function names.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-22 08:45:35 +10:00
Peter Hutterer
b2fd428f96 test: move argument parsing into a separate function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-22 08:45:35 +10:00
Peter Hutterer
9dbeb9d0f7 test: move main() into litest
This allows us to filter things based on argv before setting up tests, etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-22 08:45:33 +10:00
Peter Hutterer
ed5d43da36 Merge branch 'litest-backtrace' 2015-05-21 11:05:45 +10:00
Peter Hutterer
015151de3a test: move opening { to next line
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-20 13:06:43 +10:00
Peter Hutterer
d05363316c test: parse the LITEST_VERBOSE environment variable
--verbose only works when running a specific test, sometimes we need make
check to be more verbose. Set this by default for make check, the log becomes
a lot more expressive that way

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-19 10:49:49 +10:00
Peter Hutterer
b8af89f173 test: extract file:line from backtrace with addr2line
libunwind gives us a file and an address and usually a function name. Beyond
that, it's mostly guessing.
Fork off addr2line to resolve the addresses that libunwind gives us, if we
succeed we get a backtrace like this:

	Backtrace:
	0: litest_fail_comparison_int() (./test/litest.c:268)
	1: disable_button_scrolling() (./test/pointer.c:115)
	2: middlebutton_doubleclick() (./test/pointer.c:991)
	3: /lib64/libcheck.so.0 (srunner_run+0x7f5) [0x7f6c12d8c025]
	4: litest_run() (./test/litest.c:689)
	5: main() (./test/pointer.c:1280)
	6: /lib64/libc.so.6 (__libc_start_main+0xf0) [0x7f6c11a73790]
	7: ./test/test-pointer (_start+0x29) [0x403d99]
	8: ? (?+0x29) [0x29]

Note: I intentionally swapped function/file name in the output to make it
easier to spot which one is fully resolved and which one is the basic
libunwind output.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-18 20:55:48 +10:00
Peter Hutterer
dc3dbc4dfc test: add pointer comparison macros
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-18 20:55:48 +10:00
Peter Hutterer
84e6321f51 test: add a backtrace facility to litest
The check unit test framework isn't particularly suited to having ck_assert*
calls in helper functions. A failed assertion in a helper function or the
litest framework merely gives us a the failed line in litest.c.
which doesn't tell us which test actually failed.

Add a backtracing facility with litest_backtrace(). And since this requires
wrapping all ck_assert macros with litest_assert() this patch ended up
replacing/duplicating a bunch of ck_assert_* bits. So rather than
ck_assert_int_eq() we now use litest_assert_int_eq(), etc. in the litest
framework itself.

The int comparison macros are more type-safe than ck_assert()'s macros which
just cast all the ints to intmax_t.

Backtrace is spewed to stderr, which is good enough for debugging. Example
backtrace:

	FAILED COMPARISON: status != expected
	Resolved to: 0 != 0
	in disable_button_scrolling() (pointer.c:115)

	Backtrace:
	0: ./test/test-pointer (litest_fail_comparison_int+0xab) [0x40973b]
	1: ./test/test-pointer (disable_button_scrolling+0x174) [0x40421b]
	2: ./test/test-pointer (middlebutton_middleclick+0x40) [0x40829c]
	3: /lib64/libcheck.so.0 (srunner_run+0x7f5) [0x7f0e8a277025]
	4: ./test/test-pointer (litest_run+0x107) [0x40a42b]
	5: ./test/test-pointer (main+0x2fa) [0x4090e7]
	6: /lib64/libc.so.6 (__libc_start_main+0xf0) [0x7f0e88f5e790]
	7: ./test/test-pointer (_start+0x29) [0x403ce9]
	8: ? (?+0x29) [0x29]

litest_backtrace() itself is copied from xserver/os/backtrace.c which git
blame attributes to Marcin.

CC:  Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-18 20:55:48 +10:00