test: Make relative pointer event test more accepting
[platform/upstream/libinput.git] / test / path.c
1
2 /*
3  * Copyright © 2013 Red Hat, Inc.
4  *
5  * Permission to use, copy, modify, distribute, and sell this software and
6  * its documentation for any purpose is hereby granted without fee, provided
7  * that the above copyright notice appear in all copies and that both that
8  * copyright notice and this permission notice appear in supporting
9  * documentation, and that the name of the copyright holders not be used in
10  * advertising or publicity pertaining to distribution of the software
11  * without specific, written prior permission.  The copyright holders make
12  * no representations about the suitability of this software for any
13  * purpose.  It is provided "as is" without express or implied warranty.
14  *
15  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
16  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
18  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
20  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  */
23
24 #include <config.h>
25
26 #include <check.h>
27 #include <errno.h>
28 #include <fcntl.h>
29 #include <libinput.h>
30 #include <libudev.h>
31 #include <unistd.h>
32
33 #include "litest.h"
34
35 static int open_func_count = 0;
36 static int close_func_count = 0;
37
38 static int open_restricted(const char *path, int flags, void *data)
39 {
40         int fd;
41         open_func_count++;
42         fd = open(path, flags);
43         return fd < 0 ? -errno : fd;
44 }
45 static void close_restricted(int fd, void *data)
46 {
47         close_func_count++;
48         close(fd);
49 }
50
51 const struct libinput_interface simple_interface = {
52         .open_restricted = open_restricted,
53         .close_restricted = close_restricted,
54 };
55
56
57 START_TEST(path_create_NULL)
58 {
59         struct libinput *li;
60         const struct libinput_interface interface;
61
62         open_func_count = 0;
63         close_func_count = 0;
64
65         li = libinput_path_create_context(NULL, NULL);
66         ck_assert(li == NULL);
67         li = libinput_path_create_context(&interface, NULL);
68         ck_assert(li != NULL);
69         libinput_destroy(li);
70
71         ck_assert_int_eq(open_func_count, 0);
72         ck_assert_int_eq(close_func_count, 0);
73
74         open_func_count = 0;
75         close_func_count = 0;
76 }
77 END_TEST
78
79 START_TEST(path_create_invalid)
80 {
81         struct libinput *li;
82         struct libinput_device *device;
83         const char *path = "/tmp";
84
85         open_func_count = 0;
86         close_func_count = 0;
87
88         li = libinput_path_create_context(&simple_interface, NULL);
89         ck_assert(li != NULL);
90         device = libinput_path_add_device(li, path);
91         ck_assert(device == NULL);
92
93         ck_assert_int_eq(open_func_count, 0);
94         ck_assert_int_eq(close_func_count, 0);
95
96         libinput_destroy(li);
97         ck_assert_int_eq(close_func_count, 0);
98
99         open_func_count = 0;
100         close_func_count = 0;
101 }
102 END_TEST
103
104 START_TEST(path_create_destroy)
105 {
106         struct libinput *li;
107         struct libinput_device *device;
108         struct libevdev_uinput *uinput;
109         int rc;
110         void *userdata = &rc;
111
112         uinput = litest_create_uinput_device("test device", NULL,
113                                              EV_KEY, BTN_LEFT,
114                                              EV_KEY, BTN_RIGHT,
115                                              EV_REL, REL_X,
116                                              EV_REL, REL_Y,
117                                              -1);
118
119         li = libinput_path_create_context(&simple_interface, userdata);
120         ck_assert(li != NULL);
121         ck_assert(libinput_get_user_data(li) == userdata);
122
123         device = libinput_path_add_device(li,
124                                           libevdev_uinput_get_devnode(uinput));
125         ck_assert(device != NULL);
126
127         ck_assert_int_eq(open_func_count, 1);
128
129         libevdev_uinput_destroy(uinput);
130         libinput_destroy(li);
131         ck_assert_int_eq(close_func_count, 1);
132
133         open_func_count = 0;
134         close_func_count = 0;
135 }
136 END_TEST
137
138 START_TEST(path_added_seat)
139 {
140         struct litest_device *dev = litest_current_device();
141         struct libinput *li = dev->libinput;
142         struct libinput_event *event;
143         struct libinput_device *device;
144         struct libinput_seat *seat;
145         const char *seat_name;
146         enum libinput_event_type type;
147
148         libinput_dispatch(li);
149
150         event = libinput_get_event(li);
151         ck_assert(event != NULL);
152
153         type = libinput_event_get_type(event);
154         ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_ADDED);
155
156         device = libinput_event_get_device(event);
157         seat = libinput_device_get_seat(device);
158         ck_assert(seat != NULL);
159
160         seat_name = libinput_seat_get_logical_name(seat);
161         ck_assert_int_eq(strcmp(seat_name, "default"), 0);
162
163         libinput_event_destroy(event);
164 }
165 END_TEST
166
167 START_TEST(path_added_device)
168 {
169         struct litest_device *dev = litest_current_device();
170         struct libinput *li = dev->libinput;
171         struct libinput_event *event;
172         struct libinput_device *device;
173
174         libinput_dispatch(li);
175
176         while ((event = libinput_get_event(li))) {
177                 enum libinput_event_type type;
178                 type = libinput_event_get_type(event);
179
180                 if (type == LIBINPUT_EVENT_DEVICE_ADDED) {
181                         break;
182                 }
183
184                 libinput_event_destroy(event);
185         }
186
187         ck_assert(event != NULL);
188
189         device = libinput_event_get_device(event);
190         ck_assert(device != NULL);
191
192         libinput_event_destroy(event);
193 }
194 END_TEST
195
196 START_TEST(path_add_device)
197 {
198         struct litest_device *dev = litest_current_device();
199         struct libinput *li = dev->libinput;
200         struct libinput_event *event;
201         struct libinput_device *device;
202         const char *sysname1 = NULL, *sysname2 = NULL;
203
204         libinput_dispatch(li);
205
206         while ((event = libinput_get_event(li))) {
207                 enum libinput_event_type type;
208                 type = libinput_event_get_type(event);
209
210                 if (type == LIBINPUT_EVENT_DEVICE_ADDED) {
211                         ck_assert(sysname1 == NULL);
212                         device = libinput_event_get_device(event);
213                         ck_assert(device != NULL);
214                         sysname1 = libinput_device_get_sysname(device);
215                 }
216
217                 libinput_event_destroy(event);
218         }
219
220         device = libinput_path_add_device(li,
221                                           libevdev_uinput_get_devnode(dev->uinput));
222         ck_assert(device != NULL);
223
224         libinput_dispatch(li);
225
226         while ((event = libinput_get_event(li))) {
227                 enum libinput_event_type type;
228                 type = libinput_event_get_type(event);
229
230                 if (type == LIBINPUT_EVENT_DEVICE_ADDED) {
231                         ck_assert(sysname2 == NULL);
232                         device = libinput_event_get_device(event);
233                         ck_assert(device != NULL);
234                         sysname2 = libinput_device_get_sysname(device);
235                 }
236
237                 libinput_event_destroy(event);
238         }
239
240         ck_assert_int_eq(strcmp(sysname1, sysname2), 0);
241
242         libinput_event_destroy(event);
243 }
244 END_TEST
245
246 START_TEST(path_add_invalid_path)
247 {
248         struct litest_device *dev = litest_current_device();
249         struct libinput *li = dev->libinput;
250         struct libinput_event *event;
251         struct libinput_device *device;
252
253         litest_drain_events(li);
254
255         device = libinput_path_add_device(li, "/tmp/");
256         ck_assert(device == NULL);
257
258         libinput_dispatch(li);
259
260         while ((event = libinput_get_event(li)))
261                 ck_abort();
262 }
263 END_TEST
264
265 START_TEST(path_device_sysname)
266 {
267         struct litest_device *dev = litest_current_device();
268         struct libinput_event *ev;
269         struct libinput_device *device;
270         const char *sysname;
271
272         libinput_dispatch(dev->libinput);
273
274         while ((ev = libinput_get_event(dev->libinput))) {
275                 if (libinput_event_get_type(ev) != LIBINPUT_EVENT_DEVICE_ADDED)
276                         continue;
277
278                 device = libinput_event_get_device(ev);
279                 sysname = libinput_device_get_sysname(device);
280                 ck_assert(sysname != NULL && strlen(sysname) > 1);
281                 ck_assert(strchr(sysname, '/') == NULL);
282                 ck_assert_int_eq(strncmp(sysname, "event", 5), 0);
283
284                 libinput_event_destroy(ev);
285         }
286 }
287 END_TEST
288
289 START_TEST(path_remove_device)
290 {
291         struct litest_device *dev = litest_current_device();
292         struct libinput *li = dev->libinput;
293         struct libinput_event *event;
294         struct libinput_device *device;
295         int remove_event = 0;
296
297         device = libinput_path_add_device(li,
298                                           libevdev_uinput_get_devnode(dev->uinput));
299         ck_assert(device != NULL);
300         litest_drain_events(li);
301
302         libinput_path_remove_device(device);
303         libinput_dispatch(li);
304
305         while ((event = libinput_get_event(li))) {
306                 enum libinput_event_type type;
307                 type = libinput_event_get_type(event);
308
309                 if (type == LIBINPUT_EVENT_DEVICE_REMOVED)
310                         remove_event++;
311
312                 libinput_event_destroy(event);
313         }
314
315         ck_assert_int_eq(remove_event, 1);
316 }
317 END_TEST
318
319 START_TEST(path_double_remove_device)
320 {
321         struct litest_device *dev = litest_current_device();
322         struct libinput *li = dev->libinput;
323         struct libinput_event *event;
324         struct libinput_device *device;
325         int remove_event = 0;
326
327         device = libinput_path_add_device(li,
328                                           libevdev_uinput_get_devnode(dev->uinput));
329         ck_assert(device != NULL);
330         litest_drain_events(li);
331
332         libinput_path_remove_device(device);
333         libinput_path_remove_device(device);
334         libinput_dispatch(li);
335
336         while ((event = libinput_get_event(li))) {
337                 enum libinput_event_type type;
338                 type = libinput_event_get_type(event);
339
340                 if (type == LIBINPUT_EVENT_DEVICE_REMOVED)
341                         remove_event++;
342
343                 libinput_event_destroy(event);
344         }
345
346         ck_assert_int_eq(remove_event, 1);
347 }
348 END_TEST
349
350 START_TEST(path_suspend)
351 {
352         struct libinput *li;
353         struct libinput_device *device;
354         struct libevdev_uinput *uinput;
355         int rc;
356         void *userdata = &rc;
357
358         uinput = litest_create_uinput_device("test device", NULL,
359                                              EV_KEY, BTN_LEFT,
360                                              EV_KEY, BTN_RIGHT,
361                                              EV_REL, REL_X,
362                                              EV_REL, REL_Y,
363                                              -1);
364
365         li = libinput_path_create_context(&simple_interface, userdata);
366         ck_assert(li != NULL);
367
368         device = libinput_path_add_device(li,
369                                           libevdev_uinput_get_devnode(uinput));
370         ck_assert(device != NULL);
371
372         libinput_suspend(li);
373         libinput_resume(li);
374
375         libevdev_uinput_destroy(uinput);
376         libinput_destroy(li);
377
378         open_func_count = 0;
379         close_func_count = 0;
380 }
381 END_TEST
382
383 START_TEST(path_double_suspend)
384 {
385         struct libinput *li;
386         struct libinput_device *device;
387         struct libevdev_uinput *uinput;
388         int rc;
389         void *userdata = &rc;
390
391         uinput = litest_create_uinput_device("test device", NULL,
392                                              EV_KEY, BTN_LEFT,
393                                              EV_KEY, BTN_RIGHT,
394                                              EV_REL, REL_X,
395                                              EV_REL, REL_Y,
396                                              -1);
397
398         li = libinput_path_create_context(&simple_interface, userdata);
399         ck_assert(li != NULL);
400
401         device = libinput_path_add_device(li,
402                                           libevdev_uinput_get_devnode(uinput));
403         ck_assert(device != NULL);
404
405         libinput_suspend(li);
406         libinput_suspend(li);
407         libinput_resume(li);
408
409         libevdev_uinput_destroy(uinput);
410         libinput_destroy(li);
411
412         open_func_count = 0;
413         close_func_count = 0;
414 }
415 END_TEST
416
417 START_TEST(path_double_resume)
418 {
419         struct libinput *li;
420         struct libinput_device *device;
421         struct libevdev_uinput *uinput;
422         int rc;
423         void *userdata = &rc;
424
425         uinput = litest_create_uinput_device("test device", NULL,
426                                              EV_KEY, BTN_LEFT,
427                                              EV_KEY, BTN_RIGHT,
428                                              EV_REL, REL_X,
429                                              EV_REL, REL_Y,
430                                              -1);
431
432         li = libinput_path_create_context(&simple_interface, userdata);
433         ck_assert(li != NULL);
434
435         device = libinput_path_add_device(li,
436                                           libevdev_uinput_get_devnode(uinput));
437         ck_assert(device != NULL);
438
439         libinput_suspend(li);
440         libinput_resume(li);
441         libinput_resume(li);
442
443         libevdev_uinput_destroy(uinput);
444         libinput_destroy(li);
445
446         open_func_count = 0;
447         close_func_count = 0;
448 }
449 END_TEST
450
451 START_TEST(path_add_device_suspend_resume)
452 {
453         struct libinput *li;
454         struct libinput_device *device;
455         struct libinput_event *event;
456         struct libevdev_uinput *uinput1, *uinput2;
457         int rc;
458         int nevents;
459         void *userdata = &rc;
460
461         uinput1 = litest_create_uinput_device("test device", NULL,
462                                               EV_KEY, BTN_LEFT,
463                                               EV_KEY, BTN_RIGHT,
464                                               EV_REL, REL_X,
465                                               EV_REL, REL_Y,
466                                               -1);
467         uinput2 = litest_create_uinput_device("test device 2", NULL,
468                                               EV_KEY, BTN_LEFT,
469                                               EV_KEY, BTN_RIGHT,
470                                               EV_REL, REL_X,
471                                               EV_REL, REL_Y,
472                                               -1);
473
474         li = libinput_path_create_context(&simple_interface, userdata);
475         ck_assert(li != NULL);
476
477         device = libinput_path_add_device(li,
478                                           libevdev_uinput_get_devnode(uinput1));
479         ck_assert(device != NULL);
480         device = libinput_path_add_device(li,
481                                           libevdev_uinput_get_devnode(uinput2));
482
483         libinput_dispatch(li);
484
485         nevents = 0;
486         while ((event = libinput_get_event(li))) {
487                 enum libinput_event_type type;
488                 type = libinput_event_get_type(event);
489                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_ADDED);
490                 libinput_event_destroy(event);
491                 nevents++;
492         }
493
494         ck_assert_int_eq(nevents, 2);
495
496
497         libinput_suspend(li);
498         libinput_dispatch(li);
499
500         nevents = 0;
501         while ((event = libinput_get_event(li))) {
502                 enum libinput_event_type type;
503                 type = libinput_event_get_type(event);
504                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_REMOVED);
505                 libinput_event_destroy(event);
506                 nevents++;
507         }
508
509         ck_assert_int_eq(nevents, 2);
510
511         libinput_resume(li);
512         libinput_dispatch(li);
513
514         nevents = 0;
515         while ((event = libinput_get_event(li))) {
516                 enum libinput_event_type type;
517                 type = libinput_event_get_type(event);
518                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_ADDED);
519                 libinput_event_destroy(event);
520                 nevents++;
521         }
522
523         ck_assert_int_eq(nevents, 2);
524
525         libevdev_uinput_destroy(uinput1);
526         libevdev_uinput_destroy(uinput2);
527         libinput_destroy(li);
528
529         open_func_count = 0;
530         close_func_count = 0;
531 }
532 END_TEST
533
534 START_TEST(path_add_device_suspend_resume_fail)
535 {
536         struct libinput *li;
537         struct libinput_device *device;
538         struct libinput_event *event;
539         struct libevdev_uinput *uinput1, *uinput2;
540         int rc;
541         int nevents;
542         void *userdata = &rc;
543
544         uinput1 = litest_create_uinput_device("test device", NULL,
545                                               EV_KEY, BTN_LEFT,
546                                               EV_KEY, BTN_RIGHT,
547                                               EV_REL, REL_X,
548                                               EV_REL, REL_Y,
549                                               -1);
550         uinput2 = litest_create_uinput_device("test device 2", NULL,
551                                               EV_KEY, BTN_LEFT,
552                                               EV_KEY, BTN_RIGHT,
553                                               EV_REL, REL_X,
554                                               EV_REL, REL_Y,
555                                               -1);
556
557         li = libinput_path_create_context(&simple_interface, userdata);
558         ck_assert(li != NULL);
559
560         device = libinput_path_add_device(li,
561                                           libevdev_uinput_get_devnode(uinput1));
562         ck_assert(device != NULL);
563         device = libinput_path_add_device(li,
564                                           libevdev_uinput_get_devnode(uinput2));
565         ck_assert(device != NULL);
566
567         libinput_dispatch(li);
568
569         nevents = 0;
570         while ((event = libinput_get_event(li))) {
571                 enum libinput_event_type type;
572                 type = libinput_event_get_type(event);
573                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_ADDED);
574                 libinput_event_destroy(event);
575                 nevents++;
576         }
577
578         ck_assert_int_eq(nevents, 2);
579
580
581         libinput_suspend(li);
582         libinput_dispatch(li);
583
584         nevents = 0;
585         while ((event = libinput_get_event(li))) {
586                 enum libinput_event_type type;
587                 type = libinput_event_get_type(event);
588                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_REMOVED);
589                 libinput_event_destroy(event);
590                 nevents++;
591         }
592
593         ck_assert_int_eq(nevents, 2);
594
595         /* now drop one of the devices */
596         libevdev_uinput_destroy(uinput1);
597         rc = libinput_resume(li);
598         ck_assert_int_eq(rc, -1);
599
600         libinput_dispatch(li);
601
602         nevents = 0;
603         while ((event = libinput_get_event(li))) {
604                 enum libinput_event_type type;
605                 type = libinput_event_get_type(event);
606                 /* We expect one device being added, second one fails,
607                  * causing a removed event for the first one */
608                 if (type != LIBINPUT_EVENT_DEVICE_ADDED &&
609                     type != LIBINPUT_EVENT_DEVICE_REMOVED)
610                         ck_abort();
611                 libinput_event_destroy(event);
612                 nevents++;
613         }
614
615         ck_assert_int_eq(nevents, 2);
616
617         libevdev_uinput_destroy(uinput2);
618         libinput_destroy(li);
619
620         open_func_count = 0;
621         close_func_count = 0;
622 }
623 END_TEST
624
625 START_TEST(path_add_device_suspend_resume_remove_device)
626 {
627         struct libinput *li;
628         struct libinput_device *device;
629         struct libinput_event *event;
630         struct libevdev_uinput *uinput1, *uinput2;
631         int rc;
632         int nevents;
633         void *userdata = &rc;
634
635         uinput1 = litest_create_uinput_device("test device", NULL,
636                                               EV_KEY, BTN_LEFT,
637                                               EV_KEY, BTN_RIGHT,
638                                               EV_REL, REL_X,
639                                               EV_REL, REL_Y,
640                                               -1);
641         uinput2 = litest_create_uinput_device("test device 2", NULL,
642                                               EV_KEY, BTN_LEFT,
643                                               EV_KEY, BTN_RIGHT,
644                                               EV_REL, REL_X,
645                                               EV_REL, REL_Y,
646                                               -1);
647
648         li = libinput_path_create_context(&simple_interface, userdata);
649         ck_assert(li != NULL);
650
651         device = libinput_path_add_device(li,
652                                           libevdev_uinput_get_devnode(uinput1));
653         ck_assert(device != NULL);
654         device = libinput_path_add_device(li,
655                                           libevdev_uinput_get_devnode(uinput2));
656
657         libinput_device_ref(device);
658         libinput_dispatch(li);
659
660         nevents = 0;
661         while ((event = libinput_get_event(li))) {
662                 enum libinput_event_type type;
663                 type = libinput_event_get_type(event);
664                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_ADDED);
665                 libinput_event_destroy(event);
666                 nevents++;
667         }
668
669         ck_assert_int_eq(nevents, 2);
670
671
672         libinput_suspend(li);
673         libinput_dispatch(li);
674
675         nevents = 0;
676         while ((event = libinput_get_event(li))) {
677                 enum libinput_event_type type;
678                 type = libinput_event_get_type(event);
679                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_REMOVED);
680                 libinput_event_destroy(event);
681                 nevents++;
682         }
683
684         ck_assert_int_eq(nevents, 2);
685
686         /* now drop and remove one of the devices */
687         libevdev_uinput_destroy(uinput2);
688         libinput_path_remove_device(device);
689         libinput_device_unref(device);
690
691         rc = libinput_resume(li);
692         ck_assert_int_eq(rc, 0);
693
694         libinput_dispatch(li);
695
696         nevents = 0;
697         while ((event = libinput_get_event(li))) {
698                 enum libinput_event_type type;
699                 type = libinput_event_get_type(event);
700                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_ADDED);
701                 libinput_event_destroy(event);
702                 nevents++;
703         }
704
705         ck_assert_int_eq(nevents, 1);
706
707         libevdev_uinput_destroy(uinput1);
708         libinput_destroy(li);
709
710         open_func_count = 0;
711         close_func_count = 0;
712 }
713 END_TEST
714
715 START_TEST(path_seat_recycle)
716 {
717         struct libinput *li;
718         struct libevdev_uinput *uinput;
719         int rc;
720         void *userdata = &rc;
721         struct libinput_event *ev;
722         struct libinput_device *device;
723         struct libinput_seat *saved_seat = NULL;
724         struct libinput_seat *seat;
725         int data = 0;
726         int found = 0;
727         void *user_data;
728
729         uinput = litest_create_uinput_device("test device", NULL,
730                                              EV_KEY, BTN_LEFT,
731                                              EV_KEY, BTN_RIGHT,
732                                              EV_REL, REL_X,
733                                              EV_REL, REL_Y,
734                                              -1);
735
736         li = libinput_path_create_context(&simple_interface, userdata);
737         ck_assert(li != NULL);
738
739         device = libinput_path_add_device(li,
740                                           libevdev_uinput_get_devnode(uinput));
741         ck_assert(device != NULL);
742
743         libinput_dispatch(li);
744         while ((ev = libinput_get_event(li))) {
745                 switch (libinput_event_get_type(ev)) {
746                 case LIBINPUT_EVENT_DEVICE_ADDED:
747                         if (saved_seat)
748                                 break;
749
750                         device = libinput_event_get_device(ev);
751                         ck_assert(device != NULL);
752                         saved_seat = libinput_device_get_seat(device);
753                         libinput_seat_set_user_data(saved_seat, &data);
754                         libinput_seat_ref(saved_seat);
755                         break;
756                 default:
757                         break;
758                 }
759
760                 libinput_event_destroy(ev);
761         }
762
763         ck_assert(saved_seat != NULL);
764
765         libinput_suspend(li);
766
767         litest_drain_events(li);
768
769         libinput_resume(li);
770
771         libinput_dispatch(li);
772         while ((ev = libinput_get_event(li))) {
773                 switch (libinput_event_get_type(ev)) {
774                 case LIBINPUT_EVENT_DEVICE_ADDED:
775                         device = libinput_event_get_device(ev);
776                         ck_assert(device != NULL);
777
778                         seat = libinput_device_get_seat(device);
779                         user_data = libinput_seat_get_user_data(seat);
780                         if (user_data == &data) {
781                                 found = 1;
782                                 ck_assert(seat == saved_seat);
783                         }
784                         break;
785                 default:
786                         break;
787                 }
788
789                 libinput_event_destroy(ev);
790         }
791
792         ck_assert(found == 1);
793
794         libinput_destroy(li);
795
796         libevdev_uinput_destroy(uinput);
797 }
798 END_TEST
799
800 int main (int argc, char **argv) {
801
802         litest_add("path:create", path_create_NULL, LITEST_ANY, LITEST_ANY);
803         litest_add("path:create", path_create_invalid, LITEST_ANY, LITEST_ANY);
804         litest_add("path:create", path_create_destroy, LITEST_ANY, LITEST_ANY);
805         litest_add("path:suspend", path_suspend, LITEST_ANY, LITEST_ANY);
806         litest_add("path:suspend", path_double_suspend, LITEST_ANY, LITEST_ANY);
807         litest_add("path:suspend", path_double_resume, LITEST_ANY, LITEST_ANY);
808         litest_add("path:suspend", path_add_device_suspend_resume, LITEST_ANY, LITEST_ANY);
809         litest_add("path:suspend", path_add_device_suspend_resume_fail, LITEST_ANY, LITEST_ANY);
810         litest_add("path:suspend", path_add_device_suspend_resume_remove_device, LITEST_ANY, LITEST_ANY);
811         litest_add("path:seat events", path_added_seat, LITEST_ANY, LITEST_ANY);
812         litest_add("path:device events", path_added_device, LITEST_ANY, LITEST_ANY);
813         litest_add("path:device events", path_device_sysname, LITEST_ANY, LITEST_ANY);
814         litest_add("path:device events", path_add_device, LITEST_ANY, LITEST_ANY);
815         litest_add("path:device events", path_add_invalid_path, LITEST_ANY, LITEST_ANY);
816         litest_add("path:device events", path_remove_device, LITEST_ANY, LITEST_ANY);
817         litest_add("path:device events", path_double_remove_device, LITEST_ANY, LITEST_ANY);
818         litest_add("path:seat", path_seat_recycle,
819                    LITEST_DISABLE_DEVICE, LITEST_DISABLE_DEVICE);
820
821         return litest_run(argc, argv);
822 }