2 # Reports generator funcitons lives here
5 # List of xfstests's enviroment variables to include reports
6 ## TODO automate list population inside common/conf
7 REPORT_ENV_LIST="$REPORT_ENV_LIST SECTION"
8 REPORT_ENV_LIST="$REPORT_ENV_LIST FSTYP"
9 REPORT_ENV_LIST="$REPORT_ENV_LIST PLATFORM"
10 REPORT_ENV_LIST="$REPORT_ENV_LIST MKFS_OPTIONS"
11 REPORT_ENV_LIST="$REPORT_ENV_LIST MOUNT_OPTIONS"
13 REPORT_ENV_LIST="$REPORT_ENV_LIST HOST_OPTIONS"
14 REPORT_ENV_LIST="$REPORT_ENV_LIST CHECK_OPTIONS"
15 REPORT_ENV_LIST="$REPORT_ENV_LIST XFS_MKFS_OPTIONS"
16 REPORT_ENV_LIST="$REPORT_ENV_LIST TIME_FACTOR"
17 REPORT_ENV_LIST="$REPORT_ENV_LIST LOAD_FACTOR"
19 REPORT_ENV_LIST="$REPORT_ENV_LIST TEST_DIR"
20 REPORT_ENV_LIST="$REPORT_ENV_LIST TEST_DEV"
21 REPORT_ENV_LIST="$REPORT_ENV_LIST SCRATCH_DEV"
22 REPORT_ENV_LIST="$REPORT_ENV_LIST SCRATCH_MNT"
24 REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_UPPER"
25 REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_LOWER"
26 REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_WORK"
30 sed -e 's/&/\&/g' \
38 # Xunit format report functions
42 local value="${!name}"
44 if [ ! -z "$value" ]; then
45 echo -e "\t\t<property name=\"$name\" value=\"$value\"/>" >> $REPORT_DIR/result.xml
48 _xunit_make_section_report()
50 # xfstest:section ==> xunit:testsuite
51 local sect_name=$section
52 local sect_time=`expr $sect_stop - $sect_start`
53 local n_total=`expr $n_try + $n_notrun`
55 if [ $sect_name == '-no-sections-' ]; then
58 local report=$tmp.report.xunit.$sect_name.xml
60 echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $REPORT_DIR/result.xml
61 local dtime=`echo $date_time| tr " " 'T'`
62 local stats="errors=\"$n_bad\" skipped=\"$n_notrun\" tests=\"$n_total\" time=\"$sect_time\""
63 local hw_info="hostname=\"$HOST\" timestamp=\"$dtime\" "
64 echo "<testsuite name=\"xfstests\" $stats $hw_info >" >> $REPORT_DIR/result.xml
67 echo -e "\t<properties>" >> $REPORT_DIR/result.xml
68 for p in $REPORT_ENV_LIST;do
69 _xunit_add_property "$p"
71 echo -e "\t</properties>" >> $REPORT_DIR/result.xml
72 cat $tmp.report.xunit.$sect_name.xml >> $REPORT_DIR/result.xml
73 echo "</testsuite>" >> $REPORT_DIR/result.xml
74 echo "Xunit report: $REPORT_DIR/result.xml"
77 _xunit_make_testcase_report()
79 local test_status="$1"
80 local test_time=`expr $stop - $start`
81 local strip="$SRC_DIR/"
82 local test_name=${seq#$strip}
83 local sect_name=$section
85 # TODO: other places may also win if no-section mode will be named like 'default/global'
86 if [ $sect_name == '-no-sections-' ]; then
90 local report=$tmp.report.xunit.$sect_name.xml
92 echo -e "\t<testcase classname=\"xfstests.$sect_name\" name=\"$test_name\" time=\"$test_time\">" >> $report
97 if [ -f $seqres.notrun ]; then
98 local msg=`cat $seqres.notrun | encode_xml`
99 echo -e "\t\t<skipped message=\"$msg\" />" >> $report
101 echo -e "\t\t<skipped/>" >> $report
105 echo -e "\t\t<skipped/>" >> $report
108 if [ -z "$err_msg" ]; then
109 err_msg="Test $sequm failed, reason unknown"
111 echo -e "\t\t<failure message=\"$err_msg\" type=\"TestFail\" />" >> $report
112 if [ -s $seqres.full ]; then
113 echo -e "\t\t<system-out>" >> $report
114 printf '<![CDATA[\n' >>$report
115 cat $seqres.full | tr -dc '[:print:][:space:]' | encode_xml >>$report
116 printf ']]>\n' >>$report
117 echo -e "\t\t</system-out>" >> $report
119 if [ -f $seqres.dmesg ]; then
120 echo -e "\t\t<system-err>" >> $report
121 printf '<![CDATA[\n' >>$report
122 cat $seqres.dmesg | tr -dc '[:print:][:space:]' | encode_xml >>$report
123 printf ']]>\n' >>$report
124 echo -e "\t\t</system-err>" >> $report
125 elif [ -s $seqres.out.bad ]; then
126 echo -e "\t\t<system-err>" >> $report
127 printf '<![CDATA[\n' >>$report
128 $diff $seq.out $seqres.out.bad | encode_xml >>$report
129 printf ']]>\n' >>$report
130 echo -e "\t\t</system-err>" >> $report
134 echo -e "\t\t<failure message=\"Unknown ret_state=$ret_state\" type=\"TestFail\"/>" >> $report
137 echo -e "\t</testcase>" >> $report
142 # Common report generator entry points
143 _make_section_report()
145 for report in $REPORT_LIST; do
148 _xunit_make_section_report "$test_status"
151 _dump_err "format '$report' is not supported"
157 _make_testcase_report()
160 for report in $REPORT_LIST; do
163 _xunit_make_testcase_report "$test_status"
166 _dump_err "report format '$report' is not supported"
172 _assert_report_list() {
173 for report in $REPORT_LIST; do
178 _fatal "report format '$report' is not supported"