Commit graph

375 commits

Author SHA1 Message Date
Peter Hutterer
4de756766c test: remove a compiler warning
Leftover from a previous iteration of this code - having a static but
unnecessarily large size for dirname results in:

../test/litest.c:1251:38: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
   snprintf(dest, sizeof(dest), "%s/%s", dirname, filename);
                                      ^
../test/litest.c:1251:3: note: ‘snprintf’ output 2 or more bytes (assuming 4097) into a destination of size 4096
   snprintf(dest, sizeof(dest), "%s/%s", dirname, filename);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-19 13:13:24 +10:00
Peter Hutterer
7266ed600a test: pass the open mode to open(O_CREAT)
Found by coverity

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-18 13:41:18 +10:00
Peter Hutterer
870ddce9e4 Drop the udev hwdb model quirks
Replaced with the quirks files in merge commit
000ac14c27

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-18 11:04:43 +10:00
Peter Hutterer
a50e13d50f test: init the quirks once per test suite run
So we have them available per litest device and can check in tests for certain
quirks to be present.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-08 14:37:17 +10:00
Peter Hutterer
5e4dee22fd test: install per-test device quirks files
These will replace the custom udev rules we currently have in place.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-08 14:33:35 +10:00
Peter Hutterer
c81809d0aa test: remove created directories too
If we created it, remove it again. No change because we're not adding any of
the directories yet.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-08 13:47:33 +10:00
Peter Hutterer
4738c5cde5 test: make litest_copy_file copy normal files too
Make the tempfile creation dependent on whether the required template is
present. Currently unused, this is just prep work for future patches.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-08 13:47:33 +10:00
Peter Hutterer
d5c705a539 tablet: increase the proximity timeout during test runs
This is causing too many false positives and they're not easy to filter out.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-30 09:42:06 +10:00
Peter Hutterer
25d309bde7 test: print the device name for a wrong event
So we can rule out any between device race conditions

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-20 14:25:57 +10:00
Peter Hutterer
dec1b4f93c test: print the full event in case of a mismatch
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-20 14:25:54 +10:00
Peter Hutterer
2857cfe87d test: use a udev monitor to wait for a device to disappear
Reduces potential race conditions.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 14:36:31 +10:00
Peter Hutterer
fb8a5b040a test: replace a strcmp with streq
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 14:36:31 +10:00
Peter Hutterer
1531c9dc88 test: call K_OFF when run on the vt
Slight disadvantage: this breaks Ctrl+C to cancel the test suite. Still
potentially better than injecting random events into your vt.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2018-04-06 10:35:36 +10:00
Peter Hutterer
1e9925735a test: reliably sort the udev rules
This guarantees the device rules have a static order between test runs.
Previously and in some cases, the temporary file name could affect the order
of the udev rules - let's not do that.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-23 10:17:52 +10:00
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