* [LTP] [PATCH] Verify virtual device availability
@ 2024-12-10 14:13 Andrea Cervesato
2024-12-10 17:21 ` Petr Vorel
2024-12-10 20:22 ` Petr Vorel
0 siblings, 2 replies; 5+ messages in thread
From: Andrea Cervesato @ 2024-12-10 14:13 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
Virtual device is supposed to be found in /dev/uinput or
/dev/input/uinput, but in some cases this is not true. For instance, a
kernel which is not exposing any virtual device. This patch is meant to
verify that the device is available and we eventually skip test if it's
not found.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Just skip tests which cannot find any virtual device in the current
system.
---
testcases/kernel/input/input01.c | 3 +++
testcases/kernel/input/input02.c | 3 +++
testcases/kernel/input/input03.c | 2 ++
testcases/kernel/input/input04.c | 3 +++
testcases/kernel/input/input05.c | 3 +++
testcases/kernel/input/input06.c | 2 ++
testcases/kernel/uevents/uevent03.c | 3 +++
7 files changed, 19 insertions(+)
diff --git a/testcases/kernel/input/input01.c b/testcases/kernel/input/input01.c
index 0872204111b81fd19a1525ef7f099e8ddead9658..5e85133028e25ea4a4596475f9aa876cb913694d 100644
--- a/testcases/kernel/input/input01.c
+++ b/testcases/kernel/input/input01.c
@@ -53,6 +53,9 @@ static void run(void)
static void setup(void)
{
fd_send = open_uinput();
+ if (fd_send == -1)
+ tst_brk(TCONF, "Virtual device is not available");
+
setup_mouse_events(fd_send);
create_input_device(fd_send);
diff --git a/testcases/kernel/input/input02.c b/testcases/kernel/input/input02.c
index eeff54ed21cbff6eac2d90dc53c6447d379e29ed..8e48f12d9a1108c9a5b1d8452e07386d5534fbfb 100644
--- a/testcases/kernel/input/input02.c
+++ b/testcases/kernel/input/input02.c
@@ -53,6 +53,9 @@ static void run(void)
static void setup(void)
{
fd_send = open_uinput();
+ if (fd_send == -1)
+ tst_brk(TCONF, "Virtual device is not available");
+
setup_mouse_events(fd_send);
create_input_device(fd_send);
diff --git a/testcases/kernel/input/input03.c b/testcases/kernel/input/input03.c
index 4a3eb464ee0322b134f44158a08dbb4ed000216f..2e6161beefccc1133b654be8cf2529e97610960f 100644
--- a/testcases/kernel/input/input03.c
+++ b/testcases/kernel/input/input03.c
@@ -82,6 +82,8 @@ static void run(void)
static void setup(void)
{
fd_send = open_uinput();
+ if (fd_send == -1)
+ tst_brk(TCONF, "Virtual device is not available");
setup_mouse_events(fd_send);
SAFE_IOCTL(fd_send, UI_SET_EVBIT, EV_KEY);
diff --git a/testcases/kernel/input/input04.c b/testcases/kernel/input/input04.c
index 3c76d7c82ad7fe76f35f5a4ecfc78f27069d3fa0..fb13500fe6ab5eba7fed4640ed51dfbc8105cd09 100644
--- a/testcases/kernel/input/input04.c
+++ b/testcases/kernel/input/input04.c
@@ -33,6 +33,9 @@ static void run(void)
static void setup(void)
{
fd_send = open_uinput();
+ if (fd_send == -1)
+ tst_brk(TCONF, "Virtual device is not available");
+
setup_mouse_events(fd_send);
create_input_device(fd_send);
diff --git a/testcases/kernel/input/input05.c b/testcases/kernel/input/input05.c
index 4e5072a038ea8e4f7b8e0899d88a58bdf18e9e94..fa37ac7acb22b690b7bb35d9fe655d3e49532a61 100644
--- a/testcases/kernel/input/input05.c
+++ b/testcases/kernel/input/input05.c
@@ -38,6 +38,9 @@ static void run(void)
static void setup(void)
{
fd_send = open_uinput();
+ if (fd_send == -1)
+ tst_brk(TCONF, "Virtual device is not available");
+
SAFE_IOCTL(fd_send, UI_SET_EVBIT, EV_KEY);
SAFE_IOCTL(fd_send, UI_SET_KEYBIT, BTN_LEFT);
create_input_device(fd_send);
diff --git a/testcases/kernel/input/input06.c b/testcases/kernel/input/input06.c
index cb871cbaec0fc8e35182dc0256dc2672dae4a419..d3584a2b0b9f540b29def3d98b7c77db09faefe9 100644
--- a/testcases/kernel/input/input06.c
+++ b/testcases/kernel/input/input06.c
@@ -178,6 +178,8 @@ static void run(void)
static void setup(void)
{
fd_send = open_uinput();
+ if (fd_send == -1)
+ tst_brk(TCONF, "Virtual device is not available");
SAFE_IOCTL(fd_send, UI_SET_EVBIT, EV_KEY);
SAFE_IOCTL(fd_send, UI_SET_EVBIT, EV_REP);
diff --git a/testcases/kernel/uevents/uevent03.c b/testcases/kernel/uevents/uevent03.c
index 5b3dd701f0cf8f2f12a910b57d5f49d58712fe52..f7072db1c5f076e811e473438db3aa895644eaec 100644
--- a/testcases/kernel/uevents/uevent03.c
+++ b/testcases/kernel/uevents/uevent03.c
@@ -27,6 +27,9 @@ static int mouse_fd;
static void create_uinput_mouse(void)
{
mouse_fd = open_uinput();
+ if (mouse_fd == -1)
+ tst_brk(TCONF, "Virtual device is not available");
+
setup_mouse_events(mouse_fd);
create_input_device(mouse_fd);
}
---
base-commit: b5e2ea3cc02a2466c5bee3b0e650869f4ddf438c
change-id: 20241210-fix_input_suite-5c9c2546aaa2
Best regards,
--
Andrea Cervesato <andrea.cervesato@suse.com>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] Verify virtual device availability
2024-12-10 14:13 [LTP] [PATCH] Verify virtual device availability Andrea Cervesato
@ 2024-12-10 17:21 ` Petr Vorel
2024-12-11 10:15 ` Andrea Cervesato via ltp
2024-12-10 20:22 ` Petr Vorel
1 sibling, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2024-12-10 17:21 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi Andrea,
Looks reasonable.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] Verify virtual device availability
2024-12-10 14:13 [LTP] [PATCH] Verify virtual device availability Andrea Cervesato
2024-12-10 17:21 ` Petr Vorel
@ 2024-12-10 20:22 ` Petr Vorel
2024-12-11 8:00 ` Andrea Cervesato via ltp
1 sibling, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2024-12-10 20:22 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi Andrea,
...
> static void setup(void)
> {
> fd_send = open_uinput();
> + if (fd_send == -1)
> + tst_brk(TCONF, "Virtual device is not available");
Thinking about it twice, how about renaming the function safe_open_uinput()
and add tst_brk(TCONF, ...) there?
Function is not used in library where tst_brk(TCONF, ...) would be problematic,
therefore I would not even bother with having SAFE_OPEN_UINPUT() which would
evaluate open_uinput().
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] Verify virtual device availability
2024-12-10 20:22 ` Petr Vorel
@ 2024-12-11 8:00 ` Andrea Cervesato via ltp
0 siblings, 0 replies; 5+ messages in thread
From: Andrea Cervesato via ltp @ 2024-12-11 8:00 UTC (permalink / raw)
To: Petr Vorel, Andrea Cervesato; +Cc: ltp
Hi Petr,
On 12/10/24 21:22, Petr Vorel wrote:
> Hi Andrea,
>
> ...
>> static void setup(void)
>> {
>> fd_send = open_uinput();
>> + if (fd_send == -1)
>> + tst_brk(TCONF, "Virtual device is not available");
> Thinking about it twice, how about renaming the function safe_open_uinput()
> and add tst_brk(TCONF, ...) there?
>
> Function is not used in library where tst_brk(TCONF, ...) would be problematic,
> therefore I would not even bother with having SAFE_OPEN_UINPUT() which would
> evaluate open_uinput().
Usually SAFE_* macros just TBROK the tests, so I'm not sure about this
approach.
Alternatives?
> Kind regards,
> Petr
Andrea
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] Verify virtual device availability
2024-12-10 17:21 ` Petr Vorel
@ 2024-12-11 10:15 ` Andrea Cervesato via ltp
0 siblings, 0 replies; 5+ messages in thread
From: Andrea Cervesato via ltp @ 2024-12-11 10:15 UTC (permalink / raw)
To: Petr Vorel, Andrea Cervesato; +Cc: ltp
Pushed, thanks!
Andrea
On 12/10/24 18:21, Petr Vorel wrote:
> Reviewed-by: Petr Vorel<pvorel@suse.cz>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-12-11 10:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-10 14:13 [LTP] [PATCH] Verify virtual device availability Andrea Cervesato
2024-12-10 17:21 ` Petr Vorel
2024-12-11 10:15 ` Andrea Cervesato via ltp
2024-12-10 20:22 ` Petr Vorel
2024-12-11 8:00 ` Andrea Cervesato via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox