mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
report: encode XML Character Entities in xUnit report
Since the xUnit report is an XML document, special XML characters such as '<', '>', '&', etc. have to be encoded as "<", ">", etc. Otherwise programs parsing something like this: <testcase classname="xfstests.global" name="generic/450" time="0"> <skipped message="Only test on sector size < half of block size" /> </testcase> Will get choke the unescaped '<' character in the skipped message. Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: Dmitry Monakhov <dmonakhov@openvz.org> Reviewed-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
+13
-4
@@ -25,6 +25,15 @@ REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_UPPER"
|
|||||||
REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_LOWER"
|
REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_LOWER"
|
||||||
REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_WORK"
|
REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_WORK"
|
||||||
|
|
||||||
|
encode_xml()
|
||||||
|
{
|
||||||
|
sed -e 's/&/\&/g' \
|
||||||
|
-e 's/>/\>/g' \
|
||||||
|
-e 's/</\</g' \
|
||||||
|
-e "s/'/\'/g" \
|
||||||
|
-e 's/"/\"/g'
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Xunit format report functions
|
# Xunit format report functions
|
||||||
_xunit_add_property()
|
_xunit_add_property()
|
||||||
@@ -86,7 +95,7 @@ _xunit_make_testcase_report()
|
|||||||
;;
|
;;
|
||||||
"notrun")
|
"notrun")
|
||||||
if [ -f $seqres.notrun ]; then
|
if [ -f $seqres.notrun ]; then
|
||||||
local msg=`cat $seqres.notrun`
|
local msg=`cat $seqres.notrun | encode_xml`
|
||||||
echo -e "\t\t<skipped message=\"$msg\" />" >> $report
|
echo -e "\t\t<skipped message=\"$msg\" />" >> $report
|
||||||
else
|
else
|
||||||
echo -e "\t\t<skipped/>" >> $report
|
echo -e "\t\t<skipped/>" >> $report
|
||||||
@@ -103,20 +112,20 @@ _xunit_make_testcase_report()
|
|||||||
if [ -s $seqres.full ]; then
|
if [ -s $seqres.full ]; then
|
||||||
echo -e "\t\t<system-out>" >> $report
|
echo -e "\t\t<system-out>" >> $report
|
||||||
printf '<![CDATA[\n' >>$report
|
printf '<![CDATA[\n' >>$report
|
||||||
cat $seqres.full | tr -dc '[:print:][:space:]' >>$report
|
cat $seqres.full | tr -dc '[:print:][:space:]' | encode_xml >>$report
|
||||||
printf ']]>\n' >>$report
|
printf ']]>\n' >>$report
|
||||||
echo -e "\t\t</system-out>" >> $report
|
echo -e "\t\t</system-out>" >> $report
|
||||||
fi
|
fi
|
||||||
if [ -f $seqres.dmesg ]; then
|
if [ -f $seqres.dmesg ]; then
|
||||||
echo -e "\t\t<system-err>" >> $report
|
echo -e "\t\t<system-err>" >> $report
|
||||||
printf '<![CDATA[\n' >>$report
|
printf '<![CDATA[\n' >>$report
|
||||||
cat $seqres.dmesg | tr -dc '[:print:][:space:]' >>$report
|
cat $seqres.dmesg | tr -dc '[:print:][:space:]' | encode_xml >>$report
|
||||||
printf ']]>\n' >>$report
|
printf ']]>\n' >>$report
|
||||||
echo -e "\t\t</system-err>" >> $report
|
echo -e "\t\t</system-err>" >> $report
|
||||||
elif [ -s $seqres.out.bad ]; then
|
elif [ -s $seqres.out.bad ]; then
|
||||||
echo -e "\t\t<system-err>" >> $report
|
echo -e "\t\t<system-err>" >> $report
|
||||||
printf '<![CDATA[\n' >>$report
|
printf '<![CDATA[\n' >>$report
|
||||||
$diff $seq.out $seqres.out.bad >>$report
|
$diff $seq.out $seqres.out.bad | encode_xml >>$report
|
||||||
printf ']]>\n' >>$report
|
printf ']]>\n' >>$report
|
||||||
echo -e "\t\t</system-err>" >> $report
|
echo -e "\t\t</system-err>" >> $report
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user