public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Marius Kittler <mkittler@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] Avoid messing with system tty in ioctl01.c
Date: Mon, 11 Sep 2023 17:14:53 +0200	[thread overview]
Message-ID: <ZP8u7Zf0GZpi5TpF@yuki> (raw)
In-Reply-To: <20230911120408.31921-1-mkittler@suse.de>

Hi!
> * Use `openpty()` to create a new tty
> * Remove `-D` option
> * Remove requirement to run as root
> 
> Signed-off-by: Marius Kittler <mkittler@suse.de>
> ---
>  runtest/syscalls                           |  2 +-
>  testcases/kernel/syscalls/ioctl/ioctl01.c  | 25 ++++++++++------------
>  testcases/kernel/syscalls/ioctl/test_ioctl | 23 --------------------
>  3 files changed, 12 insertions(+), 38 deletions(-)
> 
> diff --git a/runtest/syscalls b/runtest/syscalls
> index b1125dd75..f999bd74f 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -557,10 +557,10 @@ init_module01 init_module01
>  init_module02 init_module02
>  
>  #Needs tty device.
> -#ioctl01 ioctl01 -D /dev/tty0
>  #ioctl02 ioctl02 -D /dev/tty0
>  
>  # Introducing ioctl tests for all /dev/tty* devices
> +ioctl01      ioctl01
>  ioctl01_02   test_ioctl

This should be renamed to ioctl02 now I suppose.

>  ioctl03      ioctl03
>  ioctl04      ioctl04
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl01.c b/testcases/kernel/syscalls/ioctl/ioctl01.c
> index 3ca8a9a3b..fe6a5591d 100644
> --- a/testcases/kernel/syscalls/ioctl/ioctl01.c
> +++ b/testcases/kernel/syscalls/ioctl/ioctl01.c
> @@ -23,11 +23,13 @@
>  #include <fcntl.h>
>  #include <stdio.h>
>  #include <termios.h>
> +#include <pty.h>
>  #include "tst_test.h"
>  #include "lapi/ioctl.h"
>  
>  #define	INVAL_IOCTL	9999999
>  
> +static int amaster, aslave;
>  static int fd, fd_file;
>  static int bfd = -1;
>  
> @@ -59,8 +61,6 @@ static struct tcase {
>  	{&fd, TCGETS, 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),
> @@ -69,31 +69,28 @@ static void verify_ioctl(unsigned int i)
>  
>  static void setup(void)
>  {
> -	if (!device)
> -		tst_brk(TBROK, "You must specify a tty device with -D option");
> +	if (openpty(&amaster, &aslave, NULL, &termios, NULL) < 0) {
> +		tst_brk(TBROK | TERRNO, "unable to open pty");
> +	}

It's better just to pass NULL instead of the zero filled &termios here.

The rest looks good to me, if you agree I can merge the patch with the
changes I've proposed.

-- 
Cyril Hrubis
chrubis@suse.cz

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

  reply	other threads:[~2023-09-11 15:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11 12:04 [LTP] [PATCH v1] Avoid messing with system tty in ioctl01.c Marius Kittler
2023-09-11 15:14 ` Cyril Hrubis [this message]
2023-09-11 15:23   ` Marius Kittler
2023-09-13 11:07     ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZP8u7Zf0GZpi5TpF@yuki \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=mkittler@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox