[RFC,hid,v1,09/10] selftests: hid: ensure the program is correctly pinned
Commit Message
Turns out that if bpffs was not mounted, the test was silently passing.
So ensure it passes, but also force the mount of the bpffs in vmtest.sh
so we get passing results.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
tools/testing/selftests/hid/hid_bpf.c | 3 ++-
tools/testing/selftests/hid/vmtest.sh | 4 +++-
2 files changed, 5 insertions(+), 2 deletions(-)
@@ -712,7 +712,8 @@ TEST_F(hid_bpf, test_attach_detach)
/* pin the 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);
@@ -108,8 +108,10 @@ EOF
if [[ "${debug_shell}" != "yes" ]]
then
touch ${OUTPUT_DIR}/${LOG_FILE}
- command="set -o pipefail ; ${command} 2>&1 | tee ${OUTPUT_DIR}/${LOG_FILE}"
+ command="mount bpffs -t bpf /sys/fs/bpf/; set -o pipefail ; ${command} 2>&1 | tee ${OUTPUT_DIR}/${LOG_FILE}"
post_command="cat ${OUTPUT_DIR}/${LOG_FILE}"
+ else
+ command="mount bpffs -t bpf /sys/fs/bpf/; ${command}"
fi
set +e