debuggers.hg

view tools/xm-test/runtest.sh @ 22848:6341fe0f4e5a

Added tag 4.1.0-rc2 for changeset 9dca60d88c63
author Keir Fraser <keir@xen.org>
date Tue Jan 25 14:06:55 2011 +0000 (2011-01-25)
parents 3a8e5f79ff41
children
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 <group> : run a group test set"
15 echo " available goups are:"
16 echo " "`ls grouptest`
17 echo " -e <email> : set email address for report"
18 echo " -r <url> : url of test results repository to use"
19 echo " -s <report> : just submit report <report>"
20 echo " -u : unsafe -- do not run the sanity checks before starting"
21 echo " -md : all created domains are xend-'managed' domains"
22 echo " -h | --help : show this help"
23 }
25 # Just submit the report
26 submit_report() {
28 reportfile=$1
30 ./lib/XmTestReport/Report.py $reportserver $reportfile
31 }
33 # Generate XML result report from output file
34 make_result_report() {
35 output=$1
36 reportfile=$2
37 if ! ./lib/XmTestReport/ResultReport.py $output > $reportfile; then
38 echo "Unable to generate clean ResultReport"
39 echo "Take a look at $report"
40 exit 1
41 fi
42 }
44 # Collect environment information for XML report
45 make_environment_report() {
46 os=$1
47 prog=$2
48 if ! ./lib/XmTestReport/OSReport.py > $os; then
49 echo "Unable to generate clean OSReport"
50 echo "Take a look at $os"
51 exit 1
52 fi
53 if ! ./lib/XmTestReport/ProgReport.py > $prog; then
54 echo "Unable to generate clean ProgReport"
55 echo "Take a look at $prog"
56 exit 1
57 fi
58 }
60 # Check conditions needed to actually run the tests
61 runnable_tests() {
62 # Make sure we're root
63 uid=$(id -u)
64 if [ $uid != 0 ]; then
65 echo "ERROR: I must be run as root!"
66 exit 1
67 fi
69 # See if the ramdisk has been built
70 rdsize=$(stat -Lc %s ramdisk/initrd.img 2>/dev/null)
71 if [ -z "$rdsize" ] || [ $rdsize -le 16384 ]; then
72 echo "Cannot find a valid ramdisk. You need to run \"make\" or"
73 echo "copy in a previously-built ramdisk to the ramdisk/ directory"
74 exit 1
75 fi
77 # Figure out the version of the ramdisk link and compare it
78 # to what it should be as a cheap way of making sure we're
79 # using the right version
80 realrd=$(readlink ramdisk/initrd.img)
81 eval $(./lib/XmTestReport/xmtest.py)
82 ARCH=$(uname -m | sed -e s/i.86/i386/)
83 rrdver="initrd-${XM_TEST_MAJ}.${XM_TEST_MIN}-${ARCH}.img"
84 exp_flag=0
85 realarch=`echo $realrd | awk -F- '{print $3}' | awk -F. '{print $1}'`
86 rrdarch=`echo $rrdver | awk -F- '{print $3}' | awk -F. '{print $1}'`
87 if [ "$realarch" = "i386" -a "$rrdarch" = "x86_64" ]; then
88 exp_flag=1
89 fi
90 if [ $exp_flag -eq 0 -a "$realrd" != "$rrdver" ]; then
91 echo "Error: ramdisk/initrd.img is from an old version, or is not for this "
92 echo "architecture ($ARCH)."
93 echo "You need to build a ramdisk from at least ${XM_TEST_MAJ}.${XM_TEST_MIN}"
94 #exit 1
95 fi
97 # See if xend is running
98 if ! xm list >/dev/null 2>&1; then
99 echo "'xm list' failed: is xend running?"
100 exit 1
101 fi
103 # Run a few sample tests to make sure things are working
104 # before we take the plunge
105 echo "Running sanity checks..."
106 make -C tests/_sanity check 2>&1 | grep REASON
107 if [ $? -eq 0 ]; then
108 echo "Sanity checks failed"
109 exit 1
110 fi
112 }
115 # Get contact info if needed
116 get_contact_info() {
118 if [ ! -f contact_info ]; then
119 if [ "$batch" = "yes" ]; then
120 echo "Unable to read contact_info!"
121 echo "Please run me once interactively before using batch mode!"
122 exit 1
123 else
124 echo "Please provide your email address so that we can "
125 echo "contact you if we need further information concerning"
126 echo "your results. Any information provided will be"
127 echo "kept private. If you wish to remain anonymous, please"
128 echo "hit [ENTER] now."
130 while ! echo "$EMAIL" | grep -q '@'; do
131 echo
132 echo -n "Your email address: "
133 read EMAIL
134 if [ -z $EMAIL ]; then
135 EMAIL="anonymous@somewhere.com"
136 fi
137 done
138 echo $EMAIL > contact_info
139 fi
140 fi
141 }
143 # Run the tests
144 run_tests() {
145 groupentered=$1
146 output=$2
147 report=$3
148 startfile=${report}.start
149 stopfile=${report}.stop
151 date -R > $startfile
152 exec < grouptest/$groupentered
153 while read casename testlist; do
154 echo Running $casename tests...
155 echo "*** case $casename from group $groupentered" >> $output
156 if [ -z "$testlist" ]; then
157 echo "*** Running tests for case $casename" >> $output
158 (cd tests/$casename && TEST_VERBOSE=1 make -k check) >> $output 2>&1
159 else
160 echo "*** Running tests $testlist from case $casename" >> $output
161 (cd tests/$casename && TEST_VERBOSE=1 make -k check TESTS="$testlist") >> $output 2>&1
162 fi
164 done
165 date -R > $stopfile
167 }
169 # Generate some plain-text reports
170 make_text_reports() {
171 passfail=$1
172 failures=$2
173 output=$3
174 reportfile=$4
175 report=$5
176 summary=summary.tmp
177 startfile=${report}.start
178 stopfile=${report}.stop
179 echo "Making PASS/FAIL report ($passfail)..."
180 cat $OUTPUT | egrep '(REASON|PASS|FAIL|XPASS|XFAIL|SKIP)' | perl -pe 's/^(PASS|FAIL|XPASS|XFAIL)(.+)$/$1$2\n/' > $passfail
182 echo "Making FAIL report ($failures)..."
183 cat $passfail | egrep '(REASON|FAIL)' > $failures
185 NUMPASS=`grep -c PASS $output`
186 NUMFAIL=`grep -c FAIL $output`
187 NUMXPASS=`grep -c XPASS $output`
188 NUMXFAIL=`grep -c XFAIL $output`
189 START=`cat $startfile`
190 STOP=`cat $stopfile`
191 cat > $summary << EOF
192 Xm-test timing summary:
193 Run Started : $START
194 Run Stoped : $STOP
195 Xm-test execution summary:
196 PASS: $NUMPASS
197 FAIL: $NUMFAIL
198 XPASS: $NUMXPASS
199 XFAIL: $NUMXFAIL
200 EOF
202 cat $summary > $reportfile
204 echo -e '\n\nDetails:\n' >> $reportfile
206 ./mkreport $passfail >> $reportfile
208 rm $summary
209 }
211 ############
212 ### Main ###
213 ############
215 # Defaults
216 MAXFAIL=10
217 report=yes
218 reportserver=${xmtest_repo:-'http://xmtest.dague.org/cgi-bin/report-results'}
219 batch=no
220 run=yes
221 unsafe=no
222 GROUPENTERED=default
224 #Prepare for usage with ACM
225 if [ -d /etc/xen/acm-security/policies ]; then
226 cp -f tests/security-acm/xm-test-security_policy.xml \
227 /etc/xen/acm-security/policies
228 fi
230 unset XM_MANAGED_DOMAINS
232 # Resolve options
233 while [ $# -gt 0 ]
234 do
235 case "$1" in
236 -d)
237 echo "(Skipping report submission)"
238 report=no
239 ;;
240 -b)
241 echo "(Batch mode)"
242 batch=yes
243 ;;
244 -e)
245 shift
246 echo $1 > contact_info
247 echo "(Email set to $1)"
248 ;;
249 -g)
250 shift
251 GROUPENTERED=$1
252 if [ ! -f grouptest/$GROUPENTERED ]; then
253 echo "No file for group $GROUPENTERED"
254 exit 1
255 fi
256 ;;
257 -r)
258 shift
259 reportserver=$1
260 ;;
261 -s)
262 run=no
263 ;;
264 -u)
265 echo "(Unsafe mode)"
266 unsafe=yes
267 report=no
268 ;;
269 -md)
270 echo "(use managed domains)"
271 export XM_MANAGED_DOMAINS=1
272 ;;
273 -h|--help)
274 usage
275 exit 0
276 ;;
277 *)
278 REPORT=$1
279 break
280 ;;
281 esac
282 shift
283 done
285 # Usage
286 if [ -z $REPORT ]; then
287 usage
288 exit 1
289 fi
291 # Output files
292 OSREPORTTEMP=${REPORT}.os.xml
293 PROGREPORTTEMP=${REPORT}.prog.xml
294 RESULTREPORTTEMP=${REPORT}.result.xml
295 XMLREPORT=${REPORT}.xml
296 OUTPUT=${REPORT}.output
297 SUMMARY=${REPORT}.summary
298 PASSFAIL=${REPORT}.passfail
299 TXTREPORT=${REPORT}.report
300 FAILURES=${REPORT}.failures
302 # Make sure permissions are correct
303 chmod a+x lib/XmTestReport/*
304 chmod a+x mkreport mergereport
306 if [ ! -f contact_info ]; then
307 if [ "$batch" = "yes" ]; then
308 echo "Unable to read contact_info"
309 echo "You must run me interactively once!"
310 exit 1
311 else
312 get_contact_info
313 fi
314 fi
316 if [ "$GROUPENTERED" != "default" ]; then
317 report=no;
318 fi
320 if [ "$run" != "no" ]; then
321 if [ "$unsafe" = "no" ]; then
322 runnable_tests
323 fi
324 rm -f $REPORT"*"
325 if [ "$unsafe" = "no" ]; then
326 make_environment_report $OSREPORTTEMP $PROGREPORTTEMP
327 fi
328 run_tests $GROUPENTERED $OUTPUT $REPORT
329 make_text_reports $PASSFAIL $FAILURES $OUTPUT $TXTREPORT $REPORT
330 if [ "$unsafe" = "no" ]; then
331 make_result_report $OUTPUT $RESULTREPORTTEMP
332 cat $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP > $XMLREPORT
333 rm $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP
334 fi
335 fi
337 if [ "$report" = "yes" ]; then
338 if [ ! -f "$XMLREPORT" ]; then
339 echo "No such file: $XMLREPORT"
340 exit 1
341 fi
342 submit_report $XMLREPORT
343 fi