All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Wei Gao <wegao@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v3] Add test for UI_GET_NAME ioctl
Date: Tue, 17 Oct 2023 13:08:40 +0200	[thread overview]
Message-ID: <ZS5rOMFkG-znhXMf@yuki> (raw)
In-Reply-To: <20231014033104.31424-1-wegao@suse.com>

Hi!
> Fix:#573
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
>  testcases/kernel/input/input_helper.c | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/input/input_helper.c b/testcases/kernel/input/input_helper.c
> index 09530fb4d..b9dc50a7f 100644
> --- a/testcases/kernel/input/input_helper.c
> +++ b/testcases/kernel/input/input_helper.c
> @@ -32,6 +32,7 @@
>  
>  static int uinput_loaded;
>  static int check_device(void);
> +static void check_ui_get_sysname_ioctl(int fd);

I do not think that this is needed, we do not call the function before
it's definition.

>  static int try_open_device(void)
>  {
> @@ -185,6 +186,22 @@ void send_rel_move(int fd, int x, int y)
>  	send_event(fd, EV_SYN, 0, 0);
>  }
>  
> +static void check_ui_get_sysname_ioctl(int fd)
> +{
> +	char sys_name[256];
> +	char dev_name[256];
> +	char *path;
> +
> +	SAFE_IOCTL(NULL, fd, UI_GET_SYSNAME(sizeof(sys_name)), sys_name, NULL);
> +	SAFE_ASPRINTF(NULL, &path, "/sys/devices/virtual/input/%s/name", sys_name);
> +	SAFE_FILE_SCANF(NULL, path, "%s", dev_name);

I would be inclined to use the FILE_SCANF() instead here and report
failure if the file does not exist or couldn't be read, something as:

	if (FILE_SCANF(NULL, path, "%s", dev_name)) {
		tst_res(TFAIL, "Failed to read name from the sysfs path");
		free(path);
		return;
	}

> +	if (strcmp(VIRTUAL_DEVICE, dev_name)) {
> +		tst_brkm(TBROK, NULL, "Unable to find the input device through ioctl");
> +	}

I do not think that tst_brkm() is the right here either, this is simple
TPASS/TFAIL situation. Can we just print TPASS/TFAIL based on if these
names match?

> +	free(path);
> +}
> +
>  void create_device(int fd)
>  {
>  	int nb;
> @@ -202,8 +219,10 @@ void create_device(int fd)
>  	SAFE_IOCTL(NULL, fd, UI_DEV_CREATE, NULL);
>  
>  	for (nb = 100; nb > 0; nb--) {
> -		if (check_device())
> +		if (check_device()) {
> +			check_ui_get_sysname_ioctl(fd);
>  			return;
> +		}
>  		usleep(10000);
>  	}
>  
> -- 
> 2.35.3
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

  reply	other threads:[~2023-10-17 11:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 11:13 [LTP] [PATCH v1] Add test for UI_GET_NAME ioctl Wei Gao via ltp
2023-10-12 11:25 ` [LTP] [PATCH v2] " Wei Gao via ltp
2023-10-12 14:05   ` Cyril Hrubis
2023-10-14  3:36     ` Wei Gao via ltp
2023-10-16 15:49       ` Cyril Hrubis
2023-10-16 23:52         ` Wei Gao via ltp
2023-10-14  3:31   ` [LTP] [PATCH v3] " Wei Gao via ltp
2023-10-17 11:08     ` Cyril Hrubis [this message]
2023-10-17 13:16     ` [LTP] [PATCH v4] " Wei Gao via ltp
2023-10-23 14:16       ` Cyril Hrubis
2023-10-24  9:10         ` [LTP] [CI FAILURE] " Petr Vorel
2023-10-24  9:33           ` 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=ZS5rOMFkG-znhXMf@yuki \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=wegao@suse.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.