Commit graph

70 commits

Author SHA1 Message Date
Sicelo A. Mhlongo
b3f7b4b1ea evdev: add support for SW_KEYPAD_SLIDE
A few devices have a keyboard/keypad which can be slid under the device,
leaving the device with only touch-based interaction. The corresponding kernel
event is reported as SW_KEYPAD_SLIDE [0]. Implement support in libinput.

Since the position of the switch varies across devices, it cannot always be
certain whether the keypad is usable when the switch is in the set position.
Therefore, do not automatically disable the keyboard.

[0] e68d80b13b/include/linux/linux/input-event-codes.h (L885)

Closes: #1069
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1242>
2025-12-11 13:28:41 +02:00
Peter Hutterer
2a1095924b Run clang-format over the code
This uses the .clang-format file in the follow-up commit, but committed
prior to that to ease review of said file and various integrations.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
2025-07-01 16:42:44 +10:00
Peter Hutterer
ed29a4f200 test: disable clang-format in test collections
It's too much effort fighting clang-format for these snippets which
all don't really do much anyway but are important to be read easily.

Let's categorically disable all formatting in the test collections and
move on.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
2025-07-01 16:36:14 +10:00
Peter Hutterer
aebf3cd491 Add trailing commas to prevent clang-format oddities
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
2025-07-01 16:36:14 +10:00
Peter Hutterer
784312a494 test: add clang-format directives to prevent formatting
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
2025-07-01 16:36:14 +10:00
Peter Hutterer
d72df04e7d test: auto-unref the litest devices
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184>
2025-04-16 17:04:58 +10:00
Peter Hutterer
6cbe4568de test: rename litest_delete_device to litest_device_destroy
To be closer to the common free/destroy/unref pattern

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184>
2025-04-16 17:04:58 +10:00
Peter Hutterer
6f6bba9588 test: use __attribute__(cleanup) for the test libinput contexts
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184>
2025-04-16 17:04:58 +10:00
Peter Hutterer
5a652e5116 test: make the timeout functions auto-dispatching
The overwhelmingly vast majority of invocations want to have a dispatch
before/after, so let's automate that. In case NULL is passed, that
dispatch is skipped.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1169>
2025-04-04 05:13:00 +00:00
Peter Hutterer
b0cfcfab34 test: standardize the wacom device names
Consistently use the pen/pad/finger suffix for the subdevices, both in
the device's name and the device type.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1157>
2025-03-13 05:57:37 +00:00
Peter Hutterer
1de6ac8916 test: rename the 12WX test device short name and enum
Make this more specific, we have quite a few other cintiqs in here

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1143>
2025-02-25 05:18:53 +00:00
Peter Hutterer
41c08f0816 test: add litest-runner as test suite runner
This replaces check. The code is a copy of pwtest which I wrote years
ago for pipewire but adjusted for us here the last few days.

There are a few advantages over check:
- Ability to SKIP tests or mark them as NOT_APPLICABLE, the latter
  of which is used for early checks if a device doesn't meet
  requirements.
- it captures stdout/stderr separately
- colors!
- YAML output format makes it a lot easier to read the results and
  eventually parse them for e.g. "restart failed tests"

Less abstraction: we set up the tests, pass them to the runner and run
them with the given number of forks. This is an improvement over before
where we forked into N test suites which each called check which then
forked again. Since we're now keeping track of those processes
ourselves we can also write tests that are expected to fail with
signals.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
f89fd6d924 test: switch ck_assert over to litest_assert
This is the first step in switching away from the check framework.
Our litest macros already do almost exactly the same anyway so most of
this is a simple sed with a few compiler fixes where things mismatch
(nonnull -> notnull) and (_tol -> _epsilon).

This now generates a whole bunch of integer mismatch warnings: check
casts everything to intmax_t whereas we use typeof, so lots of warnings
especially for enums.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1059>
2024-10-15 12:44:27 +10:00
Peter Hutterer
25bdda0b8a test: use litest_assert_event_type instead of direct type check
This provides better debugging logs and is slightly less code in
the checks too.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1050>
2024-09-19 23:43:53 +10:00
Peter Hutterer
86c47be816 test: add litest_dispatch() for better test debugging
Wraps libinput_dispatch() with a location which will make things a bit
easier to track. Output (in --verbose) is something like:

  gestures_swipe_3fg_unaccel_fn():1346 - dispatching

Which makes it easier to associate the various calls to libinput
dispatch with the other output from libinput.

