Verify virtual device availability
PATCH 1/1 Verify virtual device availability
From: Andrea Cervesato <[email protected]>
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.
---
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(+)
testcases/kernel/input/input01.c +3 -0
@@ -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);
testcases/kernel/input/input02.c +3 -0
@@ -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);
testcases/kernel/input/input03.c +2 -0
@@ -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 );
testcases/kernel/input/input04.c +3 -0
@@ -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);
testcases/kernel/input/input05.c +3 -0
@@ -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);
testcases/kernel/input/input06.c +2 -0
@@ -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 );
testcases/kernel/uevents/uevent03.c +3 -0
@@ -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,
Signature · 5 lines
Andrea Cervesato <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Andrea,
Looks reasonable.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Pushed, thanks!
Andrea
Quoted 1 line · Petr Vorel
Reviewed-by Petr Vorel<[email protected]>
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Andrea,
...
testcases/kernel/input/input01.c static void run(void) · line 57
Quoted 5 lines
static void setup(void)
{testcases/kernel/input/input01.c +2
-0fd_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
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Petr,
Quoted 11 lines · Petr Vorel
Hi Andrea,
...
Review
Quoted 5 lines
static void setup(void) { fd_send = open_uinput();(quoted diff) +2
-0+ 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 addtst_brk(TCONF, ...)there?
Quoted 3 lines
Function is not used in library where
tst_brk(TCONF, ...)would be problematic, therefore I would not even bother with havingSAFE_OPEN_UINPUT()which would evaluateopen_uinput().
Usually SAFE_* macros just TBROK the tests, so I'm not sure about this approach. Alternatives?
Quoted 2 lines
Kind regards,
Petr
Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp