ia64/xen-unstable

view tools/xm-test/runtest.sh @ 8186:28bd01c9b596

Merge
author djm@kirby.fc.hp.com
date Fri Dec 02 12:52:25 2005 -0600 (2005-12-02)
parents 206731134e18
children 000d5ccb2bec
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 " -q : run a quick 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 }
101 # Get contact info if needed
102 get_contact_info() {
104 if [ ! -f contact_info ]; then
105 if [ "$batch" = "yes" ]; then
106 echo "Unable to read contact_info!"
107 echo "Please run me once interactively before using batch mode!"
108 exit 1
109 else
110 echo "Please provide your email address so that we can "
111 echo "contact you if we need further information concerning"
112 echo "your results. Any information provided will be"
113 echo "kept private. If you wish to remain anonymous, please"
114 echo "hit [ENTER] now."
116 while ! echo "$EMAIL" | grep -q '@'; do
117 echo
118 echo -n "Your email address: "
119 read EMAIL
120 if [ -z $EMAIL ]; then
121 EMAIL="anonymous@somewhere.com"
122 fi
123 done
124 echo $EMAIL > contact_info
125 fi
126 fi
127 }
129 # Run the tests
130 run_tests() {
131 output=$1
132 echo Running real tests...
133 TEST_VERBOSE=1 make -k check > $output 2>&1
134 }
136 run_tests_quick() {
138 output=$1
140 create_tests="01_create_basic_pos.test 07_create_mem64_pos.test 10_create_fastdestroy.test 14_create_blockroot_pos.test"
141 unpause_tests="01_unpause_basic_pos.test"
142 memset_tests="01_memset_basic_pos.test 03_memset_random_pos.test"
143 help_tests="06_help_allcmds.test"
144 testgroups="create unpause memset help"
146 echo "*** Quick test" > $output
147 for group in $testgroups; do
148 eval $(echo list=\$${group}_tests)
149 echo "*** Running tests [$list] from $group"
150 (cd tests/$group && TEST_VERBOSE=1 make -k check TESTS="$list") >> $output 2>&1
151 done
153 }
155 # Generate some plain-text reports
156 make_text_reports() {
157 passfail=$1
158 failures=$2
159 output=$3
160 reportfile=$4
161 summary=summary.tmp
162 echo "Making PASS/FAIL report ($passfail)..."
163 cat $OUTPUT | egrep '(REASON|PASS|FAIL|XPASS|XFAIL|SKIP)' | perl -pe 's/^(PASS|FAIL|XPASS|XFAIL)(.+)$/$1$2\n/' > $passfail
165 echo "Making FAIL report ($failures)..."
166 cat $passfail | egrep '(REASON|FAIL)' > $failures
168 NUMPASS=`grep -c PASS $output`
169 NUMFAIL=`grep -c FAIL $output`
170 NUMXPASS=`grep -c XPASS $output`
171 NUMXFAIL=`grep -c XFAIL $output`
172 cat > $summary << EOF
173 Xm-test execution summary:
174 PASS: $NUMPASS
175 FAIL: $NUMFAIL
176 XPASS: $NUMXPASS
177 XFAIL: $NUMXFAIL
178 EOF
180 cat $summary > $reportfile
182 echo -e '\n\nDetails:\n' >> $reportfile
184 ./mkreport $passfail >> $reportfile
186 rm $summary
187 }
189 ############
190 ### Main ###
191 ############
193 # Defaults
194 MAXFAIL=10
195 report=yes
196 batch=no
197 run=yes
199 # Resolve options
200 while [ $# -gt 0 ]
201 do
202 case "$1" in
203 -d)
204 echo "(Skipping report submission)"
205 report=no
206 ;;
207 -b)
208 echo "(Batch mode)"
209 batch=yes
210 ;;
211 -e)
212 shift
213 echo $1 > contact_info
214 echo "(Email set to $1)"
215 ;;
216 -q)
217 run=quick
218 ;;
219 -s)
220 run=no
221 ;;
222 -h|--help)
223 usage
224 exit 0
225 ;;
226 *)
227 REPORT=$1
228 break
229 ;;
230 esac
231 shift
232 done
234 # Usage
235 if [ -z $REPORT ]; then
236 usage
237 exit 1
238 fi
240 # Output files
241 OSREPORTTEMP=${REPORT}.os.xml
242 PROGREPORTTEMP=${REPORT}.prog.xml
243 RESULTREPORTTEMP=${REPORT}.result.xml
244 XMLREPORT=${REPORT}.xml
245 OUTPUT=${REPORT}.output
246 SUMMARY=${REPORT}.summary
247 PASSFAIL=${REPORT}.passfail
248 TXTREPORT=${REPORT}.report
249 FAILURES=${REPORT}.failures
251 # Make sure permissions are correct
252 chmod a+x lib/XmTestReport/*
253 chmod a+x mkreport mergereport
255 if [ ! -f contact_info ]; then
256 if [ "$batch" = "yes" ]; then
257 echo "Unable to read contact_info"
258 echo "You must run me interactively once!"
259 exit 1
260 else
261 get_contact_info
262 fi
263 fi
265 if [ "$run" != "no" ]; then
266 runnable_tests
267 make_environment_report $OSREPORTTEMP $PROGREPORTTEMP
268 if [ "$run" = "yes" ]; then
269 run_tests $OUTPUT
270 else
271 run_tests_quick $OUTPUT
272 fi
273 make_text_reports $PASSFAIL $FAILURES $OUTPUT $TXTREPORT
274 make_result_report $OUTPUT $RESULTREPORTTEMP
275 cat $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP > $XMLREPORT
276 rm $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP
277 fi
279 if [ "$report" = "yes" ] && [ "$run" = "yes" ]; then
280 if [ ! -f "$XMLREPORT" ]; then
281 echo "No such file: $XMLREPORT"
282 exit 1
283 fi
284 submit_report $XMLREPORT
285 fi