Skip to contentSkip to conversation

Fix test for termios

PATCH Superseded Marius Kittler 2 participants 5 messages Sep 5, 2023 – Sep 7, 2023

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Fix test for termios

Fix test for termios

Marius Kittler (2):
Use correct ioctl request for termios
Detangle test cases for termio and termios

 testcases/kernel/syscalls/ioctl/ioctl01.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
Signature · 5 lines
2.41.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH v2 1/2 Use correct ioctl request for termios

With the termios struct one is supposed to use TCGETS instead of TCGETA, see man ioctl_tty.

Related issue: https://github.com/linux-test-project/ltp/issues/637#issuecomment-1705334874

---
 testcases/kernel/syscalls/ioctl/ioctl01.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
testcases/kernel/syscalls/ioctl/ioctl01.c +10 -9
index 1be38e79d..983208925 100644
@@ -36,34 +36,35 @@ static struct termios termios;
 
 static struct tcase {
 	int *fd;
-	int request;
+	int request_tio;
+	int request_tios;
 	struct termio *s_tio;
 	struct termios *s_tios;
 	int error;
 } tcases[] = {
 	/* file descriptor is invalid */
-	{&bfd, TCGETA, &termio, &termios, EBADF},
+	{&bfd, TCGETA, TCGETS, &termio, &termios, EBADF},
 	/* termio address is invalid */
-	{&fd, TCGETA, (struct termio *)-1, (struct termios *)-1, EFAULT},
-	/* command is invalid */
+	{&fd, TCGETA, TCGETS, (struct termio *)-1, (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, &termio, &termios, ENOTTY},
+	{&fd, INVAL_IOCTL, INVAL_IOCTL, &termio, &termios, ENOTTY},
 	/* file descriptor is for a regular file */
-	{&fd_file, TCGETA, &termio, &termios, ENOTTY},
+	{&fd_file, TCGETA, TCGETS, &termio, &termios, ENOTTY},
 	/* termio is NULL */
-	{&fd, TCGETA, NULL, NULL, EFAULT}
+	{&fd, TCGETA, TCGETS, NULL, NULL, EFAULT}
 };
 
 static char *device;
 
 static void verify_ioctl(unsigned int i)
 {
-	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request, tcases[i].s_tio),
+	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, tcases[i].s_tios),
+	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request_tios, tcases[i].s_tios),
 		     tcases[i].error);
 }
 
Signature · 5 lines
2.41.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Re: [LTP] [PATCH v2 1/2] Use correct ioctl request for termios

Hi,
this patch will be effectively reverted by the second one. Merge them into a single patch.

Quoted 57 lines · Marius Kittler

With the termios struct one is supposed to use TCGETS instead of TCGETA, see man ioctl_tty.

Related issue: https://github.com/linux-test-project/ltp/issues/637#issuecomment-1705334874

---
  testcases/kernel/syscalls/ioctl/ioctl01.c | 19 ++++++++++---------
  1 file changed, 10 insertions(+), 9 deletions(-)
testcases/kernel/syscalls/ioctl/ioctl01.c +10 -9
index 1be38e79d..983208925 100644
@@ -36,34 +36,35 @@ static struct termios termios;
 
  static struct tcase {
  	int *fd;
-	int request;
+	int request_tio;
+	int request_tios;
  	struct termio *s_tio;
  	struct termios *s_tios;
  	int error;
  } tcases[] = {
  	/* file descriptor is invalid */
-	{&bfd, TCGETA, &termio, &termios, EBADF},
+	{&bfd, TCGETA, TCGETS, &termio, &termios, EBADF},
  	/* termio address is invalid */
-	{&fd, TCGETA, (struct termio *)-1, (struct termios *)-1, EFAULT},
-	/* command is invalid */
+	{&fd, TCGETA, TCGETS, (struct termio *)-1, (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, &termio, &termios, ENOTTY},
+	{&fd, INVAL_IOCTL, INVAL_IOCTL, &termio, &termios, ENOTTY},
  	/* file descriptor is for a regular file */
-	{&fd_file, TCGETA, &termio, &termios, ENOTTY},
+	{&fd_file, TCGETA, TCGETS, &termio, &termios, ENOTTY},
  	/* termio is NULL */
-	{&fd, TCGETA, NULL, NULL, EFAULT}
+	{&fd, TCGETA, TCGETS, NULL, NULL, EFAULT}
  };
 
  static char *device;
 
  static void verify_ioctl(unsigned int i)
  {
-	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request, tcases[i].s_tio),
+	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, tcases[i].s_tios),
+	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request_tios, tcases[i].s_tios),
  		     tcases[i].error);
  }
 
Signature · 11 lines
Martin Doucha   [email protected]
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

PATCH v2 2/2 Detangle test cases for termio and termios

In reply to Marius Kittler

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(-)
testcases/kernel/syscalls/ioctl/ioctl01.c +12 -13
index 983208925..d552746f8 100644
@@ -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);
 }
 
Signature · 5 lines
2.41.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

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

Hi,
a two notes below.

Quoted 28 lines · Marius Kittler

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(-)
testcases/kernel/syscalls/ioctl/ioctl01.c +4 -5
index 983208925..d552746f8 100644
@@ -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 */

testcases/kernel/syscalls/ioctl/ioctl01.c static struct termios termios; · line 54

Quoted 10 lines
testcases/kernel/syscalls/ioctl/ioctl01.c +4 -2
-	{&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},

The INVAL_IOCTL, &termios testcase is probably redundant.

testcases/kernel/syscalls/ioctl/ioctl01.c static struct termios termios; · line 59

Quoted 7 lines
testcases/kernel/syscalls/ioctl/ioctl01.c +3 -2
  	/* 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}

No TCGETS testcase here?

Quoted 14 lines
testcases/kernel/syscalls/ioctl/ioctl01.c +1 -4
  };
 
  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);
  }
 
Signature · 11 lines
Martin Doucha   [email protected]
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


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