From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: Jiri Olsa <jolsa@kernel.org>,
Clark Williams <williams@redhat.com>,
dwarves@vger.kernel.org, bpf@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH v1 1/1] tests: Only use a vmlinux that has DWARF
Date: Tue, 1 Dec 2026 15:53:34 -0300 [thread overview]
Message-ID: <20261201185334.419392-1-acme@kernel.org> (raw)
get_vmlinux() takes $VMLINUX as given and only checks that the file
exists, and find_vmlinux() picks the newest of the standard paths
without looking inside them. A kernel image installed without its
debuginfo package - /lib/modules/<version>/build/vmlinux on Debian
arm64 boards - has .BTF and .BTF_ids but no .debug_* sections, so
pahole encodes an empty BTF and the vmlinux tests fail:
FAIL: basic BTF file is empty
even though nothing in pahole is wrong. Check for .debug_info before
accepting a vmlinux, both in the caller-provided one and while
searching, and skip when no vmlinux with DWARF is available, as the
tests that need one already say they do.
Fixes: ae0e65e71943658a ("tests: Skip and find vmlinux tests when the running kernel vmlinux is not available")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tests/test_lib.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 47 insertions(+), 3 deletions(-)
diff --git a/tests/test_lib.sh b/tests/test_lib.sh
index bd3784ebaa0f0fb0..69ef1591a81f1122 100755
--- a/tests/test_lib.sh
+++ b/tests/test_lib.sh
@@ -94,6 +94,28 @@ color_print()
fi
}
+# Does this vmlinux carry the DWARF the tests encode from? A kernel image
+# installed without its debuginfo package has .BTF and .BTF_ids but no
+# .debug_* sections: pahole then writes an empty BTF and every check on the
+# encoded output fails, which is an environment gap, not a pahole bug.
+vmlinux_has_dwarf()
+{
+ local vmlinux=$1
+
+ [ -f "$vmlinux" ] || return 1
+
+ if command -v readelf > /dev/null 2>&1; then
+ readelf -SW "$vmlinux" 2>/dev/null | grep -q '^\s*\[ *[0-9]*\] \.debug_info'
+ return $?
+ fi
+ if command -v objdump > /dev/null 2>&1; then
+ objdump -h "$vmlinux" 2>/dev/null | grep -q '\.debug_info'
+ return $?
+ fi
+ # Neither tool: cannot tell, keep the previous behaviour.
+ return 0
+}
+
# Look for a vmlinux to use in the tests, given that most tests don't
# need the vmlinux to match the running kernel, just need a vmlinux
# with the kernel data structures, so search the standard places where
@@ -107,9 +129,15 @@ find_vmlinux()
# /lib/modules/<version>/build/vmlinux is how the kernel build
# directory installs it, and /boot/vmlinux-<version> on some other
# distributions.
- ls -1 /usr/lib/debug/lib/modules/*/vmlinux \
+ for vmlinux in $(ls -1 /usr/lib/debug/lib/modules/*/vmlinux \
/lib/modules/*/build/vmlinux \
- /boot/vmlinux-* 2>/dev/null | sort -V | tail -1
+ /boot/vmlinux-* 2>/dev/null | sort -Vr) ; do
+ if vmlinux_has_dwarf "$vmlinux" ; then
+ printf '%s\n' "$vmlinux"
+ return 0
+ fi
+ done
+ return 1
}
get_vmlinux()
@@ -125,8 +153,21 @@ get_vmlinux()
vmlinux=""
fi
+ # A vmlinux without DWARF cannot be encoded from, so treat it as not
+ # specified and look for one that can be, instead of letting every
+ # check on the encoded output fail.
+ local vmlinux_nodwarf=""
+ if [ -n "$vmlinux" ] && ! vmlinux_has_dwarf "$vmlinux" ; then
+ vmlinux_nodwarf=$vmlinux
+ vmlinux=""
+ fi
+
if [ -z "$vmlinux" ] ; then
vmlinux=$(pahole --running_kernel_vmlinux 2>/dev/null)
+ if [ -n "$vmlinux" ] && ! vmlinux_has_dwarf "$vmlinux" ; then
+ [ -n "$vmlinux_nodwarf" ] || vmlinux_nodwarf=$vmlinux
+ vmlinux=""
+ fi
if [ -z "$vmlinux" ] ; then
# No vmlinux matching the running kernel, so try to find
# any vmlinux to run the tests, most tests don't need it
@@ -142,7 +183,10 @@ get_vmlinux()
if [ ! -f "$vmlinux" ] ; then
check_color_support
- if [ -n "$VMLINUX" ] ; then
+ if [ -n "$vmlinux_nodwarf" ] ; then
+ color_print ${RED} "No vmlinux with DWARF available: $vmlinux_nodwarf has none" >&2
+ echo " skip: no vmlinux with DWARF available" >&2
+ elif [ -n "$VMLINUX" ] ; then
color_print ${RED} "VMLINUX env var points to non-existent file: $vmlinux" >&2
color_print ${RED} "Either unset VMLINUX or set it to a valid path" >&2
echo " skip: no vmlinux available (VMLINUX points to non-existent file)" >&2
--
2.56.0
reply other threads:[~2026-12-01 18:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261201185334.419392-1-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=alan.maguire@oracle.com \
--cc=bpf@vger.kernel.org \
--cc=dwarves@vger.kernel.org \
--cc=jolsa@kernel.org \
--cc=williams@redhat.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 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.