selftests: add tests for the HID-bpf initial implementation
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Thu, 3 Nov 2022 15:57:45 +0000 (16:57 +0100)
committerJiri Kosina <jkosina@suse.cz>
Tue, 15 Nov 2022 15:28:29 +0000 (16:28 +0100)
commitdbb60c8a26daf388f183f599e1e96de5bb9f96e1
treeb813c4021e3b8b68e2a86f30c8c619ce249293ca
parentf5c27da4e3c8a2e42fb4f41a0c685debcb9af294
selftests: add tests for the HID-bpf initial implementation

The tests are pretty basic:
- create a virtual uhid device that no userspace will like (to not mess
  up the running system)
- attach a BPF prog to it
- open the matching hidraw node
- inject one event and check:
  * that the BPF program can do something on the event stream
  * can modify the event stream
- add another test where we attach/detach BPF programs to see if we get
  errors

Note: the Makefile is extracted from selftests/bpf so we can rebuild
the libbpf and bpftool components from the current kernel tree without
relying on system installed components.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
MAINTAINERS
tools/testing/selftests/Makefile
tools/testing/selftests/hid/.gitignore [new file with mode: 0644]
tools/testing/selftests/hid/Makefile [new file with mode: 0644]
tools/testing/selftests/hid/config [new file with mode: 0644]
tools/testing/selftests/hid/hid_bpf.c [new file with mode: 0644]
tools/testing/selftests/hid/progs/hid.c [new file with mode: 0644]
tools/testing/selftests/hid/progs/hid_bpf_helpers.h [new file with mode: 0644]