summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* test: ignore a failure to UI_DEV_DESTROY the devicePeter Hutterer2016-03-041-1/+1
| | | | | | | Coverity complains about it. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* test: drop unnecessary return valuePeter Hutterer2016-03-043-28/+24
| | | | | | | | | | We abort if anything goes wrong anyway, so we never returned anything but success. Found by coverity. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Accept LIBEVDEV_READ_FLAG_BLOCKING as valid flagPeter Hutterer2015-04-081-0/+33
| | | | | | | https://bugs.freedesktop.org/show_bug.cgi?id=89798 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Disable test-static-link in case of shared only build.Peter Seiderer2015-03-161-2/+7
| | | | | | | | | | | | | Fixes the following buildroot compile failure: libtool: link: [..]/host/usr/bin/arm-buildroot-linux-uclibcgnueabi-gcc -std=gnu99 -I.. -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -static -o test-static-link test_static_link-test-link.o ../libevdev/.libs/libevdev.so -Wl,-rpath -Wl,[...]/build/libevdev-1.4/libevdev/.libs [...]/arm-buildroot-linux-uclibcgnueabi/bin/ld: attempted static link of dynamic object `../libevdev/.libs/libevdev.so' collect2: error: ld returned 1 exit status Makefile:719: recipe for target 'test-static-link' failed Signed-off-by: Peter Seiderer <ps.report@gmx.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* cosmetic: fix a couple of duplicate/missing empty linesPeter Hutterer2015-03-047-14/+0
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: use -std=c89 instead of c90 for the build testPeter Hutterer2015-02-091-1/+1
| | | | | | | | | They're identical, but RHEL6 doesn't support -std=c90 https://gcc.gnu.org/onlinedocs/gcc/Standards.html https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#C-Dialect-Options Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: always build the build-testsPeter Hutterer2015-02-041-23/+31
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* configure: rename BUILD_TESTS to ENABLE_RUNTIME_TESTSPeter Hutterer2015-02-041-2/+2
| | | | | | | Avoids confusion when we build tests in the future even though BUILD_TESTS is disabled. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: add test for clock id setting on an invalid devicePeter Hutterer2014-11-181-0/+33
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: add test for setting absinfo on invalid devicesPeter Hutterer2014-11-181-0/+39
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: add test case for grab calls on invalid devicesPeter Hutterer2014-11-181-0/+34
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: add missing tests for invalid calls on next_event/has_event_pendingPeter Hutterer2014-11-181-0/+56
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: fix EVIOCREVOKE test on non-supporting kernelsPeter Hutterer2014-08-251-2/+2
| | | | | | The ioctl-returned errno is positive. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Hook up nm to check for leaking symbols in the static libraryPeter Hutterer2014-08-251-1/+21
| | | | | | | | | We ignore anything that starts with an underscore, anything that starts with libevdev and main (since we test the test-static-link binary) and a couple of gcov-related functions. This should catch any functions we accidentally export. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: handle the GCOV_LDFLAGS in all testsPeter Hutterer2014-08-251-2/+3
| | | | | | | We rebuild the libevdev object files with the gcov flags for the tests, so we need to make sure those flags are present on all binaries. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: override check-local instead of checkPeter Hutterer2014-08-251-2/+6
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: add basic static link testPeter Hutterer2014-08-251-1/+6
| | | | | | Same as the dynamic link test, just with the -static flag Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add libevdev_property_from_name()Peter Hutterer2014-08-201-0/+37
| | | | | | | | | 12717d79 "Add libevdev_event_type/code_from_name() resolvers" added the lookup functions for types and codes, this commit adds the missing ones for input properties. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* test: drop include of libevdev-int.hPeter Hutterer2014-08-181-1/+0
| | | | | | Not needed, and shouldn't be used in a test anyway Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: use ck_assert_int_eq() where comparing integersPeter Hutterer2014-08-181-52/+52
| | | | | | | A simple ck_assert() just fails, a ck_assert_int_eq() also shows the two values. Makes failures a bit easier to debug. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: ignore any timer_create errors in valgrindPeter Hutterer2014-06-121-2/+0
| | | | | | | | | Drop the rest of the stack trace, we know whenever check calls this we get a valgrind error if sevp in timer_create(2) is NULL. https://bugs.freedesktop.org/show_bug.cgi?id=79921 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add per-device log handlersPeter Hutterer2014-06-051-0/+74
| | | | | | | | | | | | | | | | | | | | | | The global log handler isn't a good choice for a low-level library. In the caser of the X server, both evdev and synaptics are now using the libevdev but are loaded from the same server process. Thus, there's only one log handler, but evdev and synaptics don't talk to each other (a bit childish, I know). Add a per-device log handler that overrides the global log handler, and fall back to the global log handler if no device log handler is set. The log macros take care of that automatically, especially as we can't do per-device log handlers for the uinput code. Note that we use the same struct for the global and device logging, so in each instance one of the two function pointers is NULL. Suicide triggers are in place in case we mess that up. This also makes libevdev_new_from_fd() a bit less useful since we can't set the log handler beforehand. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* test: unconditionally distribute the valgrind suppressionsPeter Hutterer2014-05-071-3/+1
| | | | | Reported-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: run all tests through valgrindPeter Hutterer2014-04-292-0/+39
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* test: disable parallel testingPeter Hutterer2014-04-291-0/+2
| | | | | | | | The tests create devices on the host system, avoid running them in parallel to avoid interference between the test devices. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* test: silence some valgrind warningsPeter Hutterer2014-04-282-1/+3
| | | | | | | ioctl points to uninitialized bytes - correct but we didn't use those anyway. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Drain all events before synchronizing after SYN_DROPPEDPeter Hutterer2014-04-241-0/+219
| | | | | | | | | | | | | | | | | | | | The kernel ring buffer drops all events on SYN_DROPPED, but then continues to fill up again. So by the time we read the events, the kernel's client buffer is essentially like this: SYN_DROPPED, ev1, ev2, ev3, ...., evN The kernel's device state represents the device after evN, and that is what the ioctls return. For EV_KEY, EV_SND, EV_LED and EV_SW the kernel removes potential duplicates from the client buffer [1], it doesn't do so for EV_ABS. So we can't actually sync while there are events on the wire because the events represent an earlier state. So simply discard all events in the kernel buffer, synchronize, and then start processing again. We lose some granularity but at least the events are correct. [1] http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/input/evdev.c?id=483180281f0ac60d1138710eb21f4b9961901294 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: restore default log priority after testsPeter Hutterer2014-04-081-0/+15
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Drop invalid ABS_MT_TRACKING_ID changesPeter Hutterer2014-04-031-0/+160
| | | | | | | | | | | | | | | | | | | | | | Follow-up to commit 41334b5b40cd5456f5f584b55d8888aaafa1f26e Author: Peter Hutterer <peter.hutterer@who-t.net> Date: Thu Mar 6 11:54:00 2014 +1000 If the tracking ID changes during SYN_DROPPED, terminate the touch first In normal mode, we may get double tracking ID events in the same slot, but only if we either have a user-generated event sequence (uinput) or a malicious device that tries to send data on a slot > dev->num_slots. Since the client is unlikely to be able to handle these events, discard the ABS_MT_TRACKING_ID completely. This is a bug somewhere in the stack, so complain and hobble on along. Note: the kernel doesn't allow that, but we cap to num_slots anyway, see 66fee1bec4c4b021e1b54adcd775cf6e2aa84869. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Drop hardcoded MAX_SLOTS in favour of pre-allocated memoryPeter Hutterer2014-04-031-107/+0
| | | | | | | | | | | | | | | | | | | | | We can't allocate in sync_mt_state since it may be called in the signal handler. So pre-allocate based on the device's number of slots, store that in the libevdev struct and use it for the sync process. This fixes a remaining bug with the handling of ABS_MT_TRACKING_ID. If a device had > MAX_SLOTS and a slot above that limit would start or stop during a SYN_DROPPED event, the slot would not be synced, and a subsequent touch in that slot may double-terminate or double-open a touchpoint in the client. For the effects of that see commit 41334b5b40cd5456f5f584b55d8888aaafa1f26e Author: Peter Hutterer <peter.hutterer@who-t.net> Date: Thu Mar 6 11:54:00 2014 +1000 If the tracking ID changes during SYN_DROPPED, terminate the touch first Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* test: remove checks for test device creation failurePeter Hutterer2014-04-024-361/+290
| | | | | | test_create_... fails on a non-zero return code anyway Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: the kernel test build doesn't need to link to libevdevPeter Hutterer2014-04-021-3/+1
| | | | | | We statically compile libevdev in anyway through $(common_sources) Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: fix kernel test for revoke afterPeter Hutterer2014-04-021-2/+1
| | | | | | | dev2 by definition doesn't initialize, we expect it to fail. Freeing it after is a bad idea. Also initialize it to NULL so this is a bit more obvious now. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: fix the tracking_id sync testPeter Hutterer2014-04-011-1/+1
| | | | | | | A max of num_slots -1 caused the first MT_SLOT event to be skipped, leading to wrong tracking IDs in the slots. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: shut up compiler warningPeter Hutterer2014-03-191-1/+1
| | | | | | | | | | | | test-libevdev-events.c: In function ‘test_double_syn_dropped_event’: test-libevdev-events.c:187:2: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result] This read was there to drain events even when there shouldn't be any on the pipe anyway. So let's add an assert. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* test: fix distcheckPeter Hutterer2014-03-111-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* If the tracking ID changes during SYN_DROPPED, terminate the touch firstPeter Hutterer2014-03-071-0/+163
| | | | | | | | | | Most clients can't deal with tracking ID changes unless a -1 is sent first. So if we notice that the tracking ID has changed during the sync process, send a set of ABS_MT_TRACKING_ID -1 events for each of those, then send the rest of the events. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Send an extra ABS_MT_SLOT event to sync the client up with the current slotBenjamin Tissoires2014-03-071-0/+93
| | | | | | | | | If multiple slots have changed during the sync handling, the client must be re-set to the current slot before continuing with normal events. Signed-off-by: Benjamin Tissoires <btissoir@redhat.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Don't sync the MT state for fake MT devicesPeter Hutterer2014-03-061-0/+82
| | | | | | | | | | | | | Devices with ABS_MT_SLOT-1 are fake MT devices, they merely overlap the axis range but don't actually provide slots. The EVIOCGABS ioctl won't work to retrieve the current value - the kernel does not store values for those axes and the return value is always 0. Thus, simply ignore those axes for fake MT devices and instead rely on the next event to update the caller with the correct state for each axis. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Cap slot values to the announced maximumPeter Hutterer2014-03-061-0/+78
| | | | | | | | | | | | | | A malicious device may announce N slots but then send a slot index >= N. The slot state is almost always allocated (definitely the case in libevdev and true for most callers), so providing a slot number higher than the announced maximum is likely to lead to invalid dereferences. Don't allow that. Likewise, don't allow negative slot numbers. Note that the kernel filters these events anyway, the only way to trigger this is to change the device fd to something outside the kernel's control. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* test: add two more checks for the current slotPeter Hutterer2014-03-061-0/+3
| | | | | | | When syncing, we expect the slot to stay the same until the client has processed the events. This already worked, just add a check to make sure. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Increase MAX_SLOTS to 60Peter Hutterer2014-03-061-1/+1
| | | | | | | | | As seen on 3M devices, which seems to be the maximum seen so far. Some Stantum devices report 255 touches but are only capable of 10, so the are not affected by our limits. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* test: add a test for > MAX_SLOTS mt valuesPeter Hutterer2014-03-061-0/+102
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* test: whitespace fixes (newlines)Peter Hutterer2014-03-054-7/+5
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: plug more memory leaksPeter Hutterer2014-02-272-0/+4
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: fix memleak when using the test-uinput devicePeter Hutterer2014-02-271-0/+1
| | | | | | The libevdev-created uinput device was never freed. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add a test for EVIOCREVOKEPeter Hutterer2014-02-263-1/+199
| | | | | | | | | | | New in 3.12, EVIOCREVOKE revokes access to an evdev device. This is unlikely to be used by a libevdev user, see. http://lists.freedesktop.org/archives/input-tools/2014-January/000688.html This patch adds a new test-kernel binary that tests the kernel API directly. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* test: remove a bunch of superfluous empty linesPeter Hutterer2014-02-251-3/+0
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Actually filter by log priorityPeter Hutterer2014-02-131-0/+76
| | | | | | | | If a message is higher than the current priority, filter it. And add a few tests that the priority is handled the way it should. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* test: remove NULL test for SW_MAX, 3.13 defines SW_MUTE_DEVICEPeter Hutterer2014-01-291-3/+0
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>