summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/hid
AgeCommit message (Collapse)AuthorFilesLines
2023-02-23selftest: hid: fix hid_bpf not set in configBenjamin Tissoires1-0/+1
Now that CONFIG_HID_BPF is not automatically implied by HID, we need to set it properly in the selftests config. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-01-19selftests: hid: enforce new attach APIBenjamin Tissoires1-5/+1
Now that the new API for hid_bpf_attach_prog() is in place, ensure we get an fd when calling this function. And remove the fallback code. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-01-19selftests: hid: prepare tests for HID_BPF API changeBenjamin Tissoires1-4/+25
We plan on changing the return value of hid_bpf_attach_prog(). Instead of returning an error code, it will return an fd to a bpf_link. This bpf_link is responsible for the binding between the bpf program and the hid device. Add a fallback mechanism to not break bisections by pinning the program when we run this test against the non changed kernel. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-01-19selftests: hid: ensure the program is correctly pinnedBenjamin Tissoires1-1/+2
Turns out that if bpffs was not mounted, the test was silently passing. So ensure it passes by checking the mount command result. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-01-19selftests: hid: attach/detach 2 bpf programs, not just oneBenjamin Tissoires2-1/+20
Add a second BPF program to attach to the device, as the development of this feature showed that we also need to ensure we can detach multiple programs to a device (hid_bpf_link->hid_table_index was actually not set initially, and this lead to any BPF program not being released except for the first one). Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-01-19selftests: hid: allow to compile hid_bpf with LLVMBenjamin Tissoires1-5/+5
clang doesn't like to compile a source to the final binary directly: clang-14: error: cannot specify -o when generating multiple output files So split the final rule in 2, and ensure we compile all dependencies before. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-01-19selftests: hid: add vmtest.shBenjamin Tissoires4-0/+530
Similar-ish in many points from the script in selftests/bpf, with a few differences: - relies on boot2container instead of a plain qemu image (meaning that we can take any container in a registry as a base) - runs in the hid selftest dir, and such uses the test program from there - the working directory to store the config is in tools/selftests/hid/results Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-12-10kselftests: hid: fix missing headers_install stepBenjamin Tissoires1-14/+12
The Makefile was assuming that headers_install was already done in the top source directory, and was searching for installed uapi headers there. Unfortunately this is not the case and we need to manually call that step. To do so, reorder the declaration of the variables, and reuses top_srcdir provided by lib.mk Reported-by: kernel test robot <lkp@intel.com> Link: https://lore.kernel.org/all/202212060216.a6X8Py5H-lkp@intel.com/#t Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Reviewed-by: Jiri Kosina <jkosina@suse.cz> Link: https://lore.kernel.org/r/20221206145936.922196-6-benjamin.tissoires@redhat.com
2022-12-10selftests: hid: ensures we have the proper requirements in configBenjamin Tissoires1-0/+1
DYNAMIC_FTRACE_WITH_DIRECT_CALLS is implicit on x86_64 but is still a WIP on aarm64. Ensure we get it selected to not have any surprises. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Reviewed-by: Jiri Kosina <jkosina@suse.cz> Link: https://lore.kernel.org/r/20221206145936.922196-5-benjamin.tissoires@redhat.com
2022-11-15selftests/hid: Add a test for BPF_F_INSERT_HEADBenjamin Tissoires2-1/+97
Insert 3 programs to check that we are doing the correct thing: '2', '1', '3' are inserted, but '1' is supposed to be executed first. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-11-15selftests/hid: add report descriptor fixup testsBenjamin Tissoires2-0/+85
Simple report descriptor override in HID: replace part of the report descriptor from a static definition in the bpf kernel program. Note that this test should be run last because we disconnect/reconnect the device, meaning that it changes the overall uhid device. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-11-15selftests/hid: add tests for bpf_hid_hw_requestBenjamin Tissoires3-1/+98
Add tests for the newly implemented function. We test here only the GET_REPORT part because the other calls are pure HID protocol and won't infer the result of the test of the bpf hook. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-11-15selftests/hid: add test to change the report sizeBenjamin Tissoires2-1/+55
Use a different report with a bigger size and ensures we are doing things properly. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-11-15selftests: add tests for the HID-bpf initial implementationBenjamin Tissoires6-0/+987
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>