public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] kernel/uevents: Fix compiler errors
@ 2019-09-03 12:48 Jinhui huang
  2019-09-03 12:48 ` [LTP] [PATCH 2/2] uevents/uevent03.c: Check if "UI_GET_SYSNAME" is supported Jinhui huang
  2019-09-03 14:25 ` [LTP] [PATCH 1/2] kernel/uevents: Fix compiler errors Cyril Hrubis
  0 siblings, 2 replies; 6+ messages in thread
From: Jinhui huang @ 2019-09-03 12:48 UTC (permalink / raw)
  To: ltp

1)Add uevents into "kernel/Makefile".
2)Define "sys/socket.h" in uevent02.c for struct sockaddr, fix incomplete
  types on old relesase.
3)Add "lapi/uinput.h" and define "UI_GET_SYSNAME", then define the header
  file in uevent03.c, fix implicit declaration on old relesase.

Signed-off-by: Jinhui huang <huangjh.jy@cn.fujitsu.com>
---
 include/lapi/uinput.h               | 16 ++++++++++++++++
 testcases/kernel/Makefile           |  1 +
 testcases/kernel/uevents/uevent02.c |  1 +
 testcases/kernel/uevents/uevent03.c |  3 +--
 4 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100644 include/lapi/uinput.h

diff --git a/include/lapi/uinput.h b/include/lapi/uinput.h
new file mode 100644
index 0000000..87e3384
--- /dev/null
+++ b/include/lapi/uinput.h
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
+ * Authors: Jinhui huang <huangjh.jy@cn.fujitsu.com>
+ */
+
+#ifndef __LAPI_UINPUT_H_
+#define __LAPI_UINPUT_H_
+
+#include <linux/uinput.h>
+
+#ifndef UI_GET_SYSNAME
+#define UI_GET_SYSNAME(len)	_IOC(_IOC_READ, UINPUT_IOCTL_BASE, 44, len)
+#endif
+
+#endif /* __LAPI_UINPUT_H_ */
diff --git a/testcases/kernel/Makefile b/testcases/kernel/Makefile
index 03ea253..3319b31 100644
--- a/testcases/kernel/Makefile
+++ b/testcases/kernel/Makefile
@@ -54,6 +54,7 @@ SUBDIRS			+= connectors \
 			   security \
 			   sound \
 			   tracing \
+			   uevents \
 
 ifeq ($(WITH_POWER_MANAGEMENT_TESTSUITE),yes)
 SUBDIRS			+= power_management
diff --git a/testcases/kernel/uevents/uevent02.c b/testcases/kernel/uevents/uevent02.c
index b94748c..9dd4cd6 100644
--- a/testcases/kernel/uevents/uevent02.c
+++ b/testcases/kernel/uevents/uevent02.c
@@ -14,6 +14,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/wait.h>
+#include <sys/socket.h>
 #include <linux/if.h>
 #include <linux/if_tun.h>
 
diff --git a/testcases/kernel/uevents/uevent03.c b/testcases/kernel/uevents/uevent03.c
index 991737e..9b901dc 100644
--- a/testcases/kernel/uevents/uevent03.c
+++ b/testcases/kernel/uevents/uevent03.c
@@ -16,11 +16,10 @@
 #include <sys/wait.h>
 #include <sys/sysmacros.h>
 
-#include <linux/uinput.h>
-
 #include "tst_test.h"
 #include "tst_uinput.h"
 #include "uevent.h"
+#include "lapi/uinput.h"
 
 static int mouse_fd;
 
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 2/2] uevents/uevent03.c: Check if "UI_GET_SYSNAME" is supported
  2019-09-03 12:48 [LTP] [PATCH 1/2] kernel/uevents: Fix compiler errors Jinhui huang
@ 2019-09-03 12:48 ` Jinhui huang
  2019-09-03 14:35   ` Cyril Hrubis
  2019-09-04 14:01   ` Cyril Hrubis
  2019-09-03 14:25 ` [LTP] [PATCH 1/2] kernel/uevents: Fix compiler errors Cyril Hrubis
  1 sibling, 2 replies; 6+ messages in thread
From: Jinhui huang @ 2019-09-03 12:48 UTC (permalink / raw)
  To: ltp

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");
+		}
+	}
+
 	handlers = get_input_handlers();
 
 	tst_res(TINFO, "Sysname: %s", sysname);
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 1/2] kernel/uevents: Fix compiler errors
  2019-09-03 12:48 [LTP] [PATCH 1/2] kernel/uevents: Fix compiler errors Jinhui huang
  2019-09-03 12:48 ` [LTP] [PATCH 2/2] uevents/uevent03.c: Check if "UI_GET_SYSNAME" is supported Jinhui huang
@ 2019-09-03 14:25 ` Cyril Hrubis
  1 sibling, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2019-09-03 14:25 UTC (permalink / raw)
  To: ltp

Hi!
Applied, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 2/2] uevents/uevent03.c: Check if "UI_GET_SYSNAME" is supported
  2019-09-03 12:48 ` [LTP] [PATCH 2/2] uevents/uevent03.c: Check if "UI_GET_SYSNAME" is supported Jinhui huang
@ 2019-09-03 14:35   ` Cyril Hrubis
  2019-09-04 14:01   ` Cyril Hrubis
  1 sibling, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2019-09-03 14:35 UTC (permalink / raw)
  To: ltp

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
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 2/2] uevents/uevent03.c: Check if "UI_GET_SYSNAME" is supported
  2019-09-03 12:48 ` [LTP] [PATCH 2/2] uevents/uevent03.c: Check if "UI_GET_SYSNAME" is supported Jinhui huang
  2019-09-03 14:35   ` Cyril Hrubis
@ 2019-09-04 14:01   ` Cyril Hrubis
  2019-09-05  9:48     ` Yang Xu
  1 sibling, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2019-09-04 14:01 UTC (permalink / raw)
  To: ltp

Hi!
I've pushed this patch, thanks.

Anyone can fix the test on older kernel later on, if there is a need.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 2/2] uevents/uevent03.c: Check if "UI_GET_SYSNAME" is supported
  2019-09-04 14:01   ` Cyril Hrubis
@ 2019-09-05  9:48     ` Yang Xu
  0 siblings, 0 replies; 6+ messages in thread
From: Yang Xu @ 2019-09-05  9:48 UTC (permalink / raw)
  To: ltp

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-09-05  9:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-03 12:48 [LTP] [PATCH 1/2] kernel/uevents: Fix compiler errors Jinhui huang
2019-09-03 12:48 ` [LTP] [PATCH 2/2] uevents/uevent03.c: Check if "UI_GET_SYSNAME" is supported Jinhui huang
2019-09-03 14:35   ` Cyril Hrubis
2019-09-04 14:01   ` Cyril Hrubis
2019-09-05  9:48     ` Yang Xu
2019-09-03 14:25 ` [LTP] [PATCH 1/2] kernel/uevents: Fix compiler errors Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox