Re: [PATCH bpf-next 2/2] selftests/bpf: ensure snprintf_btf/bpf_iter tests compatibility with old vmlinux.h

From: Andrii Nakryiko
Date: Tue Sep 29 2020 - 14:08:58 EST


On Tue, Sep 29, 2020 at 5:26 AM Alan Maguire <alan.maguire@xxxxxxxxxx> wrote:
>
> Andrii reports that bpf selftests relying on "struct btf_ptr" and BTF_F_*
> values will not build as vmlinux.h for older kernels will not include
> "struct btf_ptr" or the BTF_F_* enum values. Undefine and redefine
> them to work around this.
>
> Fixes: b72091bd4ee4 ("selftests/bpf: Add test for bpf_seq_printf_btf helper")
> Fixes: 076a95f5aff2 ("selftests/bpf: Add bpf_snprintf_btf helper tests")
> Reported-by: Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx>
> Signed-off-by: Alan Maguire <alan.maguire@xxxxxxxxxx>
> ---

That works, thanks!

Acked-by: Andrii Nakryiko <andriin@xxxxxx>

> tools/testing/selftests/bpf/progs/bpf_iter.h | 23 ++++++++++++++++++
> tools/testing/selftests/bpf/progs/btf_ptr.h | 27 ++++++++++++++++++++++
> .../selftests/bpf/progs/netif_receive_skb.c | 2 +-
> 3 files changed, 51 insertions(+), 1 deletion(-)
> create mode 100644 tools/testing/selftests/bpf/progs/btf_ptr.h
>

[...]