summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-05-04 14:50:31 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-05-05 12:50:57 +1000
commit8dcd71b3951bdd105c5782fbb319b5456ca70db8 (patch)
tree36d8c117849d28f7def264ab899336e1c16cac02 /test
parent9d1fdb0c6deacf11bfa2e32a56ff2ce0df2291c1 (diff)
lid: remove the keyboard listener on remove and re-init the listener
If the event listener is added, then removed again on a lid switch on/off event, the list is set to null. This can trigger two crashes: * when the keyboard is removed first, the call to libinput_device_remove_event_listener() dereferences the null pointer * when the switch is removed first, the call to device_destroy will find a remaining event listener and assert https://bugzilla.redhat.com/show_bug.cgi?id=1440927 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'test')
-rw-r--r--test/test-lid.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/test-lid.c b/test/test-lid.c
index 6b2fa3c..258f8e3 100644
--- a/test/test-lid.c
+++ b/test/test-lid.c
@@ -407,6 +407,35 @@ START_TEST(lid_open_on_key_touchpad_enabled)
}
END_TEST
+START_TEST(lid_suspend_with_keyboard)
+{
+ struct libinput *li;
+ struct litest_device *keyboard;
+ struct litest_device *sw;
+
+ li = litest_create_context();
+
+ sw = litest_add_device(li, LITEST_LID_SWITCH);
+ libinput_dispatch(li);
+
+ keyboard = litest_add_device(li, LITEST_KEYBOARD);
+ libinput_dispatch(li);
+
+ litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON);
+ litest_drain_events(li);
+ litest_lid_action(sw, LIBINPUT_SWITCH_STATE_OFF);
+ litest_drain_events(li);
+
+ litest_delete_device(keyboard);
+ litest_drain_events(li);
+
+ litest_delete_device(sw);
+ libinput_dispatch(li);
+
+ libinput_unref(li);
+}
+END_TEST
+
START_TEST(lid_suspend_with_touchpad)
{
struct libinput *li;
@@ -493,6 +522,7 @@ litest_setup_tests_lid(void)
litest_add("lid:keyboard", lid_open_on_key, LITEST_SWITCH, LITEST_ANY);
litest_add("lid:keyboard", lid_open_on_key_touchpad_enabled, LITEST_SWITCH, LITEST_ANY);
+ litest_add_no_device("lid:keyboard", lid_suspend_with_keyboard);
litest_add_no_device("lid:disable_touchpad", lid_suspend_with_touchpad);
litest_add_for_device("lid:buggy", lid_update_hw_on_key, LITEST_LID_SWITCH_SURFACE3);