diff mbox series

[2/2] uevents/uevent03.c: Check if "UI_GET_SYSNAME" is supported

Message ID 1567514890-1216-2-git-send-email-huangjh.jy@cn.fujitsu.com
State Accepted
Headers show
Series [1/2] kernel/uevents: Fix compiler errors | expand

Commit Message

Jinhui Huang Sept. 3, 2019, 12:48 p.m. UTC
Signed-off-by: Jinhui huang <huangjh.jy@cn.fujitsu.com>
---
 testcases/kernel/uevents/uevent03.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

Comments

Cyril Hrubis Sept. 3, 2019, 2:35 p.m. UTC | #1
Hi!
> Signed-off-by: Jinhui huang <huangjh.jy@cn.fujitsu.com>
> ---
>  testcases/kernel/uevents/uevent03.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/testcases/kernel/uevents/uevent03.c b/testcases/kernel/uevents/uevent03.c
> index 9b901dc..f676984 100644
> --- a/testcases/kernel/uevents/uevent03.c
> +++ b/testcases/kernel/uevents/uevent03.c
> @@ -52,7 +52,7 @@ static void get_minor_major(char *device, char *minor, char *major, size_t buf_s
>  
>  static void verify_uevent(void)
>  {
> -	int pid, fd;
> +	int pid, fd, ret;
>  	char sysname[64];
>  	char add_msg[1024];
>  	char rem_msg[1024];
> @@ -167,7 +167,18 @@ static void verify_uevent(void)
>  
>  	create_uinput_mouse();
>  
> -	SAFE_IOCTL(mouse_fd, UI_GET_SYSNAME(sizeof(sysname)), sysname);
> +	ret = ioctl(mouse_fd, UI_GET_SYSNAME(sizeof(sysname)), sysname);
> +	if (ret < 0) {
> +		if (errno == EINVAL) {
> +			tst_brk(TCONF,
> +				"kernel does not support UI_GET_SYSNAME");
> +		} else {
> +			tst_brk(TBROK,
> +				"ioctl(%d, %s,...) failed",
> +				mouse_fd, "UI_GET_SYSNAME");
> +		}
> +	}

I do wonder if it makes sense to add a fallback that reads the sysname
from /proc/bus/input/devices.

We do have the sysname as the last component of the SysFs= path.

I guess that it's probably not worth of the effort.

>  	handlers = get_input_handlers();
>  
>  	tst_res(TINFO, "Sysname: %s", sysname);
> -- 
> 1.8.3.1
> 
> 
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
Cyril Hrubis Sept. 4, 2019, 2:01 p.m. UTC | #2
Hi!
I've pushed this patch, thanks.

Anyone can fix the test on older kernel later on, if there is a need.
Yang Xu Sept. 5, 2019, 9:48 a.m. UTC | #3
on 2019/09/04 22:01, Cyril Hrubis wrote:

> Hi!
> I've pushed this patch, thanks.
>
> Anyone can fix the test on older kernel later on, if there is a need.
>
Hi Cyril

  I have sent a patch to use a generic way to get sysname for old kernel.

Thanks
Yang Xu
diff mbox series

Patch

diff --git a/testcases/kernel/uevents/uevent03.c b/testcases/kernel/uevents/uevent03.c
index 9b901dc..f676984 100644
--- a/testcases/kernel/uevents/uevent03.c
+++ b/testcases/kernel/uevents/uevent03.c
@@ -52,7 +52,7 @@  static void get_minor_major(char *device, char *minor, char *major, size_t buf_s
 
 static void verify_uevent(void)
 {
-	int pid, fd;
+	int pid, fd, ret;
 	char sysname[64];
 	char add_msg[1024];
 	char rem_msg[1024];
@@ -167,7 +167,18 @@  static void verify_uevent(void)
 
 	create_uinput_mouse();
 
-	SAFE_IOCTL(mouse_fd, UI_GET_SYSNAME(sizeof(sysname)), sysname);
+	ret = ioctl(mouse_fd, UI_GET_SYSNAME(sizeof(sysname)), sysname);
+	if (ret < 0) {
+		if (errno == EINVAL) {
+			tst_brk(TCONF,
+				"kernel does not support UI_GET_SYSNAME");
+		} else {
+			tst_brk(TBROK,
+				"ioctl(%d, %s,...) failed",
+				mouse_fd, "UI_GET_SYSNAME");
+		}
+	}
+
 	handlers = get_input_handlers();
 
 	tst_res(TINFO, "Sysname: %s", sysname);