Commit graph

1768 commits

Author SHA1 Message Date
Peter Hutterer
63a8ad2ead util: add some extra strv helpers
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1178>
2025-04-04 22:19:47 +00:00
Peter Hutterer
6770131e94 util: fix a memleak in mkdir_p
In the error case path would leak.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1175>
2025-04-04 15:47:23 +00:00
Peter Hutterer
0fc52abd79 util: change the builddir_lookup() to return a boolean
All but one callers of this function only care about yes/no, so let's
change it to only return the build dir in the one case it's needed.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1175>
2025-04-04 15:47:23 +00:00
Peter Hutterer
a92d635af1 test: rename test-util-includes.c to .c.in
This way it doesn't get picked up by static analysis tools which are
then unhappy about the @FILE@ placeholder

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1175>
2025-04-04 15:47:23 +00:00
Peter Hutterer
f123da174e Add a few 0 enum values to shut up clang-tidy
These are all internal API so having a NONE value means we can shut up
warnings about 0 not being an enum value without having those exposed in
our public API.

And they slightly improve readability in the callers anyway.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1175>
2025-04-04 15:47:23 +00:00
Peter Hutterer
a55dd604e1 util: add a newtype macro
In a valiant approach to introduce some type-safety (after spending time
debugging a int vs double confusion) this adds a DECLARE_NEWTYPE()
macro that declares a named struct with a single typed value field.

This is basically the C version of Rusts "struct Foo(u32)" with
a few accessors auto-generated by the macro.

C is happy to silently convert between base types but it doesn't do
so for structs so this allows us to have some type safety
when we accidentally assign two incompatible fields to each other (e.g.
an axis value in device units vs a percentage value).

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1171>
2025-04-04 11:05:20 +00:00
Peter Hutterer
000d9282cd test: split litest's main() into a separate file
Instead of having this ifdef'd out split the main and directly
associated functions out into a separate file.

That ifdef used to exist so we can use parts of litest in some other
files (the selftest and the utils test). Those tests care mostly
about the assertion helpers so long-term a split into
assert helpers and "rest of litest" would be better. For now, this will
do.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1174>
2025-04-04 06:28:07 +00:00
Peter Hutterer
bbd9df60de test: use the local variable for njobs, not the global one
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1174>
2025-04-04 06:28:07 +00: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
734ffea934 test: use a single litest_timeout function only
This can be easily wrapped with a macro that passes in the millis to
time out for.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1169>
2025-04-04 05:13:00 +00:00
Peter Hutterer
b43abaeacb test: allow passing func/line up from litest_abort_msg()
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1169>
2025-04-04 05:13:00 +00:00
Peter Hutterer
90dafb33b4 test: print drained events when draining typed events
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1169>
2025-04-04 05:13:00 +00:00
Peter Hutterer
b3471a960e test: add missing proximity timeouts to the tablet tests
A bunch of tests that left proximity but didn't wait for the proximity
timeout.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1169>
2025-04-04 05:13:00 +00:00
Peter Hutterer
7a9f4f1c38 test: switch to litest_dispatch()
litest_dispatch() was added in 86c47be816, the rectangle tests spawn
from the same time but didn't get updated before merging.

Fixes: 86c47be816 ("test: add litest_dispatch() for better test debugging")
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1169>
2025-04-04 05:13:00 +00:00
Peter Hutterer
978871c450 test: abort litest_wait_for_events() if we don't get events after 2s
Previously we kept polling but this just delays what will almost
certainly be a failure anyway - none of our tests require even 2000ms
for an event to arrive.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1169>
2025-04-04 05:13:00 +00:00
Peter Hutterer
35b223aa8e test: fix wacom test devices to use pressure 0 on proximity out
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1169>
2025-04-04 05:13:00 +00:00
Peter Hutterer
8683457ee9 test: re-enable the selftests
An `#if 0` was accidentally checked in in 1e445f3f84, disabling all but
the newly added tests there.

Fixes: 1e445f3f84 ("test: implement support for parametrizing tests")
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1177>
2025-04-04 12:09:49 +10:00
Peter Hutterer
7d4e152aea tablet: delete the tablet's pressure range from the tool pressure ranges
Commit 48cd4c7287 ("tablet: track pressure ranges per tablet") added
up to 4 per-tablet pressure ranges that are stored in the tool on the
assumption that tools are never used across more than 4 tools.

However, if the tablet gets unplugged it will show up as new devices.
Fix this by removing the tool's reference to the previous tablet after
device removal.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1165>
2025-03-31 19:41:00 +10:00
Peter Hutterer
fc4e806e0b tablet: always initialize the pressure thresholds
When the tool is moved in proximity of a new tablet but the pressure
range hasn't changed since the last proximity, the new tablet was left
with a threshold range of 0:0.

