Re: [PATCH 1/3] test/bpf: skip some testing if null net driver not present

Bruce Richardson
2026-01-22T16:23:51Z

On Thu, Jan 22, 2026 at 08:19:48AM -0800, Stephen Hemminger wrote:
> On Thu, 22 Jan 2026 12:23:51 +0000
> Bruce Richardson <bruce.richardson@intel.com> wrote:
>
> > Some of the BPF tests require the net/null driver to be present, so skip
> > those tests if it's not found. If the early part of the tests fail,
> > return that failure - on if they succeed do we return skipped on the
> > missing dependency.
> >
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > ---
> > app/test/test_bpf.c | 9 +++++++++
> > 1 file changed, 9 insertions(+)
> >
> > diff --git a/app/test/test_bpf.c b/app/test/test_bpf.c
> > index a7d56f8d86..ae588acb16 100644
> > --- a/app/test/test_bpf.c
> > +++ b/app/test/test_bpf.c
> > @@ -3725,6 +3725,11 @@ test_bpf_elf_rx_load(void)
> > return ret == 0 ? TEST_SUCCESS : TEST_FAILED;
> > }
> >
> > +#ifdef RTE_NET_NULL
> > +static const bool have_net_null = true;
> > +#else
> > +static const bool have_net_null; /* statics default to false */
> > +#endif
> >
> > static int
> > test_bpf_elf(void)
> > @@ -3732,6 +3737,10 @@ test_bpf_elf(void)
> > int ret;
> >
> > ret = test_bpf_elf_load();
> > + if (ret == TEST_SUCCESS && !have_net_null) {
> > + printf("net_null driver not available, skipping remainder of BPF tests\n");
> > + return TEST_SKIPPED;
> > + }
> > if (ret == TEST_SUCCESS)
> > ret = test_bpf_elf_tx_load();
> > if (ret == TEST_SUCCESS)
>
> Only the tests doing ELF load need a device.
> I think that part can be handled at compile time with the #ifdef
> or by splitting the ELF load tests to another file and doing it with meson.build

We could do that using ifdefs, but it means adding ifdefs around lots of
code blocks as the compiler will complain about unused functions if we just
ifdef out the calls to them. That's why I took this approach, to have the
minimal possible ifdef. If we don't want to mark the test as skipped we can
just change it to return success immedately if we don't have the null
driver.

/Bruce