[LTP] [PATCH v1] Add test for UI_GET_NAME ioctl

Wei Gao wegao@suse.com
Thu Oct 12 13:13:33 CEST 2023


Fix:#573
Signed-off-by: Wei Gao <wegao@suse.com>
---
 testcases/kernel/input/input_helper.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/input/input_helper.c b/testcases/kernel/input/input_helper.c
index 09530fb4d..a5e7bb109 100644
--- a/testcases/kernel/input/input_helper.c
+++ b/testcases/kernel/input/input_helper.c
@@ -32,6 +32,7 @@
 
 static int uinput_loaded;
 static int check_device(void);
+static int check_ui_get_sysname_ioctl(int fd);
 
 static int try_open_device(void)
 {
@@ -185,6 +186,27 @@ void send_rel_move(int fd, int x, int y)
 	send_event(fd, EV_SYN, 0, 0);
 }
 
+static int check_ui_get_sysname_ioctl(int fd)
+{
+	char name[256];
+	SAFE_IOCTL(NULL, fd, UI_GET_SYSNAME(sizeof(name)), name, NULL);
+
+	DIR *test_dir;
+	struct dirent *ent;
+
+	test_dir = SAFE_OPENDIR(NULL, "/sys/devices/virtual/input/");
+
+	while ((ent = SAFE_READDIR(NULL, test_dir))) {
+		if (!strcmp(ent->d_name, name)) {
+			return 1;
+		}
+		else
+			continue;
+	}
+
+	return 0;
+}
+
 void create_device(int fd)
 {
 	int nb;
@@ -202,7 +224,7 @@ void create_device(int fd)
 	SAFE_IOCTL(NULL, fd, UI_DEV_CREATE, NULL);
 
 	for (nb = 100; nb > 0; nb--) {
-		if (check_device())
+		if (check_device() && check_ui_get_sysname_ioctl(fd))
 			return;
 		usleep(10000);
 	}
-- 
2.35.3



More information about the ltp mailing list