Re: [PATCH bpf-next v2 3/4] selftests/bpf: Add negative C tests for kptrs

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

 



On Thu, May 12, 2022 at 08:38:16AM IST, Andrii Nakryiko wrote:
> On Wed, May 11, 2022 at 12:46 PM Kumar Kartikeya Dwivedi
> <memxor@xxxxxxxxx> wrote:
> >
> > This uses the newly added SEC("?foo") naming to disable autoload of
> > programs, and then loads them one by one for the object and verifies
> > that loading fails and matches the returned error string from verifier.
> > This is similar to already existing verifier tests but provides coverage
> > for BPF C.
> >
> > Signed-off-by: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx>
> > ---
> >  .../selftests/bpf/prog_tests/map_kptr.c       |  87 +++-
> >  .../selftests/bpf/progs/map_kptr_fail.c       | 418 ++++++++++++++++++
> >  2 files changed, 504 insertions(+), 1 deletion(-)
> >  create mode 100644 tools/testing/selftests/bpf/progs/map_kptr_fail.c
> >
>
> [...]
>
> > +
> > +static void test_map_kptr_success(void)
> >  {
> >         struct map_kptr *skel;
> >         int key = 0, ret;
> > @@ -35,3 +113,10 @@ void test_map_kptr(void)
> >
> >         map_kptr__destroy(skel);
> >  }
> > +
> > +void test_map_kptr(void)
> > +{
> > +       if (test__start_subtest("success"))
> > +               test_map_kptr_success();
> > +       test_map_kptr_fail();
>
> I think the intent for this was to be another subtest, right? Worth
> fixing in a follow up?
>

No, instead I am calling test__start_subtest inside it for each program name
that is failing, to make them the subtest. In that case, it should be alright?

> > +}
> > diff --git a/tools/testing/selftests/bpf/progs/map_kptr_fail.c b/tools/testing/selftests/bpf/progs/map_kptr_fail.c
> > new file mode 100644
> > index 000000000000..05e209b1b12a
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/progs/map_kptr_fail.c
> > @@ -0,0 +1,418 @@
>
> [...]

--
Kartikeya



[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