Add testcases to test the kernel input stack
PATCH v3 1/1 Add testcases to test the kernel input stack
1) Create a virtual mouse and write in /dev/uinput and check that the data is well received in /dev/input/eventX
2) Create a virtual mouse, write in /dev/uinput, grab the device and check that the data are not received in other proccess.
3) Create a virtual mouse and check that the data are well received in /dev/input/mice
4) Create a virtual mouse and send empty moves: check that nothing is received in /dev/input/mice
5) Create a virtual mouse and send events which cannot be sent and check that they are not received in eventX
6) Test auto-repeat
--- runtest/input | 6 ++ scenario_groups/default | 1 + testcases/kernel/Makefile | 1 + testcases/kernel/input/.gitignore | 6 ++ testcases/kernel/input/Makefile | 27 +++++ testcases/kernel/input/input01.c | 183 +++++++++++++++++++++++++++++++++ testcases/kernel/input/input02.c | 98 ++++++++++++++++++ testcases/kernel/input/input03.c | 123 ++++++++++++++++++++++ testcases/kernel/input/input04.c | 130 ++++++++++++++++++++++++ testcases/kernel/input/input05.c | 97 ++++++++++++++++++ testcases/kernel/input/input06.c | 163 ++++++++++++++++++++++++++++++ testcases/kernel/input/input_helper.c | 185 ++++++++++++++++++++++++++++++++++ testcases/kernel/input/input_helper.h | 34 +++++++ 13 files changed, 1054 insertions(+) create mode 100644 runtest/input create mode 100644 testcases/kernel/input/.gitignore create mode 100644 testcases/kernel/input/Makefile create mode 100644 testcases/kernel/input/input01.c create mode 100644 testcases/kernel/input/input02.c create mode 100644 testcases/kernel/input/input03.c create mode 100644 testcases/kernel/input/input04.c create mode 100644 testcases/kernel/input/input05.c create mode 100644 testcases/kernel/input/input06.c create mode 100644 testcases/kernel/input/input_helper.c create mode 100644 testcases/kernel/input/input_helper.h
runtest/input new file +6 -0
@@ -0,0 +1,6 @@ +input01 input01 +input02 input02 +input03 input03 +input04 input04 +input05 input05 +input06 input06
scenario_groups/default +1 -0
@@ -32,3 +32,4 @@ dma_thread_diotest can cpuhotplug ipv6_lib +input
testcases/kernel/Makefile +1 -0
@@ -42,6 +42,7 @@ SUBDIRS += connectors \ firmware \ fs \ hotplug \ + input \ io \ ipc \ logging \
testcases/kernel/input/.gitignore new file +6 -0
@@ -0,0 +1,6 @@ +/input01 +/input02 +/input03 +/input04 +/input05 +/input06
testcases/kernel/input/Makefile new file +27 -0
@@ -0,0 +1,27 @@ +# +# Copyright (c) SUSE 2015 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +# the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + +top_srcdir ?= ../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +FILTER_OUT_MAKE_TARGETS := input_helper + +include $(top_srcdir)/include/mk/generic_leaf_target.mk + +$(MAKE_TARGETS): %: %.o input_helper.o
testcases/kernel/input/input01.c new file +183 -0
183 lines not on this page · raw message
testcases/kernel/input/input02.c new file +98 -0
98 lines not on this page · raw message
testcases/kernel/input/input03.c new file +123 -0
123 lines not on this page · raw message
testcases/kernel/input/input04.c new file +130 -0
130 lines not on this page · raw message
testcases/kernel/input/input05.c new file +97 -0
97 lines not on this page · raw message
testcases/kernel/input/input06.c new file +163 -0
163 lines not on this page · raw message
testcases/kernel/input/input_helper.c new file +185 -0
185 lines not on this page · raw message
testcases/kernel/input/input_helper.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright (c) 2015 Cedric Hnyda <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef INPUT_HELPER_H +#define INPUT_HELPER_H + +#include <sys/types.h> +#include <dirent.h> + +int setup_read (void ); +void send_rel_move (int fd,int x,int y); +void send_event (int fd,int event,int code,int value); +int open_uinput (void ); +void create_device (int fd); +void setup_mouse_events (int fd); +void destroy_device (int fd); +int check_no_data_and_close_fd (int fd); + +#endif /* INPUT_HELPER_H */
Signature · 1 line
2.1.4
PATCH v3 1/1 Add testcases to test the kernel input stack
Hi!
Pushed with a couple of fixes, thanks.
The main problem with the code were subtle race conditions that made the testcases fail rarely. This was because the reader must open the device before writer starts writing in it otherwise events could be lost (it's not defined which of parent or child will resume execution first). So now the testcases open the device for reading before the test loop even happens.
The second big problem was the /dev/input/mice that produces merged mouse events in PS/2 protocol. I had to switch the test from relative pointer movements to right button clicks since the kernel merges the movement events in unpredictable ways (and because of that the test would fail even if nobody has moved the mouse while the test was running). The mouse clicks are much easier to identify and hopefully right button clicks are safe enough. The same goes for the tests that expects that no events are generated for relative movements by zero. The PS/2 protocol actually sends packes with zero movements on mouse clicks. So I changed that test to work with the input device.
Then there was couple of mostly cosmetic things, a few typos, a few return value checks missing, etc.
The full diff is attached.
Signature · 9 lines
Cyril Hrubis [email protected] -------------- next part -------------- A non-text attachment was scrubbed... Name: input.patch Type: text/x-diff Size: 22922 bytes Desc: not available URL: <http://lists.linux.it/pipermail/ltp/attachments/20160113/9c83d675/attachment.patch>