[LTP] [PATCH v2 2/2] Detangle test cases for termio and termios

Marius Kittler mkittler@suse.de
Tue Sep 5 11:30:19 CEST 2023


As suggested in the review it is clearer to separate the test
cases for termio and termios into separate entries in the
`tcases` array.
---
 testcases/kernel/syscalls/ioctl/ioctl01.c | 25 +++++++++++------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/testcases/kernel/syscalls/ioctl/ioctl01.c b/testcases/kernel/syscalls/ioctl/ioctl01.c
index 983208925..d552746f8 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl01.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl01.c
@@ -36,35 +36,34 @@ static struct termios termios;
 
 static struct tcase {
 	int *fd;
-	int request_tio;
-	int request_tios;
-	struct termio *s_tio;
-	struct termios *s_tios;
+	int request;
+	void *s_tio;
 	int error;
 } tcases[] = {
 	/* file descriptor is invalid */
-	{&bfd, TCGETA, TCGETS, &termio, &termios, EBADF},
+	{&bfd, TCGETA, &termio, EBADF},
+	{&bfd, TCGETS, &termios, EBADF},
 	/* termio address is invalid */
-	{&fd, TCGETA, TCGETS, (struct termio *)-1, (struct termios *)-1, EFAULT},
+	{&fd, TCGETA, (struct termio *)-1, EFAULT},
+	{&fd, TCGETS, (struct termios *)-1, EFAULT},
 	// /* command is invalid */
 	/* This errno value was changed from EINVAL to ENOTTY
 	 * by kernel commit 07d106d0 and bbb63c51
 	 */
-	{&fd, INVAL_IOCTL, INVAL_IOCTL, &termio, &termios, ENOTTY},
+	{&fd, INVAL_IOCTL, &termio, ENOTTY},
+	{&fd, INVAL_IOCTL, &termios, ENOTTY},
 	/* file descriptor is for a regular file */
-	{&fd_file, TCGETA, TCGETS, &termio, &termios, ENOTTY},
+	{&fd_file, TCGETA, &termio, ENOTTY},
+	{&fd_file, TCGETS, &termios, ENOTTY},
 	/* termio is NULL */
-	{&fd, TCGETA, TCGETS, NULL, NULL, EFAULT}
+	{&fd, TCGETA, NULL, EFAULT}
 };
 
 static char *device;
 
 static void verify_ioctl(unsigned int i)
 {
-	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request_tio, tcases[i].s_tio),
-		     tcases[i].error);
-
-	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request_tios, tcases[i].s_tios),
+	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request, tcases[i].s_tio),
 		     tcases[i].error);
 }
 
-- 
2.41.0



More information about the ltp mailing list