Skip to content

Commit

Permalink
Verify virtual device availability
Browse files Browse the repository at this point in the history
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.

Reviewed-by: Petr Vorel <[email protected]>
Signed-off-by: Andrea Cervesato <[email protected]>
  • Loading branch information
acerv committed Dec 11, 2024
1 parent 34dc7d2 commit 8f2292a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions testcases/kernel/input/input01.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions testcases/kernel/input/input02.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions testcases/kernel/input/input03.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions testcases/kernel/input/input04.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions testcases/kernel/input/input05.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions testcases/kernel/input/input06.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions testcases/kernel/uevents/uevent03.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 8f2292a

Please sign in to comment.