Skip to contentSkip to conversation

selftests/input: Introduce basic tests for evdev ioctls

PATCH New Enric Balletbo i Serra 1 participant 1 message Jun 7, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 selftests/input: Introduce basic tests for evdev ioctls

This provides a basic infrastructure for the creation of tests for the evdev interface. Most of this code is adapted from the libevdev wrapper library. While most of evdev ioctls are covered and tested using libevdev tests there are some evdev ioctls that aren't because are not supported (and will not be supported) by libevdev [1]. So, adding, at least those tests, would make sense.

The test creates an uinput device (and an evdev device) so you can call the wanted ioctl from userspace. So, to run those tests you need to have support for uinput and evdev as well.

[1] For example, libevdev doesn't support setting EV_REP because it's inherently racy - one libevdev context to set those values via the ioctl would cause all other libevdev contexts on the same device to be out of sync. Since we do not get notifications when the values changed, libevdev's buffered values for EV_REP will remain whatever they were initially.

---
Test output:

TAP version 13
1..3
# Starting 3 tests from 1 test cases.
# RUN global.eviocgname_get_device_name ...
# OK global.eviocgname_get_device_name
ok 1 global.eviocgname_get_device_name
# RUN global.eviocgrep_get_repeat_settings ...
# OK global.eviocgrep_get_repeat_settings
ok 2 global.eviocgrep_get_repeat_settings
# RUN global.eviocsrep_set_repeat_settings ...
# OK global.eviocsrep_set_repeat_settings
ok 3 global.eviocsrep_set_repeat_settings
# PASSED: 3 / 3 tests passed.
# Totals: pass:3 fail:0 xfail:0 xpass:0 skip:0 error:0

Changes since v1:
- As UI_GET_SYSNAME has been around 3.15 remove the fallback code that pre-dates that ioctl.
- Fix a bug in the va-args handling in selftest_uinput_create_device calls.
- Fix typo s/an/and
- Implement a test case for EVIOCSREP.

Changes since v2:
- Fix a buf left in the va-args handling in selftest_uinput_create_device calls.
- Replace fetch_syspath_and_devnode() function to open_devnode() function that return the openend file descriptor, so we can reduce the code.

 tools/testing/selftests/Makefile           |   1 +
 tools/testing/selftests/input/.gitignore   |   2 +
 tools/testing/selftests/input/Makefile     |   5 +
 tools/testing/selftests/input/config       |   3 +
 tools/testing/selftests/input/evioc-test.c | 237 +++++++++++++++++++++
 5 files changed, 248 insertions(+)
 create mode 100644 tools/testing/selftests/input/.gitignore
 create mode 100644 tools/testing/selftests/input/Makefile
 create mode 100644 tools/testing/selftests/input/config
 create mode 100644 tools/testing/selftests/input/evioc-test.c
tools/testing/selftests/Makefile +1 -0
index 90a62cf75008..29fc77168aa7 100644
@@ -28,6 +28,7 @@ TARGETS += futex
 TARGETS += gpio
 TARGETS += hid
 TARGETS += intel_pstate
+TARGETS += input
 TARGETS += iommu
 TARGETS += ipc
 TARGETS += ir
tools/testing/selftests/input/.gitignore new file +2 -0
new file mode 100644
index 000000000000..37f5dff3255b
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+evioc-test
tools/testing/selftests/input/Makefile new file +5 -0
new file mode 100644
index 000000000000..031729be0628
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+CFLAGS +=  -D_GNU_SOURCE -std=gnu99 -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
+
+TEST_GEN_PROGS := evioc-test
+include ../lib.mk
tools/testing/selftests/input/config new file +3 -0
new file mode 100644
index 000000000000..b7512f3e6d8d
@@ -0,0 +1,3 @@
+CONFIG_INPUT=y
+CONFIG_INPUT_EVDEV=y
+CONFIG_INPUT_UINPUT=m
tools/testing/selftests/input/evioc-test.c new file +237 -0

237 lines not on this page · raw message

Signature · 1 line
2.40.1