aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2024-02-05 16:06:57 -0800
committerDarrick J. Wong <djwong@kernel.org>2024-05-10 17:20:20 -0700
commite486d1df9dc458e78da2d4136589a0aa532c9d04 (patch)
tree3f5f43502d9233921dc6c6b1665192f2b67a3ac9
parent318b4fd21e46a93891c65aea707e8b126937665a (diff)
downloadxfstests-dev-capture-mount-failures.tar.gz
check: capture dmesg of mount failures if test failscapture-mount-failures_2024-05-10capture-mount-failures
Capture the kernel output after a mount failure occurs. If the test itself fails, then keep the logging output for further diagnosis. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rwxr-xr-xcheck20
-rw-r--r--common/rc26
-rw-r--r--common/report8
3 files changed, 52 insertions, 2 deletions
diff --git a/check b/check
index 5363d0fd10..0ea2a4420f 100755
--- a/check
+++ b/check
@@ -613,7 +613,7 @@ _stash_fail_loop_files() {
local seq_prefix="${REPORT_DIR}/${1}"
local cp_suffix="$2"
- for i in ".full" ".dmesg" ".out.bad" ".notrun" ".core" ".hints"; do
+ for i in ".full" ".dmesg" ".out.bad" ".notrun" ".core" ".hints" ".mountfail"; do
rm -f "${seq_prefix}${i}${cp_suffix}"
if [ -f "${seq_prefix}${i}" ]; then
cp "${seq_prefix}${i}" "${seq_prefix}${i}${cp_suffix}"
@@ -993,6 +993,7 @@ function run_section()
echo -n " $seqnum -- "
cat $seqres.notrun
tc_status="notrun"
+ rm -f "$seqres.mountfail?"
_stash_test_status "$seqnum" "$tc_status"
# Unmount the scratch fs so that we can wipe the scratch
@@ -1052,6 +1053,7 @@ function run_section()
if [ ! -f $seq.out ]; then
_dump_err "no qualified output"
tc_status="fail"
+ rm -f "$seqres.mountfail?"
_stash_test_status "$seqnum" "$tc_status"
continue;
fi
@@ -1088,6 +1090,22 @@ function run_section()
rm -f $seqres.hints
fi
fi
+
+ if [ -f "$seqres.mountfail?" ]; then
+ if [ "$tc_status" = "fail" ]; then
+ # Let the user know if there were mount
+ # failures on a test that failed because that
+ # could be interesting.
+ mv "$seqres.mountfail?" "$seqres.mountfail"
+ _dump_err "check: possible mount failures (see $seqres.mountfail)"
+ else
+ # Don't retain mount failure logs for tests
+ # that pass or were skipped because some tests
+ # intentionally drive mount failures.
+ rm -f "$seqres.mountfail?"
+ fi
+ fi
+
_stash_test_status "$seqnum" "$tc_status"
done
diff --git a/common/rc b/common/rc
index 455f1a5a3f..e4c8b4bcb6 100644
--- a/common/rc
+++ b/common/rc
@@ -126,9 +126,33 @@ _get_hugepagesize()
awk '/Hugepagesize/ {print $2 * 1024}' /proc/meminfo
}
+# Does dmesg have a --since flag?
+_dmesg_detect_since()
+{
+ if [ -z "$DMESG_HAS_SINCE" ]; then
+ test "$DMESG_HAS_SINCE" = "yes"
+ return
+ elif dmesg --help | grep -q -- --since; then
+ DMESG_HAS_SINCE=yes
+ else
+ DMESG_HAS_SINCE=no
+ fi
+}
+
_mount()
{
- $MOUNT_PROG $*
+ $MOUNT_PROG $*
+ ret=$?
+ if [ "$ret" -ne 0 ]; then
+ echo "\"$MOUNT_PROG $*\" failed at $(date)" >> "$seqres.mountfail?"
+ if _dmesg_detect_since; then
+ dmesg --since '30s ago' >> "$seqres.mountfail?"
+ else
+ dmesg | tail -n 100 >> "$seqres.mountfail?"
+ fi
+ fi
+
+ return $ret
}
# Call _mount to do mount operation but also save mountpoint to
diff --git a/common/report b/common/report
index 0e91e481f9..b57697f76d 100644
--- a/common/report
+++ b/common/report
@@ -199,6 +199,7 @@ _xunit_make_testcase_report()
local out_src="${SRC_DIR}/${test_name}.out"
local full_file="${REPORT_DIR}/${test_name}.full"
local dmesg_file="${REPORT_DIR}/${test_name}.dmesg"
+ local mountfail_file="${REPORT_DIR}/${test_name}.mountfail"
local outbad_file="${REPORT_DIR}/${test_name}.out.bad"
if [ -z "$_err_msg" ]; then
_err_msg="Test $test_name failed, reason unknown"
@@ -225,6 +226,13 @@ _xunit_make_testcase_report()
printf ']]>\n' >>$report
echo -e "\t\t</system-err>" >> $report
fi
+ if [ -z "$quiet" -a -f "$mountfail_file" ]; then
+ echo -e "\t\t<mount-failure>" >> $report
+ printf '<![CDATA[\n' >>$report
+ cat "$mountfail_file" | tr -dc '[:print:][:space:]' | encode_cdata >>$report
+ printf ']]>\n' >>$report
+ echo -e "\t\t</mount-failure>" >> $report
+ fi
;;
*)
echo -e "\t\t<failure message=\"Unknown test_status=$test_status\" type=\"TestFail\"/>" >> $report