BPF List
 help / color / mirror / Atom feed
From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
To: bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	Ihor Solodrai <ihor.solodrai@linux.dev>,
	kkd@meta.com, kernel-team@meta.com
Subject: [PATCH bpf-next] selftests/bpf: Resolve bpftool through bpftool_helpers in core_reloc
Date: Mon, 24 Aug 2026 21:57:46 +0200	[thread overview]
Message-ID: <20260824195746.3070450-1-memxor@gmail.com> (raw)

run_btfgen() shells out to a hardcoded "./bpftool". That path only
exists in the build tree, where DEFINE_TEST_RUNNER_RULES symlinks
bpftool next to each runner binary. After "make install" it is not
there: commit 0b236ac75d04 ("selftests/bpf: Fix make install target")
dropped bpftool from TEST_GEN_PROGS_EXTENDED, which used to flatten it
into $(INSTALL_PATH), and installs it under $(INSTALL_PATH)/tools/sbin/
instead, matching detect_bpftool_path().

Running test_progs from the install tree therefore fails all 64
core_reloc_btfgen subtests:

  run_core_reloc_tests:FAIL:run_btfgen unexpected error: 32512 (errno 95)
  sh: line 1: ./bpftool: No such file or directory

32512 is 127 << 8, i.e. the shell could not find the binary.

Use run_bpftool_command() from bpftool_helpers.h, which locates bpftool
via $BPFTOOL, ./tools/sbin/bpftool or ../tools/sbin/bpftool, the last of
which also covers the test_progs flavors. bpftool_helpers.c is already
in TRUNNER_EXTRA_SOURCES, so no build change is needed.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 tools/testing/selftests/bpf/prog_tests/core_reloc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/core_reloc.c b/tools/testing/selftests/bpf/prog_tests/core_reloc.c
index 08963c82f30b..80432c4656b5 100644
--- a/tools/testing/selftests/bpf/prog_tests/core_reloc.c
+++ b/tools/testing/selftests/bpf/prog_tests/core_reloc.c
@@ -7,6 +7,7 @@
 #include <sys/mman.h>
 #include <sys/syscall.h>
 #include <bpf/btf.h>
+#include "bpftool_helpers.h"

 static int duration = 0;

@@ -985,16 +986,15 @@ static size_t roundup_page(size_t sz)

 static int run_btfgen(const char *src_btf, const char *dst_btf, const char *objpath)
 {
-	char command[4096];
+	char args[4096];
 	int n;

-	n = snprintf(command, sizeof(command),
-		     "./bpftool gen min_core_btf %s %s %s",
+	n = snprintf(args, sizeof(args), "gen min_core_btf %s %s %s",
 		     src_btf, dst_btf, objpath);
-	if (n < 0 || n >= sizeof(command))
+	if (n < 0 || n >= sizeof(args))
 		return -1;

-	return system(command);
+	return run_bpftool_command(args);
 }

 static void run_core_reloc_tests(bool use_btfgen)
--
2.53.0-Meta


             reply	other threads:[~2026-08-24 19:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 19:57 Kumar Kartikeya Dwivedi [this message]
2026-08-25 13:59 ` [PATCH bpf-next] selftests/bpf: Resolve bpftool through bpftool_helpers in core_reloc Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260824195746.3070450-1-memxor@gmail.com \
    --to=memxor@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=kernel-team@meta.com \
    --cc=kkd@meta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox