direct-io.hg

view tools/xm-test/runtest.sh @ 9336:a6f1b3d653a9

Patch to correct inconsistencies of xm-test reporting.


Signed-off-by: Woody Marvel <marvel@us.ibm.com>
author root@dyn9047022116.beaverton.ibm.com
date Tue Mar 21 01:08:59 2006 +0100 (2006-03-21)
parents 000d5ccb2bec
children b78cab886a1e
line source
1 #!/bin/sh
3 ##
4 ## Test driver script
5 ##
7 usage() {
8 echo "Usage: $0 [opts] <report>"
9 echo " Where report is a name that will be used for report files"
10 echo ""
11 echo " Where opts are:"
12 echo " -d : do not submit a report for this run"
13 echo " -b : do not ask any questions (batch mode)"
14 echo " -g : run a group test set"
15 echo " -e <email> : set email address for report"
16 echo " -s <report> : just submit report <report>"
17 echo " -h | --help : show this help"
18 }
20 # Just submit the report
21 submit_report() {
23 reportfile=$1
25 ./lib/XmTestReport/Report.py $reportfile
26 }
28 # Generate XML result report from output file
29 make_result_report() {
30 output=$1
31 reportfile=$2
32 if ! ./lib/XmTestReport/ResultReport.py $output > $reportfile; then
33 echo "Unable to generate clean ResultReport"
34 echo "Take a look at $report"
35 exit 1
36 fi
37 }
39 # Collect environment information for XML report
40 make_environment_report() {
41 os=$1
42 prog=$2
43 if ! ./lib/XmTestReport/OSReport.py > $os; then
44 echo "Unable to generate clean OSReport"
45 echo "Take a look at $os"
46 exit 1
47 fi
48 if ! ./lib/XmTestReport/ProgReport.py > $prog; then
49 echo "Unable to generate clean ProgReport"
50 echo "Take a look at $prog"
51 exit 1
52 fi
53 }
55 # Check conditions needed to actually run the tests
56 runnable_tests() {
57 # Make sure we're root
58 uid=$(id -u)
59 if [ $uid != 0 ]; then
60 echo "ERROR: I must be run as root!"
61 exit 1
62 fi
64 # See if the ramdisk has been built
65 rdsize=$(stat -Lc %s ramdisk/initrd.img 2>/dev/null)
66 if [ -z "$rdsize" ] || [ $rdsize -le 16384 ]; then
67 echo "Cannot find a valid ramdisk. You need to run \"make\" or"
68 echo "copy in a previously-built ramdisk to the ramdisk/ directory"
69 exit 1
70 fi
72 # Figure out the version of the ramdisk link and compare it
73 # to what it should be as a cheap way of making sure we're
74 # using the right version
75 realrd=$(readlink ramdisk/initrd.img)
76 eval $(./lib/XmTestReport/xmtest.py)
77 rrdver="initrd-${XM_TEST_MAJ}.${XM_TEST_MIN}.img"
78 if [ "$realrd" != "$rrdver" ]; then
79 echo "Error: ramdisk/initrd.img is from an old version"
80 echo "You need to build a ramdisk from at least ${XM_TEST_MAJ}.${XM_TEST_MIN}"
81 exit 1
82 fi
84 # See if xend is running
85 if ! xm list >/dev/null 2>&1; then
86 echo "'xm list' failed: is xend running?"
87 exit 1
88 fi
90 # Run a few sample tests to make sure things are working
91 # before we take the plunge
92 echo "Running sanity checks..."
93 make -C tests/_sanity check 2>&1 | grep REASON
94 if [ $? -eq 0 ]; then
95 echo "Sanity checks failed"
96 exit 1
97 fi
99 }
102 # Get contact info if needed
103 get_contact_info() {
105 if [ ! -f contact_info ]; then
106 if [ "$batch" = "yes" ]; then
107 echo "Unable to read contact_info!"
108 echo "Please run me once interactively before using batch mode!"
109 exit 1
110 else
111 echo "Please provide your email address so that we can "
112 echo "contact you if we need further information concerning"
113 echo "your results. Any information provided will be"
114 echo "kept private. If you wish to remain anonymous, please"
115 echo "hit [ENTER] now."
117 while ! echo "$EMAIL" | grep -q '@'; do
118 echo
119 echo -n "Your email address: "
120 read EMAIL
121 if [ -z $EMAIL ]; then
122 EMAIL="anonymous@somewhere.com"
123 fi
124 done
125 echo $EMAIL > contact_info
126 fi
127 fi
128 }
130 # Run the tests
131 run_tests() {
132 groupentered=$1
133 output=$2
135 exec < grouptest/$groupentered
136 while read casename testlist; do
137 echo Running $casename tests...
138 echo "*** case $casename from group $groupentered" >> $output
139 if [ -z "$testlist" ]; then
140 echo "*** Running tests for case $casename" >> $output
141 (cd tests/$casename && TEST_VERBOSE=1 make -k check) >> $output 2>&1
142 else
143 echo "*** Running tests $testlist from case $casename" >> $output
144 (cd tests/$casename && TEST_VERBOSE=1 make -k check TESTS="$testlist") >> $output 2>&1
145 fi
147 done
149 }
151 # Generate some plain-text reports
152 make_text_reports() {
153 passfail=$1
154 failures=$2
155 output=$3
156 reportfile=$4
157 summary=summary.tmp
158 echo "Making PASS/FAIL report ($passfail)..."
159 cat $OUTPUT | egrep '(REASON|PASS|FAIL|XPASS|XFAIL|SKIP)' | perl -pe 's/^(PASS|FAIL|XPASS|XFAIL)(.+)$/$1$2\n/' > $passfail
161 echo "Making FAIL report ($failures)..."
162 cat $passfail | egrep '(REASON|FAIL)' > $failures
164 NUMPASS=`grep -c PASS $output`
165 NUMFAIL=`grep -c FAIL $output`
166 NUMXPASS=`grep -c XPASS $output`
167 NUMXFAIL=`grep -c XFAIL $output`
168 cat > $summary << EOF
169 Xm-test execution summary:
170 PASS: $NUMPASS
171 FAIL: $NUMFAIL
172 XPASS: $NUMXPASS
173 XFAIL: $NUMXFAIL
174 EOF
176 cat $summary > $reportfile
178 echo -e '\n\nDetails:\n' >> $reportfile
180 ./mkreport $passfail >> $reportfile
182 rm $summary
183 }
185 ############
186 ### Main ###
187 ############
189 # Defaults
190 MAXFAIL=10
191 report=yes
192 batch=no
193 run=yes
194 GROUPENTERED=default
196 # Resolve options
197 while [ $# -gt 0 ]
198 do
199 case "$1" in
200 -d)
201 echo "(Skipping report submission)"
202 report=no
203 ;;
204 -b)
205 echo "(Batch mode)"
206 batch=yes
207 ;;
208 -e)
209 shift
210 echo $1 > contact_info
211 echo "(Email set to $1)"
212 ;;
213 -g)
214 shift
215 GROUPENTERED=$1
216 if [ ! -f grouptest/$GROUPENTERED ]; then
217 echo "No file for group $GROUPENTERED"
218 exit 1
219 fi
220 ;;
221 -s)
222 run=no
223 ;;
224 -h|--help)
225 usage
226 exit 0
227 ;;
228 *)
229 REPORT=$1
230 break
231 ;;
232 esac
233 shift
234 done
236 # Usage
237 if [ -z $REPORT ]; then
238 usage
239 exit 1
240 fi
242 # Output files
243 OSREPORTTEMP=${REPORT}.os.xml
244 PROGREPORTTEMP=${REPORT}.prog.xml
245 RESULTREPORTTEMP=${REPORT}.result.xml
246 XMLREPORT=${REPORT}.xml
247 OUTPUT=${REPORT}.output
248 SUMMARY=${REPORT}.summary
249 PASSFAIL=${REPORT}.passfail
250 TXTREPORT=${REPORT}.report
251 FAILURES=${REPORT}.failures
253 # Make sure permissions are correct
254 chmod a+x lib/XmTestReport/*
255 chmod a+x mkreport mergereport
257 if [ ! -f contact_info ]; then
258 if [ "$batch" = "yes" ]; then
259 echo "Unable to read contact_info"
260 echo "You must run me interactively once!"
261 exit 1
262 else
263 get_contact_info
264 fi
265 fi
267 if [ "$GROUPENTERED" != "default" ]; then
268 report=no;
269 fi
271 if [ "$run" != "no" ]; then
272 runnable_tests
273 rm -f $REPORT"*"
274 make_environment_report $OSREPORTTEMP $PROGREPORTTEMP
275 run_tests $GROUPENTERED $OUTPUT
276 make_text_reports $PASSFAIL $FAILURES $OUTPUT $TXTREPORT
277 make_result_report $OUTPUT $RESULTREPORTTEMP
278 cat $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP > $XMLREPORT
279 rm $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP
281 fi
283 if [ "$report" = "yes" ]; then
284 if [ ! -f "$XMLREPORT" ]; then
285 echo "No such file: $XMLREPORT"
286 exit 1
287 fi
288 submit_report $XMLREPORT
289 fi