add support for the vdi image format
[qemu-iotests/stefanha.git] / check
blob79d8cc076a80ba340573e835dc92aec93f891d02
1 #!/bin/sh
3 # Copyright (C) 2009 Red Hat, Inc.
4 # Copyright (c) 2000-2002,2006 Silicon Graphics, Inc. All Rights Reserved.
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation.
10 # This program is distributed in the hope that it would be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write the Free Software Foundation,
17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 # Control script for QA
23 tmp=/tmp/$$
24 status=0
25 needwrap=true
26 try=0
27 n_bad=0
28 bad=""
29 notrun=""
30 interrupt=true
32 # by default don't output timestamps
33 timestamp=${TIMESTAMP:=false}
35 # generic initialization
36 iam=check
38 # we need common.config
39 if ! . ./common.config
40 then
41 echo "$iam: failed to source common.config"
42 exit 1
45 # we need common
46 . ./common
48 # we need common.rc
49 if ! . ./common.rc
50 then
51 echo "check: failed to source common.rc"
52 exit 1
55 #if [ `id -u` -ne 0 ]
56 #then
57 # echo "check: QA must be run as root"
58 # exit 1
59 #fi
61 _wallclock()
63 date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
66 _timestamp()
68 now=`date "+%T"`
69 echo -n " [$now]"
72 _wrapup()
74 # for hangcheck ...
75 # remove files that were used by hangcheck
77 [ -f /tmp/check.pid ] && rm -rf /tmp/check.pid
78 [ -f /tmp/check.sts ] && rm -rf /tmp/check.sts
80 if $showme
81 then
83 elif $needwrap
84 then
85 if [ -f check.time -a -f $tmp.time ]
86 then
87 cat check.time $tmp.time \
88 | $AWK_PROG '
89 { t[$1] = $2 }
90 END { if (NR > 0) {
91 for (i in t) print i " " t[i]
93 }' \
94 | sort -n >$tmp.out
95 mv $tmp.out check.time
98 if [ -f $tmp.expunged ]
99 then
100 notrun=`wc -l <$tmp.expunged | sed -e 's/ *//g'`
101 try=`expr $try - $notrun`
102 list=`echo "$list" | sed -f $tmp.expunged`
105 echo "" >>check.log
106 date >>check.log
107 echo $list | fmt | sed -e 's/^/ /' >>check.log
108 $interrupt && echo "Interrupted!" >>check.log
110 if [ ! -z "$notrun" ]
111 then
112 echo "Not run:$notrun"
113 echo "Not run:$notrun" >>check.log
115 if [ ! -z "$n_bad" -a $n_bad != 0 ]
116 then
117 echo "Failures:$bad"
118 echo "Failed $n_bad of $try tests"
119 echo "Failures:$bad" | fmt >>check.log
120 echo "Failed $n_bad of $try tests" >>check.log
121 else
122 echo "Passed all $try tests"
123 echo "Passed all $try tests" >>check.log
125 needwrap=false
128 rm -f /tmp/*.out /tmp/*.err /tmp/*.time
129 rm -f /tmp/check.pid /tmp/check.sts
130 rm -f $tmp.*
133 trap "_wrapup; exit \$status" 0 1 2 3 15
135 # for hangcheck ...
136 # Save pid of check in a well known place, so that hangcheck can be sure it
137 # has the right pid (getting the pid from ps output is not reliable enough).
139 rm -rf /tmp/check.pid
140 echo $$ >/tmp/check.pid
142 # for hangcheck ...
143 # Save the status of check in a well known place, so that hangcheck can be
144 # sure to know where check is up to (getting test number from ps output is
145 # not reliable enough since the trace stuff has been introduced).
147 rm -rf /tmp/check.sts
148 echo "preamble" >/tmp/check.sts
150 # don't leave old full output behind on a clean run
151 rm -f check.full
153 [ -f check.time ] || touch check.time
155 FULL_IMGFMT_DETAILS=`_full_imgfmt_details`
156 FULL_HOST_DETAILS=`_full_platform_details`
157 #FULL_MKFS_OPTIONS=`_scratch_mkfs_options`
158 #FULL_MOUNT_OPTIONS=`_scratch_mount_options`
160 cat <<EOF
161 IMGFMT -- $FULL_IMGFMT_DETAILS
162 PLATFORM -- $FULL_HOST_DETAILS
165 #MKFS_OPTIONS -- $FULL_MKFS_OPTIONS
166 #MOUNT_OPTIONS -- $FULL_MOUNT_OPTIONS
168 seq="check"
170 [ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG
172 for seq in $list
174 err=false
175 echo -n "$seq"
176 if [ -n "$TESTS_REMAINING_LOG" ] ; then
177 sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp
178 mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG
179 sync
182 if $showme
183 then
184 echo
185 continue
186 elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null
187 then
188 echo " - expunged"
189 rm -f $seq.out.bad
190 echo "/^$seq\$/d" >>$tmp.expunged
191 elif [ ! -f $seq ]
192 then
193 echo " - no such test?"
194 echo "/^$seq\$/d" >>$tmp.expunged
195 else
196 # really going to try and run this one
198 rm -f $seq.out.bad
199 lasttime=`sed -n -e "/^$seq /s/.* //p" <check.time`
200 if [ "X$lasttime" != X ]; then
201 echo -n " ${lasttime}s ..."
202 else
203 echo -n " " # prettier output with timestamps.
205 rm -f core $seq.notrun
207 # for hangcheck ...
208 echo "$seq" >/tmp/check.sts
210 start=`_wallclock`
211 $timestamp && echo -n " ["`date "+%T"`"]"
212 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
213 ./$seq >$tmp.out 2>&1
214 sts=$?
215 $timestamp && _timestamp
216 stop=`_wallclock`
218 if [ -f core ]
219 then
220 echo -n " [dumped core]"
221 mv core $seq.core
222 err=true
225 if [ -f $seq.notrun ]
226 then
227 $timestamp || echo -n " [not run] "
228 $timestamp && echo " [not run]" && echo -n " $seq -- "
229 cat $seq.notrun
230 notrun="$notrun $seq"
231 else
232 if [ $sts -ne 0 ]
233 then
234 echo -n " [failed, exit status $sts]"
235 err=true
237 if [ ! -f $seq.out ]
238 then
239 echo " - no qualified output"
240 err=true
241 else
242 if diff $seq.out $tmp.out >/dev/null 2>&1
243 then
244 echo ""
245 if $err
246 then
248 else
249 echo "$seq `expr $stop - $start`" >>$tmp.time
251 else
252 echo " - output mismatch (see $seq.out.bad)"
253 mv $tmp.out $seq.out.bad
254 $diff $seq.out $seq.out.bad
255 err=true
262 # come here for each test, except when $showme is true
264 if $err
265 then
266 bad="$bad $seq"
267 n_bad=`expr $n_bad + 1`
268 quick=false
270 [ -f $seq.notrun ] || try=`expr $try + 1`
272 seq="after_$seq"
273 done
275 interrupt=false
276 status=`expr $n_bad`
277 exit