selftests/bpf: Test cgroup_iter.
authorHao Luo <haoluo@google.com>
Wed, 24 Aug 2022 23:31:14 +0000 (16:31 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 25 Aug 2022 18:35:37 +0000 (11:35 -0700)
commitfe0dd9d4b7402c9773fc7a453fa65875abaa24ec
treea2e9b98b65debf547ea106b5f7a9d82c4351ae0a
parentd4ccaf58a8472123ac97e6db03932c375b5c45ba
selftests/bpf: Test cgroup_iter.

Add a selftest for cgroup_iter. The selftest creates a mini cgroup tree
of the following structure:

    ROOT (working cgroup)
     |
   PARENT
  /      \
CHILD1  CHILD2

and tests the following scenarios:

 - invalid cgroup fd.
 - pre-order walk over descendants from PARENT.
 - post-order walk over descendants from PARENT.
 - walk of ancestors from PARENT.
 - process only a single object (i.e. PARENT).
 - early termination.

Acked-by: Yonghong Song <yhs@fb.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Hao Luo <haoluo@google.com>
Link: https://lore.kernel.org/r/20220824233117.1312810-3-haoluo@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/btf_dump.c
tools/testing/selftests/bpf/prog_tests/cgroup_iter.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/bpf_iter.h
tools/testing/selftests/bpf/progs/cgroup_iter.c [new file with mode: 0644]