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"
29 # Xunit format report functions
33 local value="${!name}"
35 if [ ! -z "$value" ]; then
36 echo -e "\t\t<property name=\"$name\" value=\"$value\"/>" >> $REPORT_DIR/result.xml
39 _xunit_make_section_report()
41 # xfstest:section ==> xunit:testsuite
42 local sect_name=$section
43 local sect_time=`expr $sect_stop - $sect_start`
44 local n_total=`expr $n_try + $n_notrun`
46 if [ $sect_name == '-no-sections-' ]; then
49 local report=$tmp.report.xunit.$sect_name.xml
51 echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $REPORT_DIR/result.xml
52 local dtime=`echo $date_time| tr " " 'T'`
53 local stats="errors=\"$n_bad\" skipped=\"$n_notrun\" tests=\"$n_total\" time=\"$sect_time\""
54 local hw_info="hostname=\"$HOST\" timestamp=\"$dtime\" "
55 echo "<testsuite name=\"xfstests\" $stats $hw_info >" >> $REPORT_DIR/result.xml
58 echo -e "\t<properties>" >> $REPORT_DIR/result.xml
59 for p in $REPORT_ENV_LIST;do
60 _xunit_add_property "$p"
62 echo -e "\t</properties>" >> $REPORT_DIR/result.xml
63 cat $tmp.report.xunit.$sect_name.xml >> $REPORT_DIR/result.xml
64 echo "</testsuite>" >> $REPORT_DIR/result.xml
65 echo "Xunit report: $REPORT_DIR/result.xml"
68 _xunit_make_testcase_report()
70 local test_status="$1"
71 local test_time=`expr $stop - $start`
72 local strip="$SRC_DIR/"
73 local test_name=${seq#$strip}
74 local sect_name=$section
76 # TODO: other places may also win if no-section mode will be named like 'default/global'
77 if [ $sect_name == '-no-sections-' ]; then
81 local report=$tmp.report.xunit.$sect_name.xml
83 echo -e "\t<testcase classname=\"xfstests.$sect_name\" name=\"$test_name\" time=\"$test_time\">" >> $report
88 if [ -f $seqres.notrun ]; then
89 local msg=`cat $seqres.notrun`
90 echo -e "\t\t<skipped message=\"$msg\" />" >> $report
92 echo -e "\t\t<skipped/>" >> $report
96 echo -e "\t\t<skipped/>" >> $report
99 if [ -z "$err_msg" ]; then
100 err_msg="Test $sequm failed, reason unknown"
102 echo -e "\t\t<failure message=\"$err_msg\" type=\"TestFail\" />" >> $report
103 if [ -s $seqres.full ]; then
104 echo -e "\t\t<system-out>" >> $report
105 printf '<![CDATA[\n' >>$report
106 cat $seqres.full | tr -dc '[:print:][:space:]' >>$report
107 printf ']]>\n' >>$report
108 echo -e "\t\t</system-out>" >> $report
110 if [ -f $seqres.dmesg ]; then
111 echo -e "\t\t<system-err>" >> $report
112 printf '<![CDATA[\n' >>$report
113 cat $seqres.dmesg | tr -dc '[:print:][:space:]' >>$report
114 printf ']]>\n' >>$report
115 echo -e "\t\t</system-err>" >> $report
116 elif [ -s $seqres.out.bad ]; then
117 echo -e "\t\t<system-err>" >> $report
118 printf '<![CDATA[\n' >>$report
119 $diff $seq.out $seqres.out.bad >>$report
120 printf ']]>\n' >>$report
121 echo -e "\t\t</system-err>" >> $report
125 echo -e "\t\t<failure message=\"Unknown ret_state=$ret_state\" type=\"TestFail\"/>" >> $report
128 echo -e "\t</testcase>" >> $report
133 # Common report generator entry points
134 _make_section_report()
136 for report in $REPORT_LIST; do
139 _xunit_make_section_report "$test_status"
142 _dump_err "format '$report' is not supported"
148 _make_testcase_report()
151 for report in $REPORT_LIST; do
154 _xunit_make_testcase_report "$test_status"
157 _dump_err "report format '$report' is not supported"
163 _assert_report_list() {
164 for report in $REPORT_LIST; do
169 _fatal "report format '$report' is not supported"