Commit graph

461 commits

Author SHA1 Message Date
Peter Hutterer
ce80e40006 test: move all the _setup() functions into a special section
This way we can loop through them instead of having to add them manually.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-23 10:17:52 +10:00
Peter Hutterer
ab59264bb3 test: fix vert axis printing on error
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-21 10:18:45 +10:00
Peter Hutterer
2a378beab0 touchpad: delay arbitration by 90ms after touch toggle
When drawing on a tablet, the hand usually rests on the device, causing touch
events. The kernel arbitrates for us in most cases, so we get a touch up
and no events while the stylus is in proximity. When lifting the hand off in a
natural position, the hand still touches the device when the pen goes out of
proximity. This is 'immediately' followed by the hand lifting off the device.

When kernel pen/touch arbitration is active, the pen proximity out causes a
touch begin for the hand still on the pad. This is followed by a touch up when
the hand lifts which happens to look exactly like a tap-to-click.

Fix this by delaying the 'arbitration is now off' toggle, causing any touch
that starts immediately after proximity out to be detected as palm and
ignored for its lifetime.

https://bugs.freedesktop.org/show_bug.cgi?id=104985

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-21 15:58:35 +10:00
Peter Hutterer
dd096a50fe touchpad: add a touch index for debugging
Makes debugging a bit easier when you know *which* touch was marked as palm,
etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-20 15:45:01 +10:00
Peter Hutterer
d4b76be18b evdev: log all evdev_msg_* on one line
So we don't have to have newline handling in the callers. This effectively
reverts 6ab2999be9 "test: detect linebreaks in log messages".

https://bugs.freedesktop.org/show_bug.cgi?id=104957

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2018-02-06 19:29:26 +10:00
Peter Hutterer
394f343e70 test: don't abort for timer offset errors during valgrind runs
Too easy to trigger with the short button debouncing offsets

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-01 16:52:02 +10:00
Peter Hutterer
7175cafe78 test: inhibit nasty keys and switches during test runs
Having the system suspend or shutdown halfway through a test run is a tad
annoying. So let's talk to logind and tell it to inhibit the various keys
we're testing.

https://bugs.freedesktop.org/show_bug.cgi?id=104720

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-01 16:52:02 +10:00
Peter Hutterer
613ecda1cb test: collect test case failures and print them on each fd
When running the test suite in full fork mode, the error messages are in the
quite verbose output and searching for them is annoying. Work around this by
opening a pipe to each subprocess and writing the failed test cases to that
pipe. When all tests have finished, print the messages to stdout. This way the
failures are always the last thing printed by the test suite.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-01-09 13:47:42 +10:00
Greg V
8adfac3975 Include stdarg.h where variadic functions are used
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-12-01 09:31:42 +10:00
Peter Hutterer
3fea53c3a9 test: restore the non-debounced litest_button_click()
8cf6893 removed it to make search/replace easier, restore it for the tests
where we don't want debouncing to automatically be handled.

Still left in place are the various top software button cases. Because of the
button re-routing through the fallback interface we need those to be
debounced.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-20 11:31:56 +10:00
Peter Hutterer
de994d135e evdev: add new debouncing code
The current debouncing code monitors events and switches on when events are
too close together. From then on, any event can be delayed.

Vicente Bergas provided an algorithm that avoids most of these delays:
on a button state change we now forward the change without delay but start a
timer. If the button changes state during that timer, the changes are
ignored. On timer expiry, events are sent to match the hardware state
with the client's view of the device. This is only done if needed.

Thus, a press-release sequence of: PRP sends a single press event, a sequence of
PRPR sends press and then the release at the end of the timeout. The timeout
is short enough that the delay should not be noticeable.

This new mode is called the 'bounce' mode. The old mode is now referred to as
'spurious' mode and only covers the case of a button held down that loses
contact. It works as before, monitoring a button for these spurious contact
losses and switching on. When on, button release events are delayed as before.

The whole button debouncing moves to a state machine which makes debugging a
lot easier. See the accompanying SVG for the diagram.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-20 09:55:05 +10:00
Peter Hutterer
8cf6893f6d test: replace litest_button_click with a debounced version
This is via a simple search & replace. Later auditing is needed to switch
clicks that should not be debounced (e.g. touchpads) back to a non-debounced
version.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-20 09:55:05 +10:00
Peter Hutterer
aaded3d01d Merge branch 'wip/touchpad-hysteresis-issues-v2' 2017-11-03 11:00:03 +10:00
Peter Hutterer
d332a64df8 test: mkdir -p the udev rules and hwdb directories
Especially /run/udev/rules.d may not exist, causing a test suite failure.

https://bugs.freedesktop.org/show_bug.cgi?id=103527

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-03 08:43:15 +10:00
Peter Hutterer
2313f0382c Revert "test: mkdir -p the udev rules and hwdb directories"
recursive functions are hard...

This reverts commit 8a2177b3ba.
2017-11-03 08:43:15 +10:00
Peter Hutterer
026a215a65 test: if we don't have a uinput device node, skip the test suite
When running ninja dist in a container, we cannot create devices.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-01 14:23:21 +10:00
Peter Hutterer
8a2177b3ba test: mkdir -p the udev rules and hwdb directories
Especially /run/udev/rules.d may not exist, causing a test suite failure.

https://bugs.freedesktop.org/show_bug.cgi?id=103527

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-01 14:23:21 +10:00
Peter Hutterer
50daa7b30f touchpad: automatically disable the hysteresis where not required
Touchpads that require the hysteresis do not have filtering in the firmware
and holding a finger still causes continuous cursor movements. This implies
that we get a continuous stream of events with motion data.

If the finger is on the touchpad but we don't see any motion, the finger is
stationary and the touchpad firmware does filtering. In that case, we don't
need to add a hysteresis on top.

https://bugs.freedesktop.org/show_bug.cgi?id=98839

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-31 09:08:44 +10:00
Peter Hutterer
a06256d1c3 test: unref the litest device *after* removing it from the path interface
Our own reference may be the last one that's still alive if the context is
currently suspended (litest_suspend()). If we unref before removing it from
the path interface, we access already freed memory.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2017-10-17 16:55:27 +10:00
Peter Hutterer
916e8296f6 test: if we're not root, return with status 77
exit code 77 signals "skip this test"

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-27 13:50:11 +10:00
Peter Hutterer
ad5df72d57 test: fix test listing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-21 15:56:29 +10:00
Peter Hutterer
8c2ed7adbf test: fix no-device test name handling
All these tests were stored with "no device" as test name.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-21 15:55:18 +10:00
Peter Hutterer
2346801b0e test: switch to a TEST_DEVICE macro for all the litest test devices
The test device initialization code was a bit of duplicated boilerplate and
required adding a reference to the devices to the 'devices' list in litest.c.
Automate this with a new TEST_DEVICE macro that adds the devices to a custom
section in the binary, then loops throught that section to get the device out.

This reduces the boilerplate for each test device to just the TEST_MACRO and
the LITEST_foo device enum entry. It also now automates the shortname of the
device.

The device's shortname was standardised in this approach as well, lowercase
and dashes only.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-21 15:06:17 +10:00
Peter Hutterer
5516e9ea74 test: add missing newline to an error message
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-21 13:39:46 +10:00
Peter Hutterer
a6f0e4ae60 timer: flush the timer funcs if our events come in late
Avoid processing an event with a time later than the earliest timer expiry. If
libinput_dispatch() isn't called frequently enough, we may have e.g. a tap
timeout happening but read a subsequent input event first. In that case we can
erroneously trigger or miss out on taps, see wrong palm detection, etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-09-21 12:27:46 +10:00
Peter Hutterer
0ac868143a tablet: support tablet devices without BTN_TOOL_PEN
Some devices like the UC Logic WP5540U has BTN_STYLUS but not BTN_TOOL_PEN.
While a kernel bug, let's just handle these correctly anyway.

https://bugs.freedesktop.org/show_bug.cgi?id=102570

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Yay-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-09-20 09:30:06 +10:00
Peter Hutterer
1962c6f2db tablet: add a quirk for the HUION PenTablet that doesn't send proximity out events
Could be fixed in the kernel, but these tablets are effectively abandoned and
fixing them is a one-by-one issue. Let's put the infrastructure in place to
have this fixed once for this type of device and move on.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Yay-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-09-20 09:30:06 +10:00
Peter Hutterer
82f2dd8faa Add support for SW_TABLET_MODE
https://bugs.freedesktop.org/show_bug.cgi?id=101008

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-06 09:26:00 +10:00
Peter Hutterer
aeca8739c7 test: make the lid action helper function a generic switch action helper
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-04 12:42:44 +10:00
Peter Hutterer
7a7595e044 test: fix the litest_touch_move_to() step counter
We were undercounting by one, causing a slight jump by (step-distance * 2) on
the last event.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-01 14:55:28 +10:00
Peter Hutterer
7d97bb0087 evdev: accept accelerometers if they are tagged as other devices too
Devices tagged as accelerometers may also be other devices like tablet pads.
Only ignore pure accelerometer devices but disable the accelerometer axes for
devices that have multiple types.

https://bugs.freedesktop.org/show_bug.cgi?id=102100

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
2017-08-28 09:19:54 +10:00
Peter Hutterer
00272cfbb1 Add support for LIBINPUT_IGNORE_DEVICE
The recommended way to have libinput ignore specific devices so far was to
remove the ID_INPUT* properties from the device. That may also affect other
pieces of the stack that need access to this device.

For the niche case of a device that should only be ignored by libinput but
otherwise be treated normally by the system, we now support the
LIBINPUT_IGNORE_DEVICE property.

If the property is set to "0", it's equivalent to being unset. This gets
around some technical limitations in udev where unsetting a property is
impossible via a hwdb entry.

