1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) 2015 Cedric Hnyda <chnyda@suse.com>
4 * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
5 */
6
7 /*\
8 * [Description]
9 *
10 * Verify that /dev/input/eventX doesn't receive any event sent from a virtual
11 * device, that in our case is a mouse, when relative move is (0, 0)
12 */
13
14 #include "input_common.h"
15
16 #define NUM_EVENTS 20
17
18 static int fd_send = -1;
19 static int fd_recv = -1;
20
run(void)21 static void run(void)
22 {
23 tst_res(TINFO, "Sending empty relative move");
24
25 for (int i = 0; i < NUM_EVENTS; i++) {
26 send_relative_move(fd_send, 0, 0);
27 usleep(1000);
28 }
29
30 verify_no_events_queued(fd_recv);
31 }
32
setup(void)33 static void setup(void)
34 {
35 fd_send = open_uinput();
36 if (fd_send == -1)
37 tst_brk(TCONF, "Virtual device is not available");
38
39 setup_mouse_events(fd_send);
40 create_input_device(fd_send);
41
42 fd_recv = open_event_device();
43 }
44
cleanup(void)45 static void cleanup(void)
46 {
47 if (fd_send != -1)
48 destroy_input_device(fd_send);
49
50 if (fd_recv != -1)
51 SAFE_CLOSE(fd_recv);
52 }
53
54 static struct tst_test test = {
55 .test_all = run,
56 .setup = setup,
57 .cleanup = cleanup,
58 .needs_root = 1,
59 };
60