From: David Disseldorp <ddiss@suse.de>
To: fstests@vger.kernel.org
Cc: David Disseldorp <ddiss@suse.de>
Subject: [PATCH 1/2] report: put failure cdata collection in a helper fn
Date: Mon, 14 Sep 2026 23:46:11 +1000 [thread overview]
Message-ID: <20260914140710.111641-2-ddiss@suse.de> (raw)
In-Reply-To: <20260914140710.111641-1-ddiss@suse.de>
xunit-quiet output omits all of this, so check for it once instead of
chaining "if [ -z "$quiet" -a ..." conditions.
Signed-off-by: David Disseldorp <ddiss@suse.de>
---
common/report | 79 +++++++++++++++++++++++++++------------------------
1 file changed, 42 insertions(+), 37 deletions(-)
diff --git a/common/report b/common/report
index 2fa15e62..eff01a7f 100644
--- a/common/report
+++ b/common/report
@@ -162,6 +162,46 @@ ENDL
echo "Xunit report: $out_fn"
}
+_xunit_log_failure_cdata()
+{
+ local report="$1"
+ local test_name="$2"
+ local full_file="${REPORT_DIR}/${test_name}.full"
+ local dmesg_file="${REPORT_DIR}/${test_name}.dmesg"
+ local out_src="${SRC_DIR}/${test_name}.out"
+ local outbad_file="${REPORT_DIR}/${test_name}.out.bad"
+ local mountfail_file="${REPORT_DIR}/${test_name}.mountfail"
+
+ if [ -s "$full_file" ]; then
+ echo -e "\t\t<system-out>" >> $report
+ printf '<![CDATA[\n' >>$report
+ cat "$full_file" | tr -dc '[:print:][:space:]' | encode_cdata >>$report
+ printf ']]>\n' >>$report
+ echo -e "\t\t</system-out>" >> $report
+ fi
+ if [ -f "$dmesg_file" ]; then
+ echo -e "\t\t<kernel-log>" >> $report
+ printf '<![CDATA[\n' >>$report
+ cat "$dmesg_file" | tr -dc '[:print:][:space:]' | encode_cdata >>$report
+ printf ']]>\n' >>$report
+ echo -e "\t\t</kernel-log>" >> $report
+ fi
+ if [ -s "$outbad_file" ]; then
+ echo -e "\t\t<system-err>" >> $report
+ printf '<![CDATA[\n' >>$report
+ $diff "$out_src" "$outbad_file" | encode_cdata >>$report
+ printf ']]>\n' >>$report
+ echo -e "\t\t</system-err>" >> $report
+ fi
+ if [ -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
+}
+
_xunit_make_testcase_report()
{
local sect_name="$1"
@@ -169,11 +209,6 @@ _xunit_make_testcase_report()
local test_status="$3"
local test_time="$4"
local report_format="$5"
- local quiet
-
- if [ "$report_format" = xunit-quiet ]; then
- quiet=yes
- fi
# TODO: other places may also win if no-section mode will be named like 'default/global'
if [ $sect_name == '-no-sections-' ]; then
@@ -198,42 +233,12 @@ _xunit_make_testcase_report()
echo -e "\t\t<skipped/>" >> $report
;;
"fail")
- 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"
fi
echo -e "\t\t<failure message=\"$_err_msg\" type=\"TestFail\" />" >> $report
- if [ -z "$quiet" -a -s "$full_file" ]; then
- echo -e "\t\t<system-out>" >> $report
- printf '<![CDATA[\n' >>$report
- cat "$full_file" | tr -dc '[:print:][:space:]' | encode_cdata >>$report
- printf ']]>\n' >>$report
- echo -e "\t\t</system-out>" >> $report
- fi
- if [ -z "$quiet" -a -f "$dmesg_file" ]; then
- echo -e "\t\t<kernel-log>" >> $report
- printf '<![CDATA[\n' >>$report
- cat "$dmesg_file" | tr -dc '[:print:][:space:]' | encode_cdata >>$report
- printf ']]>\n' >>$report
- echo -e "\t\t</kernel-log>" >> $report
- fi
- if [ -z "$quiet" -a -s "$outbad_file" ]; then
- echo -e "\t\t<system-err>" >> $report
- printf '<![CDATA[\n' >>$report
- $diff "$out_src" "$outbad_file" | encode_cdata >>$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
+ if [ "$report_format" != xunit-quiet ]; then
+ _xunit_log_failure_cdata "$report" "$test_name"
fi
;;
*)
--
2.55.0
next prev parent reply other threads:[~2026-09-14 14:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 13:46 [PATCH 0/2] report: optionally gzip xunit output David Disseldorp
2026-09-14 13:46 ` David Disseldorp [this message]
2026-09-14 13:46 ` [PATCH 2/2] report: add xunit-gzip report type David Disseldorp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260914140710.111641-2-ddiss@suse.de \
--to=ddiss@suse.de \
--cc=fstests@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox