public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/7] Rewrite input testing suite
@ 2024-12-02 10:12 Andrea Cervesato
  2024-12-02 10:12 ` [LTP] [PATCH v2 1/7] Refactor input01 test Andrea Cervesato
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Andrea Cervesato @ 2024-12-02 10:12 UTC (permalink / raw)
  To: ltp

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.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Changes in v2:
- use checkpoint in input03
- move check_ui_get_sysname_ioctl() in tst_uinput.h
- Link to v1: https://lore.kernel.org/r/20241125-input_refactoring-v1-0-b622b3aa698d@suse.com

---
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

 libs/uinput/tst_uinput.c              |  26 ++-
 testcases/kernel/input/Makefile       |   6 +-
 testcases/kernel/input/input01.c      | 205 +++++-----------------
 testcases/kernel/input/input02.c      | 132 ++++++--------
 testcases/kernel/input/input03.c      | 176 ++++++++-----------
 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 ----
 11 files changed, 443 insertions(+), 970 deletions(-)
---
base-commit: ec4161186e51b55d4faaa394dc4607200cb30f68
change-id: 20241113-input_refactoring-16aea13ed7b8

Best regards,
-- 
Andrea Cervesato <andrea.cervesato@suse.com>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [LTP] [PATCH v2 1/7] Refactor input01 test
  2024-12-02 10:12 [LTP] [PATCH v2 0/7] Rewrite input testing suite Andrea Cervesato
@ 2024-12-02 10:12 ` Andrea Cervesato
  2024-12-02 15:15   ` Petr Vorel
  2024-12-02 10:12 ` [LTP] [PATCH v2 2/7] Refactor input02 test Andrea Cervesato
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Andrea Cervesato @ 2024-12-02 10:12 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Reviewed-by: Li Wang <liwang@redhat.com>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 libs/uinput/tst_uinput.c              |  26 ++++-
 testcases/kernel/input/Makefile       |   5 +-
 testcases/kernel/input/input01.c      | 205 ++++++++--------------------------
 testcases/kernel/input/input_common.h |  97 ++++++++++++++++
 4 files changed, 173 insertions(+), 160 deletions(-)

diff --git a/libs/uinput/tst_uinput.c b/libs/uinput/tst_uinput.c
index 6dc8a7d4ec41f1c53eb675c894cdcd059ee1198a..36f3d5e2759bc13c5ae989799741bbd288a2c234 100644
--- a/libs/uinput/tst_uinput.c
+++ b/libs/uinput/tst_uinput.c
@@ -13,6 +13,7 @@
 #include "tst_test.h"
 
 #include "tst_uinput.h"
+#include "tst_safe_stdio.h"
 
 #define VIRTUAL_DEVICE "virtual-device-ltp"
 
@@ -127,6 +128,27 @@ void destroy_input_device(int fd)
 	SAFE_CLOSE(fd);
 }
 
+static void check_ui_get_sysname_ioctl(int fd)
+{
+	char sys_name[256];
+	char dev_name[256];
+	char *path;
+
+	SAFE_IOCTL(fd, UI_GET_SYSNAME(sizeof(sys_name)), sys_name, NULL);
+	SAFE_ASPRINTF(&path, "/sys/devices/virtual/input/%s/name", sys_name);
+
+	if (FILE_SCANF(path, "%s", dev_name)) {
+		tst_brk(TBROK|TERRNO, "Failed to read '%s'", path);
+		free(path);
+		return;
+	}
+
+	if (strcmp(VIRTUAL_DEVICE, dev_name))
+		tst_brk(TBROK, "ioctl UI_GET_SYSNAME returned wrong name");
+
+	free(path);
+}
+
 void create_input_device(int fd)
 {
 	int nb;
@@ -144,8 +166,10 @@ void create_input_device(int fd)
 	SAFE_IOCTL(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);
 	}
 
diff --git a/testcases/kernel/input/Makefile b/testcases/kernel/input/Makefile
index 032254444e1a1e5d53e3299dfe5d7e4cba6a5162..e686005c69da8b83d954da754b2e5db93ae89da7 100644
--- a/testcases/kernel/input/Makefile
+++ b/testcases/kernel/input/Makefile
@@ -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
diff --git a/testcases/kernel/input/input01.c b/testcases/kernel/input/input01.c
index 95db3f43f37f361db2691beb0d077626e81b6368..0872204111b81fd19a1525ef7f099e8ddead9658 100644
--- a/testcases/kernel/input/input01.c
+++ b/testcases/kernel/input/input01.c
@@ -1,187 +1,76 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) 2015 Cedric Hnyda <chnyda@suse.com>
- *
- * 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 <andrea.cervesato@suse.com>
  */
 
- /*
-  *  Create a virtual device (mouse), send events to /dev/uinput
-  *  and check that the events are well received in /dev/input/eventX
-  */
-
-#include <linux/input.h>
-
-#include "input_helper.h"
-#include "test.h"
-#include "safe_macros.h"
-#include "lapi/fcntl.h"
-
-#define NB_TEST 20
+/*\
+ * [Description]
+ *
+ * Verify that /dev/input/eventX receive events sent from a virtual device,
+ * that in our case is a mouse.
+ */
 
-static void setup(void);
-static void send_events(void);
-static int verify_data(struct input_event *iev, int nb);
-static int check_events(void);
-static void cleanup(void);
+#include "input_common.h"
 
-static int fd;
-static int fd2;
+#define NUM_EVENTS 20
+#define MOVE_X 10
+#define MOVE_Y 1
 
-char *TCID = "input01";
+static int fd_send = -1;
+static int fd_recv = -1;
 
-int main(int ac, char **av)
+static void run(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 read from eventX");
-			else
-				tst_resm(TPASS, "Data received from eventX");
-		break;
-		}
-
-		SAFE_WAITPID(NULL, pid, NULL, 0);
-	}
+	struct input_event iev[3];
 
-	cleanup();
-	tst_exit();
-}
+	tst_res(TINFO, "Sending relative move: (%i, %i)", MOVE_X, MOVE_Y);
 
