Re: [PATCH bpf-next 5/5] selftests/bpf: Test bpftool loading and dumping metadata

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 20, 2020 at 3:03 PM Yonghong Song <yhs@xxxxxx> wrote:
>
>
>
> On 8/20/20 2:42 AM, YiFei Zhu wrote:
> > From: YiFei Zhu <zhuyifei@xxxxxxxxxx>
> >
> > This is a simple test to check that loading and dumping metadata
> > works, whether or not metadata contents are used by the program.
> >
> > Signed-off-by: YiFei Zhu <zhuyifei@xxxxxxxxxx>
> > ---
> >   tools/testing/selftests/bpf/Makefile          |  3 +-
> >   .../selftests/bpf/progs/metadata_unused.c     | 15 ++++
> >   .../selftests/bpf/progs/metadata_used.c       | 15 ++++
> >   .../selftests/bpf/test_bpftool_metadata.sh    | 82 +++++++++++++++++++
> >   4 files changed, 114 insertions(+), 1 deletion(-)
> >   create mode 100644 tools/testing/selftests/bpf/progs/metadata_unused.c
> >   create mode 100644 tools/testing/selftests/bpf/progs/metadata_used.c
> >   create mode 100755 tools/testing/selftests/bpf/test_bpftool_metadata.sh
> >
> > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> > index a83b5827532f..04e56c6843c6 100644
> > --- a/tools/testing/selftests/bpf/Makefile
> > +++ b/tools/testing/selftests/bpf/Makefile
> > @@ -68,7 +68,8 @@ TEST_PROGS := test_kmod.sh \
> >       test_tc_edt.sh \
> >       test_xdping.sh \
> >       test_bpftool_build.sh \
> > -     test_bpftool.sh
> > +     test_bpftool.sh \
> > +     test_bpftool_metadata.sh \
>
> This is mostly testing bpftool side.
> We should add testing to test_progs too as it is what most developer
> runs. If you add skeleton support for metadata, similar to bss, it will
> both make user interface easy and make testing easy.
>

I concur. It also seems that program code can use metadata variables
just like .rodata variables (e.g., for debug logging, etc), so we need
to add tests exercising that ability as well.

> >
> >   TEST_PROGS_EXTENDED := with_addr.sh \
> >       with_tunnels.sh \
> > diff --git a/tools/testing/selftests/bpf/progs/metadata_unused.c b/tools/testing/selftests/bpf/progs/metadata_unused.c
> > new file mode 100644
> > index 000000000000..523b3c332426
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/progs/metadata_unused.c
> > @@ -0,0 +1,15 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +
> > +#include <linux/bpf.h>
> > +#include <bpf/bpf_helpers.h>
> > +
> > +char metadata_a[] SEC(".metadata") = "foo";
> > +int metadata_b SEC(".metadata") = 1;
> > +
> > +SEC("cgroup_skb/egress")
> > +int prog(struct xdp_md *ctx)
> > +{
> > +     return 0;
> > +}
> > +
> > +char _license[] SEC("license") = "GPL";
> [...]



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux