]> git.proxmox.com Git - qemu.git/blame - tests/qemu-iotests/check
Merge remote-tracking branch 'kwolf/for-anthony' into staging
[qemu.git] / tests / qemu-iotests / check
CommitLineData
908eaf68 1#!/bin/bash
6bf19c94
CH
2#
3# Copyright (C) 2009 Red Hat, Inc.
4# Copyright (c) 2000-2002,2006 Silicon Graphics, Inc. All Rights Reserved.
5#
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.
9#
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.
14#
15# You should have received a copy of the GNU General Public License
e8c212d6 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
6bf19c94
CH
17#
18#
19# Control script for QA
20#
21
22tmp=/tmp/$$
23status=0
24needwrap=true
25try=0
26n_bad=0
27bad=""
28notrun=""
29interrupt=true
30
31# by default don't output timestamps
32timestamp=${TIMESTAMP:=false}
33
34# generic initialization
35iam=check
36
37# we need common.config
38if ! . ./common.config
39then
40 echo "$iam: failed to source common.config"
41 exit 1
42fi
43
6bf19c94
CH
44# we need common.rc
45if ! . ./common.rc
46then
47 echo "check: failed to source common.rc"
48 exit 1
49fi
50
89004368
KW
51# we need common
52. ./common
53
6bf19c94
CH
54#if [ `id -u` -ne 0 ]
55#then
56# echo "check: QA must be run as root"
57# exit 1
58#fi
59
60_wallclock()
61{
62 date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
63}
64
65_timestamp()
66{
67 now=`date "+%T"`
68 echo -n " [$now]"
69}
70
71_wrapup()
72{
73 # for hangcheck ...
74 # remove files that were used by hangcheck
75 #
76 [ -f /tmp/check.pid ] && rm -rf /tmp/check.pid
77 [ -f /tmp/check.sts ] && rm -rf /tmp/check.sts
78
79 if $showme
80 then
81 :
82 elif $needwrap
83 then
84 if [ -f check.time -a -f $tmp.time ]
85 then
86 cat check.time $tmp.time \
87 | $AWK_PROG '
88 { t[$1] = $2 }
89END { if (NR > 0) {
90 for (i in t) print i " " t[i]
91 }
92 }' \
93 | sort -n >$tmp.out
94 mv $tmp.out check.time
95 fi
96
97 if [ -f $tmp.expunged ]
98 then
99 notrun=`wc -l <$tmp.expunged | sed -e 's/ *//g'`
100 try=`expr $try - $notrun`
101 list=`echo "$list" | sed -f $tmp.expunged`
102 fi
103
104 echo "" >>check.log
105 date >>check.log
106 echo $list | fmt | sed -e 's/^/ /' >>check.log
107 $interrupt && echo "Interrupted!" >>check.log
108
109 if [ ! -z "$notrun" ]
110 then
111 echo "Not run:$notrun"
112 echo "Not run:$notrun" >>check.log
113 fi
114 if [ ! -z "$n_bad" -a $n_bad != 0 ]
115 then
116 echo "Failures:$bad"
117 echo "Failed $n_bad of $try tests"
118 echo "Failures:$bad" | fmt >>check.log
119 echo "Failed $n_bad of $try tests" >>check.log
120 else
121 echo "Passed all $try tests"
122 echo "Passed all $try tests" >>check.log
123 fi
124 needwrap=false
125 fi
126
127 rm -f /tmp/*.out /tmp/*.err /tmp/*.time
128 rm -f /tmp/check.pid /tmp/check.sts
129 rm -f $tmp.*
130}
131
132trap "_wrapup; exit \$status" 0 1 2 3 15
133
134# for hangcheck ...
135# Save pid of check in a well known place, so that hangcheck can be sure it
136# has the right pid (getting the pid from ps output is not reliable enough).
137#
138rm -rf /tmp/check.pid
139echo $$ >/tmp/check.pid
140
141# for hangcheck ...
142# Save the status of check in a well known place, so that hangcheck can be
143# sure to know where check is up to (getting test number from ps output is
144# not reliable enough since the trace stuff has been introduced).
145#
146rm -rf /tmp/check.sts
147echo "preamble" >/tmp/check.sts
148
149# don't leave old full output behind on a clean run
150rm -f check.full
151
152[ -f check.time ] || touch check.time
153
154FULL_IMGFMT_DETAILS=`_full_imgfmt_details`
9cdfa1b3 155FULL_IMGPROTO_DETAILS=`_full_imgproto_details`
6bf19c94
CH
156FULL_HOST_DETAILS=`_full_platform_details`
157#FULL_MKFS_OPTIONS=`_scratch_mkfs_options`
158#FULL_MOUNT_OPTIONS=`_scratch_mount_options`
159
160cat <<EOF
df4b627e
LMR
161QEMU -- $QEMU
162QEMU_IMG -- $QEMU_IMG
163QEMU_IO -- $QEMU_IO
6bf19c94 164IMGFMT -- $FULL_IMGFMT_DETAILS
9cdfa1b3 165IMGPROTO -- $FULL_IMGPROTO_DETAILS
6bf19c94
CH
166PLATFORM -- $FULL_HOST_DETAILS
167
168EOF
169#MKFS_OPTIONS -- $FULL_MKFS_OPTIONS
170#MOUNT_OPTIONS -- $FULL_MOUNT_OPTIONS
171
172seq="check"
173
174[ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG
175
176for seq in $list
177do
178 err=false
179 echo -n "$seq"
180 if [ -n "$TESTS_REMAINING_LOG" ] ; then
181 sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp
182 mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG
183 sync
184 fi
185
186 if $showme
187 then
188 echo
189 continue
190 elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null
191 then
192 echo " - expunged"
193 rm -f $seq.out.bad
194 echo "/^$seq\$/d" >>$tmp.expunged
195 elif [ ! -f $seq ]
196 then
197 echo " - no such test?"
198 echo "/^$seq\$/d" >>$tmp.expunged
199 else
200 # really going to try and run this one
201 #
202 rm -f $seq.out.bad
203 lasttime=`sed -n -e "/^$seq /s/.* //p" <check.time`
204 if [ "X$lasttime" != X ]; then
205 echo -n " ${lasttime}s ..."
206 else
207 echo -n " " # prettier output with timestamps.
208 fi
209 rm -f core $seq.notrun
210
211 # for hangcheck ...
212 echo "$seq" >/tmp/check.sts
213
214 start=`_wallclock`
215 $timestamp && echo -n " ["`date "+%T"`"]"
216 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
217 ./$seq >$tmp.out 2>&1
218 sts=$?
219 $timestamp && _timestamp
220 stop=`_wallclock`
221
222 if [ -f core ]
223 then
224 echo -n " [dumped core]"
225 mv core $seq.core
226 err=true
227 fi
228
229 if [ -f $seq.notrun ]
230 then
231 $timestamp || echo -n " [not run] "
232 $timestamp && echo " [not run]" && echo -n " $seq -- "
233 cat $seq.notrun
234 notrun="$notrun $seq"
235 else
236 if [ $sts -ne 0 ]
237 then
238 echo -n " [failed, exit status $sts]"
239 err=true
240 fi
241 if [ ! -f $seq.out ]
242 then
243 echo " - no qualified output"
244 err=true
245 else
92ab69b6 246 if diff -w $seq.out $tmp.out >/dev/null 2>&1
6bf19c94
CH
247 then
248 echo ""
249 if $err
250 then
251 :
252 else
253 echo "$seq `expr $stop - $start`" >>$tmp.time
254 fi
255 else
256 echo " - output mismatch (see $seq.out.bad)"
257 mv $tmp.out $seq.out.bad
92ab69b6 258 $diff -w $seq.out $seq.out.bad
6bf19c94
CH
259 err=true
260 fi
261 fi
262 fi
263
264 fi
265
266 # come here for each test, except when $showme is true
267 #
268 if $err
269 then
270 bad="$bad $seq"
271 n_bad=`expr $n_bad + 1`
272 quick=false
273 fi
274 [ -f $seq.notrun ] || try=`expr $try + 1`
275
276 seq="after_$seq"
277done
278
279interrupt=false
280status=`expr $n_bad`
281exit