summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/hid
diff options
context:
space:
mode:
authorBenjamin Tissoires <bentiss@kernel.org>2024-07-23 19:21:52 +0300
committerBenjamin Tissoires <bentiss@kernel.org>2024-07-24 19:27:21 +0300
commitf64c1a4593391c57accf32693a14ef45f8162b5c (patch)
tree1934086f2f586eb84fd81be3997b10e1d22082e4 /tools/testing/selftests/hid
parentff9fbcafbaf13346c742c0d672a22f5ac20b9d92 (diff)
downloadlinux-f64c1a4593391c57accf32693a14ef45f8162b5c.tar.xz
selftests/hid: disable struct_ops auto-attach
Since commit 08ac454e258e ("libbpf: Auto-attach struct_ops BPF maps in BPF skeleton"), libbpf automatically calls bpf_map__attach_struct_ops() on every struct_ops it sees in the bpf object. The problem is that our test bpf object has many of them but only one should be manually loaded at a time, or we end up locking the syscall. Link: https://patch.msgid.link/20240723-fix-6-11-bpf-v1-2-b9d770346784@kernel.org Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
Diffstat (limited to 'tools/testing/selftests/hid')
-rw-r--r--tools/testing/selftests/hid/hid_bpf.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/testing/selftests/hid/hid_bpf.c b/tools/testing/selftests/hid/hid_bpf.c
index dc0408a831d0..9c935fd0dffc 100644
--- a/tools/testing/selftests/hid/hid_bpf.c
+++ b/tools/testing/selftests/hid/hid_bpf.c
@@ -532,6 +532,7 @@ static void load_programs(const struct test_program programs[],
FIXTURE_DATA(hid_bpf) * self,
const FIXTURE_VARIANT(hid_bpf) * variant)
{
+ struct bpf_map *iter_map;
int err = -EINVAL;
ASSERT_LE(progs_count, ARRAY_SIZE(self->hid_links))
@@ -564,6 +565,13 @@ static void load_programs(const struct test_program programs[],
*ops_hid_id = self->hid_id;
}
+ /* we disable the auto-attach feature of all maps because we
+ * only want the tested one to be manually attached in the next
+ * call to bpf_map__attach_struct_ops()
+ */
+ bpf_object__for_each_map(iter_map, *self->skel->skeleton->obj)
+ bpf_map__set_autoattach(iter_map, false);
+
err = hid__load(self->skel);
ASSERT_OK(err) TH_LOG("hid_skel_load failed: %d", err);