summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-07-25 09:38:46 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-07-27 19:00:43 +1000
commit6bb05c594a73cee2ed9cf62af88fdcab4011f57a (patch)
tree722299f95acbd886cb981cbc0b7299c08c56e07f /test
parent55d1bb1217388e99b9405654c14881a9ebf8f880 (diff)
downloadlibinput-6bb05c594a73cee2ed9cf62af88fdcab4011f57a.tar.gz
lid: disable all types but EV_SYN and EV_SW
The lid dispatch interface is a one-trick pony and can only handle SW_LID. It ignores other switches but crashes on any event type other than EV_SW and EV_SYN. Disable those types so we just ignore the event instead of asserting. https://bugs.freedesktop.org/show_bug.cgi?id=101853 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Diffstat (limited to 'test')
-rw-r--r--test/litest-device-gpio-keys.c75
-rw-r--r--test/litest.c2
-rw-r--r--test/litest.h1
-rw-r--r--test/test-lid.c20
4 files changed, 98 insertions, 0 deletions
diff --git a/test/litest-device-gpio-keys.c b/test/litest-device-gpio-keys.c
new file mode 100644
index 00000000..37b058c1
--- /dev/null
+++ b/test/litest-device-gpio-keys.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright © 2017 Red Hat, Inc
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "config.h"
+
+#include "litest.h"
+#include "litest-int.h"
+
+static void
+litest_gpio_keys_setup(void)
+{
+ struct litest_device *d = litest_create_device(LITEST_GPIO_KEYS);
+ litest_set_current_device(d);
+}
+
+static struct input_id input_id = {
+ .bustype = 0x19,
+ .vendor = 0x1,
+ .product = 0x1,
+};
+
+static int events[] = {
+ EV_SW, SW_LID,
+ EV_SW, SW_TABLET_MODE,
+ EV_KEY, KEY_POWER,
+ EV_KEY, KEY_VOLUMEUP,
+ EV_KEY, KEY_VOLUMEDOWN,
+ EV_KEY, KEY_POWER,
+ -1, -1,
+};
+
+static const char udev_rule[] =
+"ACTION==\"remove\", GOTO=\"switch_end\"\n"
+"KERNEL!=\"event*\", GOTO=\"switch_end\"\n"
+"\n"
+"ATTRS{name}==\"litest gpio-keys*\",\\\n"
+" ENV{ID_INPUT_SWITCH}=\"1\",\\\n"
+" ENV{LIBINPUT_ATTR_gpio_keys_RELIABILITY}=\"reliable\"\n"
+"\n"
+"LABEL=\"switch_end\"";
+
+struct litest_test_device litest_gpio_keys_device = {
+ .type = LITEST_GPIO_KEYS,
+ .features = LITEST_SWITCH,
+ .shortname = "gpio keys",
+ .setup = litest_gpio_keys_setup,
+ .interface = NULL,
+
+ .name = "gpio-keys",
+ .id = &input_id,
+ .events = events,
+ .absinfo = NULL,
+
+ .udev_rule = udev_rule,
+};
diff --git a/test/litest.c b/test/litest.c
index ec4683a5..c33ba759 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -414,6 +414,7 @@ extern struct litest_test_device litest_mouse_wheel_tilt_device;
extern struct litest_test_device litest_lid_switch_device;
extern struct litest_test_device litest_lid_switch_surface3_device;
extern struct litest_test_device litest_appletouch_device;
+extern struct litest_test_device litest_gpio_keys_device;
struct litest_test_device* devices[] = {
&litest_synaptics_clickpad_device,
@@ -479,6 +480,7 @@ struct litest_test_device* devices[] = {
&litest_lid_switch_device,
&litest_lid_switch_surface3_device,
&litest_appletouch_device,
+ &litest_gpio_keys_device,
NULL,
};
diff --git a/test/litest.h b/test/litest.h
index abe6ca0b..4416bbc2 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -234,6 +234,7 @@ enum litest_device_type {
LITEST_LID_SWITCH,
LITEST_LID_SWITCH_SURFACE3,
LITEST_APPLETOUCH,
+ LITEST_GPIO_KEYS,
};
enum litest_device_feature {
diff --git a/test/test-lid.c b/test/test-lid.c
index 4bf4c059..b5d3d586 100644
--- a/test/test-lid.c
+++ b/test/test-lid.c
@@ -555,6 +555,24 @@ START_TEST(lid_update_hw_on_key_closed_on_init)
}
END_TEST
+START_TEST(lid_key_press)
+{
+ struct litest_device *sw = litest_current_device();
+ struct libinput *li = sw->libinput;
+
+ litest_drain_events(li);
+
+ litest_keyboard_key(sw, KEY_POWER, true);
+ litest_keyboard_key(sw, KEY_POWER, false);
+ libinput_dispatch(li);
+
+ /* We should route the key events correctly, but for now we just
+ * ignore them. This test will fail once the key events are handled
+ * correctly. */
+ litest_assert_empty_queue(li);
+}
+END_TEST
+
void
litest_setup_tests_lid(void)
{
@@ -576,4 +594,6 @@ litest_setup_tests_lid(void)
litest_add_for_device("lid:buggy", lid_update_hw_on_key, LITEST_LID_SWITCH_SURFACE3);
litest_add_for_device("lid:buggy", lid_update_hw_on_key_closed_on_init, LITEST_LID_SWITCH_SURFACE3);
+
+ litest_add_for_device("lid:keypress", lid_key_press, LITEST_GPIO_KEYS);
}