Commit graph

39 commits

Author SHA1 Message Date
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
Peter Hutterer
4277d63bc6 Merge branch 'wip/custom-pointer-acceleration-function-v2' 2018-05-02 10:53:08 +10:00
Peter Hutterer
59eb10e593 util: allow for palm pressure > 255
https://bugs.freedesktop.org/show_bug.cgi?id=105753

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-30 11:18:07 +10:00
Peter Hutterer
bd04826aa4 util: add a helper function to split a key-value pair string
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-26 14:48:37 +10:00
Peter Hutterer
ce80e40006 test: move all the _setup() functions into a special section
This way we can loop through them instead of having to add them manually.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-23 10:17:52 +10:00
Greg V
8adfac3975 Include stdarg.h where variadic functions are used
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-12-01 09:31:42 +10:00
Peter Hutterer
3fea53c3a9 test: restore the non-debounced litest_button_click()
8cf6893 removed it to make search/replace easier, restore it for the tests
where we don't want debouncing to automatically be handled.

Still left in place are the various top software button cases. Because of the
button re-routing through the fallback interface we need those to be
debounced.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-20 11:31:56 +10:00
Peter Hutterer
8cf6893f6d test: replace litest_button_click with a debounced version
This is via a simple search & replace. Later auditing is needed to switch
clicks that should not be debounced (e.g. touchpads) back to a non-debounced
version.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-20 09:55:05 +10:00
Peter Hutterer
a6f0e4ae60 timer: flush the timer funcs if our events come in late
Avoid processing an event with a time later than the earliest timer expiry. If
libinput_dispatch() isn't called frequently enough, we may have e.g. a tap
timeout happening but read a subsequent input event first. In that case we can
erroneously trigger or miss out on taps, see wrong palm detection, etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-09-21 12:27:46 +10:00
Peter Hutterer
635dc7d790 util: add a safe_atoi_base() function
For parsing hex numbers

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-07 08:59:18 +10:00
Peter Hutterer
aeca8739c7 test: make the lid action helper function a generic switch action helper
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-04 12:42:44 +10:00
Peter Hutterer
e08a76674a util: rename the pressure range parser to a more generic range_parser
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-11 12:26:17 +10:00
Peter Hutterer
756c7e3dac timer: add a timer name to each timer
So we have something useful to print when we trigger an error in the timer
code.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-10 12:00:50 +10:00
Peter Hutterer
25d54b90db touchpad: add pressure-base palm detection
If a touch goes past the fixed pressure threshold it is labelled as a palm and
stays a palm. Default value is one that works well here on a T440 and is
virtually impossible to trigger by a normal finger or thumb. A udev property
is exposed so we can handle this in the udev hwdb and the new tool introduce a
few commits ago can help finding the palm detection threshold.

Unlike the other palm detection features, once a palm goes past the threshold
it remains a palm until the touch is released. This means palm overrides any
other palm detection features. For code simplicity, we don't combine the
states but merely check for pressure before and after the other palm detection
functions. If the pressure triggers, it will trigger before anything else. And
if something else is already active (e.g. edge where the pressure doesn't work
well) it will trigger as soon as the palm is released.

The palm threshold should thus be chosen with some room to spare between the
highest finger pressure.

https://bugs.freedesktop.org/show_bug.cgi?id=94236

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-03 15:58:13 +10:00
Peter Hutterer
dcbf2c2a44 test: don't leak test warnings to stdout
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-02 10:53:50 +10:00
Peter Hutterer
8d5f4decb4 touchpad: move the pressure range to a hwdb entry
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-26 12:38:15 +10:00
Peter Hutterer
784241427b evdev: split calibration property parsing into a helper
So we can test it externally.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-02-09 11:54:03 +10:00
Peter Hutterer
5f2402a41a switch: only sync the initial state if we know the state is reliable
This changes the default behavior to "disable the touchpad on the first lid
close event", thus filtering any laptops where the switch state is buggy and
always in "on" state. Devices where we know the lid switch state is
reliable can be marked as such.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-26 14:44:04 +10:00
James Ye
a817098fcb test: add tests for lid switch
Ship a custom udev rule for the test device until systemd v333 is commonplace.

Signed-off-by: James Ye <jye836@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-26 14:44:04 +10:00
Peter Hutterer
9ab8e7f783 util: make all property parsing helpers ignore NULL strings
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-20 10:35:43 +10:00
Peter Hutterer
5d66edc9f4 test: prefix all test source files with "test-"
They weren't originally prefixed but the various tests were, but now that we
only have one test runner binary anyway, the prefix helps sorting the files
easily within e.g. gcov results.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-16 08:59:00 +10:00
Renamed from test/misc.c (Browse further)