tests: Add test to verify behaviour when debuginfo is absent/debuglink
PATCH 1/1 tests: Add test to verify behaviour when debuginfo is absent/debuglink
Since BTF encoding behaviour has changed recently to
- succeed but do nothing when no debug info is present
- skip debuglink case
add a test that verifies these behaviours.
Debuglink test based on Ihor's instructions in [1].
[1] https://lore.kernel.org/dwarves/[email protected]/
Signed-off-by Alan Maguire <[email protected]>
--- tests/missing_debuginfo.sh | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 tests/missing_debuginfo.sh
tests/missing_debuginfo.sh new file +68 -0
@@ -0,0 +1,68 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (c) 2025, Oracle and/or its affiliates. +# +# Ensure correct behaviour for missing/debuglink DWARF. + +outdir= + +fail() +{ + # Do not remove test dir; might be useful for analysis + trap - EXIT + if [[ -d "$outdir" ]]; then + echo "Test data is in $outdir" + fi + exit 1 +} + +cleanup() +{ + rm ${outdir}/* + rmdir $outdir +} + +vmlinux=${vmlinux:-$1} + +if [ -z "$vmlinux" ] ; then + vmlinux=$(pahole --running_kernel_vmlinux 2>/dev/null) +fi + +outdir=$(mktemp -d /tmp/missing_debuginfo.sh.XXXXXX) + +trap cleanup EXIT + +echo -n "Validation of correct behaviour with missing/debuglink DWARF: " + +emptyfile=$outdir/emptyfile +touch $emptyfile +pahole --btf_features=default --btf_encode_detached=$emptyfile.btf $emptyfile +ret=$? +if [[ $ret -ne 0 ]]; then + echo "non-zero return value $ret for empty file with no debug info" + fail +fi +if [[ -f $emptyfile.btf ]]; then + echo "$emptyfile.btf should not exist" + fail +fi + +if [[ -f "$vmlinux" ]]; then + debuginfo=$outdir/vmlinux.debug + objcopy --only-keep-debug $vmlinux $debuginfo + objcopy --strip-all --add-gnu-debuglink=$debuginfo $vmlinux $outdir/vmlinux.stripped + pahole --btf_features=default --btf_encode_detached=$outdir/debuglink.btf $outdir/vmlinux.stripped 2>/dev/null + ret=$? + if [[ $ret -ne 0 ]]; then + echo "non-zero return value $ret for stripped vmlinux $vmlinux with debuglink" + fail + fi + if [[ -f $outdir/debuglink.btf ]]; then + echo "$outdir/debuglink.btf should not exist" + fail + fi +fi + +echo "Ok" +exit 0
Signature · 1 line
2.43.5