test: fix uinput creation for the slotted devices with too many slots
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 14 Oct 2024 09:29:15 +0000 (19:29 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 14 Oct 2024 23:56:19 +0000 (09:56 +1000)
Kernel commit 206f533a0a7c
       "Input: uinput - reject requests with unreasonable number of slots"
limits the number of slots to 99 - let's manually adjust that so we can
keep creating uinput devices.

Since these are just a test device and we don't use the slots here
anyway (they're all fake MT devices) we can manually work around this.
The real devices won't be affected by this since this is a limitation
in uinput, not the input subsystem.

Also move the comment one line up in the ms-surface device, the previous
comment referred to the wrong event code.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1061>

test/litest-device-anker-mouse-kbd.c
test/litest-device-keyboard-razer-blackwidow.c
test/litest-device-keyboard-razer-blade-stealth.c
test/litest-device-ms-surface-cover.c
test/litest.c

index ef515364ccbb5d6e7aa573f633f0bd07baf343d7..1e315e3eafbc419d5ffc12fbc8eab16f065d3faa 100644 (file)
@@ -193,7 +193,10 @@ static struct input_absinfo absinfo[] = {
        { 0x2c, 0, 255, 0, 0, 0 },
        { 0x2d, 0, 255, 0, 0, 0 },
        { 0x2e, 0, 255, 0, 0, 0 },
-       { ABS_MT_SLOT, 0, 255, 0, 0, 0 },
+       /* Note: slot count artificially reduced for kernel
+        * commit 206f533a0a7c ("Input: uinput - reject requests with unreasonable number of slots")
+        */
+       { ABS_MT_SLOT, 0, 64, 0, 0, 0 },
        { ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0, 0 },
        { ABS_MT_TOUCH_MINOR, 0, 255, 0, 0, 0 },
        { ABS_MT_WIDTH_MINOR, 0, 255, 0, 0, 0 },
index 5dee7f469afdd745d3c077df674af17bf6fca987..5585ea4633d86d6003b63099ec84c55b90eccc71 100644 (file)
@@ -309,7 +309,10 @@ static struct input_absinfo absinfo[] = {
        { 0x2c, 0, 255, 0, 0, 0 },
        { 0x2d, 0, 255, 0, 0, 0 },
        { 0x2e, 0, 255, 0, 0, 0 },
-       { 0x2f, 0, 255, 0, 0, 0 },
+       /* Note: slot count artificially reduced for kernel
+        * commit 206f533a0a7c ("Input: uinput - reject requests with unreasonable number of slots")
+        */
+       { 0x2f, 0, 64, 0, 0, 0 },
        { 0x30, 0, 255, 0, 0, 0 },
        { 0x31, 0, 255, 0, 0, 0 },
        { 0x32, 0, 255, 0, 0, 0 },
index b08ee43365c536413508caf07fd64c37f173844f..b27af149a2f455e7780df1ed273aa7879015eaaa 100644 (file)
@@ -307,7 +307,10 @@ static struct input_absinfo absinfo[] = {
        { 0x2c, 0, 255, 0, 0, 0 },
        { 0x2d, 0, 255, 0, 0, 0 },
        { 0x2e, 0, 255, 0, 0, 0 },
-       { 0x2f, 0, 255, 0, 0, 0 },
+       /* Note: slot count artificially reduced for kernel
+        * commit 206f533a0a7c ("Input: uinput - reject requests with unreasonable number of slots")
+        */
+       { 0x2f, 0, 64, 0, 0, 0 },
        { 0x30, 0, 255, 0, 0, 0 },
        { 0x31, 0, 255, 0, 0, 0 },
        { 0x32, 0, 255, 0, 0, 0 },
index 3114721139128bd42bc60cc9b9a799475b6594e0..77306fb5aafd4fa7aa8098aab4362b2f0b61b2dd 100644 (file)
@@ -63,9 +63,12 @@ static struct input_absinfo absinfo[] = {
        { 44, -127, 127, 0, 0, 0 },
        { 45, -127, 127, 0, 0, 0 },
        { 46, -127, 127, 0, 0, 0 },
-       { 47, -127, 127, 0, 0, 0 },
        /* ABS_MT range overlap starts here */
-       { 48, -127, 127, 0, 0, 0 }, /* ABS_MT_SLOT */
+       /* Note: slot count artificially reduced for kernel
+        * commit 206f533a0a7c ("Input: uinput - reject requests with unreasonable number of slots")
+        */
+       { 47, 0, 64, 0, 0, 0 }, /* ABS_MT_SLOT */
+       { 48, -127, 127, 0, 0, 0 },
        { 49, -127, 127, 0, 0, 0 },
        { 50, -127, 127, 0, 0, 0 },
        { 51, -127, 127, 0, 0, 0 },
index 5c0c9070f45d5fa0824117494e03edb5352f950b..7e6339b51b58250353ad3e4a4c1c5648049a0e20 100644 (file)
@@ -3451,6 +3451,15 @@ litest_create_uinput(const char *name,
                .flat = 0,
                .resolution = 100
        };
+       /* See kernel commit 206f533a0a7c ("Input: uinput - reject requests with unreasonable number of slots") */
+       const struct input_absinfo default_abs_mt_slot = {
+               .value = 0,
+               .minimum = 0,
+               .maximum = 64,
+               .fuzz = 0,
+               .flat = 0,
+               .resolution = 100
+       };
        char buf[512];
 
        dev = libevdev_new();
@@ -3483,8 +3492,10 @@ litest_create_uinput(const char *name,
                if (type == INPUT_PROP_MAX) {
                        rc = libevdev_enable_property(dev, code);
                } else {
+                       const struct input_absinfo *abs =
+                               (code == ABS_MT_SLOT) ? &default_abs_mt_slot : &default_abs;
                        rc = libevdev_enable_event_code(dev, type, code,
-                                                       type == EV_ABS ? &default_abs : NULL);
+                                                       type == EV_ABS ? abs : NULL);
                }
                litest_assert_int_eq(rc, 0);
        }