@@ -923,11 +923,19 @@ function run_section()
sts=$?
fi
- if [ -f core ]; then
- _dump_err_cont "[dumped core]"
- mv core $RESULT_BASE/$seqnum.core
+ # If someone sets kernel.core_pattern or kernel.core_uses_pid,
+ # coredumps generated by fstests might have a longer name than
+ # just "core". Use globbing to find the most common patterns,
+ # assuming there are no other coredump capture packages set up.
+ local cores=0
+ for i in core core.*; do
+ test -f "$i" || continue
+ if ((cores++ == 0)); then
+ _dump_err_cont "[dumped core]"
+ fi
+ (_adjust_oom_score 250; _save_coredump "$i")
tc_status="fail"
- fi
+ done
if [ -f $seqres.notrun ]; then
$timestamp && _timestamp
@@ -960,6 +968,16 @@ function run_section()
# of the check script itself.
(_adjust_oom_score 250; _check_filesystems) || tc_status="fail"
_check_dmesg || tc_status="fail"
+
+ # Save any coredumps from the post-test fs checks
+ for i in core core.*; do
+ test -f "$i" || continue
+ if ((cores++ == 0)); then
+ _dump_err_cont "[dumped core]"
+ fi
+ (_adjust_oom_score 250; _save_coredump "$i")
+ tc_status="fail"
+ done
fi
# Reload the module after each test to check for leaks or
@@ -4949,6 +4949,28 @@ _create_file_sized()
return $ret
}
+# Save an arbitrary coredump to the report directory.
+_save_coredump()
+{
+ local path="$1"
+
+ if [ -z "$seqres" ]; then
+ echo "$path: seqres is not defined; ignoring coredump!"
+ return 1
+ fi
+
+ local core_hash="$(_md5_checksum "$path")"
+ local out_file="${seqres}.core.${core_hash}"
+
+ if [ -s "$out_file" ]; then
+ rm -f "$path"
+ return
+ fi
+ rm -f "$out_file"
+
+ mv "$path" "$out_file"
+}
+
init_rc
################################################################################