Re: [PATCH bpf-next v2 3/3] selftests/bpf: Verify program FD after non-autoload programs in lskel

From: Thiébaud Weksteen

Date: Wed Sep 16 2026 - 21:06:59 EST


On Thu, Sep 10, 2026 at 3:49 PM Leon Hwang <leon.hwang@xxxxxxxxx> wrote:
>
> On 9/9/26 12:24, Thiébaud Weksteen wrote:
> > In test_global_percpu_data.c, dump_percpu_data is defined after two
> > non-autoload SEC("?kprobe") programs (verifier_strncmp and
> > verifier_snprintf). Verify in test_global_percpu_data_lskel() that
> > lskel->progs.dump_percpu_data.prog_fd is properly populated (> 0) when
> > loaded via the light skeleton.
> >
> > Signed-off-by: Thiébaud Weksteen <tweek@xxxxxxxxxx>
> > ---
> > No changes since v1.
>
> The Fixes tags of v1 are dropped.
>
> >
> > tools/testing/selftests/bpf/prog_tests/global_data_init.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/global_data_init.c b/tools/testing/selftests/bpf/prog_tests/global_data_init.c
> > index 7c539cbcf3a1..ebda60200b71 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/global_data_init.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/global_data_init.c
> > @@ -214,6 +214,8 @@ static void test_global_percpu_data_lskel(void)
> > lskel = test_global_percpu_data_lskel__open_and_load();
> > if (!ASSERT_OK_PTR(lskel, "test_global_percpu_data_lskel__open_and_load"))
> > goto out;
> > + if (!ASSERT_GT(lskel->progs.dump_percpu_data.prog_fd, 0, "dump_percpu_data.prog_fd"))
> > + goto out;
>
> When the light skeleton does not skip the non-autoload progs,
> lskel->progs.dump_percpu_data.prog_fd is 0, actually.
>
> But, theoretically, this ASSERT_GT() is not good enough to prove the FD
> is the correct FD of dump_percpu_data prog.
>
> How about running the iter subtest against the lskel? Factor out
> test_global_percpu_data_iter_fd() helper first. Then, add an iter
> subtest using lskel.
> When factoring out test_global_percpu_data_iter_fd() helper, pls change
> 'do { } while (0);' to '{ /* no-op */ }' btw.
>

Thanks for the review Leon. That sounds good, I can implement these
changes. I am just waiting for Quentin's feedback on the first patch
in this series before spinning up a new patch set.