Rewrite input testing suite
cover Rewrite input testing suite
Cleanup of the input testing suite, using new LTP API and changing the way we are obtaining information from input devices. Usage of the tst_uinput.h utilities, rewritten input helper and simplified the source code.
---
Andrea Cervesato (7):
Refactor input01 test
Refactor input02 test
Refactor input03 test
Refactor input04 test
Refactor input05 test
Refactor input06 test
Delete depreacted input test suite helper
testcases/kernel/input/Makefile | 6 +- testcases/kernel/input/input01.c | 205 +++++----------------- testcases/kernel/input/input02.c | 132 ++++++-------- testcases/kernel/input/input03.c | 174 ++++++++----------- testcases/kernel/input/input04.c | 113 ++++-------- testcases/kernel/input/input05.c | 119 ++++--------- testcases/kernel/input/input06.c | 190 +++++++++------------ testcases/kernel/input/input_common.h | 97 +++++++++++ testcases/kernel/input/input_helper.c | 313 ---------------------------------- testcases/kernel/input/input_helper.h | 36 ---- 10 files changed, 415 insertions(+), 970 deletions(-)
---
base-commit: ec4161186e51b55d4faaa394dc4607200cb30f68
change-id: 20241113-input_refactoring-16aea13ed7b8
Best regards,
Signature · 5 lines
Andrea Cervesato <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/7 Refactor input01 test
From: Andrea Cervesato <[email protected]>
--- testcases/kernel/input/Makefile | 5 +- testcases/kernel/input/input01.c | 205 ++++++++-------------------------- testcases/kernel/input/input_common.h | 97 ++++++++++++++++ 3 files changed, 148 insertions(+), 159 deletions(-)
testcases/kernel/input/Makefile +4 -1
@@ -3,10 +3,13 @@ top_srcdir ?= ../../.. +LTPLIBS = uinput + include $(top_srcdir)/include/mk/testcases.mk FILTER_OUT_MAKE_TARGETS := input_helper +input01: LDLIBS += -lltpuinput include $(top_srcdir)/include/mk/generic_leaf_target.mk -$(MAKE_TARGETS): %: input_helper.o +input02 input03 input04 input05 input06: %: input_helper.o
testcases/kernel/input/input01.c +47 -158
234 lines not on this page · raw message
testcases/kernel/input/input_common.h new file +97 -0
97 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/7] Refactor input01 test
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/7 Refactor input02 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
--- testcases/kernel/input/Makefile | 4 +- testcases/kernel/input/input02.c | 132 +++++++++++++++------------------------ 2 files changed, 54 insertions(+), 82 deletions(-)
testcases/kernel/input/Makefile +2 -2
@@ -8,8 +8,8 @@ LTPLIBS = uinput include $(top_srcdir)/include/mk/testcases.mk FILTER_OUT_MAKE_TARGETS := input_helper -input01: LDLIBS += -lltpuinput +input01 input02: LDLIBS += -lltpuinput include $(top_srcdir)/include/mk/generic_leaf_target.mk -input02 input03 input04 input05 input06: %: input_helper.o +input03 input04 input05 input06: %: input_helper.o
testcases/kernel/input/input02.c +52 -80
158 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/7] Refactor input02 test
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 3/7 Refactor input03 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
--- testcases/kernel/input/Makefile | 4 +- testcases/kernel/input/input03.c | 174 +++++++++++++++------------------------ 2 files changed, 70 insertions(+), 108 deletions(-)
testcases/kernel/input/Makefile +2 -2
@@ -8,8 +8,8 @@ LTPLIBS = uinput include $(top_srcdir)/include/mk/testcases.mk FILTER_OUT_MAKE_TARGETS := input_helper -input01 input02: LDLIBS += -lltpuinput +input01 input02 input03: LDLIBS += -lltpuinput include $(top_srcdir)/include/mk/generic_leaf_target.mk -input03 input04 input05 input06: %: input_helper.o +input04 input05 input06: %: input_helper.o
testcases/kernel/input/input03.c +68 -106
213 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/7] Refactor input03 test
Quoted 187 lines · Andrea Cervesato
From: Andrea Cervesato <[email protected]>
Signed-off-by Andrea Cervesato <[email protected]>--- testcases/kernel/input/Makefile | 4 +- testcases/kernel/input/input03.c | 174 +++++++++++++++------------------------ 2 files changed, 70 insertions(+), 108 deletions(-)testcases/kernel/input/Makefile +0
-0index
5bc729802d1e302d7d52d71be0b6b22a20efb852..8c302dbc8c75cf4fd42bc162b4bb8a9882237164100644testcases/kernel/input/Makefile +2
-2@@ -8,8 +8,8 @@ LTPLIBS = uinput include $(top_srcdir)/include/mk/testcases.mk FILTER_OUT_MAKE_TARGETS := input_helper -input01 input02: LDLIBS += -lltpuinput +input01 input02 input03: LDLIBS += -lltpuinput include $(top_srcdir)/include/mk/generic_leaf_target.mk -input03 input04 input05 input06: %: input_helper.o +input04 input05 input06: %: input_helper.otestcases/kernel/input/input03.c +0
-0index
6cd753d0b1bf98ce671dfa739cde817b4c52c547..f66a5b1e504ca63a032ec9b49b5ab1e69a4bc2ce100644testcases/kernel/input/input03.c +2
-14@@ -1,145 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * 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 +* Copyright (C) 2024 SUSE LLC Andrea Cervesato < - /*
testcases/kernel/input/input03.c +5
-3-* Create a virtual device (mouse), send events to /dev/uinput -* and check that the events are well received in /dev/input/mice -*/ +/*\ +* [Description] +* +* Verify that /dev/input/mice receive events sent from a virtual device, +* that in our case is a mouse. The events are a sequence of mouse right click.
+ */testcases/kernel/input/input03.c +6
-37-#include <linux/input.h> #include <linux/uinput.h> -#include "test.h" -#include "safe_macros.h" -#include "lapi/fcntl.h" -#include "input_helper.h" +#include "input_common.h" -#define NB_TEST 10 +#define NUM_EVENTS 10#define PS2_RIGHT_BTN 0x02 +#define MOUSE_DEV "/dev/input/mice" -static void setup (void ); -static void send_events (void ); -static int check_events (void ); -static void cleanup (void ); +static int fd_send =-1 ; +static int fd_recv =-1 ; -static int fd, fd2; - -char *TCID ="input03" ; - -int main (int ac,char **av) +static void recv_data (void ) { -int lc; -int pid; - -tst_parse_opts (ac, av,NULL ,NULL ); - -setup (); - -for (lc =0 ;TEST_LOOPING (lc); ++lc) { - pid =tst_fork (); - -switch (pid) { -case 0 : -send_events (); -exit (0 ); -case -1 : -tst_brkm (TBROK |TERRNO , cleanup,"fork() failed" ); -default : -if (check_events ()) -tst_resm (TFAIL ,"Wrong data received" ); -else - tst_resm(TPASS, - "Data received in
/dev/input/mice");testcases/kernel/input/input03.c +27
-25-break ; - } - -SAFE_WAITPID (NULL , pid,NULL ,0 ); - } +tst_res (TINFO ,"Reading events back" ); -cleanup (); -tst_exit (); -} +char buf[30 ]; +int events =0 ; +int pressed =0 ; +int num_bytes =0 ; -static void setup (void ) -{ -tst_require_root (); +while (events <NUM_EVENTS ) { +memset (buf,0 ,sizeof (buf)); - fd =open_uinput (); + num_bytes =SAFE_READ (0 , fd_recv, buf,sizeof (buf)); -setup_mouse_events (fd); -SAFE_IOCTL (NULL , fd,UI_SET_EVBIT ,EV_KEY ); -SAFE_IOCTL (NULL , fd,UI_SET_KEYBIT ,BTN_RIGHT ); +for (int i =0 ; i < num_bytes /3 ; i++) { +if (buf[3 *i] &PS2_RIGHT_BTN ) + pressed =1 ; -create_device (fd); +if (pressed ==1 && !(buf[3 *i] &PS2_RIGHT_BTN )) { + pressed =0 ; + events++; + } + } + } - fd2 =SAFE_OPEN (NULL ,"/dev/input/mice" ,O_RDONLY ); +TST_EXP_EQ_LI (events,NUM_EVENTS ); } -static void send_events (void ) +static void send_mouse_events (void ) { -int nb; +tst_res (TINFO ,"Sending right click" ); -for (nb =0 ; nb <NB_TEST ; ++nb) { -send_event (fd,EV_KEY ,BTN_RIGHT ,1 ); -send_event (fd,EV_SYN ,0 ,0 ); +for (int i =0 ; i <NUM_EVENTS ; i++) { +send_event (fd_send,EV_KEY ,BTN_RIGHT ,1 ); +send_event (fd_send,EV_SYN ,0 ,0 );usleep (1000 ); -send_event (fd,EV_KEY ,BTN_RIGHT ,0 ); -send_event (fd,EV_SYN ,0 ,0 ); + +send_event (fd_send,EV_KEY ,BTN_RIGHT ,0 ); +send_event (fd_send,EV_SYN ,0 ,0 );usleep (1000 ); } } -static int check_events (void ) +static void run (void )
testcases/kernel/input/input03.c
Quoted 10 lines
testcases/kernel/input/input03.c +5
-3{ -int nb, rd, i, pressed =0 ; -char buf[30 ]; +if (!SAFE_FORK ()) { +send_mouse_events (); +exit (0 ); + } - nb =0 ; +recv_data ();
We have to make sure recv_data() is performed first then sending mouse events,
Otherwise, it will be more easily stuck here forever.
testcases/kernel/input/input03.c +5 -0
@@ -31,6 +31,8 @@ static void recv_data(void)int pressed =0 ;int num_bytes =0 ; +TST_CHECKPOINT_WAKE (0 ); +while (events <NUM_EVENTS ) {memset (buf,0 ,sizeof (buf));
@@ -54,6 +56,8 @@ static void send_mouse_events(void) {tst_res (TINFO ,"Sending right click" ); +TST_CHECKPOINT_WAIT (0 ); +for (int i =0 ; i <NUM_EVENTS ; i++) {send_event (fd_send,EV_KEY ,BTN_RIGHT ,1 );send_event (fd_send,EV_SYN ,0 ,0 );
@@ -103,5 +107,6 @@ static struct tst_test test = { .cleanup = cleanup, .forks_child = 1, .needs_root = 1, + .needs_checkpoints = 1, };
The reset looks good.
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 4/7 Refactor input04 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
--- testcases/kernel/input/Makefile | 4 +- testcases/kernel/input/input04.c | 113 ++++++++++++--------------------------- 2 files changed, 35 insertions(+), 82 deletions(-)
testcases/kernel/input/Makefile +2 -2
@@ -8,8 +8,8 @@ LTPLIBS = uinput include $(top_srcdir)/include/mk/testcases.mk FILTER_OUT_MAKE_TARGETS := input_helper -input01 input02 input03: LDLIBS += -lltpuinput +input01 input02 input03 input04: LDLIBS += -lltpuinput include $(top_srcdir)/include/mk/generic_leaf_target.mk -input04 input05 input06: %: input_helper.o +input05 input06: %: input_helper.o
testcases/kernel/input/input04.c +33 -80
136 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 4/7] Refactor input04 test
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 5/7 Refactor input05 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
--- testcases/kernel/input/Makefile | 6 +- testcases/kernel/input/input05.c | 119 ++++++++++++--------------------------- 2 files changed, 40 insertions(+), 85 deletions(-)
testcases/kernel/input/Makefile +3 -3
@@ -8,8 +8,8 @@ LTPLIBS = uinput include $(top_srcdir)/include/mk/testcases.mk FILTER_OUT_MAKE_TARGETS := input_helper -input01 input02 input03 input04: LDLIBS += -lltpuinput +input01 input02 input03 input04 input05: LDLIBS += -lltpuinput -include $(top_srcdir)/include/mk/generic_leaf_target.mk +input06: %: input_helper.o -input05 input06: %: input_helper.o +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/input/input05.c +37 -82
144 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/7] Refactor input05 test
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 6/7 Refactor input06 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
--- testcases/kernel/input/Makefile | 5 +- testcases/kernel/input/input06.c | 190 ++++++++++++++++----------------------- 2 files changed, 79 insertions(+), 116 deletions(-)
testcases/kernel/input/Makefile +1 -4
@@ -7,9 +7,6 @@ LTPLIBS = uinput include $(top_srcdir)/include/mk/testcases.mk -FILTER_OUT_MAKE_TARGETS := input_helper -input01 input02 input03 input04 input05: LDLIBS += -lltpuinput - -input06: %: input_helper.o +LDLIBS += -lltpuinput include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/input/input06.c +78 -112
274 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 7/7 Delete depreacted input test suite helper
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
--- testcases/kernel/input/input_helper.c | 313 ---------------------------------- testcases/kernel/input/input_helper.h | 36 ---- 2 files changed, 349 deletions(-)
testcases/kernel/input/input_helper.c deleted +0 -313
@@ -1,313 +0,0 @@ -/* -* 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 -*/ - -#include <linux/input.h> -#include <linux/uinput.h> -#include <fnmatch.h> -#include <errno.h> -#include <poll.h> - -#include "test.h" -#include "safe_macros.h" -#include "input_helper.h" -#include "lapi/uinput.h" - -#define VIRTUAL_DEVICE "virtual-device-ltp" - -#define VIRTUAL_DEVICE_REGEX "*virtual-device-ltp*" - -static int uinput_loaded; -static int check_device (void ); - -static int try_open_device (void ) -{ -char path[256 ]; -char name[256 ]; -int ret, fd =-1 ; -unsigned int i; - -for (i =0 ; i <100 ; i++) { -snprintf (path,sizeof (path),"/dev/input/event%i" , i); - - fd =open (path,O_RDONLY ); - -if (fd <0 && errno ==ENOENT ) -continue ; - -if (fd <0 ) { -tst_resm (TINFO |TERRNO ,"failed to open %s" , path); -break ; - } - - ret =ioctl (fd,EVIOCGNAME (sizeof (name)), name); -if (ret <0 ) { -tst_resm (TINFO |TERRNO , -"ioctl(%s, EVIOCGNAME(256), ...) failed" , - path); -break ; - } - -if (strcmp (name,VIRTUAL_DEVICE ) ==0 ) -return fd; -close (fd); - } - -return -1 ; -} - -int open_device (void ) -{ -int fd; -int retries =10 ; - -while (retries--) { - fd =try_open_device (); -if (fd >0 ) -return fd; -tst_resm (TINFO ,"Device not found, retrying..." ); -usleep (10000 ); - } - -tst_brkm (TBROK ,NULL ,"Unable to find the input device" ); -} - -static int try_load_uinput (void ) -{ -const char *argv[] = {"modprobe" ,"uinput" ,NULL }; -int ret; - -tst_resm (TINFO ,"Trying to load uinput kernel module" ); - - ret =tst_cmd (NULL , argv,NULL ,NULL ,TST_CMD_PASS_RETVAL ); -if (ret) { -tst_resm (TINFO ,"Failed to load the uinput module" ); -return 0 ; - } - -return 1 ; -} - -static void unload_uinput (void ) -{ -const char *argv[] = {"modprobe" ,"-r" ,"uinput" ,NULL }; -int ret; - -tst_resm (TINFO ,"Unloading uinput kernel module" ); - - ret =tst_cmd (NULL , argv,NULL ,NULL ,TST_CMD_PASS_RETVAL ); -if (ret) -tst_resm (TWARN ,"Failed to unload uinput module" ); -} - -static const char *uinput_paths[] = { -"/dev/input/uinput" , -"/dev/uinput" , -}; - -static int try_open_uinput (void ) -{ -unsigned int i; -int fd; - -for (i =0 ; i <ARRAY_SIZE (uinput_paths); i++) { - fd =open (uinput_paths[i],O_WRONLY |O_NONBLOCK ); - -if (fd >0 ) { -tst_resm (TINFO ,"Found uinput dev at %s" , - uinput_paths[i]); -return fd; - } - -if (fd <0 && errno !=ENOENT ) { -tst_brkm (TBROK |TERRNO ,NULL , -"open(%s)" , uinput_paths[i]); - } - } - -return -1 ; -} - -int open_uinput (void ) -{ -int fd; -int retries =10 ; - - fd =try_open_uinput (); -if (fd >0 ) -return fd; - -if (try_load_uinput ()) { -while (retries--) { - fd =try_open_uinput (); -if (fd >0 ) { - uinput_loaded =1 ; -return fd; - } -tst_resm (TINFO ,"Uinput dev not found, retrying..." ); -usleep (10000 ); - } - -unload_uinput (); - } - -tst_brkm (TCONF ,NULL ,"Unable to find and open uinput" ); -} - -void send_event (int fd,int event,int code,int value) -{ -struct input_event ev = { - .type = event, - .code = code, - .value = value, - }; - -SAFE_WRITE (NULL ,SAFE_WRITE_ALL , fd, &ev,sizeof (ev)); -} - -void send_rel_move (int fd,int x,int y) -{ -send_event (fd,EV_REL ,REL_X , x); -send_event (fd,EV_REL ,REL_Y , y); -send_event (fd,EV_SYN ,0 ,0 ); -} - -static void check_ui_get_sysname_ioctl (int fd) -{ -char sys_name[256 ]; -char dev_name[256 ]; -char *path; - -SAFE_IOCTL (NULL , fd,UI_GET_SYSNAME (sizeof (sys_name)), sys_name,NULL ); -SAFE_ASPRINTF (NULL , &path,"/sys/devices/virtual/input/%s/name" , sys_name); - -if (FILE_SCANF (path,"%s" , dev_name)) { -tst_resm (TFAIL |TERRNO ,"Failed to read '%s'" , path); -free (path); -return ; - } - -if (!strcmp (VIRTUAL_DEVICE , dev_name)) -tst_resm (TPASS ,"ioctl UI_GET_SYSNAME returned correct name" ); -else -tst_resm (TFAIL ,"ioctl UI_GET_SYSNAME returned wrong name" ); - -free (path); -} - -void create_device (int fd) -{ -int nb; -struct uinput_user_dev uidev = { - .name =VIRTUAL_DEVICE , - .id = { - .bustype =BUS_USB , - .vendor =0x1 , - .product =0x1 , - .version =1 , - } - }; - -SAFE_WRITE (NULL ,SAFE_WRITE_ALL , fd, &uidev,sizeof (uidev)); -SAFE_IOCTL (NULL , fd,UI_DEV_CREATE ,NULL ); - -for (nb =100 ; nb >0 ; nb--) { -if (check_device ()) { -check_ui_get_sysname_ioctl (fd); -return ; - } -usleep (10000 ); - } - -destroy_device (fd); -tst_brkm (TBROK ,NULL ,"Failed to create device" ); -} - -void setup_mouse_events (int fd) -{ -SAFE_IOCTL (NULL , fd,UI_SET_EVBIT ,EV_KEY ); -SAFE_IOCTL (NULL , fd,UI_SET_KEYBIT ,BTN_LEFT ); -SAFE_IOCTL (NULL , fd,UI_SET_EVBIT ,EV_REL ); -SAFE_IOCTL (NULL , fd,UI_SET_RELBIT ,REL_X ); -SAFE_IOCTL (NULL , fd,UI_SET_RELBIT ,REL_Y ); -} - -void destroy_device (int fd) -{ -SAFE_IOCTL (NULL , fd,UI_DEV_DESTROY ,NULL ); -SAFE_CLOSE (NULL , fd); - -if (uinput_loaded) -unload_uinput (); -} - -int check_event_code (struct input_event *iev,int event,int code) -{ -return iev->type == event && iev->code == code; -} - -int check_sync_event (struct input_event *iev) -{ -return check_event_code (iev,EV_SYN ,SYN_REPORT ); -} - -/* -* the value of stray_sync_event: -* 0: EV_SYN/SYN_REPORT events should not be received in /dev/input/eventX -* 1: EV_SYN/SYN_REPORT events may be received in /dev/input/eventX -* On an old kernel(before v3.7.0), EV_SYN/SYN_REPORT events are always -* received even though we send empty moves. -*/ -int no_events_queued (int fd,int stray_sync_event) -{ -struct pollfd fds = {.fd = fd, .events =POLLIN }; -int ret, res; -struct input_event ev; - - ret =poll (&fds,1 ,30 ); - -if (ret >0 ) { - res =read (fd, &ev,sizeof (ev)); - -if (res ==sizeof (ev)) { -tst_resm (TINFO , -"Unexpected ev type=%i code=%i value=%i" , - ev.type, ev.code, ev.value); - } - } - -return ret ==0 ; -} - -static int check_device (void ) -{ -FILE *file; -char line[256 ]; - - file =fopen ("/proc/bus/input/devices" ,"r" ); -if (!file) -return 0 ; - -while (fgets (line,256 , file)) { -if (fnmatch (VIRTUAL_DEVICE_REGEX , line,0 ) ==0 ) -return 1 ; - } - -fclose (file); - -return 0 ; -}
testcases/kernel/input/input_helper.h deleted +0 -36
@@ -1,36 +0,0 @@ -/* -* 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 open_device (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_event_code (struct input_event *iev,int event,int code); -int check_sync_event (struct input_event *iev); -int no_events_queued (int fd,int stray_sync_event); - -#endif /* INPUT_HELPER_H */
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 7/7] Delete depreacted input test suite helper
Hi!
Quoted 32 lines
testcases/kernel/input/input_helper.c deleted +0
-32-static void check_ui_get_sysname_ioctl (int fd) -{ -char sys_name[256 ]; -char dev_name[256 ]; -char *path; - -SAFE_IOCTL (NULL , fd,UI_GET_SYSNAME (sizeof (sys_name)), sys_name,NULL ); -SAFE_ASPRINTF (NULL , &path,"/sys/devices/virtual/input/%s/name" , sys_name); - -if (FILE_SCANF (path,"%s" , dev_name)) { -tst_resm (TFAIL |TERRNO ,"Failed to read '%s'" , path); -free (path); -return ; - } - -if (!strcmp (VIRTUAL_DEVICE , dev_name)) -tst_resm (TPASS ,"ioctl UI_GET_SYSNAME returned correct name" ); -else -tst_resm (TFAIL ,"ioctl UI_GET_SYSNAME returned wrong name" ); - -free (path); -} - -void create_device (int fd) -{ -int nb; -struct uinput_user_dev uidev = { - .name =VIRTUAL_DEVICE , - .id = { - .bustype =BUS_USB , - .vendor =0x1 , - .product =0x1 ,
testcases/kernel/input/input_helper.c line 230
Quoted 10 lines
testcases/kernel/input/input_helper.c deleted +0
-10- .version = 1, - } - }; - -SAFE_WRITE (NULL ,SAFE_WRITE_ALL , fd, &uidev,sizeof (uidev)); -SAFE_IOCTL (NULL , fd,UI_DEV_CREATE ,NULL ); - -for (nb =100 ; nb >0 ; nb--) { -if (check_device ()) { -check_ui_get_sysname_ioctl (fd);
This check is being removed without replacement. This was added in:
commit ccc8bc7b8104d932daf5d1131b0522250eaa14ce
Author: Wei Gao via ltp <[email protected]> Date: Tue Oct 17 09:16:46 2023 -0400
testcases/input: Add test for UI_GET_NAME ioctl
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp