[PATCH 4/5] tests default_vmlinux_btf: Cover the no args segfault too

Arnaldo Carvalho de Melo
2024-11-19T13:41:01Z

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

root@x1:/home/acme/git/pahole# pahole --running_kernel_vmlinux
pahole: couldn't find a vmlinux that matches the running kernel
HINT: Maybe you're inside a container or missing a debuginfo package?
root@x1:/home/acme/git/pahole# tests/default_vmlinux_btf.sh
Default BTF on a system without BTF: FAILED
root@x1:/home/acme/git/pahole# pahole
Segmentation fault (core dumped)
root@x1:/home/acme/git/pahole#

Now to fix this one as well.

Reported-by: Matthias Schwarzott <zzam@gentoo.org>
Cc: Alan Maguire <alan.maguire@oracle.com>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Song Liu <song@kernel.org>
Cc: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tests/default_vmlinux_btf.sh | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/tests/default_vmlinux_btf.sh b/tests/default_vmlinux_btf.sh
index a9effa2d6d37e0ee..a855ca7587380934 100755
--- a/tests/default_vmlinux_btf.sh
+++ b/tests/default_vmlinux_btf.sh
@@ -17,5 +17,16 @@ if [ $nr_lines -eq 0 ] ; then
exit 1
fi

+# There is also the case where no debugging info is available, be it DWARF of
+# BTF and it segfaults when calling just 'pahole', with no args, so check for
+# that as well
+#
+nr_lines=$(PAHOLE_VMLINUX_BTF_FILENAME=foobar pahole 2>&1 | wc -l)
+
+if [ $nr_lines -eq 0 ] ; then
+ echo "FAILED"
+ exit 1
+fi
+
echo "Ok"
exit 0
--
2.47.0