From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796409046; b=UVvKdPW1v+gGOG20YiAuFt5xwPSwIeoOIlzApfQccGNr1+Y6al4nkNkWKDPjli0FYB1z ir6BOhoG+hySjkz77uciXCo1YK7feUNQ3Wrdx2lFR9Cj8+wosv24LlF5FWVtBOzfFuBgk KCB6otipGAG5w2gNLHsqTNz6kYm6ni/MmOjOGbkmm4xxWnJd0j++xVPkNdyg/ohxiO/wj 706LzQXLe9Pz5qMahLehpfW9gIJCabxEKHpxN8vKs0JONS+DXsxSR2j3gkYWmKCgVGkAn HLEOoBEUcJ2Io5gwRu4mqbuPc3mN2JMWpCbZfOSQFRUMwJt8GS0EklYi51/7RwSg9dQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796409046; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=AaSKlVyTpw5BweHXTsUyGky8OAem/mMvWX+/TMJIXlI=; b=0uiW/8OvOt7Edc+bctEgr7mXhtvYzIpFlHgnfQEQ6lGRjcUa628Bwpdudx+jzGldl6wj 6u/r+7r2NEU/DuA/FNS4OgkbODL4K+DIcZ0V0fZxF6/62kLJgAUqCyXvMyBg7lDTpmIXB ARM1xmn+2bj2KWo61Ui5hCrigBfGF2mgpgA2cILSdK1GTtPYhBEkqiY37n7zzwPHlg8Xi W8dlrSNb/WQGMxTcQOw/hycnDueBTpgfBgJwwS+tztE/VxbjFIH0M+rbC51Z+MX95zs2x i3zlH7x4qugo7bTlPEu113qcFOLhDELz5XpIE3/7eAFa0iTg+8Xe0u+Tg0DXYUpX4+g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bEZ81cCC; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A1DC606A322; Fri, 4 Dec 2026 18:30:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bEZ81cCC Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52A471F00936; Fri, 4 Dec 2026 18:30:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796409045; bh=AaSKlVyTpw5BweHXTsUyGky8OAem/mMvWX+/TMJIXlI=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=bEZ81cCCdWCgRpp8g8e2SNxhvTFGZkIFkdlhGOJ4dnOoWqz7LWvX0I5trI6zQj76P byXEl+OZzOkFa2nfOY9abXUH1s+f1VAf7UMunf+sb1iyYiPbUHIO2oGfYyFswkP6NF XfMj7bzPcNYfsMpYORYGjmaOl7wciV6HjxZP+dC2rzjDDu0uQD+4A9YSbidLG+D674 2zt8LWYScruM56naCxbrdhh2cEiPqbp3b0XDTLhSlH+fGAh6kJJ4YoBzqqxCYJbDoi nNoYHiKjRCVpit2sFLZT9TeiBKFoILbEOajqhdeoY/tsD3Jtq24W9P6XUHy3PNqnmZ jxkp2fsTWURww== Message-ID: <12ca03bb-8109-4e89-be65-765f3e1fec4b@kernel.org> Date: Fri, 4 Dec 2026 18:30:42 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/1] tests: Only use a vmlinux that has DWARF To: Arnaldo Carvalho de Melo , Alan Maguire Cc: Jiri Olsa , Clark Williams , dwarves@vger.kernel.org, bpf@vger.kernel.org, Arnaldo Carvalho de Melo References: <20261201185334.419392-1-acme@kernel.org> Content-Language: en-GB From: Alan Maguire In-Reply-To: <20261201185334.419392-1-acme@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/1/26 6:53 PM, Arnaldo Carvalho de Melo wrote: > 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//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 think we might need to tweak where we error out, see below.. > --- > 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//build/vmlinux is how the kernel build > # directory installs it, and /boot/vmlinux- 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 I _think_ we need to deal with the case of vmlinux having no dwarf and then our fallback find_vmlinux turns up empty up here, i.e vmlinux=$(find_vmlinux) if [ -z "$vmlinux" ] ; then check_color_support - color_print ${RED} "Please specify a vmlinux file to operate on" >&2 + 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 + else + color_print ${RED} "Please specify a vmlinux file to operate on" >&2 + fi exit 2 fi fi > 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