The BPF testing framework has evolved significantly over time. However, some legacy tests in the samples/bpf directory have not kept up with these changes. These outdated tests can cause confusion and increase maintenance efforts.
This patchset focuses on migrating outdated cgroup and tracing-related tests from samples/bpf to selftests/bpf, ensuring the BPF test suite remains current and efficient. Tests that are already covered by selftests/bpf are removed, while those not yet covered are migrated. This includes cgroup sock create tests for setting socket attributes and blocking socket creation, as well as the removal of redundant cgroup and tracing tests that have been replaced by newer tests.
This patchset covers the following cgroup/tracing tests: - test_overhead: tests the overhead of BPF programs with task_rename, now covered by selftests and benchmark tests (rename-*). [1]
- test_override_return: tests the return override functionality, now handled by kprobe_multi_override in selftests.
- test_probe_write_user: tests the probe_write_user functionality, now replaced by the probe_user test in selftests.
- test_cgrp2_sock: tests cgroup BPF's ability to set sk_bound_dev_if, mark, and priority during socket creation. Migrated to selftests as 'sock_create' since no existing tests fully cover this.
- test_cgrp2_sock2: tests blocking socket creation for specific types (AF_INET{6}, SOCK_DGRAM, IPPROTO_ICMP{V6}). Migrated to selftests in 'sock_create' test for coverage.
- test_current_task_under_cgroup: tests bpf_current_task_under_cgroup() to check if a task belongs to a cgroup. Already covered by task_under_cgroup at selftest and other cgroup ID tests.
- test_cgrp2_tc: tests bpf_skb_under_cgroup() to filter packets based on cgroup. This behavior is now validated by cgroup_skb_sk_lookup, which uses bpf_skb_cgroup_id, making this test redundant.
Daniel T. Lee (4): selftests/bpf: migrate cgroup sock create test for setting iface/mark/prio selftests/bpf: migrate sock create tests for prohibitig sockets samples/bpf: remove obsolete cgroup related tests samples/bpf: remove obsolete tracing related tests
samples/bpf/Makefile | 24 -- samples/bpf/sock_flags.bpf.c | 47 --- samples/bpf/test_cgrp2_array_pin.c | 106 ------ samples/bpf/test_cgrp2_attach.c | 177 ---------- samples/bpf/test_cgrp2_sock.c | 296 ---------------- samples/bpf/test_cgrp2_sock.sh | 137 ------- samples/bpf/test_cgrp2_sock2.c | 95 ----- samples/bpf/test_cgrp2_sock2.sh | 103 ------ samples/bpf/test_cgrp2_tc.bpf.c | 56 --- samples/bpf/test_cgrp2_tc.sh | 187 ---------- .../bpf/test_current_task_under_cgroup.bpf.c | 43 --- .../bpf/test_current_task_under_cgroup_user.c | 115 ------ samples/bpf/test_overhead_kprobe.bpf.c | 41 --- samples/bpf/test_overhead_raw_tp.bpf.c | 17 - samples/bpf/test_overhead_tp.bpf.c | 23 -- samples/bpf/test_overhead_user.c | 225 ------------ samples/bpf/test_override_return.sh | 16 - samples/bpf/test_probe_write_user.bpf.c | 52 --- samples/bpf/test_probe_write_user_user.c | 108 ------ samples/bpf/tracex7.bpf.c | 15 - samples/bpf/tracex7_user.c | 56 --- .../selftests/bpf/prog_tests/sock_create.c | 333 ++++++++++++++++++ 22 files changed, 333 insertions(+), 1939 deletions(-) delete mode 100644 samples/bpf/sock_flags.bpf.c delete mode 100644 samples/bpf/test_cgrp2_array_pin.c delete mode 100644 samples/bpf/test_cgrp2_attach.c delete mode 100644 samples/bpf/test_cgrp2_sock.c delete mode 100755 samples/bpf/test_cgrp2_sock.sh delete mode 100644 samples/bpf/test_cgrp2_sock2.c delete mode 100755 samples/bpf/test_cgrp2_sock2.sh delete mode 100644 samples/bpf/test_cgrp2_tc.bpf.c delete mode 100755 samples/bpf/test_cgrp2_tc.sh delete mode 100644 samples/bpf/test_current_task_under_cgroup.bpf.c delete mode 100644 samples/bpf/test_current_task_under_cgroup_user.c delete mode 100644 samples/bpf/test_overhead_kprobe.bpf.c delete mode 100644 samples/bpf/test_overhead_raw_tp.bpf.c delete mode 100644 samples/bpf/test_overhead_tp.bpf.c delete mode 100644 samples/bpf/test_overhead_user.c delete mode 100755 samples/bpf/test_override_return.sh delete mode 100644 samples/bpf/test_probe_write_user.bpf.c delete mode 100644 samples/bpf/test_probe_write_user_user.c delete mode 100644 samples/bpf/tracex7.bpf.c delete mode 100644 samples/bpf/tracex7_user.c create mode 100644 tools/testing/selftests/bpf/prog_tests/sock_create.c
-- 2.43.0