selftests/bpf: convert test_skb_cgroup_id_user to test_progs
authorAlexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
Tue, 13 Aug 2024 12:45:08 +0000 (14:45 +0200)
committerMartin KaFai Lau <martin.lau@kernel.org>
Thu, 15 Aug 2024 01:49:57 +0000 (18:49 -0700)
commitf957c230e173cf227566686015016d05f7102d27
treeb1cc3df35b3f5a2e4ef885a20b7e23c75f60fff7
parent7b4400a0a69b8255a2afed0bead0ce2c2c457545
selftests/bpf: convert test_skb_cgroup_id_user to test_progs

test_skb_cgroup_id_user allows testing skb cgroup id retrieval at different
levels, but is not integrated in test_progs, so it is not run
automatically in CI. The test overlaps a bit with
cgroup_skb_sk_lookup_kern, which is integrated in test_progs and test
extensively skb cgroup helpers, but there is still one major difference
between the two tests which justifies the conversion:
cgroup_skb_sk_lookup_kern deals with a BPF_PROG_TYPE_CGROUP_SKB (attached
on a cgroup), while test_skb_cgroup_id_user deals with a
BPF_PROG_TYPE_SCHED_CLS (attached on a qdisc)

Convert test_skb_cgroup_id_user into test_progs framework in order to run
it automatically in CI. The main differences with the original test are the
following:
- rename the test to make it shorter and more straightforward regarding
  tested feature
- the wrapping shell script has been dropped since every setup step is now
  handled in the main C test file
- the test has been renamed for a shorter name and reflecting the tested
  API
- add dedicated assert log per level to ease test failure debugging
- use global variables instead of maps to access bpf prog data

Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
Link: https://lore.kernel.org/r/20240813-convert_cgroup_tests-v4-4-a33c03458cf6@bootlin.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
tools/testing/selftests/bpf/.gitignore
tools/testing/selftests/bpf/Makefile
tools/testing/selftests/bpf/prog_tests/cgroup_ancestor.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/cgroup_ancestor.c
tools/testing/selftests/bpf/test_skb_cgroup_id.sh [deleted file]
tools/testing/selftests/bpf/test_skb_cgroup_id_user.c [deleted file]