https://bugs.freedesktop.org/show_bug.cgi?id=102229

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-23 14:56:51 +10:00
Peter Hutterer
dddcc1f959 test: expose litest_create() to test cases
And make it init the full litest device minus the libinput device. This
enables us to add litest devices that aren't handled by libinput.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-23 14:56:51 +10:00
Peter Hutterer
35bfab4f6e test: when restoring the log handler to defaults, also restore log priority
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-08-17 01:29:32 +02:00
Peter Hutterer
6bb05c594a lid: disable all types but EV_SYN and EV_SW
The lid dispatch interface is a one-trick pony and can only handle SW_LID. It
ignores other switches but crashes on any event type other than EV_SW and
EV_SYN. Disable those types so we just ignore the event instead of asserting.

https://bugs.freedesktop.org/show_bug.cgi?id=101853

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
2017-07-27 19:00:43 +10:00
Peter Hutterer
55d1bb1217 pointer: add button debouncing
Some devices have worn-out switches or just cheap switches that trigger
multiple button events for each press. These can be identified by unfeasably
short time deltas between the release and the next press event. In the
recordings I've seen so far, that timeout is 8ms.

We have a two-stage behavior: by default, we do not delay any events but we
monitor timestamps. The first time a bouncing button is detected we switch to
debounce mode. From then on, release events are delayed slightly to check for
subsequent button events. If one occurs, the releas and press are filtered. If
none occurs, the release event is passed to the caller.

https://bugs.freedesktop.org/show_bug.cgi?id=100057

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-26 00:21:46 +10:00
Peter Hutterer
688142c8a2 Merge branch 'wip/touchpad-apple-touch-major-v2' 2017-07-14 13:47:29 +10:00
Peter Hutterer
1cf7c88ae6 test: silence a coverity warning
Value set but overwritten before use.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-12 15:39:31 +10:00
Peter Hutterer
2e4895b888 Add safe_strdup()
Return value is either NULL or a strdup'd string, depending on the input
value.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-12 15:39:31 +10:00
Peter Hutterer
e71ade2755 Replace calloc calls with zalloc
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-12 10:18:08 +10:00
Peter Hutterer
d5d6d4cd53 Abort if zalloc ever fails
There's no guarantee that libinput does the right thing if memory allocation
fails and it's such a niche case on the systems we're targeting that it just
doesn't matter. Simply abort if zalloc ever fails.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-12 10:18:07 +10:00
Peter Hutterer
f13abd202a test: loosen up litest to allow major/minor handling
The max values on ABS_MT_TOUCH_MAJOR/MINOR aren't hard limits, they basically
represent the size of a finger with (afaict) a suggestion that anything
greater than the max may be a palm. Disable the 0-100% range checks for those
axes so we can send custom events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-11 12:26:17 +10:00
Peter Hutterer
4af403ab5e test: force-release major/minor on the default touch up
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-11 12:26:17 +10:00
Peter Hutterer
9ddf8a6421 test: skip double-initialization of all_tests lists
Already done in main(), this here is a leftover from having multiple mains fro
different tests.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-07 09:58:45 +10:00
Peter Hutterer
7e06b47018 test: stop changing argv[0] for forked tests
This was useful when we had a small number of test-forks with the suites
distributed. It helped debug which one is still running and then which suites
are in it. Now that we simply distributed everything across the forks it
doesn't have a lot of usefulness and it interferes with the ability to
backtrace properly.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-06 09:33:18 +10:00
Peter Hutterer
3b2c47a86d test: strdup the suite and test name
The check framework takes and stores the pointer and expects it to be live for
the livetime of the test but it doesn't strdup it. We have to keep those
pointers around ourselves.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-26 18:43:59 +10:00
Peter Hutterer
42ee99ee4d test: decouple our tests/test suites from the ones used by check
Check arranges the tests into suites and test cases (which then can have
multiple test functions). The primary feature for suites is the ability to
select them with environment variables and that the log messages are printed
per suite, not per test case.

We used the suites to distribute tests across the processes forked by the test
runner, but that also resulted in slow suites relying on timeouts (tap/dwt) to
take a lot longer than other suites and hold everything else up.

This patch basically drops the use of check test suites. Our test runner has a
--filter-group argument which selects on suite names, the log messages are
more useful if they immediately include the device and the test case name.

So we just save the test metatdata in our own struct and then assemble a
suite/test case on the fly for each test.

The advantage of this is that tests of the same suite are now distributed
across the forks so slow tests that rely on length timeouts are now run in
parallel. This brings the test runs down to under 6 min again.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-13 10:09:55 +10:00
Peter Hutterer
57d4d7d3b4 test: use unique names for all the test suite names
This makes it possible to run multiple test suite simultaneously on the same
host without messing up the other runs (provided that all instances use
the same udev/hwdb files). Previously, removing the udev rules/hwdb at the end
of a test run would cause test case failures in other runs that hadn't
completed yet.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-06-09 07:48:55 +10:00
Peter Hutterer
a369b2c208 test: remove unused devices field from struct test
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-07 14:23:47 +10:00
Peter Hutterer
09a8c5b505 test: remove unused litest_handle_events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-02 10:53:53 +10:00