selftests/bpf: Add more test case for field flattening
authorHou Tao <houtao1@huawei.com>
Tue, 8 Oct 2024 07:11:14 +0000 (15:11 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 9 Oct 2024 23:32:47 +0000 (16:32 -0700)
commitc456f08040589a5096481277c83168a4e7ae7ed7
tree9c608a91d62af4614fd05f8ac7ea1034e5385a35
parent797d73ee232dd1833dec4824bc53a22032e97c1c
selftests/bpf: Add more test case for field flattening

Add three success test cases to test the flattening of array of nested
struct. For these three tests, the number of special fields in map is
BTF_FIELDS_MAX, but the array is defined in structs with different
nested level.

Add one failure test case for the flattening as well. In the test case,
the number of special fields in map is BTF_FIELDS_MAX + 1. It will make
btf_parse_fields() in map_create() return -E2BIG, the creation of map
will succeed, but the load of program will fail because the btf_record
is invalid for the map.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20241008071114.3718177-3-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/cpumask.c
tools/testing/selftests/bpf/progs/cpumask_common.h
tools/testing/selftests/bpf/progs/cpumask_failure.c
tools/testing/selftests/bpf/progs/cpumask_success.c