Commit graph

20 commits

Author SHA1 Message Date
Sertonix
aa7d58005e Fix format strings on 32-bit with 64-bit time_t
This fixes a segfault when running the test suite on ppc musl

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1318>
2025-10-14 05:40:19 +00:00
Peter Hutterer
80b45ff28e test: a skipped test does not count as failure
There's a blurry line between NOT_APPLICABLE and SKIP but the latter
has a stronger "should run but can't right now". But where it happens
the skip shouldn't count as a failure.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1276>
2025-07-21 11:53:57 +10: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
45ab542cc3 test: move a comment to avoid confusing clang-format
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
2025-07-01 16:36:14 +10:00
Peter Hutterer
b61a896407 util: fix the ANSI escape codes for bright colors, add some more
The previous incarnations of BRIGHT_FOO were actually bold foo. Change
the colors over to use the actual bright colors and make bold a separate
set of defines.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1240>
2025-06-23 12:52:57 +00: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
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
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
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
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
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
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
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
1e445f3f84 test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.

This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:

	struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
	                                                         "enabled", 'b', '2', true, false,
	                                                         "number", 'u', '2', 10, 11,
	                                                         NULL);
	litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
	litest_parameters_unref(params);

Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).

In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:

	const char *axis;
	uint32_t number;
	bool enabled;
	litest_test_param_fetch(test_env->params,
	                        "axis", &axis,
	                        "enabled", &enabled,
	                        "number", &number,
	                        NULL);

Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.

Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.

A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
   "pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
   "pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"

Filtering by parameters can be done via globs of their string
representation:
   libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2025-01-07 02:02:37 +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
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
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
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
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
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