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"
31 sed -e 's/&/\&/g' \
39 # Xunit format report functions
43 local value="${!name}"
45 if [ ! -z "$value" ]; then
46 echo -e "\t\t<property name=\"$name\" value=\"$value\"/>" >> $REPORT_DIR/result.xml
49 _xunit_make_section_report()
51 # xfstest:section ==> xunit:testsuite
52 local sect_name=$section
53 local sect_time=`expr $sect_stop - $sect_start`
54 local n_total=`expr $n_try + $n_notrun`
56 if [ $sect_name == '-no-sections-' ]; then
59 local report=$tmp.report.xunit.$sect_name.xml
61 echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $REPORT_DIR/result.xml
62 local dtime=`echo $date_time| tr " " 'T'`
63 local stats="failures=\"$n_bad\" skipped=\"$n_notrun\" tests=\"$n_total\" time=\"$sect_time\""
64 local hw_info="hostname=\"$HOST\" timestamp=\"$dtime\" "
65 echo "<testsuite name=\"xfstests\" $stats $hw_info >" >> $REPORT_DIR/result.xml
68 echo -e "\t<properties>" >> $REPORT_DIR/result.xml
69 for p in $REPORT_ENV_LIST;do
70 _xunit_add_property "$p"
72 echo -e "\t</properties>" >> $REPORT_DIR/result.xml
73 cat $tmp.report.xunit.$sect_name.xml >> $REPORT_DIR/result.xml
74 echo "</testsuite>" >> $REPORT_DIR/result.xml
75 echo "Xunit report: $REPORT_DIR/result.xml"
78 _xunit_make_testcase_report()
81 local test_status="$2"
82 local test_time=`expr $stop - $start`
83 local strip="$SRC_DIR/"
84 local test_name=${test_seq#$strip}
85 local sect_name=$section
87 # TODO: other places may also win if no-section mode will be named like 'default/global'
88 if [ $sect_name == '-no-sections-' ]; then
92 local report=$tmp.report.xunit.$sect_name.xml
94 echo -e "\t<testcase classname=\"xfstests.$sect_name\" name=\"$test_name\" time=\"$test_time\">" >> $report
99 if [ -f $seqres.notrun ]; then
100 local msg=`cat $seqres.notrun | encode_xml`
101 echo -e "\t\t<skipped message=\"$msg\" />" >> $report
103 echo -e "\t\t<skipped/>" >> $report
107 echo -e "\t\t<skipped/>" >> $report
110 if [ -z "$_err_msg" ]; then
111 _err_msg="Test $sequm failed, reason unknown"
113 echo -e "\t\t<failure message=\"$_err_msg\" type=\"TestFail\" />" >> $report
114 if [ -s $seqres.full ]; then
115 echo -e "\t\t<system-out>" >> $report
116 printf '<![CDATA[\n' >>$report
117 cat $seqres.full | tr -dc '[:print:][:space:]' | encode_xml >>$report
118 printf ']]>\n' >>$report
119 echo -e "\t\t</system-out>" >> $report
121 if [ -f $seqres.dmesg ]; then
122 echo -e "\t\t<system-err>" >> $report
123 printf '<![CDATA[\n' >>$report
124 cat $seqres.dmesg | tr -dc '[:print:][:space:]' | encode_xml >>$report
125 printf ']]>\n' >>$report
126 echo -e "\t\t</system-err>" >> $report
127 elif [ -s $seqres.out.bad ]; then
128 echo -e "\t\t<system-err>" >> $report
129 printf '<![CDATA[\n' >>$report
130 $diff $test_seq.out $seqres.out.bad | encode_xml >>$report
131 printf ']]>\n' >>$report
132 echo -e "\t\t</system-err>" >> $report
136 echo -e "\t\t<failure message=\"Unknown test_status=$test_status\" type=\"TestFail\"/>" >> $report
139 echo -e "\t</testcase>" >> $report
144 # Common report generator entry points
145 _make_section_report()
147 for report in $REPORT_LIST; do
150 _xunit_make_section_report "$test_status"
153 _dump_err "format '$report' is not supported"
159 _make_testcase_report()
162 local test_status="$2"
163 for report in $REPORT_LIST; do
166 _xunit_make_testcase_report "$test_seq" "$test_status"
169 _dump_err "report format '$report' is not supported"
175 _assert_report_list() {
176 for report in $REPORT_LIST; do
181 _fatal "report format '$report' is not supported"