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 if [ -z "$date_time" ]; then
63 date_time=$(date +"%F %T")
65 local dtime=`echo $date_time| tr " " 'T'`
66 local stats="failures=\"$n_bad\" skipped=\"$n_notrun\" tests=\"$n_total\" time=\"$sect_time\""
67 local hw_info="hostname=\"$HOST\" timestamp=\"$dtime\" "
68 echo "<testsuite name=\"xfstests\" $stats $hw_info >" >> $REPORT_DIR/result.xml
71 echo -e "\t<properties>" >> $REPORT_DIR/result.xml
72 for p in $REPORT_ENV_LIST;do
73 _xunit_add_property "$p"
75 echo -e "\t</properties>" >> $REPORT_DIR/result.xml
76 if [ -f $report ]; then
77 cat $report >> $REPORT_DIR/result.xml
79 echo "</testsuite>" >> $REPORT_DIR/result.xml
80 echo "Xunit report: $REPORT_DIR/result.xml"
83 _xunit_make_testcase_report()
86 local test_status="$2"
87 local test_time=`expr $stop - $start`
88 local strip="$SRC_DIR/"
89 local test_name=${test_seq#$strip}
90 local sect_name=$section
92 # TODO: other places may also win if no-section mode will be named like 'default/global'
93 if [ $sect_name == '-no-sections-' ]; then
97 local report=$tmp.report.xunit.$sect_name.xml
99 echo -e "\t<testcase classname=\"xfstests.$sect_name\" name=\"$test_name\" time=\"$test_time\">" >> $report
104 if [ -f $seqres.notrun ]; then
105 local msg=`cat $seqres.notrun | encode_xml`
106 echo -e "\t\t<skipped message=\"$msg\" />" >> $report
108 echo -e "\t\t<skipped/>" >> $report
112 echo -e "\t\t<skipped/>" >> $report
115 if [ -z "$_err_msg" ]; then
116 _err_msg="Test $sequm failed, reason unknown"
118 echo -e "\t\t<failure message=\"$_err_msg\" type=\"TestFail\" />" >> $report
119 if [ -s $seqres.full ]; then
120 echo -e "\t\t<system-out>" >> $report
121 printf '<![CDATA[\n' >>$report
122 cat $seqres.full | tr -dc '[:print:][:space:]' | encode_xml >>$report
123 printf ']]>\n' >>$report
124 echo -e "\t\t</system-out>" >> $report
126 if [ -f $seqres.dmesg ]; then
127 echo -e "\t\t<system-err>" >> $report
128 printf '<![CDATA[\n' >>$report
129 cat $seqres.dmesg | tr -dc '[:print:][:space:]' | encode_xml >>$report
130 printf ']]>\n' >>$report
131 echo -e "\t\t</system-err>" >> $report
132 elif [ -s $seqres.out.bad ]; then
133 echo -e "\t\t<system-err>" >> $report
134 printf '<![CDATA[\n' >>$report
135 $diff $test_seq.out $seqres.out.bad | encode_xml >>$report
136 printf ']]>\n' >>$report
137 echo -e "\t\t</system-err>" >> $report
141 echo -e "\t\t<failure message=\"Unknown test_status=$test_status\" type=\"TestFail\"/>" >> $report
144 echo -e "\t</testcase>" >> $report
149 # Common report generator entry points
150 _make_section_report()
152 for report in $REPORT_LIST; do
155 _xunit_make_section_report "$test_status"
158 _dump_err "format '$report' is not supported"
164 _make_testcase_report()
167 local test_status="$2"
168 for report in $REPORT_LIST; do
171 _xunit_make_testcase_report "$test_seq" "$test_status"
174 _dump_err "report format '$report' is not supported"
180 _assert_report_list() {
181 for report in $REPORT_LIST; do
186 _fatal "report format '$report' is not supported"