This patch switches all uses of libinput_dispatch() in test cases over
but not the litest functions that may call dispatch too. Remains to be
seen if that is necessary.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1048>
2024-09-19 15:21:04 +10:00
José Expósito
f6a1f264df sparse: make some variables static
Fix warnings about variables that should be made static when compiling
with Sparse enabled:

        $ CC=cgcc meson builddir

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/987>
2024-03-18 23:35:34 +00:00
Peter Hutterer
3644372696 test: add helpers for checking (negative) errnos
This way we get to see the actual error when it happens.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/984>
2024-03-18 16:25:47 +00:00
Peter Hutterer
a1e9150210 timer: only warn about timer expiry issues when we're more than 20ms behind
The most common trigger for this is the debouncing timer which is a mere
12ms and is effectively unavoidable, virtually every caller will
trigger those messages at some point.

Let's add a grace period of 20ms below which we don't log this message
to avoid logspam. And in the process, bump the equivalent warning
message up to 20ms as well.

Related #711

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-12-07 11:54:08 +10:00
José Expósito
f0d3761f73 libinput: add hold to get base event
LIBINPUT_EVENT_GESTURE_HOLD_BEGIN and LIBINPUT_EVENT_GESTURE_HOLD_END
were missing from libinput_event_gesture_get_base_event.

Add them to avoid triggering an erroneous client bug warning.

Fix #671

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-09-24 19:06:53 +02:00
Peter Hutterer
d3115f4875 test: drop the custom group names
The group names are forced by check (they are called suite names there) but
for our test suite they provide very little benefit. Much easier to just
use the filename a test is in as group name.

This removes the pure substring match for --filter-group, it's now fnmatch
only. group names are short enough that the typing isn't an issue and we don't
want to run tests twice (e.g. 'pad' is also in 'touchpad').

This patch caused #574 until it got fixed in d838e3a3a4

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-12 15:24:15 +10:00
Peter Hutterer
d838e3a3a4 test: use motion events to check the "system is too slow" message
Using buttons for this test can trigger debounce warnings instead (in
addition?) to the warning we actually check for. Let's use motion events
instead and double the loop while we're at it so we have double the chance of
triggering at least one warning.

Fixes #574 for unknown reasons

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-12 11:05:38 +10:00
Peter Hutterer
aed15dd791 test: wrap the litest user data into a struct
litest itself requires the libinput user_data to be set to its own context
struct (see close_restricted). A test that needs its own user_data must not
override this struct - if the context is accessed during libinput_dispatch()
we'll get memory corruption.

See #574

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-12 11:04:57 +10:00
Peter Hutterer
c83c739a8c tests: drop the duplicate test for pointer event conversion
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-11 15:54:17 +10:00
Peter Hutterer
1d714e68df test: don't set the log handler 10 times
Once is enough, we don't need to set it inside the loop.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-11 15:53:53 +10:00
Torstein Husebø
18c9265224 treewide: fix typos
Signed-off-by: Torstein Husebø <torstein@huseboe.net>
2020-12-16 22:08:23 +01:00
Peter Hutterer
86946342fb test: store the list of open file descriptors in the litest context
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-07 18:51:33 +10:00
Peter Hutterer
52d6398753 test: use litest_destroy_context() for test-suite contexts
Symmetrical to litest_create_context(), this allows us to store special data
in that context that we have access to during the tests.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-07 18:51:33 +10:00
Peter Hutterer
d78d662928 test: use context creation helper in the log tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-07 18:51:33 +10:00
Peter Hutterer
bd7b91065b evdev: warn if our event processing lags by 10ms or more
Take a snapshot of the time every 10 libinput_dispatch() calls. During event
processing, check if the event timestamp is more than 10ms in the past and
warn if it is. This should provide a warning to users when the compositor is
too slow to processes events but events aren't coming in fast enough to
trigger SYN_DROPPED.

Because we check the device event time against the dispatch time we may get
warnings for multiple devices on delayed processing. This is intended, it's
good to know which devices were affected.

