BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: Resolve bpftool through bpftool_helpers in core_reloc
@ 2026-08-24 19:57 Kumar Kartikeya Dwivedi
  2026-08-25 13:59 ` Jiri Olsa
  0 siblings, 1 reply; 2+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2026-08-24 19:57 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Eduard Zingerman, Emil Tsalapatis, Ihor Solodrai, kkd,
	kernel-team

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: Resolve bpftool through bpftool_helpers in core_reloc
  2026-08-24 19:57 [PATCH bpf-next] selftests/bpf: Resolve bpftool through bpftool_helpers in core_reloc Kumar Kartikeya Dwivedi
@ 2026-08-25 13:59 ` Jiri Olsa
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Olsa @ 2026-08-25 13:59 UTC (permalink / raw)
  To: Kumar Kartikeya Dwivedi
  Cc: bpf, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Eduard Zingerman, Emil Tsalapatis, Ihor Solodrai, kkd,
	kernel-team

On Mon, Aug 24, 2026 at 09:57:46PM +0200, Kumar Kartikeya Dwivedi wrote:
> 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>

Acked-by: Jiri Olsa <jolsa@kernel.org>

jirka

> ---
>  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
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-25 13:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-24 19:57 [PATCH bpf-next] selftests/bpf: Resolve bpftool through bpftool_helpers in core_reloc Kumar Kartikeya Dwivedi
2026-08-25 13:59 ` Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox