ia64/xen-unstable

view tools/xm-test/runtest.sh @ 7757:139aabe357a4

Various chmod a+x.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Thu Nov 10 12:00:09 2005 +0100 (2005-11-10)
parents 578736096552
children ab845d97de72
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 }
19 # Just submit the report
20 submit_report() {
22 reportfile=$1
24 ./lib/XmTestReport/Report.py $reportfile
25 }
27 # Generate XML result report from output file
28 make_result_report() {
29 output=$1
30 reportfile=$2
31 if ! ./lib/XmTestReport/ResultReport.py $output > $reportfile; then
32 echo "Unable to generate clean ResultReport"
33 echo "Take a look at $report"
34 exit 1
35 fi
36 }
38 # Collect environment information for XML report
39 make_environment_report() {
40 os=$1
41 prog=$2
42 if ! ./lib/XmTestReport/OSReport.py > $os; then
43 echo "Unable to generate clean OSReport"
44 echo "Take a look at $os"
45 exit 1
46 fi
47 if ! ./lib/XmTestReport/ProgReport.py > $prog; then
48 echo "Unable to generate clean ProgReport"
49 echo "Take a look at $prog"
50 exit 1
51 fi
52 }
54 # Check conditions needed to actually run the tests
55 runnable_tests() {
56 # Make sure we're root
57 uid=$(id -u)
58 if [ $uid != 0 ]; then
59 echo "ERROR: I must be run as root!"
60 exit 1
61 fi
63 # See if the ramdisk has been built
64 rdsize=$(stat -c %s ramdisk/initrd.img 2>/dev/null)
65 if [ -z "$rdsize" ] || [ $rdsize -le 16384 ]; then
66 echo "Cannot find a valid ramdisk. You need to run \"make\" or"
67 echo "copy in a previously-built ramdisk to the ramdisk/ directory"
68 exit 1
69 fi
71 # See if xend is running
72 if ! xm list >/dev/null 2>&1; then
73 echo "'xm list' failed: is xend running?"
74 exit 1
75 fi
77 }
79 # Get contact info if needed
80 get_contact_info() {
82 if [ ! -f contact_info ]; then
83 if [ "$batch" = "yes" ]; then
84 echo "Unable to read contact_info!"
85 echo "Please run me once interactively before using batch mode!"
86 exit 1
87 else
88 echo "Please provide your email address so that we can "
89 echo "contact you if we need further information concerning"
90 echo "your results. Any information provided will be"
91 echo "kept private. If you wish to remain anonymous, please"
92 echo "hit [ENTER] now."
94 while ! echo "$EMAIL" | grep -q '@'; do
95 echo
96 echo -n "Your email address: "
97 read EMAIL
98 if [ -z $EMAIL ]; then
99 EMAIL="anonymous@somewhere.com"
100 fi
101 done
102 echo $EMAIL > contact_info
103 fi
104 fi
105 }
107 # Run the tests
108 run_tests() {
109 output=$1
110 echo Running tests...
111 TEST_VERBOSE=1 make -k check > $output 2>&1
112 }
114 run_tests_quick() {
116 output=$1
118 create_tests="01_create_basic_pos.test 07_create_mem64_pos.test 10_create_fastdestroy.test 14_create_blockroot_pos.test"
119 unpause_tests="01_unpause_basic_pos.test"
120 memset_tests="01_memset_basic_pos.test 03_memset_random_pos.test"
121 help_tests="06_help_allcmds.test"
122 testgroups="create unpause memset help"
124 echo "*** Quick test" > $output
125 for group in $testgroups; do
126 eval $(echo list=\$${group}_tests)
127 echo "*** Running tests [$list] from $group"
128 (cd tests/$group && TEST_VERBOSE=1 make -k check TESTS="$list") >> $output 2>&1
129 done
131 }
133 # Generate some plain-text reports
134 make_text_reports() {
135 passfail=$1
136 failures=$2
137 output=$3
138 reportfile=$4
139 summary=summary.tmp
140 echo "Making PASS/FAIL report ($passfail)..."
141 cat $OUTPUT | egrep '(REASON|PASS|FAIL|XPASS|XFAIL|SKIP)' | perl -pe 's/^(PASS|FAIL|XPASS|XFAIL)(.+)$/$1$2\n/' > $passfail
143 echo "Making FAIL report ($failures)..."
144 cat $passfail | egrep '(REASON|FAIL)' > $failures
146 NUMPASS=`grep -c PASS $output`
147 NUMFAIL=`grep -c FAIL $output`
148 NUMXPASS=`grep -c XPASS $output`
149 NUMXFAIL=`grep -c XFAIL $output`
150 cat > $summary << EOF
151 Xm-test execution summary:
152 PASS: $NUMPASS
153 FAIL: $NUMFAIL
154 XPASS: $NUMXPASS
155 XFAIL: $NUMXFAIL
156 EOF
158 cat $summary > $reportfile
160 echo -e '\n\nDetails:\n' >> $reportfile
162 ./mkreport $passfail >> $reportfile
164 rm $summary
165 }
167 ############
168 ### Main ###
169 ############
171 # Defaults
172 MAXFAIL=10
173 report=yes
174 batch=no
175 run=yes
177 # Resolve options
178 while [ $# -gt 0 ]
179 do
180 case "$1" in
181 -d)
182 echo "(Skipping report submission)"
183 report=no
184 ;;
185 -b)
186 echo "(Batch mode)"
187 batch=yes
188 ;;
189 -e)
190 shift
191 echo $1 > contact_info
192 echo "(Email set to $1)"
193 ;;
194 -q)
195 run=quick
196 ;;
197 -s)
198 run=no
199 ;;
200 *)
201 REPORT=$1
202 break
203 ;;
204 esac
205 shift
206 done
208 # Usage
209 if [ -z $REPORT ]; then
210 usage
211 exit 1
212 fi
214 # Output files
215 OSREPORTTEMP=${REPORT}.os.xml
216 PROGREPORTTEMP=${REPORT}.prog.xml
217 RESULTREPORTTEMP=${REPORT}.result.xml
218 XMLREPORT=${REPORT}.xml
219 OUTPUT=${REPORT}.output
220 SUMMARY=${REPORT}.summary
221 PASSFAIL=${REPORT}.passfail
222 TXTREPORT=${REPORT}.report
223 FAILURES=${REPORT}.failures
225 # Make sure permissions are correct
226 chmod a+x lib/XmTestReport/*
227 chmod a+x mkreport mergereport
229 if [ ! -f contact_info ]; then
230 if [ "$batch" = "yes" ]; then
231 echo "Unable to read contact_info"
232 echo "You must run me interactively once!"
233 exit 1
234 else
235 get_contact_info
236 fi
237 fi
239 if [ "$run" != "no" ]; then
240 runnable_tests
241 make_environment_report $OSREPORTTEMP $PROGREPORTTEMP
242 if [ "$run" = "yes" ]; then
243 run_tests $OUTPUT
244 else
245 run_tests_quick $OUTPUT
246 fi
247 make_text_reports $PASSFAIL $FAILURES $OUTPUT $TXTREPORT
248 make_result_report $OUTPUT $RESULTREPORTTEMP
249 cat $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP > $XMLREPORT
250 rm $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP
251 fi
253 if [ "$report" = "yes" ] && [ "$run" = "yes" ]; then
254 if [ ! -f "$XMLREPORT" ]; then
255 echo "No such file: $XMLREPORT"
256 exit 1
257 fi
258 submit_report $XMLREPORT
259 fi