selftests: hid: ensure the program is correctly pinned
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Fri, 13 Jan 2023 09:09:30 +0000 (10:09 +0100)
committerJiri Kosina <jkosina@suse.cz>
Wed, 18 Jan 2023 21:08:38 +0000 (22:08 +0100)
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>
tools/testing/selftests/hid/hid_bpf.c

index d215bb492eb492a51de9975f76d5f39001d74763..3b204a15e44be8bed2843624cbed401bbcd6b433 100644 (file)
@@ -640,7 +640,8 @@ TEST_F(hid_bpf, test_attach_detach)
 
        /* pin the first program and immediately unpin it */
 #define PIN_PATH "/sys/fs/bpf/hid_first_event"
-       bpf_program__pin(self->skel->progs.hid_first_event, PIN_PATH);
+       err = bpf_program__pin(self->skel->progs.hid_first_event, PIN_PATH);
+       ASSERT_OK(err) TH_LOG("error while calling bpf_program__pin");
        remove(PIN_PATH);
 #undef PIN_PATH
        usleep(100000);