All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] tests: Skip bpftool checks when it cannot parse the BTF
@ 2026-11-29  2:11 Arnaldo Carvalho de Melo
  2026-11-30 18:45 ` Alan Maguire
  0 siblings, 1 reply; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-29  2:11 UTC (permalink / raw)
  To: Alan Maguire; +Cc: Jiri Olsa, Clark Williams, dwarves, Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <acme@redhat.com>

bpftool older than 7.8 cannot load BTF carrying inline locations or the
kinds enabled by --btf_gen_all: it fails with "Invalid argument" and
dumps nothing, so btf_inline.sh reports missing LOCSEC call sites and
btf_vmlinux.sh reports btf_gen_all producing zero types, even though
pahole encoded the BTF.

Skip the check when the dump fails or is empty, as the basic vmlinux
dump already does.  When bpftool parses the BTF, a missing LOCSEC or a
lower btf_gen_all count still fails the test.

Verified in the fedora:45 image (bpftool 7.7.0): both tests skip.  In
the fedora:46 image (bpftool 7.8.1): both pass, with 1529341
btf_gen_all lines against 388493 basic.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tests/btf_inline.sh  | 8 ++++++--
 tests/btf_vmlinux.sh | 4 ++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/tests/btf_inline.sh b/tests/btf_inline.sh
index 007fc4872a99b2c6..51ea199e0a467c9f 100755
--- a/tests/btf_inline.sh
+++ b/tests/btf_inline.sh
@@ -128,8 +128,12 @@ if ! inline_sites=$(pfunct --inline_sites --elf "$obj" "$btf" 2>/dev/null) ||
 fi
 
 if command -v bpftool >/dev/null 2>&1; then
-	locsec_vlen=$(bpftool btf dump file "$btf" format raw 2>/dev/null |
-		     sed -n 's/.*LOCSEC .*vlen=\([0-9][0-9]*\).*/\1/p')
+	if ! dump=$(bpftool btf dump file "$btf" format raw 2>/dev/null) ||
+	   [ -z "$dump" ]; then
+		info_log "skip: bpftool cannot parse inline BTF (too old or missing features)"
+		test_skip
+	fi
+	locsec_vlen=$(sed -n 's/.*LOCSEC .*vlen=\([0-9][0-9]*\).*/\1/p' <<<"$dump")
 	if [[ -z "$locsec_vlen" || "$locsec_vlen" -lt 2 ]]; then
 		error_log "multiple inline call sites are missing from LOCSEC"
 		test_fail
diff --git a/tests/btf_vmlinux.sh b/tests/btf_vmlinux.sh
index e3c00502bdfeef32..dd135f7e1a460698 100755
--- a/tests/btf_vmlinux.sh
+++ b/tests/btf_vmlinux.sh
@@ -116,6 +116,10 @@ fi
 # btf_gen_all should produce at least as many types as the basic encode
 basic_types=$(bpftool btf dump file "$btf_basic" 2>/dev/null | wc -l)
 all_types=$(bpftool btf dump file "$btf_all" 2>/dev/null | wc -l)
+if [ "$all_types" -eq 0 ]; then
+	info_log "skip: bpftool cannot parse btf_gen_all BTF (too old or missing features)"
+	test_skip
+fi
 if [ "$all_types" -lt "$basic_types" ]; then
 	error_log "FAIL: btf_gen_all produced fewer types ($all_types) than basic ($basic_types)"
 	test_fail
-- 
2.56.0


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

* Re: [PATCH v1 1/1] tests: Skip bpftool checks when it cannot parse the BTF
  2026-11-29  2:11 [PATCH v1 1/1] tests: Skip bpftool checks when it cannot parse the BTF Arnaldo Carvalho de Melo
@ 2026-11-30 18:45 ` Alan Maguire
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Maguire @ 2026-11-30 18:45 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Alan Maguire
  Cc: Jiri Olsa, Clark Williams, dwarves, Arnaldo Carvalho de Melo

On 11/29/26 2:11 AM, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> bpftool older than 7.8 cannot load BTF carrying inline locations or the
> kinds enabled by --btf_gen_all: it fails with "Invalid argument" and
> dumps nothing, so btf_inline.sh reports missing LOCSEC call sites and
> btf_vmlinux.sh reports btf_gen_all producing zero types, even though
> pahole encoded the BTF.
> 
> Skip the check when the dump fails or is empty, as the basic vmlinux
> dump already does.  When bpftool parses the BTF, a missing LOCSEC or a
> lower btf_gen_all count still fails the test.
> 
> Verified in the fedora:45 image (bpftool 7.7.0): both tests skip.  In
> the fedora:46 image (bpftool 7.8.1): both pass, with 1529341
> btf_gen_all lines against 388493 basic.
> 
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

applied, thanks!

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

end of thread, other threads:[~2026-11-30 18:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29  2:11 [PATCH v1 1/1] tests: Skip bpftool checks when it cannot parse the BTF Arnaldo Carvalho de Melo
2026-11-30 18:45 ` Alan Maguire

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.