Peter Hutterer
ea50e1a92c
test: add litest_assert_str_in/not_in() helpers
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1204 >
2025-05-26 05:22:33 +00:00
Peter Hutterer
14c4667980
test: add litest_assert_not_reached()
...
Simpler than a specific litest_abort_msg() everywhere
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1204 >
2025-05-26 05:22:33 +00:00
Peter Hutterer
e91e1c3111
util: add a tmpdir helper
...
With the __attribute__(cleanup) helper this makes it simple
enough to provide a tempdir inside a function that is (recursively)
automatically deleted when the variable is deleted.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1204 >
2025-05-26 05:22:33 +00:00
Peter Hutterer
91d4f9e58e
util: add an rmdir_r helper function
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1204 >
2025-05-26 05:22:33 +00:00
Peter Hutterer
efea8463fe
util: add a helper to find files in a set of directories
...
Returns a number of paths for files with a given suffix in a
priority-sorted list of directories.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1204 >
2025-05-26 05:22:33 +00:00
Peter Hutterer
95a417cefa
util: add a helper to find substrings in a strv
...
Returns true and optionally the first index of any string in strv that
contains the given substring.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1204 >
2025-05-26 05:22:33 +00:00
Peter Hutterer
15b4ea59e9
test: improve an error message for an unlikely error
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1204 >
2025-05-26 05:22:33 +00:00
Peter Hutterer
d5cd398b77
test: improve an error message for unhandled parameter types
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1204 >
2025-05-26 05:22:33 +00:00
Peter Hutterer
8177a685c2
meson.build: fix detection of C23 auto
...
Sadly, this detection was broken because in C everything defaults to
type int. Casting a const char* to int is permitted but generates a
warning which was promptly ignored by meson.
This result in HAVE_C23_AUTO being set on compilers that don't by
default have -Werror=implicit-int and "auto" ended up being just an
"int".
Change the detection to use gmtime() which returns a struct, and add a
basic test using one of our struct-returning utility functions, just to
be sure.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1198 >
2025-05-08 23:06:58 +00:00
Peter Hutterer
d400b17bee
util: add the macros required for magic vararg expansion
...
A set of macros that expand to different things depending on the
number of arguments passed into the macro. Can be used for anything
but in the test case we use it to differ between stringifying the single
argument or taking a custom string for that same argument.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1188 >
2025-04-28 10:05:52 +10:00
Peter Hutterer
04a55d59d9
test: call rmdir for directories, not unlink
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1193 >
2025-04-24 17:34:07 +10:00
Peter Hutterer
6563b66a92
utils: add strv_find()
...
Finds and optionally returns the index of a string in a strv
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1193 >
2025-04-24 17:34:06 +10:00
Peter Hutterer
479a3d024c
test: improve debugging for one of the tablet tests
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1185 >
2025-04-16 19:57:21 +10:00
Peter Hutterer
b2c42b60da
test: rewrite the udev seat change test
...
The previous test was prone to a race condition if multiple tests were
run in parallel: since we're using a udev context here we would see any
device added through uinput. If the DEVICE_ADDED event was from a
device added by some other test we would later fail the test because
that other device still used the default seat.
Rewrite it to use a name comparison and in the process start using the
cleanup macros.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184 >
2025-04-16 19:15:56 +10:00
Peter Hutterer
2487273b5e
test: use litest_dispatch() in litest_wait_for_events()
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184 >
2025-04-16 19:15:29 +10:00
Peter Hutterer
5c1c14e567
test: parametrize some of the misc tests
...
This fixes an issue with the abs_device_missing_res tests where we only
tested for the X axis without a res.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184 >
2025-04-16 17:04:58 +10:00
Peter Hutterer
c9b92d9b6b
test: use __attribute__(cleanup) in udev tests
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184 >
2025-04-16 17:04:58 +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
cefab21e42
util: add an _unused_ macro and replace LIBINPUT_UNUSED
...
For annotating intentionally used variables it needs to be a bit
shorter, so let's replace the current one which was aimed at functions.
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
34b3881d24
test: remove an unused variable in the totem tests
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184 >
2025-04-16 17:04:58 +10:00
Peter Hutterer
923e8e43db
test: use __attribute__(cleanup) in the switch tests
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184 >
2025-04-16 17:04:58 +10:00
Peter Hutterer
1ae9462366
test: use __attribute__(cleanup) in the path tests
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184 >
2025-04-16 17:04:58 +10:00
Peter Hutterer
74e6b97d1e
test: use __attribute__(cleanup) in litest
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184 >
2025-04-16 17:04:58 +10:00
Peter Hutterer
df1c715cb0
test: use __attribute__(cleanup) in the litest-runner
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184 >
2025-04-16 17:04:58 +10:00
Peter Hutterer
fbc8eb8cb7
quirks: use __attribute__(cleanup)
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184 >
2025-04-16 17:04:58 +10:00
Peter Hutterer
76c87d2486
util: add various helper functions to use __attribute__(cleanup)
...
Taken from libei, with slight modifications. The general approach is:
basic data types use _autofoo_ to call the maching foo function on
cleanup. Struct types use _unref_, _destory_, _free_, whichever applies
to that struct.
Notably: attribute syntax depends on where it's declared [1] so in the
following examles only a, b, and d have the autofree attribute:
_autofree_ char *a, *b;
char *c, _autofree *d;
Simplest way to ensure it's all correct to keep the declarations one per
line.
[1] https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html#Attribute-Syntax
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184 >
2025-04-16 17:04:58 +10:00
Peter Hutterer
546debe926
Remove empty lines between closing braces
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1190 >
2025-04-16 11:44:09 +10:00
Peter Hutterer
265cacb246
test: properly batch litest events
...
If we push/pop event frames and combine various functions we might end
up sending the same value in the same frame multiple times. This
*should* be fine with libinput but is different to what the kernel does
in that case and harder to debug.
Let's batch any litest_event() until an EV_SYN arrives, then write them
all to libinput in one go.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1187 >
2025-04-15 05:06:53 +00:00
Peter Hutterer
c96ed7f6b8
test: convert push/pop event frames to with_event_frame
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1187 >
2025-04-15 05:06:53 +00:00
Peter Hutterer
550ffc1160
test: combine two REL_WHEEL_HI_RES events into one
...
This would be a kernel bug to send wheel events like this so let's not
test it this way.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1187 >
2025-04-15 05:06:53 +00:00
Peter Hutterer
42c685dbb0
test: fix missing SYN_REPORT events between events
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1187 >
2025-04-15 05:06:53 +00:00
Peter Hutterer
95406b2182
test: print the full test result in the list of failed tests
...
When running several tests simply having the list of failed test names
is not very convenient. The actual error may be thousands of lines north
and worse, meson only prints the last 100 lines of a test log by default.
So let's print the full test data including backtrace etc. at the end
instead.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1189 >
2025-04-15 14:05:21 +10:00
Peter Hutterer
6720c6899f
test: annotate/shorten a test case
...
This test has a tendency to fail during recent development, let's make
it easier to debug.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1186 >
2025-04-15 11:09:43 +10:00
Peter Hutterer
610cad7e82
test: disable the proximity timer for the touch arbitration test
...
Depending on race conditions we may get a proximity out event while
testing the touch arbitration timeout.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1186 >
2025-04-15 11:09:39 +10:00
Peter Hutterer
8770c74394
test: mark a checkpoint when asserting a tip or button event
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1186 >
2025-04-15 11:09:34 +10:00
Peter Hutterer
8c28783dd2
test: add litest_with_event_frame() to make things easier to visualize
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1186 >
2025-04-15 11:09:27 +10:00
Peter Hutterer
c94276fd14
test: improve the direct tool switch test
...
Use better (newer) helpers and separate the pen/eraser for readability.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1186 >
2025-04-15 11:09:18 +10:00
Peter Hutterer
d74b2adde5
test: indentation fixes
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1186 >
2025-04-15 11:09:08 +10:00
Peter Hutterer
190b796794
test: modernize a test slightly
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1186 >
2025-04-15 11:08:30 +10:00
Peter Hutterer
0e3bb4690a
test: switch some xasprintf to strdup_printf()
...
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1186 >
2025-04-15 11:07:24 +10:00
Peter Hutterer
589850e8df
test: correct the libevdev initialization in two tests
...
These are used to create a new struct libevdev so let's not wrongly
initialize them to an existing struct.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1186 >
2025-04-15 11:07:24 +10:00
Peter Hutterer
c59453e4ab
test: remove a race condition
...
If the host is a tad slow we need to wait for the events instead of
assuming they're already waiting for us.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1186 >
2025-04-15 11:07:24 +10:00
Peter Hutterer
6876d71a4d
Add a clang-tidy file
...
This gives us the ninja clang-tidy command. clang-tidy replaces
scan-build and is more featureful (and picky).
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1182 >
2025-04-07 08:43:36 +00:00
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