selftests/bpf: Add tests for bpftool btf dump format c
"bpftool btf dump format c" generates the vmlinux.h that BPF programs
are built against, and it has no test coverage at all. The only
in-tree consumers are build systems.
Building against the header only catches what a compiler rejects,
which is insufficient.
Introduce a bpftool_btf_dump selftest. Dump a small hand-built BTF and
compare the output against committed expectations.
The BTF is assembled with btf__add_*() rather than compiled from BPF C
because the fixture needs a 4-byte "long int". That is what makes
bpftool render the hole in struct holey as a pair of "long: 32;"
bitfields. A BPF target is always 64-bit, so a compiled fixture could
not supply it.
Comparing the whole dump makes every change to a generated header show
up in a patch.
Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Link: https://lore.kernel.org/r/20260828215207.3105313-6-ihor.solodrai@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
4 files changed