[PATCH] ioctl_console test microproject

Bran S archsbran at gmail.com
Mon Mar 9 10:07:18 UTC 2020


On Mon, 9 Mar 2020 at 15:35, Bran S <archsbran at gmail.com> wrote:
>
> Signed-off-by: Bran S <archsbran at gmail.com>
> ---
>  tests/.gitignore      |  1 +
>  tests/Makefile.am     |  1 +
>  tests/gen_tests.in    |  1 +
>  tests/ioctl_console.c | 32 ++++++++++++++++++++++++++++++++
>  4 files changed, 35 insertions(+)
>  create mode 100644 tests/ioctl_console.c
>
> diff --git a/tests/.gitignore b/tests/.gitignore
> index 5c73355d..8d4037a8 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -179,6 +179,7 @@ io_uring_register
>  io_uring_setup
>  ioctl
>  ioctl_block
> +ioctl_console
>  ioctl_dm
>  ioctl_dm-v
>  ioctl_evdev
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index f2a5bc6d..d223d791 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -116,6 +116,7 @@ check_PROGRAMS = $(PURE_EXECUTABLES) \
>   gettid \
>   inject-nf \
>   int_0x80 \
> + ioctl_console \
>   ioctl_dm-v \
>   ioctl_evdev-success \
>   ioctl_evdev-success-Xabbrev \
> diff --git a/tests/gen_tests.in b/tests/gen_tests.in
> index ae090d6d..f43a5a87 100644
> --- a/tests/gen_tests.in
> +++ b/tests/gen_tests.in
> @@ -158,6 +158,7 @@ io_uring_enter -y
>  io_uring_register -y
>  io_uring_setup -a26 -y
>  ioctl_block +ioctl.test
> +ioctl_console +ioctl.test
>  ioctl_dm +ioctl.test -s9
>  ioctl_dm-v +ioctl.test -v -s9
>  ioctl_evdev +ioctl.test -a26
> diff --git a/tests/ioctl_console.c b/tests/ioctl_console.c
> new file mode 100644
> index 00000000..af7f1182
> --- /dev/null
> +++ b/tests/ioctl_console.c
> @@ -0,0 +1,32 @@
> +/*
> + * Copyright (c) 2015-2020 The strace developers.
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +// #include "tests.h"
> +
> +#include <stdio.h>
> +#include <string.h>
> +#include <sys/ioctl.h>
> +#include <linux/kd.h>
> +#include <errno.h>
> +
> +#define RVAL_EBADF " = -1 EBADF (%m)\n"
> +
> +int
> +main(void)
> +{
> + char c_status;
> + unsigned long int ul_status;
> +
> + ioctl(-1, KDGETLED, &c_status);
> + printf("ioctl(-1, KDGETLED, %p)" RVAL_EBADF, &c_status);
> +
> + ioctl(-1, KDSETLED, ul_status);
> + printf("ioctl(-1, KDSETLED, %d)" RVAL_EBADF, ul_status);
> +
> + puts("+++ exited with 0 +++");
> + return 0;
> +}
> --
> 2.20.1
>

Hi Guys,

These are the changes I have made. The test is not showing up while
doing `make check`.
Please let me know what I have missed ?


More information about the Strace-devel mailing list