For some reason this requires tightening up the check for the test too,
with our default episolon 0.091 fails the test of being > 0.9

Closes #1109

Fixes: 48cd4c7287 ("tablet: track pressure ranges per tablet")
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1165>
2025-03-31 18:09:19 +10:00
Peter Hutterer
e77eb469e8 test: add no-tool testing to one of the tablet tests
Modifies an existing proximity test to also test for the case where a
tablet never sends BTN_TOOL_PEN so we have that case covered.

This is implicitly tested by the LITEST_UCLOGIC_TABLET test device but
making it explicit is a bit easier to debug.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1164>
2025-03-28 05:08:11 +00:00
Peter Hutterer
39fa451e7e pad: fix handling of direct mode switch buttons
A tablet with multiple mode toggle buttons had each mode toggle button
merely cycle to the next mode in the sequence, removing the whole point
of having multiple toggle buttons.

Fix this by defaulting each mode toggle button to "next". Once we
have initialized all buttons we can check if we have multiple buttons -
if so we number them sequentially so that the first button maps to mode
0, the second maps to mode 1, etc.

Closes #1082

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1132>
2025-03-27 04:57:33 +00:00
Peter Hutterer
4d1b836e22 test: fix the tablet tool_ref test
This was working on an assumption that there is only one ref of the
tablet tool and if we call unref it will be removed. This assumption is
not something we can guarantee in the public API so we shouldn't test
for it.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1161>
2025-03-25 15:05:45 +10:00
Peter Hutterer
056bdb733a test: add a helper call to mark the end of boilerplate in a test
Some tests have pages of debug output to get the setup for the test
correctly, add a standard marker to differentiate this from the code
that matters.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1161>
2025-03-25 15:05:45 +10:00
Peter Hutterer
0cfa2ee3f9 test: pass the func/lineno down to a few more functions
Most of them currently unused

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1159>
2025-03-14 10:18:24 +10:00
Peter Hutterer
bcb467da4c test: add extra highlighting for the backtrace
Pass through the function name where the condition failed so we can
highlight that line in the backtrace.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1159>
2025-03-14 09:52:30 +10:00
Peter Hutterer
9714253190 test: re-use the event printing in litest
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1156>
2025-03-13 06:13:38 +00:00
Peter Hutterer
3858a6c4f8 test: print events discarded while waiting for another event type
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1156>
2025-03-13 06:13:38 +00:00
Peter Hutterer
bfbecc5ef3 test: vary the colors in the test output a bit
Instead of everything bright red, let's vary the colors so it's easier
to spot the different assertions we add.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1157>
2025-03-13 05:57:37 +00:00
Peter Hutterer
aaad75ec19 test: mark _litest_checkpoint as printf function
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1157>
2025-03-13 05:57:37 +00:00
Peter Hutterer
2ec9389a0d test: stringify the LITEST_ value as the device's name
This avoids inconsistencies between the LITEST_ enum value and the
shortname but also makes it easier to grep for any test cases that use
the same define. At the cost of the test names not looking very nice
anymore but oh well.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1157>
2025-03-13 05:57:37 +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
7ae22591f3 test: add a note that the Huion PIDs are shared
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1157>
2025-03-13 05:57:37 +00:00
Peter Hutterer
99097c983d test: don't include an internal header in the totem tests
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1157>
2025-03-13 05:57:37 +00:00
Peter Hutterer
58315eb9d4 test: remove duplicate empty lines from the test/ directory
We've had a CI job for checking this since but it omitted the test
directory.

Fixes: bb6ff0ec00 ("gitlab CI: add a job to check for whitespace issues")
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1154>
2025-03-11 11:41:34 +00:00
Peter Hutterer
48cd4c7287 tablet: track pressure ranges per tablet
Tablets may have different ABS_PRESSURE ranges with the oldest tablets
having 1k pressure range, then 2k, and the newer ones 8k.

If the same tool is used across two tablets with different ABS_PRESSURE
ranges, the first tablet in proximity calculated the range on where to
normalize to. As a result the other tablet either couldn't reach the
full pressure (2k pressure first, then 8k) or the full pressure range
was reached at a fraction of the full range (8k pressure first, then
2k).

Fix this by moving the threshold handling into a separate struct and
hardcoding up to 4 of those per tool. That is 2 more than the more
complicated setups I've heard of (and this only applies to tracking the
same stylus across those tablets anyway).

This duplicates the pressure offset heuristics but that's easier than
figuring out how to handle heuristics across potentially two tablets.

The range configuration is left as-is on the assumption that this one is
per tool, not per tablet.