In the test suite we need to ignore the warning though, since we compose the
events in very specific ways it's common to exceed that threshold
(particularly when calling litest_touch_move_to).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-05-13 06:21:27 +00:00
Peter Hutterer
0dcb02d369 test: add a test case for checking EVDEV_ABS overrides
Problem: it's still not a 100% check because the way real udev handles the
EVDEV_ABS overrides ignores any that are set through udev properties only. So
we manually have to trigger the keyboard builtin for our test device which
can give us false positives (e.g. it wouldn't have detected #424). But still,
it'll alert us if the actual overridden values are different to what we
expect.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-02-12 21:22:01 +10:00
Peter Hutterer
5e25bdfb03 timer: make the timer offset error a bit more user-friendly
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-01-31 13:03:00 +10:00
Peter Hutterer
cbbd5b15c6 test: split out the unit tests into a separate test suite
All the bits that test for utility functions to work correctly can be run
separately from the main test suite (which tests devices and libinput in
general). These bits here are the ones that test the code itself and aren't
reliant on anything else.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-03-14 11:28:05 +10:00
Peter Hutterer
c0f4ede0c2 test: split the library version test out
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-03-14 11:28:05 +10:00
Peter Hutterer
fbe7abfd5d test: up the ratelimit tests to 1000ms
This fails too often on the gitlab runners, so let's expand the times.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-02-04 09:56:45 +10:00
Peter Hutterer
6041d0ba69 test: fix a clang warning
test/test-misc.c:1065:28: warning: Value stored to 't' during its
initialization is never read

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-11-05 14:28:13 +10:00
Peter Hutterer
981f3a47e6 quirks: add the ability to disable custom event codes/types
This is a more flexible approach than adding a model flag and the C code to
just call libevdev_disable_event_code(). There's a risk users will think this
is is a configuration API but there are some devices out there (e.g. the
Microsoft Sculpt mouse) that need a more generic solution.

Case in point: the Sculpt mouse insists on holding BTN_SIDE down at all times.
We cannot ship any quirks for that device because we only have the receiver's
generic VID/PID. So a local override is required, but we might as well make
that one generic enough to catch other devices too in the future.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-10-29 04:16:38 +00:00
Peter Hutterer
4fa7a6b94a test: move the custom parser test structs into the functions
No need to pollute the namespace here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-10-22 08:16:02 +10:00
Peter Hutterer
037bd0cc9c test: drop a condition from the safe_atou test
If sizeof(long) == sizeof(int), this test won't pass so let's drop it
altogether.

Fixes #137

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-09-14 10:20:40 +10:00
Peter Hutterer
19ea63bf23 util: tighten safe_atod parsing to only parse 'normal' numbers
We don't have a sensible use case where we want hex to double, or INF to
double, or any of that. So check the strings for invalid characters and bail
out early. Invalid characters include 'e' and whitespaces too, we don't need
those.

Small chance of things breaking: if the user-exposed calibration matrix
property was specified using hex numbers this will stop working now. I'll take
that risk.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-13 11:50:21 +10:00
Peter Hutterer
e73f6a3899 util: fail property parsing if the dimensions are 0
There is no use-case for a zero width/height in anything using that property.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-13 11:50:21 +10:00
Peter Hutterer
a508097e98 util: remove now-unused helper functions
Obsolete with the switch to the device quirks

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-02 15:51:47 +10:00
Greg V
db2dd43c86 Add versionsort test
And make local versionsort testable even when the native one is present.
2018-07-19 22:29:00 +03:00
Peter Hutterer
b469368790 test: misc: up the time limit on the ratelimit tests
I keep hitting this in the gitlab runner, 100ms is clearly not enough here for
slow containers.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-07-05 13:55:21 +10:00
Peter Hutterer
5ca1862bde test: add a libinput-test runner for 'deviceless' tests
These are tests that don't need *any* uinput devices at all. Mark them
accordingly and create a new binary that only runs those tests. This way we
can run some of the test suite even in containers where we're restricted.

Better have 10% tested than none, I guess.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-26 11:18:31 +10:00
Peter Hutterer
000ac14c27 Merge branch 'wip/config-files' 2018-06-11 13:45:50 +10:00
Peter Hutterer
6ad928a1b6 util: add null string test handling to strv_join
Make it return NULL for a string array in the form of [ NULL ], like the docs
say. This also adds an extra safety check for the joiner to be of a reasonable
length to avoid overflows.

Found in
https://gitlab.freedesktop.org/libinput/libinput/issues/26#note_6320

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-11 13:43:15 +10:00
Peter Hutterer
be647fbb0d util: add a safe_atou() as unsigned equivalent to safe_atoi()
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-08 13:47:33 +10:00
Peter Hutterer
e05fa8444a util: add a list_append()
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-08 13:47:33 +10:00
Peter Hutterer
a1ab4757a4 test: don't use ck_assert_ptr_null
Breaks the build on Ubuntu which ships check 0.10.0 from pre-Dec 2016.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03 15:16:33 +10:00
Peter Hutterer
1e4c5a93a8 util: add a strv_join() helper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03 12:31:30 +10:00