Commit graph

5168 commits

Author SHA1 Message Date
José Expósito
3f3071cb88 editorconfig: add settings for sym files
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1076>
2024-11-04 10:31:30 +00:00
Peter Hutterer
86915213c8 tools: sort the options in debug-events match page
We now have enough config options that having them unsorted makes it
hard to find the right option.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1075>
2024-11-04 15:48:49 +10:00
Peter Hutterer
d1e49c7b3d tablet: default to a built-in tablet
The vast majority of devices that libwacom doesn't know about are the
various built-in ones. Since the only effect in our code here is that we
enable the calibration matrix, let's default to built-in if we don't
know any better - better to have the matrix and not use it than to not
be able to calibrate a tablet.

Note that libwacom 2.11 and later also now default to a built-in tablet.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1074>
2024-10-31 15:58:31 +10:00
Peter Hutterer
2ac4227843 test: fix two race conditions waiting for proximity events
This test does a prox in/out and immediately drains events.
Where we are slow enough we may drain only one (or none) of the
proximity events which causes a failure later in the test.

Similar issue with the second test where we may get a delayed tip event.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1074>
2024-10-31 15:58:31 +10:00
Peter Hutterer
2b2959fc8b tablet: centralize the libwacom handling
Instead of re-creating the the libwacom device from the database every
time we need it let's create it once during tablet|pad_init and pass it
down to the functions.

This allows us to have one point per tablet/pad where we can log an
error if the device is not supported by libwacom - previously this was
printed during the left-handed setup.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1073>
2024-10-31 13:38:28 +10:00
Peter Hutterer
d3bc0c79ff tablet: minor rework to remove one ifdef HAVE_LIBWACOM
Change to a boolean for more obvious return values and move the ifdef
into the function so we can skip the ifdef in the caller.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1073>
2024-10-31 13:38:28 +10:00
Peter Hutterer
384e946960 pad: support dial modeswitch buttons
This requires unreleased updates to libwacom [1], currently hiding
behind an ifdef so we don't require that particular version.

[1] https://github.com/linuxwacom/libwacom/pull/805

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1070>
2024-10-31 11:04:45 +10:00
Peter Hutterer
90e9c9f832 pad: rework the tablet pad mode setup
This was historically based on the LEDs on the device: we'd loop through
the LEDs and assign them to pad mode groups, then figure out which
button is the mode toggle for that group and finally which buttons
are in the same position as that toggle button.

Devices like the XP Pen ACK05 Remote don't have LEDs though but they do
have a mode toggle button [1] inside the dial. Let's support those by
switching the initialization on its head: search for mode toggle
buttons, create a mode group per toggle button, then associate
LEDs with that group.

The outcome should be functionally the same for devices with LEDs but
allows us to create mode groups where no LEDs exist.

Closes #1045