Closes #1089

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1143>
2025-02-25 05:18:58 +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
satrmb
a71f560f3e test: fix off-by-ones in two ranges, prevent the same in remaining ranged tests
touchpad_move_after_touch contains support for up to 5 fingers but was only run
with 2..4 fingers.
touchpad_multitap and several others using the same parameter definition were
long ago tested with 3..7 taps. In 8f92b091 this was reduced to 3..4 for CI
performance, while the commit message indicates 3..5 were intended.

The common theme is that the upper bound of `struct range` is interpreted
as exclusive, while some uses assumed it would be inclusive.
There are relatively recent helper functions range_init_inclusive and
range_init_exclusive (since 817dc423) to avoid this trap. Use them on the
remaining two ranged tests.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1142>
2025-02-20 09:34:20 +01:00
satrmb
6f9a54c573 test: convert most ranged tests to parametrized ones
The two remaining ranged tests (abs_device_no_range, abs_mt_device_no_range)
are better served staying with ranges because parametrized tests need to
explicitly list all members of the range, which for these tests is not only
pretty big, but also contains abs axes reserved for future use. Those axes
have no names yet, making a future-proof conversion pretty much impossible.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1142>
2025-02-20 09:34:14 +01:00
satrmb
3a60c47e33 test: add optional value names to parametrized tests
Only implemented for i32 values so far, used for enums and enum-like constants,
replaces a runtime lookup from stringly-typed parameters.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1141>
2025-02-20 08:18:48 +01:00
Peter Hutterer
1d9e307e2b touchpad: implement support for three-finger drag
Exposed via new configuration option this enables 3 and 4 finger
dragging on touchpads. When enabled a 3/4 finger swipe
gesture is actually a button down + motion + button up sequence.

If tapping is disabled the drag starts immediately, if tapping is
enabled the drag starts after the tap timeout/motion so we can distinguish
between a tap and a drag.

When fingers are released:
- if two fingers remain -> keep dragging
- if one finger remains -> release drag, switch to pointer motion

When 3/4 fingers are set down immediately after releasing all fingers
the drag continues, similar to the tap drag lock feature. This drag lock
is not currently configurable.

This matches the macos behavior for the same feature.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1042>
2025-02-18 06:44:01 +00:00
Peter Hutterer
114af53824 test: fix the touchpad finger positions for a test
The 5th finger was placed in the same position as the 4th finger which
doesn't have an effect in libinput but it looks wrong.

And the first finger was put down at 40/30 but then moved from 70/30 to
the new position, causing pointer jumps on some touchpads.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1145>
2025-02-18 05:40:44 +00:00
Peter Hutterer
5ae31d7f46 test: fix litest_test_param_get_double
Overenthusiastic search/replace caused the name argument to be a const
double*.

Fixes: 5ed75e7e9f ("test: make litest_parameters fetching more type-safe")
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1144>
2025-02-18 14:58:28 +10:00
Peter Hutterer
5ed75e7e9f test: make litest_parameters fetching more type-safe
Require the type to be added in the litest_test_params_fetch() so we can
easily detect a mismatch. And add some type-safe getters that are much
easier to use for all the tests that only have a single parameter to
fetch anyway.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1139>
2025-02-12 09:11:51 +00:00
Peter Hutterer
d9f121b4d1 test: add a litest_with_parameters helper macro
Magic for loop that takes care of the creation and unref for us,
hopefully improving readability a bit.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1138>
2025-02-12 11:41:56 +10:00
Peter Hutterer
fefeab4efe test: a boolean parameter is always true/false
Don't require the caller to provide the values, they're always the
same.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1123>
2025-01-20 12:08:46 +00:00
Peter Hutterer
86b9142a02 test: highlight the interesting part of the backtrace
This makes it easier to immediately see where things are breaking since
the full backtrace has >70% noise.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1124>
2025-01-20 11:30:01 +00:00
Peter Hutterer
6759a2f754 test: honor NO_COLOR and FORCE_COLOR for output colorization
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1124>
2025-01-20 11:30:01 +00:00
Peter Hutterer
2c0c4a6516 Replace strneq() with hardcoded lengths with strstartswith()
Slightly less efficient but easier to read and it's not possible to
accidentally provide the wrong length. Plus it handles null pointers
correctly so get to skip the checks (which weren't needed for strneq()
either, but still).

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1121>
2025-01-20 10:29:47 +00:00
Peter Hutterer
1d8f2903ed tablet: always unset the various statuses if we're leaving proximity
The previous invocation was gated behind a TABLET_OUT_OF_AREA check
resulting in a nonresponsive tool when the tablet was moved out of
proximity outside the tablet area and the area was changed.

Move the actual status bit changes up into tablet_flush()
so we unconditionally set those.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1118>
2025-01-20 09:54:32 +00:00
Peter Hutterer
2f2612e8d7 test: use litest_checkpoint to annotate a test case
Had to debug something here and we might as well keep the printable
annotations.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1118>
2025-01-20 09:54:32 +00:00