public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fstests: report: always save the dmesg as system-err if KEEP_DMESG is set
@ 2022-12-16  6:51 Qu Wenruo
  2022-12-19 17:39 ` Darrick J. Wong
  0 siblings, 1 reply; 7+ messages in thread
From: Qu Wenruo @ 2022-12-16  6:51 UTC (permalink / raw)
  To: linux-btrfs, fstests

When KEEP_DMESG is set to "yes", we will always save the dmesg of any
test case (no matter if it passed or not) into "$seqnum.dmesg".

But this KEEP_DMESG behavior doesn't affect xunit report.

This patch will make xunit report to follow KEEP_DMESG setting.
Since error is checked by testcase.failure attribute, this new
<system-err> section should not cause the existing parsers to treat
passed cases as errors.

KEEP_DMESG is only followed if all the following conditions are met:

- KEEP_DMESG is set to yes

- Using xunit reporting
  xunit-quite won't save the dmesg for passed test cases.

This extra saved dmesg would definitely boost the xml size, but if the
end user wants to save all the dmesg (for later verification), then I'd
say it's a unavoidable cost.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 common/report | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/common/report b/common/report
index 64f9c866..4a747f8d 100644
--- a/common/report
+++ b/common/report
@@ -87,6 +87,19 @@ _xunit_make_testcase_report()
 	echo -e "\t<testcase classname=\"xfstests.$sect_name\" name=\"$test_name\" time=\"$test_time\">" >> $report
 	case $test_status in
 	"pass")
+		# If we have KEEP_DMESG and want full output, also save the
+		# dmesg into the passed result
+		if [ "$KEEP_DMESG" == yes -a "$quiet" != "yes" ]; then
+			local dmesg_file="${REPORT_DIR}/${test_name}.dmesg"
+			if [ -f "$dmesg_file" ]; then
+				echo -e "\t\t<system-err>" >> $report
+				printf	'<![CDATA[\n' >>$report
+				cat "$dmesg_file" | tr -dc '[:print:][:space:]' | \
+					encode_xml >>$report
+				printf ']]>\n'	>>$report
+				echo -e "\t\t</system-err>" >> $report
+			fi
+		fi
 		;;
 	"notrun")
 		local notrun_file="${REPORT_DIR}/${test_name}.notrun"
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-12-20  0:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-16  6:51 [PATCH] fstests: report: always save the dmesg as system-err if KEEP_DMESG is set Qu Wenruo
2022-12-19 17:39 ` Darrick J. Wong
2022-12-19 18:56   ` Theodore Ts'o
2022-12-19 22:45     ` Qu Wenruo
2022-12-19 23:49       ` Theodore Ts'o
2022-12-20  0:55         ` Qu Wenruo
2022-12-19 22:54   ` Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox