On Mon Jul 13, 2026 at 12:32 PM -03, Alexis Lothoré wrote:
> Hi,
>
> On Sat Jul 11, 2026 at 12:09 AM CEST, Ricardo B. Marlière wrote:
>> bpftool_helpers.c looks for bpftool at "tools/sbin/bpftool" or
>> "../tools/sbin/bpftool" relative to the running test_progs binary, matching
>> the build directory layout where bpftool sits at
>> $(OUTPUT)/tools/sbin/bpftool.
>>
>> INSTALL_RULE installs bpftool through the generic TEST_GEN_PROGS_EXTENDED
>> mechanism, which flattens it straight into $(INSTALL_PATH) and loses the
>> tools/sbin/ prefix. After "make install", every flavor of test_progs,
>> including the default one, fails to locate bpftool, and bpftool_maps_access
>> and bpftool_metadata error out with "Failed to detect bpftool path", even
>> though bpftool itself built and installed fine.
>>
>> Explicitly install bpftool under tools/sbin/ in the installed tree
>> so its relative location matches what detect_bpftool_path() already
>> expects, restoring the pre-install layout instead of introducing a
>> new one.
>>
>> Fixes: f21fae577446 ("selftests/bpf: Add a few helpers for bpftool testing")
>> Signed-off-by: Ricardo B. Marlière <[email protected]>
>
> I did not face the issue because I am running the selftests in-tree, and
> the CI seems to do the same, but for users using selftests after running
> `make install`, I guess the change makes sense.
>
> That's not the first fix aiming to improve bpftool
> detection/installation (eg the BPFTOOL env variable, see [1]), so it
> makes me wonder if we shouldn't just make bpftool part of
> TRUNNER_EXTRA_FILES for all flavours of test_progs, similarly to other
> binaries needed during tests (eg: urandom_read), instead of just adding
> some bpftool-specific details in this generic install rule, and just
> make the test runners assume that the needed binary is in the same
> directory.I'm not sure TRUNNER_EXTRA_FILES can be used like that, because it gets reset in test_maps definition. But maybe we can use a symlink like what's done in $(USE_BOOTSTRAP)bpftool > > Alexis > > [1] > https://lore.kernel.org/all/[email protected]/ > >> --- >> tools/testing/selftests/bpf/Makefile | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/tools/testing/selftests/bpf/Makefile >> b/tools/testing/selftests/bpf/Makefile >> index b642ee489ea6..47911c9b4977 100644 >> --- a/tools/testing/selftests/bpf/Makefile >> +++ b/tools/testing/selftests/bpf/Makefile >> @@ -1055,6 +1055,8 @@ endif >> DEFAULT_INSTALL_RULE := $(INSTALL_RULE) >> override define INSTALL_RULE >> $(DEFAULT_INSTALL_RULE) >> + @mkdir -p $(INSTALL_PATH)/tools/sbin >> + @rsync -a $(if $(PERMISSIVE),--ignore-missing-args) $(TRUNNER_BPFTOOL) >> $(INSTALL_PATH)/tools/sbin/ >> @for DIR in $(TEST_INST_SUBDIRS); do \ >> mkdir -p $(INSTALL_PATH)/$$DIR; \ >> rsync -a $(if $(PERMISSIVE),--ignore-missing-args) \

