diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2017-01-13 11:46:38 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2017-01-20 10:35:43 +1000 |
commit | 7c6784dd81974a89be49f9fa680fc68aad8a275f (patch) | |
tree | 24cef58d39ca48203eee72468e88d94c702aa360 /test/test-udev.c | |
parent | 0a34ed409e29c673d1ce6b63336f7a56f624b6ea (diff) | |
download | libinput-7c6784dd81974a89be49f9fa680fc68aad8a275f.tar.gz |
test: add test for invalid path operations on udev backends
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'test/test-udev.c')
-rw-r--r-- | test/test-udev.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/test-udev.c b/test/test-udev.c index ba6a10d9..18627663 100644 --- a/test/test-udev.c +++ b/test/test-udev.c @@ -506,6 +506,60 @@ START_TEST(udev_seat_recycle) } END_TEST +START_TEST(udev_path_add_device) +{ + struct udev *udev; + struct libinput *li; + struct libinput_device *device; + + udev = udev_new(); + ck_assert(udev != NULL); + + li = libinput_udev_create_context(&simple_interface, NULL, udev); + ck_assert(li != NULL); + ck_assert_int_eq(libinput_udev_assign_seat(li, "seat0"), 0); + + litest_set_log_handler_bug(li); + device = libinput_path_add_device(li, "/dev/input/event0"); + ck_assert(device == NULL); + litest_restore_log_handler(li); + + libinput_unref(li); + udev_unref(udev); +} +END_TEST + +START_TEST(udev_path_remove_device) +{ + struct udev *udev; + struct libinput *li; + struct libinput_device *device; + struct libinput_event *event; + + udev = udev_new(); + ck_assert(udev != NULL); + + li = libinput_udev_create_context(&simple_interface, NULL, udev); + ck_assert(li != NULL); + ck_assert_int_eq(libinput_udev_assign_seat(li, "seat0"), 0); + libinput_dispatch(li); + + litest_wait_for_event_of_type(li, LIBINPUT_EVENT_DEVICE_ADDED, -1); + event = libinput_get_event(li); + device = libinput_event_get_device(event); + ck_assert(device != NULL); + + /* no effect bug a bug log msg */ + litest_set_log_handler_bug(li); + libinput_path_remove_device(device); + litest_restore_log_handler(li); + + libinput_event_destroy(event); + libinput_unref(li); + udev_unref(udev); +} +END_TEST + void litest_setup_tests_udev(void) { @@ -522,4 +576,7 @@ litest_setup_tests_udev(void) litest_add_for_device("udev:suspend", udev_suspend_resume, LITEST_SYNAPTICS_CLICKPAD_X220); litest_add_for_device("udev:device events", udev_device_sysname, LITEST_SYNAPTICS_CLICKPAD_X220); litest_add_for_device("udev:seat", udev_seat_recycle, LITEST_SYNAPTICS_CLICKPAD_X220); + + litest_add_no_device("udev:path", udev_path_add_device); + litest_add_for_device("udev:path", udev_path_remove_device, LITEST_SYNAPTICS_CLICKPAD_X220); } |