[LTP] [PATCH 1/3] ioctl01: Add default tty device

Li Wang liwang@redhat.com
Wed Feb 8 11:13:15 CET 2023


Hi Petr,

On Tue, Feb 7, 2023 at 9:17 PM Petr Vorel <pvorel@suse.cz> wrote:

> Saves user to specify it when run manually.
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/kernel/syscalls/ioctl/ioctl01.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl01.c
> b/testcases/kernel/syscalls/ioctl/ioctl01.c
> index 1be38e79d3..cb184aee40 100644
> --- a/testcases/kernel/syscalls/ioctl/ioctl01.c
> +++ b/testcases/kernel/syscalls/ioctl/ioctl01.c
> @@ -27,6 +27,7 @@
>  #include "lapi/ioctl.h"
>
>  #define        INVAL_IOCTL     9999999
> +#define        DEFAULT_TTY_DEVICE      "/dev/tty0"
>

Hidden the device path parameter is a good idea.

But maybe can we add a function to find available char devices instead
of using the tty0 as default? In that function, we do the S_ISCHR() check
and return the valid path of it. Then the rest test (e.g. ioctl02) can make
use of it but not set the specified device as well. WDYT?



>
>  static int fd, fd_file;
>  static int bfd = -1;
> @@ -70,7 +71,9 @@ 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");
> +               device = DEFAULT_TTY_DEVICE;
> +
> +       tst_res(TINFO, "Using device '%s'", device);
>
>         fd = SAFE_OPEN(device, O_RDWR, 0777);
>         fd_file = SAFE_OPEN("x", O_CREAT, 0777);
> --
> 2.39.1
>
>

-- 
Regards,
Li Wang


More information about the ltp mailing list