diff --git a/test/lib/utils.sh b/test/lib/utils.sh index 24b7f89a1..4223ce224 100644 --- a/test/lib/utils.sh +++ b/test/lib/utils.sh @@ -138,25 +138,29 @@ STACKTRACE() { # Check for all cores newer then TESTNAME file # Assume users keep prefix 'core' # TODO: possibly better integrate with coredumpctl & systemd - while IFS= read -r i; do + local cores=() + local IFS=$IFS_NL + cores=( $(find . "$(dirname "$(sysctl -n kernel.core_pattern)")" \ + "/var/lib/systemd/coredump/" -name 'core*' -newer TESTNAME 2>/dev/null || true ) ) + + for i in "${cores[@]-}"; do bin=$(gdb -batch -c "$i" 2>&1 | grep "generated by" | \ sed -e "s,.*generated by \`\([^ ']*\).*,\1,") || continue - { - echo bt full - echo l - echo quit - } > gdb_commands.txt || rm -f gdb_commands.txt + cat > gdb_commands.txt <<- EOF || rm -f gdb_commands.txt + bt full + l + quit + EOF if test ! -s gdb_commands.txt ; then - echo "Out of disk space, can't check coredump $i generated by $bin." - continue + echo "Out of disk space, cannot check coredump \"$i\" generated by \"$bin\"." + break fi echo "## Checking coredump: $i generated by $bin." gdb -batch -c "$i" -x gdb_commands.txt "$(which "$bin")" 2>/dev/null | \ sed -e "s,^,## GDB: ," || continue - done < <(find . "$(dirname "$(sysctl -n kernel.core_pattern)")" \ - "/var/lib/systemd/coredump/" -name 'core*' -newer TESTNAME 2>/dev/null || true) + done fi test -f SKIP_THIS_TEST && exit 200