#
ae7487d11 |
|
05-Oct-2023 |
Benjamin Tissoires <bentiss@kernel.org> |
selftests/hid: ensure we can compile the tests on kernels pre-6.3 For the hid-bpf tests to compile, we need to have the definition of struct hid_bpf_ctx. This definition is an internal one from the kernel and it is supposed to be defined in the generated vmlinux.h. This vmlinux.h header is generated based on the currently running kernel or if the kernel was already compiled in the tree. If you just compile the selftests without compiling the kernel beforehand and you are running on a 6.2 kernel, you'll end up with a vmlinux.h without the hid_bpf_ctx definition. Use the clever trick from tools/testing/selftests/bpf/progs/bpf_iter.h to force the definition of that symbol in case we don't find it in the BTF and also add __attribute__((preserve_access_index)) to further support CO-RE functionality for these tests. Signed-off-by: Justin Stitt <justinstitt@google.com> Tested-by: Nick Desaulniers <ndesaulniers@google.com> # Build Tested-by: Justin Stitt <justinstitt@google.com> Link: https://lore.kernel.org/r/20230825-wip-selftests-v3-1-639963c54109@kernel.org Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
|
#
cea6c4d9 |
|
13-Jan-2023 |
Benjamin Tissoires <benjamin.tissoires@redhat.com> |
selftests: hid: attach/detach 2 bpf programs, not just one 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>
|
#
80e189f2 |
|
03-Nov-2022 |
Benjamin Tissoires <benjamin.tissoires@redhat.com> |
selftests/hid: Add a test for BPF_F_INSERT_HEAD 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>
|
#
e8445737 |
|
03-Nov-2022 |
Benjamin Tissoires <benjamin.tissoires@redhat.com> |
selftests/hid: add report descriptor fixup tests 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>
|
#
4f7153cf |
|
03-Nov-2022 |
Benjamin Tissoires <benjamin.tissoires@redhat.com> |
selftests/hid: add tests for bpf_hid_hw_request 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>
|
#
0330f725 |
|
03-Nov-2022 |
Benjamin Tissoires <benjamin.tissoires@redhat.com> |
selftests/hid: add test to change the report size 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>
|
#
dbb60c8a |
|
03-Nov-2022 |
Benjamin Tissoires <benjamin.tissoires@redhat.com> |
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>
|