root / tests / qemu-iotests / check @ 908eaf68
History | View | Annotate | Download (5.8 kB)
1 |
#!/bin/bash |
---|---|
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 |
16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 |
# |
18 |
# |
19 |
# Control script for QA |
20 |
# |
21 |
|
22 |
tmp=/tmp/$$ |
23 |
status=0 |
24 |
needwrap=true |
25 |
try=0 |
26 |
n_bad=0 |
27 |
bad="" |
28 |
notrun="" |
29 |
interrupt=true |
30 |
|
31 |
# by default don't output timestamps |
32 |
timestamp=${TIMESTAMP:=false} |
33 |
|
34 |
# generic initialization |
35 |
iam=check |
36 |
|
37 |
# we need common.config |
38 |
if ! . ./common.config |
39 |
then |
40 |
echo "$iam: failed to source common.config" |
41 |
exit 1 |
42 |
fi |
43 |
|
44 |
# we need common |
45 |
. ./common |
46 |
|
47 |
# we need common.rc |
48 |
if ! . ./common.rc |
49 |
then |
50 |
echo "check: failed to source common.rc" |
51 |
exit 1 |
52 |
fi |
53 |
|
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 } |
89 |
END { 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 |
|
132 |
trap "_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 |
# |
138 |
rm -rf /tmp/check.pid |
139 |
echo $$ >/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 |
# |
146 |
rm -rf /tmp/check.sts |
147 |
echo "preamble" >/tmp/check.sts |
148 |
|
149 |
# don't leave old full output behind on a clean run |
150 |
rm -f check.full |
151 |
|
152 |
[ -f check.time ] || touch check.time |
153 |
|
154 |
FULL_IMGFMT_DETAILS=`_full_imgfmt_details` |
155 |
FULL_HOST_DETAILS=`_full_platform_details` |
156 |
#FULL_MKFS_OPTIONS=`_scratch_mkfs_options` |
157 |
#FULL_MOUNT_OPTIONS=`_scratch_mount_options` |
158 |
|
159 |
cat <<EOF |
160 |
IMGFMT -- $FULL_IMGFMT_DETAILS |
161 |
PLATFORM -- $FULL_HOST_DETAILS |
162 |
|
163 |
EOF |
164 |
#MKFS_OPTIONS -- $FULL_MKFS_OPTIONS |
165 |
#MOUNT_OPTIONS -- $FULL_MOUNT_OPTIONS |
166 |
|
167 |
seq="check" |
168 |
|
169 |
[ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG |
170 |
|
171 |
for seq in $list |
172 |
do |
173 |
err=false |
174 |
echo -n "$seq" |
175 |
if [ -n "$TESTS_REMAINING_LOG" ] ; then |
176 |
sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp |
177 |
mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG |
178 |
sync |
179 |
fi |
180 |
|
181 |
if $showme |
182 |
then |
183 |
echo |
184 |
continue |
185 |
elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null |
186 |
then |
187 |
echo " - expunged" |
188 |
rm -f $seq.out.bad |
189 |
echo "/^$seq\$/d" >>$tmp.expunged |
190 |
elif [ ! -f $seq ] |
191 |
then |
192 |
echo " - no such test?" |
193 |
echo "/^$seq\$/d" >>$tmp.expunged |
194 |
else |
195 |
# really going to try and run this one |
196 |
# |
197 |
rm -f $seq.out.bad |
198 |
lasttime=`sed -n -e "/^$seq /s/.* //p" <check.time` |
199 |
if [ "X$lasttime" != X ]; then |
200 |
echo -n " ${lasttime}s ..." |
201 |
else |
202 |
echo -n " " # prettier output with timestamps. |
203 |
fi |
204 |
rm -f core $seq.notrun |
205 |
|
206 |
# for hangcheck ... |
207 |
echo "$seq" >/tmp/check.sts |
208 |
|
209 |
start=`_wallclock` |
210 |
$timestamp && echo -n " ["`date "+%T"`"]" |
211 |
[ ! -x $seq ] && chmod u+x $seq # ensure we can run it |
212 |
./$seq >$tmp.out 2>&1 |
213 |
sts=$? |
214 |
$timestamp && _timestamp |
215 |
stop=`_wallclock` |
216 |
|
217 |
if [ -f core ] |
218 |
then |
219 |
echo -n " [dumped core]" |
220 |
mv core $seq.core |
221 |
err=true |
222 |
fi |
223 |
|
224 |
if [ -f $seq.notrun ] |
225 |
then |
226 |
$timestamp || echo -n " [not run] " |
227 |
$timestamp && echo " [not run]" && echo -n " $seq -- " |
228 |
cat $seq.notrun |
229 |
notrun="$notrun $seq" |
230 |
else |
231 |
if [ $sts -ne 0 ] |
232 |
then |
233 |
echo -n " [failed, exit status $sts]" |
234 |
err=true |
235 |
fi |
236 |
if [ ! -f $seq.out ] |
237 |
then |
238 |
echo " - no qualified output" |
239 |
err=true |
240 |
else |
241 |
if diff $seq.out $tmp.out >/dev/null 2>&1 |
242 |
then |
243 |
echo "" |
244 |
if $err |
245 |
then |
246 |
: |
247 |
else |
248 |
echo "$seq `expr $stop - $start`" >>$tmp.time |
249 |
fi |
250 |
else |
251 |
echo " - output mismatch (see $seq.out.bad)" |
252 |
mv $tmp.out $seq.out.bad |
253 |
$diff $seq.out $seq.out.bad |
254 |
err=true |
255 |
fi |
256 |
fi |
257 |
fi |
258 |
|
259 |
fi |
260 |
|
261 |
# come here for each test, except when $showme is true |
262 |
# |
263 |
if $err |
264 |
then |
265 |
bad="$bad $seq" |
266 |
n_bad=`expr $n_bad + 1` |
267 |
quick=false |
268 |
fi |
269 |
[ -f $seq.notrun ] || try=`expr $try + 1` |
270 |
|
271 |
seq="after_$seq" |
272 |
done |
273 |
|
274 |
interrupt=false |
275 |
status=`expr $n_bad` |
276 |
exit |