[1] As per Windows default button behavior

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1070>
2024-10-31 11:04:45 +10:00
Peter Hutterer
7ae4fabb76 pad: don't clobber the errno if the pad led failed to initialize
pad_led_destroy() may call something that sets errno, so let's protect
against that.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1070>
2024-10-31 10:28:08 +10:00
Peter Hutterer
181c667266 pad: remove an unused argument
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1070>
2024-10-31 10:28:08 +10:00
Peter Hutterer
c969b5f6e2 pad: rename an argument for more clarity
Yes, we're using the LED count here but what it is used for is the
number of modes.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1070>
2024-10-31 10:28:08 +10:00
Peter Hutterer
9ae514c7b4 test: mark the pad group tests as basically broken by expectation
Since our implementation uses the sysfs LED files and we don't have
those, all our test devices have the single fallback mode and no
more. Add a comment to all these tests to make that clear and enforce a
single mode only so it's more obvious.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1070>
2024-10-31 10:28:08 +10:00
Peter Hutterer
6c350ab269 test: fix 3 compiler warnings when building without libwacom
signed/unsigned and an unused variable.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1070>
2024-10-31 10:28:08 +10:00
Peter Hutterer
266ce4218b test: fix strip values being passed to ring functions
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1070>
2024-10-31 10:28:08 +10:00
Peter Hutterer
74af5cfb9c CI: collect valgrind log files too
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
4a98e273a4 test: add --output-file to print test logs to a file
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
1f8a4df58c test: drop the --xml-prefix option
litest-runner outputs in YAML and no-one ever looks at the XML files
anyway. They are used to provide nice pipeline summaries but again,
no-one looks at those because they're not very useful.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
c6ba3e2eb8 CI: disable forking for valgrind tests
With the new test suite runner we get one fork per test which will
eventually slow down valgrind enough so our tests fail.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
a80678c241 test: add --filter-rangeval to only run tests with a range value
For ranged tests (e.g. gesture tests) it's convenient to be able to run
those with a value of N (e.g. 3 fingers) instead ov having to run all of
them all the time.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
3c2e92d169 test: add ability to collect test results from a nonforking test
Use longjmp to try to get out of a test error. This will only work for
errors triggered by our own test suite (i.e. not for SIGSEGV and
friends) but that's good enough for most things.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
c1f744a6e5 test: move the quirks setup into the global setup func
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
b21fd3cfe7 test: add runner support for a global setup/teardown func
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
1fd3cefc60 test: the created files list doesn't need to be a global
This list was used in the signal handler but that is no longer the case,
so let's localize this.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
c68c0f593b test: move the rest of the custom initialization to litest_run
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
d4c6c47677 test: move tty disabling closer to the actual running of the tests
And move the litest-specific condition out into the caller so
disable_tty() only cares about the TTY, not any surrounding conditions.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
b81cc0ceb7 test: only force gdb to no-fork, valgrind can fork
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
16e5bdabac test: intercept and collect valgrind errors
This works because we always invoke with --exit-errorcode=3 from the
test suite. It won't work for manual invocations but oh well.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
27fa85a884 test: move litest_free_test_list to inside ifndef NO_MAIN
This is now only called from one spot, so let's move it so it is
ifdef'd out.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
0cfde0f95f test: make the utils test a "pure" litest-runner test
Now that we have the runner let's use it directly for this set of simple
test.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
d84efcb4b6 test: add --exit-first to the litest test suite runner
Exits upon the first failed test.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
7b69fb2d63 test: remove now-unused check-double-macros.h
We no longer use those functions, so let's drop them.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
9928de7fa3 test: move the quirks context init into litest_run
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +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
d94407f810 test: fix utils test for types for litest assertions
check always typecasts to intmax_t so a lot of type mismatches were
hidden.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
5cbb37a3d2 test: convert utils test to litest_assert
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
6cac0d4d2f test: make the utils test another litest
This doesn't really gain us anything for now but it's prep work for
dropping check and the custom invocations of check.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
4fa5ea268e util: add a generic stringbuffer with a few helper functions
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
817dc42381 util: add the range handling as separate header file
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
d1575fbce5 test: move the deviceless check into ltest_add_tcase
This is out of place here, check this when we are about
to add the test, not later when the tests are about to be run.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
efd3dd4427 test: filter out duplicate name/device combos in --list
This doesn't have an effect yet because ranged tests are handled inside
check. But in the future these tests will be split up individually so
de-duplicating is useful here.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
e3b5c0da5f test: make litest_backtrace() available from outside litest.c
Prep-work for adding a new runner

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
b67ab51f76 test: append, not insert the suites
list_append() came later than list_insert() and there's an argument to
be made that tests added later should be run first since they're less
likely to succeed. But it's a lot harder to read test logs when they are
in reverse order, and with the TEST_COLLECTION() macro the order of the
test suite is not obvious anyway.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
f91f0a7ea5 util: add a bunch more time conversions
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
02f5faf6f6 util: move libinput_now() into a utility function
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
d3922661ba util: add xclose(fd) to close-and-reset an fd
This prevents accidentally leaving the fd set after closing.

And it includes the -1 check so we don't need this everywhere ourselves
(not that we use it right now but valgrind likes to complain about
this).

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
a61c876412 pre-commit: drop black, use ruff-format instead
And switch to the current-ish version of the ruff pre-commit hook,
including updating the repo.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1072>
2024-10-29 13:48:31 +10:00
Peter Hutterer
15af1c0017 tools: change direct type check to isinstance
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1072>
2024-10-29 13:27:35 +10:00
Peter Hutterer
5e235a6546 util: make a float to int conversion explicit
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1071>
2024-10-29 10:18:54 +10:00
Peter Hutterer
e0f671126d util: add the backtrace printing function as separate util
Might as well make this easier to re-use since it doesn't do anything
specific to litest.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1066>
2024-10-23 10:08:12 +10:00
Peter Hutterer
4546480e13 pad: default a pad group to mode 0 if all LEDs are off
Since our API doesn't accomodate for "dunno" we need to pick a mode that
we are actually in. This happens on the Intuos Pro 2 (PTH-660) which has
all LEDs on brightness zero, resulting in a failure to set up the modes
and we're left without a mode button.

Fix it by just picking zero as the default mode until specified
otherwise.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1069>
2024-10-22 18:14:15 +00:00