public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v3] Use correct ioctl request for termios
@ 2023-09-07 14:21 Marius Kittler
  2023-09-07 16:07 ` Martin Doucha
  2023-09-11  9:11 ` Cyril Hrubis
  0 siblings, 2 replies; 3+ messages in thread
From: Marius Kittler @ 2023-09-07 14:21 UTC (permalink / raw)
  To: ltp

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

Signed-off-by: Marius Kittler <mkittler@suse.de>
---
 testcases/kernel/syscalls/ioctl/ioctl01.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/testcases/kernel/syscalls/ioctl/ioctl01.c b/testcases/kernel/syscalls/ioctl/ioctl01.c
index 1be38e79d..3ca8a9a3b 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl01.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl01.c
@@ -37,23 +37,26 @@ static struct termios termios;
 static struct tcase {
 	int *fd;
 	int request;
-	struct termio *s_tio;
-	struct termios *s_tios;
+	void *s_tio;
 	int error;
 } tcases[] = {
 	/* file descriptor is invalid */
-	{&bfd, TCGETA, &termio, &termios, EBADF},
+	{&bfd, TCGETA, &termio, EBADF},
+	{&bfd, TCGETS, &termios, EBADF},
 	/* termio address is invalid */
-	{&fd, TCGETA, (struct termio *)-1, (struct termios *)-1, EFAULT},
-	/* command is invalid */
+	{&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, &termio, &termios, ENOTTY},
+	{&fd, INVAL_IOCTL, &termio, ENOTTY},
 	/* file descriptor is for a regular file */
-	{&fd_file, TCGETA, &termio, &termios, ENOTTY},
+	{&fd_file, TCGETA, &termio, ENOTTY},
+	{&fd_file, TCGETS, &termios, ENOTTY},
 	/* termio is NULL */
-	{&fd, TCGETA, NULL, NULL, EFAULT}
+	{&fd, TCGETA, NULL, EFAULT},
+	{&fd, TCGETS, NULL, EFAULT}
 };
 
 static char *device;
@@ -62,9 +65,6 @@ static void verify_ioctl(unsigned int i)
 {
 	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request, tcases[i].s_tio),
 		     tcases[i].error);
-
-	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request, tcases[i].s_tios),
-		     tcases[i].error);
 }
 
 static void setup(void)
-- 
2.42.0


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

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

* Re: [LTP] [PATCH v3] Use correct ioctl request for termios
  2023-09-07 14:21 [LTP] [PATCH v3] Use correct ioctl request for termios Marius Kittler
@ 2023-09-07 16:07 ` Martin Doucha
  2023-09-11  9:11 ` Cyril Hrubis
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Doucha @ 2023-09-07 16:07 UTC (permalink / raw)
  To: Marius Kittler, ltp

Hi,
Reviewed-by: Martin Doucha <mdoucha@suse.cz>

On 07. 09. 23 16:21, Marius Kittler wrote:
> 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
> 
> Signed-off-by: Marius Kittler <mkittler@suse.de>
> ---
>   testcases/kernel/syscalls/ioctl/ioctl01.c | 22 +++++++++++-----------
>   1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl01.c b/testcases/kernel/syscalls/ioctl/ioctl01.c
> index 1be38e79d..3ca8a9a3b 100644
> --- a/testcases/kernel/syscalls/ioctl/ioctl01.c
> +++ b/testcases/kernel/syscalls/ioctl/ioctl01.c
> @@ -37,23 +37,26 @@ static struct termios termios;
>   static struct tcase {
>   	int *fd;
>   	int request;
> -	struct termio *s_tio;
> -	struct termios *s_tios;
> +	void *s_tio;
>   	int error;
>   } tcases[] = {
>   	/* file descriptor is invalid */
> -	{&bfd, TCGETA, &termio, &termios, EBADF},
> +	{&bfd, TCGETA, &termio, EBADF},
> +	{&bfd, TCGETS, &termios, EBADF},
>   	/* termio address is invalid */
> -	{&fd, TCGETA, (struct termio *)-1, (struct termios *)-1, EFAULT},
> -	/* command is invalid */
> +	{&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, &termio, &termios, ENOTTY},
> +	{&fd, INVAL_IOCTL, &termio, ENOTTY},
>   	/* file descriptor is for a regular file */
> -	{&fd_file, TCGETA, &termio, &termios, ENOTTY},
> +	{&fd_file, TCGETA, &termio, ENOTTY},
> +	{&fd_file, TCGETS, &termios, ENOTTY},
>   	/* termio is NULL */
> -	{&fd, TCGETA, NULL, NULL, EFAULT}
> +	{&fd, TCGETA, NULL, EFAULT},
> +	{&fd, TCGETS, NULL, EFAULT}
>   };
>   
>   static char *device;
> @@ -62,9 +65,6 @@ static void verify_ioctl(unsigned int i)
>   {
>   	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request, tcases[i].s_tio),
>   		     tcases[i].error);
> -
> -	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request, tcases[i].s_tios),
> -		     tcases[i].error);
>   }
>   
>   static void setup(void)

-- 
Martin Doucha   mdoucha@suse.cz
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

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

* Re: [LTP] [PATCH v3] Use correct ioctl request for termios
  2023-09-07 14:21 [LTP] [PATCH v3] Use correct ioctl request for termios Marius Kittler
  2023-09-07 16:07 ` Martin Doucha
@ 2023-09-11  9:11 ` Cyril Hrubis
  1 sibling, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2023-09-11  9:11 UTC (permalink / raw)
  To: Marius Kittler; +Cc: ltp

Hi!
Applied, thanks.

>  static char *device;
> @@ -62,9 +65,6 @@ static void verify_ioctl(unsigned int i)
>  {
>  	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request, tcases[i].s_tio),
>  		     tcases[i].error);

It would be nice to also print a nice description here instead of the
parameteres. The third parameter to the macro is a printf-like format
string. What we usually do in these tests is to put short description of
the testcase to the tcase structrure and print it here with
TST_EXP_FAIL(... "%s", tcases[i].desc);


And another improvement would be to create a tty with openpty() and use
the fd from these for the test instead of messing up with the system
ttys. I suppose that we could drop the needs_root flag in that case as
well.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

end of thread, other threads:[~2023-09-11  9:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-07 14:21 [LTP] [PATCH v3] Use correct ioctl request for termios Marius Kittler
2023-09-07 16:07 ` Martin Doucha
2023-09-11  9:11 ` Cyril Hrubis

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