ia64/xen-unstable

view tools/xm-test/runtest.sh @ 19615:13a4f4e6d0a3

x86 hvm: Correctly emulate task switches into vm86 mode.

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