-static void setup(void)
-{
-	tst_require_root();
-
-	fd = open_uinput();
-	setup_mouse_events(fd);
-	create_device(fd);
-
-	fd2 = open_device();
-}
-
-static void send_events(void)
-{
-	int nb;
-
-	for (nb = 0; nb < NB_TEST; ++nb) {
-		send_rel_move(fd, 10, 1);
+	for (int i = 0; i < NUM_EVENTS; i++) {
+		send_relative_move(fd_send, MOVE_X, MOVE_Y);
 		usleep(1000);
 	}
-}
 
-static int check_events(void)
-{
-	int nb, rd;
-	unsigned int i;
-	struct input_event iev[64];
-
-	nb = 0;
+	tst_res(TINFO, "Reading events back");
 
-	while (nb < NB_TEST * 3) {
-		rd = read(fd2, iev, sizeof(iev));
+	for (int i = 0; i < NUM_EVENTS; i++) {
+		SAFE_READ(0, fd_recv, iev, 3 * sizeof(struct input_event));
 
-		if (rd < 0)
-			tst_brkm(TBROK | TERRNO, cleanup, "read()");
+		TST_EXP_EQ_LI(iev[0].type, EV_REL);
+		TST_EXP_EQ_LI(iev[0].code, REL_X);
+		TST_EXP_EQ_LI(iev[0].value, MOVE_X);
 
-		if (rd == 0 || rd % sizeof(struct input_event)) {
-			tst_resm(TINFO, "read() returned unexpected %i", rd);
-			return 1;
-		}
+		TST_EXP_EQ_LI(iev[1].type, EV_REL);
+		TST_EXP_EQ_LI(iev[1].code, REL_Y);
+		TST_EXP_EQ_LI(iev[1].value, MOVE_Y);
 
-		for (i = 0; i < rd / sizeof(struct input_event); i++) {
-			if (verify_data(&iev[i], nb++))
-				return 1;
-		}
+		TST_EXP_EQ_LI(iev[2].type, EV_SYN);
+		TST_EXP_EQ_LI(iev[2].code, 0);
+		TST_EXP_EQ_LI(iev[2].value, 0);
 	}
-
-	return 0;
 }
 
-static int verify_data(struct input_event *iev, int nb)
+static void setup(void)
 {
-	if (nb % 3 == 0) {
-		if (iev->type != EV_REL) {
-			tst_resm(TINFO,
-			         "%i: Unexpected event type %i expected %i",
-			         nb, iev->type, EV_REL);
-			return 1;
-		}
-
-		if (iev->code != REL_X)
-			return 1;
-
-		if (iev->value != 10)
-			return 1;
-
-		return 0;
-	}
-
-	if (nb % 3 == 1) {
-		if (iev->type != EV_REL) {
-			tst_resm(TINFO,
-			         "%i: Unexpected event type %i expected %i",
-			         nb, iev->type, EV_REL);
-			return 1;
-		}
+	fd_send = open_uinput();
+	setup_mouse_events(fd_send);
+	create_input_device(fd_send);
 
-		if (iev->code != REL_Y)
-			return 1;
-
-		if (iev->value != 1)
-			return 1;
-
-		return 0;
-	}
-
-	if (nb % 3 == 2) {
-		if (iev->type != EV_SYN) {
-			tst_resm(TINFO,
-			         "%i: Unexpected event type %i expected %i",
-			         nb, iev->type, EV_SYN);
-			return 1;
-		}
-
-		if (iev->code != 0)
-			return 1;
-
-		if (iev->value != 0)
-			return 1;
-
-		return 0;
-	}
-	return 1;
+	fd_recv = open_event_device();
 }
 
 static void cleanup(void)
 {
-	if (fd2 > 0 && close(fd2))
-		tst_resm(TWARN | TERRNO, "close(fd2)");
+	if (fd_send != -1)
+		destroy_input_device(fd_send);
 
-	destroy_device(fd);
+	if (fd_recv != -1)
+		SAFE_CLOSE(fd_recv);
 }
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+};
diff --git a/testcases/kernel/input/input_common.h b/testcases/kernel/input/input_common.h
new file mode 100644
index 0000000000000000000000000000000000000000..0ac1624b3042f0bd14f063db76189dfc18d84674
--- /dev/null
+++ b/testcases/kernel/input/input_common.h
@@ -0,0 +1,97 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+#ifndef INPUT_COMMON_H__
+#define INPUT_COMMON_H__
+
+#include <linux/input.h>
+#include <poll.h>
+
+#include "tst_test.h"
+#include "tst_uinput.h"
+
+static inline int open_event_device(void)
+{
+	int fd;
+	char path[1024];
+	char *device;
+	char *handlers;
+
+	memset(path, 0, sizeof(path));
+
+	handlers = get_input_field_value('H');
+	device = strtok(handlers, " ");
+
+	while (device) {
+		if (strstr(device, "event") != NULL) {
+			memset(path, 0, sizeof(path));
+			snprintf(path, sizeof(path), "/dev/input/%s", device);
+
+			if (!access(path, F_OK)) {
+				tst_res(TINFO, "Found event device: %s", path);
+				break;
+			}
+		}
+
+		device = strtok(NULL, " ");
+	}
+
+	free(handlers);
+
+	if (path[0] == '\0')
+		tst_brk(TBROK, "Can't find event device");
+
+	fd = SAFE_OPEN(path, O_RDONLY);
+
+	return fd;
+}
+
+static inline void send_event(
+	const int fd, const int event,
+	const int code, const int value)
+{
+	struct input_event ev = {
+		.type = event,
+		.code = code,
+		.value = value,
+	};
+
+	SAFE_WRITE(SAFE_WRITE_ALL, fd, &ev, sizeof(ev));
+}
+
+static inline void send_relative_move(const int fd, const int x, const 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 inline void verify_no_events_queued(const int fd_recv)
+{
+	int num_bytes;
+	int num_events;
+	struct input_event ev;
+	struct pollfd fds = {
+		.fd = fd_recv,
+		.events = POLLIN
+	};
+
+	num_events = poll(&fds, 1, 30);
+
+	TST_EXP_EQ_LI(num_events, 0);
+	if (!num_events)
+		return;
+
+	num_bytes = SAFE_READ(0, fd_recv, &ev, sizeof(ev));
+	if (!num_bytes)
+		return;
+
+	tst_res(TFAIL, "Received unexpected event: "
+		"type=%i, code=%i, value=%i",
+		ev.type,
+		ev.code,
+		ev.value);
+}
+#endif

-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [LTP] [PATCH v2 2/7] Refactor input02 test
  2024-12-02 10:12 [LTP] [PATCH v2 0/7] Rewrite input testing suite Andrea Cervesato
  2024-12-02 10:12 ` [LTP] [PATCH v2 1/7] Refactor input01 test Andrea Cervesato
@ 2024-12-02 10:12 ` Andrea Cervesato
  2024-12-02 10:12 ` [LTP] [PATCH v2 3/7] Refactor input03 test Andrea Cervesato
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Andrea Cervesato @ 2024-12-02 10:12 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Reviewed-by: Li Wang <liwang@redhat.com>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 testcases/kernel/input/Makefile  |   4 +-
 testcases/kernel/input/input02.c | 132 +++++++++++++++------------------------
 2 files changed, 54 insertions(+), 82 deletions(-)

diff --git a/testcases/kernel/input/Makefile b/testcases/kernel/input/Makefile
index e686005c69da8b83d954da754b2e5db93ae89da7..5bc729802d1e302d7d52d71be0b6b22a20efb852 100644
--- a/testcases/kernel/input/Makefile
+++ b/testcases/kernel/input/Makefile
@@ -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
diff --git a/testcases/kernel/input/input02.c b/testcases/kernel/input/input02.c
index 6964ed70320a585a755e926e066f5e24fc7a9a30..eeff54ed21cbff6eac2d90dc53c6447d379e29ed 100644
--- a/testcases/kernel/input/input02.c
+++ b/testcases/kernel/input/input02.c
@@ -1,106 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) 2015 Cedric Hnyda <chnyda@suse.com>
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * [Description]
  *
- * 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
+ * Verify that /dev/input/eventX won't receive any event sent from a virtual
+ * device, that in our case is a mouse, when the event device has been grabbed
+ * by an another process.
  */
 
- /*
-  *  Create a virtual device (mouse), send events to /dev/uinput
-  *  and check that the events are not received in /dev/input/eventX
-  *  because the device is grabbed by another process
-  */
+#include "input_common.h"
 
-#include <linux/input.h>
+#define MOVE_X 10
+#define MOVE_Y 1
 
-#include "test.h"
-#include "safe_macros.h"
-#include "lapi/fcntl.h"
-#include "input_helper.h"
+static int fd_send = -1;
+static int fd_recv = -1;
 
-#define NB_TEST 20
+static void send_events(void)
+{
+	int fd;
 
-static void setup(void);
-static void send_information(void);
-static void cleanup(void);
+	fd = open_event_device();
 
-static int fd;
-static int fd2;
+	SAFE_IOCTL(fd, EVIOCGRAB, 1);
+	tst_res(TINFO, "The virtual device was grabbed");
 
-char *TCID = "input02";
+	send_relative_move(fd_send, MOVE_X, MOVE_Y);
 
-int main(int ac, char **av)
-{
-	int lc;
-	int pid;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-		pid = tst_fork();
-
-		fd2 = open_device();
-
-		switch (pid) {
-		case 0:
-			send_information();
-			exit(0);
-		case -1:
-			tst_brkm(TBROK | TERRNO, cleanup, "fork() failed");
-		default:
-			if (no_events_queued(fd2, 0))
-				tst_resm(TPASS, "No data received in eventX");
-			else
-				tst_resm(TFAIL, "Data received in eventX");
-			SAFE_CLOSE(NULL, fd2);
-		break;
-		}
-
-		SAFE_WAITPID(NULL, pid, NULL, 0);
-	}
+	TST_CHECKPOINT_WAKE_AND_WAIT(0);
 
-	cleanup();
-	tst_exit();
+	SAFE_CLOSE(fd);
 }
 
-static void setup(void)
+static void run(void)
 {
-	tst_require_root();
+	if (!SAFE_FORK()) {
+		send_events();
+		exit(0);
+	}
 
-	fd = open_uinput();
-	setup_mouse_events(fd);
-	create_device(fd);
-}
+	TST_CHECKPOINT_WAIT(0);
 
-static void send_information(void)
-{
-	int nb;
+	verify_no_events_queued(fd_recv);
 
-	SAFE_IOCTL(NULL, fd2, EVIOCGRAB, 1);
-	tst_resm(TINFO, "The virtual device was grabbed");
+	TST_CHECKPOINT_WAKE(0);
+}
 
-	for (nb = 0; nb < NB_TEST; ++nb) {
-		send_rel_move(fd, 10, 1);
-		usleep(1000);
-	}
+static void setup(void)
+{
+	fd_send = open_uinput();
+	setup_mouse_events(fd_send);
+	create_input_device(fd_send);
 
-	SAFE_CLOSE(NULL, fd2);
+	fd_recv = open_event_device();
 }
 
 static void cleanup(void)
 {
-	destroy_device(fd);
+	if (fd_send != -1)
+		destroy_input_device(fd_send);
+
+	if (fd_recv != -1)
+		SAFE_CLOSE(fd_recv);
 }
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.forks_child = 1,
+	.needs_root = 1,
+	.needs_checkpoints = 1,
+};

-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [LTP] [PATCH v2 3/7] Refactor input03 test
  2024-12-02 10:12 [LTP] [PATCH v2 0/7] Rewrite input testing suite Andrea Cervesato
  2024-12-02 10:12 ` [LTP] [PATCH v2 1/7] Refactor input01 test Andrea Cervesato
  2024-12-02 10:12 ` [LTP] [PATCH v2 2/7] Refactor input02 test Andrea Cervesato
@ 2024-12-02 10:12 ` Andrea Cervesato
  2024-12-02 10:12 ` [LTP] [PATCH v2 4/7] Refactor input04 test Andrea Cervesato
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Andrea Cervesato @ 2024-12-02 10:12 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Reviewed-by: Li Wang <liwang@redhat.com>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 testcases/kernel/input/Makefile  |   4 +-
 testcases/kernel/input/input03.c | 176 ++++++++++++++++-----------------------
 2 files changed, 73 insertions(+), 107 deletions(-)

diff --git a/testcases/kernel/input/Makefile b/testcases/kernel/input/Makefile
index 5bc729802d1e302d7d52d71be0b6b22a20efb852..8c302dbc8c75cf4fd42bc162b4bb8a9882237164 100644
--- a/testcases/kernel/input/Makefile
+++ b/testcases/kernel/input/Makefile
@@ -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
diff --git a/testcases/kernel/input/input03.c b/testcases/kernel/input/input03.c
index 6cd753d0b1bf98ce671dfa739cde817b4c52c547..4a3eb464ee0322b134f44158a08dbb4ed000216f 100644
--- a/testcases/kernel/input/input03.c
+++ b/testcases/kernel/input/input03.c
@@ -1,145 +1,111 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) 2015 Cedric Hnyda <chnyda@suse.com>
- *
- * 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 <andrea.cervesato@suse.com>
  */
 
- /*
-  *  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.
+ */
 
-#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");
-		break;
-		}
+	tst_res(TINFO, "Reading events back");
 
-		SAFE_WAITPID(NULL, pid, NULL, 0);
-	}
+	char buf[30];
+	int events = 0;
+	int pressed = 0;
+	int num_bytes = 0;
 
-	cleanup();
-	tst_exit();
-}
+	TST_CHECKPOINT_WAKE(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");
+
+	TST_CHECKPOINT_WAIT(0);
 
-	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)
 {
-	int nb, rd, i, pressed = 0;
-	char buf[30];
-
-	nb = 0;
-
-	while (nb < NB_TEST) {
-		rd = read(fd2, buf, sizeof(buf));
+	if (!SAFE_FORK()) {
+		send_mouse_events();
+		exit(0);
+	}
 
-		if (rd < 0)
-			tst_brkm(TBROK | TERRNO, NULL, "read() failed");
+	recv_data();
+}
 
-		if (rd % 3) {
-			tst_resm(TINFO, "read() returned %i", rd);
-			return 1;
-		}
+static void setup(void)
+{
+	fd_send = open_uinput();
 
-		for (i = 0; i < rd / 3; i++) {
-			if (buf[3*i] & PS2_RIGHT_BTN)
-				pressed = 1;
+	setup_mouse_events(fd_send);
+	SAFE_IOCTL(fd_send, UI_SET_EVBIT, EV_KEY);
+	SAFE_IOCTL(fd_send, UI_SET_KEYBIT, BTN_RIGHT);
 
-			if (pressed == 1 && !(buf[3*i] & PS2_RIGHT_BTN)) {
-				pressed = 0;
-				nb++;
-			}
-		}
-	}
+	create_input_device(fd_send);
 
-	return nb != NB_TEST;
+	fd_recv = SAFE_OPEN(MOUSE_DEV, O_RDONLY);
 }
 
 static void cleanup(void)
 {
-	if (fd2 > 0 && close(fd2))
-		tst_resm(TWARN, "close(fd2) failed");
+	if (fd_send != -1)
+		destroy_input_device(fd_send);
 
-	destroy_device(fd);
+	if (fd_recv != -1)
+		SAFE_CLOSE(fd_recv);
 }
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.forks_child = 1,
+	.needs_root = 1,
+	.needs_checkpoints = 1,
+};

-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [LTP] [PATCH v2 4/7] Refactor input04 test
  2024-12-02 10:12 [LTP] [PATCH v2 0/7] Rewrite input testing suite Andrea Cervesato
                   ` (2 preceding siblings ...)
  2024-12-02 10:12 ` [LTP] [PATCH v2 3/7] Refactor input03 test Andrea Cervesato
@ 2024-12-02 10:12 ` Andrea Cervesato
  2024-12-02 10:12 ` [LTP] [PATCH v2 5/7] Refactor input05 test Andrea Cervesato
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Andrea Cervesato @ 2024-12-02 10:12 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Reviewed-by: Li Wang <liwang@redhat.com>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 testcases/kernel/input/Makefile  |   4 +-
 testcases/kernel/input/input04.c | 113 ++++++++++++---------------------------
 2 files changed, 35 insertions(+), 82 deletions(-)

diff --git a/testcases/kernel/input/Makefile b/testcases/kernel/input/Makefile
index 8c302dbc8c75cf4fd42bc162b4bb8a9882237164..cf35e1bfc150a6c1556ef796d4858c0df9020131 100644
--- a/testcases/kernel/input/Makefile
+++ b/testcases/kernel/input/Makefile
@@ -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
diff --git a/testcases/kernel/input/input04.c b/testcases/kernel/input/input04.c
index e57b76b0b40f8be4f851137f1a9185b37c6e64c0..3c76d7c82ad7fe76f35f5a4ecfc78f27069d3fa0 100644
--- a/testcases/kernel/input/input04.c
+++ b/testcases/kernel/input/input04.c
@@ -1,103 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) 2015 Cedric Hnyda <chnyda@suse.com>
- *
- * 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 <andrea.cervesato@suse.com>
  */
 
- /*
-  *  Create a virtual device (mouse), send empty events to /dev/uinput
-  *  and check that the events are not received in /dev/inputX
-  */
-
-#include <linux/input.h>
-
-#include "test.h"
-#include "safe_macros.h"
-#include "lapi/fcntl.h"
-#include "input_helper.h"
-
-#define NB_TEST 20
+/*\
+ * [Description]
+ *
+ * Verify that /dev/input/eventX doesn't receive any event sent from a virtual
+ * device, that in our case is a mouse, when relative move is (0, 0)
+ */
 
-static void setup(void);
-static void send_events(void);
-static void cleanup(void);
+#include "input_common.h"
 
-static int fd, fd2;
+#define NUM_EVENTS 20
 
-char *TCID = "input04";
+static int fd_send = -1;
+static int fd_recv = -1;
 
-int main(int ac, char **av)
+static void run(void)
 {
-	int lc;
-	int pid;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-		pid = tst_fork();
+	tst_res(TINFO, "Sending empty relative move");
 
-		switch (pid) {
-		case 0:
-			send_events();
-			exit(0);
-		case -1:
-			tst_brkm(TBROK | TERRNO, cleanup, "fork() failed");
-		default:
-			if (no_events_queued(fd2, 1))
-				tst_resm(TPASS,
-					"No data received in /dev/inputX");
-			else
-				tst_resm(TFAIL,
-					"Data received /dev/inputX");
-		break;
-		}
-
-		SAFE_WAITPID(NULL, pid, NULL, 0);
+	for (int i = 0; i < NUM_EVENTS; i++) {
+		send_relative_move(fd_send, 0, 0);
+		usleep(1000);
 	}
 
-	cleanup();
-	tst_exit();
+	verify_no_events_queued(fd_recv);
 }
 
 static void setup(void)
 {
-	tst_require_root();
-
-	fd = open_uinput();
-	setup_mouse_events(fd);
-	create_device(fd);
-
-	fd2 = open_device();
-}
-
-static void send_events(void)
-{
-	int nb;
+	fd_send = open_uinput();
+	setup_mouse_events(fd_send);
+	create_input_device(fd_send);
 
-	for (nb = 0; nb < NB_TEST; ++nb) {
-		send_rel_move(fd, 0, 0);
-		usleep(1000);
-	}
+	fd_recv = open_event_device();
 }
 
 static void cleanup(void)
 {
-	if (fd2 > 0 && close(fd2))
-		tst_resm(TWARN | TERRNO, "close(fd2)");
+	if (fd_send != -1)
+		destroy_input_device(fd_send);
 
-	destroy_device(fd);
+	if (fd_recv != -1)
+		SAFE_CLOSE(fd_recv);
 }
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+};

-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [LTP] [PATCH v2 5/7] Refactor input05 test
  2024-12-02 10:12 [LTP] [PATCH v2 0/7] Rewrite input testing suite Andrea Cervesato
                   ` (3 preceding siblings ...)
  2024-12-02 10:12 ` [LTP] [PATCH v2 4/7] Refactor input04 test Andrea Cervesato
@ 2024-12-02 10:12 ` Andrea Cervesato
  2024-12-02 10:12 ` [LTP] [PATCH v2 6/7] Refactor input06 test Andrea Cervesato
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Andrea Cervesato @ 2024-12-02 10:12 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Reviewed-by: Li Wang <liwang@redhat.com>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 testcases/kernel/input/Makefile  |   6 +-
 testcases/kernel/input/input05.c | 119 ++++++++++++---------------------------
 2 files changed, 40 insertions(+), 85 deletions(-)

diff --git a/testcases/kernel/input/Makefile b/testcases/kernel/input/Makefile
index cf35e1bfc150a6c1556ef796d4858c0df9020131..a37aa28fc27688901e0555a0338395a681b45b39 100644
--- a/testcases/kernel/input/Makefile
+++ b/testcases/kernel/input/Makefile
@@ -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
diff --git a/testcases/kernel/input/input05.c b/testcases/kernel/input/input05.c
index 46b4fe8b27cfcfe2d025d84c4dc005e528d46dae..4e5072a038ea8e4f7b8e0899d88a58bdf18e9e94 100644
--- a/testcases/kernel/input/input05.c
+++ b/testcases/kernel/input/input05.c
@@ -1,107 +1,62 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) 2015 Cedric Hnyda <chnyda@suse.com>
- *
- * 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 <andrea.cervesato@suse.com>
  */
 
- /*
-  *  Create a virtual device (mouse), send events to /dev/uinput
-  *  and Check that events not advertised in the input device bits
-  *  are filtered.
-  */
+/*\
+ * [Description]
+ *
+ * Verify that /dev/input/eventX doesn't receive any event sent from a virtual
+ * device, that in our case is a mouse, when events not advertised in the input
+ * device bits are filtered.
+ */
 
-#include <linux/input.h>
 #include <linux/uinput.h>
 
-#include "test.h"
-#include "safe_macros.h"
-#include "lapi/fcntl.h"
-#include "input_helper.h"
-
-#define X_VALUE 10
-#define Y_VALUE 10
+#include "input_common.h"
 
-#define NB_TEST 20
+#define NUM_EVENTS 20
+#define MOVE_X 10
+#define MOVE_Y 10
 
-static void setup(void);
-static void send_events(void);
-static void cleanup(void);
+static int fd_send = -1;
+static int fd_recv = -1;
 
-static int fd;
-static int fd2;
-
-char *TCID = "input05";
-
-int main(int ac, char **av)
+static void run(void)
 {
-	int lc;
-	int pid;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-		pid = tst_fork();
+	tst_res(TINFO, "Sending relative mouse move (%i, %i)", MOVE_X, MOVE_Y);
 
-		switch (pid) {
-		case 0:
-			send_events();
-			exit(0);
-		case -1:
-			tst_brkm(TBROK | TERRNO, cleanup, "fork() failed");
-		default:
-			if (no_events_queued(fd2, 1))
-				tst_resm(TPASS, "No data received in eventX");
-			else
-				tst_resm(TFAIL, "Data received in eventX");
-		break;
-		}
-
-		SAFE_WAITPID(NULL, pid, NULL, 0);
+	for (int i = 0; i < NUM_EVENTS; i++) {
+		send_relative_move(fd_send, MOVE_X, MOVE_Y);
+		usleep(1000);
 	}
 
-	cleanup();
-	tst_exit();
+	verify_no_events_queued(fd_recv);
 }
 
 static void setup(void)
 {
-	tst_require_root();
-
-	fd = open_uinput();
+	fd_send = open_uinput();
+	SAFE_IOCTL(fd_send, UI_SET_EVBIT, EV_KEY);
+	SAFE_IOCTL(fd_send, UI_SET_KEYBIT, BTN_LEFT);
+	create_input_device(fd_send);
 
-	SAFE_IOCTL(NULL, fd, UI_SET_EVBIT, EV_KEY);
-	SAFE_IOCTL(NULL, fd, UI_SET_KEYBIT, BTN_LEFT);
-
-	create_device(fd);
-
-	fd2 = open_device();
+	fd_recv = open_event_device();
 }
 
-static void send_events(void)
+static void cleanup(void)
 {
-	int nb;
+	if (fd_send != -1)
+		destroy_input_device(fd_send);
 
-	for (nb = 0; nb < NB_TEST; ++nb) {
-		send_rel_move(fd, X_VALUE, Y_VALUE);
-		usleep(1000);
-	}
+	if (fd_recv != -1)
+		SAFE_CLOSE(fd_recv);
 }
 
-static void cleanup(void)
-{
-	destroy_device(fd);
-}
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+};

-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [LTP] [PATCH v2 6/7] Refactor input06 test
  2024-12-02 10:12 [LTP] [PATCH v2 0/7] Rewrite input testing suite Andrea Cervesato
                   ` (4 preceding siblings ...)
  2024-12-02 10:12 ` [LTP] [PATCH v2 5/7] Refactor input05 test Andrea Cervesato
@ 2024-12-02 10:12 ` Andrea Cervesato
  2024-12-03 11:34   ` Cyril Hrubis
  2024-12-02 10:12 ` [LTP] [PATCH v2 7/7] Delete depreacted input test suite helper Andrea Cervesato
  2024-12-03 11:49 ` [LTP] [PATCH v2 0/7] Rewrite input testing suite Andrea Cervesato via ltp
  7 siblings, 1 reply; 12+ messages in thread
From: Andrea Cervesato @ 2024-12-02 10:12 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 testcases/kernel/input/Makefile  |   5 +-
 testcases/kernel/input/input06.c | 190 ++++++++++++++++-----------------------
 2 files changed, 79 insertions(+), 116 deletions(-)

diff --git a/testcases/kernel/input/Makefile b/testcases/kernel/input/Makefile
index a37aa28fc27688901e0555a0338395a681b45b39..945299a13bfcecc3eeae029931ef5ae44781b7ad 100644
--- a/testcases/kernel/input/Makefile
+++ b/testcases/kernel/input/Makefile
@@ -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
diff --git a/testcases/kernel/input/input06.c b/testcases/kernel/input/input06.c
index b698c277d875ed2df8a0f07a88784997944eeee4..5527e160c4569a94d5b5f50da3dc3360143f231d 100644
--- a/testcases/kernel/input/input06.c
+++ b/testcases/kernel/input/input06.c
@@ -1,102 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) 2015 Cedric Hnyda <chnyda@suse.com>
- *
- * 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 <andrea.cervesato@suse.com>
  */
 
- /*
-  *  Create a virtual device, activate auto-repeat and
-  *  and check that auto repeat is working
-  */
+/*\
+ * [Description]
+ *
+ * Verify that auto-repeat is working on a virtual device, that in our case
+ * it's a mouse.
+ */
 
-#include <linux/input.h>
 #include <linux/uinput.h>
-#include <linux/kd.h>
-
-#include "test.h"
-#include "safe_macros.h"
-#include "lapi/fcntl.h"
-#include "input_helper.h"
 
-static void setup(void);
-static void send_events(void);
-static int check_events(void);
-static void cleanup(void);
+#include "input_common.h"
 
-static int fd;
-static int fd2;
 struct input_event events[64];
 static int num_events;
 static int ev_iter;
-
-char *TCID = "input06";
-
-int main(int ac, char **av)
-{
-	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 in eventX");
-			else
-				tst_resm(TPASS, "Data received in eventX");
-		break;
-		}
-
-		SAFE_WAITPID(NULL, pid, NULL, 0);
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-static void setup(void)
-{
-	tst_require_root();
-
-	fd = open_uinput();
-
-	SAFE_IOCTL(NULL, fd, UI_SET_EVBIT, EV_KEY);
-	SAFE_IOCTL(NULL, fd, UI_SET_EVBIT, EV_REP);
-	SAFE_IOCTL(NULL, fd, UI_SET_KEYBIT, KEY_X);
-
-	create_device(fd);
-
-	fd2 = open_device();
-	SAFE_IOCTL(NULL, fd2, EVIOCGRAB, 1);
-}
+static int fd_send = -1;
+static int fd_recv = -1;
 
 static void send_events(void)
 {
-	send_event(fd, EV_KEY, KEY_X, 1);
-	send_event(fd, EV_SYN, 0, 0);
+	send_event(fd_send, EV_KEY, KEY_X, 1);
+	send_event(fd_send, EV_SYN, 0, 0);
 
 	/*
 	 * Sleep long enough to keep the key pressed for some time
@@ -106,8 +34,8 @@ static void send_events(void)
 	 */
 	usleep(500000);
 
-	send_event(fd, EV_KEY, KEY_X, 0);
-	send_event(fd, EV_SYN, 0, 0);
+	send_event(fd_send, EV_KEY, KEY_X, 0);
+	send_event(fd_send, EV_SYN, 0, 0);
 }
 
 static int check_event(struct input_event *iev, int event, int code, int value)
@@ -117,20 +45,18 @@ static int check_event(struct input_event *iev, int event, int code, int value)
 
 static void read_events(void)
 {
-	int rd = read(fd2, events, sizeof(events));
-	if (rd < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "read() failed");
+	int num_bytes = SAFE_READ(0, fd_recv, events, sizeof(events));
 
-	if (rd == 0)
-		tst_brkm(TBROK, cleanup, "Failed to read events");
+	if (!num_bytes)
+		tst_brk(TBROK, "Failed to read events");
 
-	if (rd % sizeof(struct input_event) != 0) {
-		tst_brkm(TBROK, cleanup, "read size %i not multiple of %zu",
-		         rd, sizeof(struct input_event));
+	if (num_bytes % sizeof(struct input_event) != 0) {
+		tst_brk(TBROK, "Read size %i is not multiple of %zu",
+			num_bytes, sizeof(struct input_event));
 	}
 
 	ev_iter = 0;
-	num_events = rd / sizeof(struct input_event);
+	num_events = num_bytes / sizeof(struct input_event);
 }
 
 static int have_events(void)
@@ -146,29 +72,37 @@ static struct input_event *next_event(void)
 	return &events[ev_iter++];
 }
 
+static int check_event_code(struct input_event *iev, int event, int code)
+{
+	return iev->type == event && iev->code == code;
+}
+
 static int parse_autorepeat_config(struct input_event *iev)
 {
 	if (!check_event_code(iev, EV_REP, REP_DELAY)) {
-		tst_resm(TFAIL,
-			 "Didn't get EV_REP configuration with code REP_DELAY");
+		tst_res(TFAIL, "Didn't get EV_REP type with REP_DELAY code");
 		return 0;
 	}
 
 	if (!check_event_code(next_event(), EV_REP, REP_PERIOD)) {
-		tst_resm(TFAIL,
-			 "Didn't get EV_REP configuration with code REP_PERIOD");
+		tst_res(TFAIL, "Didn't get EV_REP type with REP_PERIOD code");
 		return 0;
 	}
 
 	return 1;
 }
 
+static int check_sync_event(struct input_event *iev)
+{
+	return check_event_code(iev, EV_SYN, SYN_REPORT);
+}
+
 static int parse_key(struct input_event *iev)
 {
 	int autorep_count = 0;
 
 	if (!check_event(iev, EV_KEY, KEY_X, 1) || !check_sync_event(next_event())) {
-		tst_resm(TFAIL, "Didn't get expected key press for KEY_X");
+		tst_res(TFAIL, "Didn't get expected key press for KEY_X");
 		return 0;
 	}
 
@@ -180,19 +114,16 @@ static int parse_key(struct input_event *iev)
 
 	/* make sure we have at least one auto-repeated key event */
 	if (!autorep_count) {
-		tst_resm(TFAIL,
-			 "Didn't get autorepeat events for the key - KEY_X");
+		tst_res(TFAIL, "Didn't get autorepeat events for the key - KEY_X");
 		return 0;
 	}
 
 	if (!check_event(iev, EV_KEY, KEY_X, 0) || !check_sync_event(next_event())) {
-		tst_resm(TFAIL,
-			 "Didn't get expected key release for KEY_X");
+		tst_res(TFAIL, "Didn't get expected key release for KEY_X");
 		return 0;
 	}
 
-	tst_resm(TINFO,
-		 "Received %d repititions for KEY_X", autorep_count);
+	tst_res(TINFO, "Received %d repetitions for KEY_X", autorep_count);
 
 	return 1;
 }
@@ -218,8 +149,7 @@ static int check_events(void)
 			rep_keys_done = 1;
 			break;
 		default:
-			tst_resm(TFAIL,
-				 "Unexpected event type '0x%04x' received",
+			tst_res(TFAIL, "Unexpected event type '0x%04x' received",
 				iev->type);
 			ret = 0;
 			break;
@@ -232,10 +162,46 @@ static int check_events(void)
 	return ret;
 }
 
+static void run(void)
+{
+	if (!SAFE_FORK()) {
+		send_events();
+		exit(0);
+	}
+
+	if (!check_events())
+		tst_res(TFAIL, "Wrong data received from input device");
+	else
+		tst_res(TPASS, "Data received from input device");
+}
+
+static void setup(void)
+{
+	fd_send = open_uinput();
+
+	SAFE_IOCTL(fd_send, UI_SET_EVBIT, EV_KEY);
+	SAFE_IOCTL(fd_send, UI_SET_EVBIT, EV_REP);
+	SAFE_IOCTL(fd_send, UI_SET_KEYBIT, KEY_X);
+
+	create_input_device(fd_send);
+
+	fd_recv = open_event_device();
+	SAFE_IOCTL(fd_recv, EVIOCGRAB, 1);
+}
+
 static void cleanup(void)
 {
-	if (fd2 > 0 && close(fd2))
-		tst_resm(TWARN | TERRNO, "close(fd2) failed");
+	if (fd_send != -1)
+		destroy_input_device(fd_send);
 
-	destroy_device(fd);
+	if (fd_recv != -1)
+		SAFE_CLOSE(fd_recv);
 }
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.forks_child = 1,
+};

-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [LTP] [PATCH v2 7/7] Delete depreacted input test suite helper
  2024-12-02 10:12 [LTP] [PATCH v2 0/7] Rewrite input testing suite Andrea Cervesato
                   ` (5 preceding siblings ...)
  2024-12-02 10:12 ` [LTP] [PATCH v2 6/7] Refactor input06 test Andrea Cervesato
@ 2024-12-02 10:12 ` Andrea Cervesato
  2024-12-03 11:49 ` [LTP] [PATCH v2 0/7] Rewrite input testing suite Andrea Cervesato via ltp
  7 siblings, 0 replies; 12+ messages in thread
From: Andrea Cervesato @ 2024-12-02 10:12 UTC (permalink / raw)
  To: ltp

From: Andrea Cervesato <andrea.cervesato@suse.com>

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 testcases/kernel/input/input_helper.c | 313 ----------------------------------
 testcases/kernel/input/input_helper.h |  36 ----
 2 files changed, 349 deletions(-)

diff --git a/testcases/kernel/input/input_helper.c b/testcases/kernel/input/input_helper.c
deleted file mode 100644
index c929de6bab64df49cd48ac6c73b44d26e8f04e96..0000000000000000000000000000000000000000
--- a/testcases/kernel/input/input_helper.c
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Copyright (c) 2015 Cedric Hnyda <chnyda@suse.com>
- *
- * 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;
-}
diff --git a/testcases/kernel/input/input_helper.h b/testcases/kernel/input/input_helper.h
deleted file mode 100644
index 7f61be1e9a4a647ff0887aa14a89a48bd2e882a9..0000000000000000000000000000000000000000
--- a/testcases/kernel/input/input_helper.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2015 Cedric Hnyda <chnyda@suse.com>
- *
- * 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 */

-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [LTP] [PATCH v2 1/7] Refactor input01 test
  2024-12-02 10:12 ` [LTP] [PATCH v2 1/7] Refactor input01 test Andrea Cervesato
@ 2024-12-02 15:15   ` Petr Vorel
  0 siblings, 0 replies; 12+ messages in thread
From: Petr Vorel @ 2024-12-02 15:15 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi Andrea,

I would mention adding a check of the device name in /sys/devices
create_input_device(), because that modifies also a different test
(../uevents/uevent03.c).

> ---
>  libs/uinput/tst_uinput.c              |  26 ++++-
>  testcases/kernel/input/Makefile       |   5 +-
>  testcases/kernel/input/input01.c      | 205 ++++++++--------------------------
>  testcases/kernel/input/input_common.h |  97 ++++++++++++++++
>  4 files changed, 173 insertions(+), 160 deletions(-)

...
> +static void check_ui_get_sysname_ioctl(int fd)
> +{
> +	char sys_name[256];
> +	char dev_name[256];
> +	char *path;
> +
> +	SAFE_IOCTL(fd, UI_GET_SYSNAME(sizeof(sys_name)), sys_name, NULL);
> +	SAFE_ASPRINTF(&path, "/sys/devices/virtual/input/%s/name", sys_name);
> +
> +	if (FILE_SCANF(path, "%s", dev_name)) {
> +		tst_brk(TBROK|TERRNO, "Failed to read '%s'", path);
> +		free(path);
I guess free(path) here is not needed due exit() via tst_brk() right?
And if it's needed, you meant to first free and then tst_brk().

> +		return;
> +	}
> +
> +	if (strcmp(VIRTUAL_DEVICE, dev_name))
And if I'm wrong, then free(path) should be also here.
> +		tst_brk(TBROK, "ioctl UI_GET_SYSNAME returned wrong name");

The rest LGTM, nice cleanup (free can be fixed before merge).

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [LTP] [PATCH v2 6/7] Refactor input06 test
  2024-12-02 10:12 ` [LTP] [PATCH v2 6/7] Refactor input06 test Andrea Cervesato
@ 2024-12-03 11:34   ` Cyril Hrubis
  2024-12-03 11:43     ` Andrea Cervesato via ltp
  0 siblings, 1 reply; 12+ messages in thread
From: Cyril Hrubis @ 2024-12-03 11:34 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi!
> - /*
> -  *  Create a virtual device, activate auto-repeat and
> -  *  and check that auto repeat is working
> -  */
> +/*\
> + * [Description]
> + *
> + * Verify that auto-repeat is working on a virtual device, that in our case
> + * it's a mouse.

This is wrong, the device is a keyboard with a single key, at least that
is what is being constructed in the test setup. The original description
was at least correct...


The rest of the conversion looks good.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [LTP] [PATCH v2 6/7] Refactor input06 test
  2024-12-03 11:34   ` Cyril Hrubis
@ 2024-12-03 11:43     ` Andrea Cervesato via ltp
  0 siblings, 0 replies; 12+ messages in thread
From: Andrea Cervesato via ltp @ 2024-12-03 11:43 UTC (permalink / raw)
  To: Cyril Hrubis, Andrea Cervesato; +Cc: ltp

Hi Cyril,

On 12/3/24 12:34, Cyril Hrubis wrote:
> Hi!
>> - /*
>> -  *  Create a virtual device, activate auto-repeat and
>> -  *  and check that auto repeat is working
>> -  */
>> +/*\
>> + * [Description]
>> + *
>> + * Verify that auto-repeat is working on a virtual device, that in our case
>> + * it's a mouse.
> This is wrong, the device is a keyboard with a single key, at least that
> is what is being constructed in the test setup. The original description
> was at least correct...
>
>
> The rest of the conversion looks good.
>
You are right, my bad. I'm gonna fix it and merge the testing suite.

Regards,
Andrea


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [LTP] [PATCH v2 0/7] Rewrite input testing suite
  2024-12-02 10:12 [LTP] [PATCH v2 0/7] Rewrite input testing suite Andrea Cervesato
                   ` (6 preceding siblings ...)
  2024-12-02 10:12 ` [LTP] [PATCH v2 7/7] Delete depreacted input test suite helper Andrea Cervesato
@ 2024-12-03 11:49 ` Andrea Cervesato via ltp
  7 siblings, 0 replies; 12+ messages in thread
From: Andrea Cervesato via ltp @ 2024-12-03 11:49 UTC (permalink / raw)
  To: ltp

Hi,

merged, thanks for the reviews!

Andrea

On 12/2/24 11:12, Andrea Cervesato wrote:
> 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.
>
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> Changes in v2:
> - use checkpoint in input03
> - move check_ui_get_sysname_ioctl() in tst_uinput.h
> - Link to v1: https://lore.kernel.org/r/20241125-input_refactoring-v1-0-b622b3aa698d@suse.com
>
> ---
> 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
>
>   libs/uinput/tst_uinput.c              |  26 ++-
>   testcases/kernel/input/Makefile       |   6 +-
>   testcases/kernel/input/input01.c      | 205 +++++-----------------
>   testcases/kernel/input/input02.c      | 132 ++++++--------
>   testcases/kernel/input/input03.c      | 176 ++++++++-----------
>   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 ----
>   11 files changed, 443 insertions(+), 970 deletions(-)
> ---
> base-commit: ec4161186e51b55d4faaa394dc4607200cb30f68
> change-id: 20241113-input_refactoring-16aea13ed7b8
>
> Best regards,

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-12-03 11:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-02 10:12 [LTP] [PATCH v2 0/7] Rewrite input testing suite Andrea Cervesato
2024-12-02 10:12 ` [LTP] [PATCH v2 1/7] Refactor input01 test Andrea Cervesato
2024-12-02 15:15   ` Petr Vorel
2024-12-02 10:12 ` [LTP] [PATCH v2 2/7] Refactor input02 test Andrea Cervesato
2024-12-02 10:12 ` [LTP] [PATCH v2 3/7] Refactor input03 test Andrea Cervesato
2024-12-02 10:12 ` [LTP] [PATCH v2 4/7] Refactor input04 test Andrea Cervesato
2024-12-02 10:12 ` [LTP] [PATCH v2 5/7] Refactor input05 test Andrea Cervesato
2024-12-02 10:12 ` [LTP] [PATCH v2 6/7] Refactor input06 test Andrea Cervesato
2024-12-03 11:34   ` Cyril Hrubis
2024-12-03 11:43     ` Andrea Cervesato via ltp
2024-12-02 10:12 ` [LTP] [PATCH v2 7/7] Delete depreacted input test suite helper Andrea Cervesato
2024-12-03 11:49 ` [LTP] [PATCH v2 0/7] Rewrite input testing suite Andrea Cervesato via ltp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox