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, see <http://www.gnu.org/licenses/>.
19 # Control script for QA
31 # by default don't output timestamps
32 timestamp=${TIMESTAMP:=false}
34 # generic initialization
45 # called from the build tree
46 source_iotests=$(dirname "$(readlink "$0")")
47 if [ -z "$source_iotests" ]
49 _init_error "failed to obtain source tree name from check symlink"
51 source_iotests=$(cd "$source_iotests"; pwd) || _init_error "failed to enter source tree"
54 # called from the source tree
56 # this may be an in-tree build (note that in the following code we may not
57 # assume that it truly is and have to test whether the build results
62 build_root="$build_iotests/../.."
64 if [ -x "$build_iotests/socket_scm_helper" ]
66 export SOCKET_SCM_HELPER="$build_iotests/socket_scm_helper"
69 # if ./qemu exists, it should be prioritized and will be chosen by common.config
70 if [[ -z "$QEMU_PROG" && ! -x './qemu' ]]
72 arch=$(uname -m 2> /dev/null)
74 if [[ -n $arch && -x "$build_root/$arch-softmmu/qemu-system-$arch" ]]
76 export QEMU_PROG="$build_root/$arch-softmmu/qemu-system-$arch"
78 pushd "$build_root" > /dev/null
79 for binary in *-softmmu/qemu-system-*
83 export QEMU_PROG="$build_root/$binary"
91 if [[ -z $QEMU_IMG_PROG && -x "$build_root/qemu-img" && ! -x './qemu-img' ]]
93 export QEMU_IMG_PROG="$build_root/qemu-img"
96 if [[ -z $QEMU_IO_PROG && -x "$build_root/qemu-io" && ! -x './qemu-io' ]]
98 export QEMU_IO_PROG="$build_root/qemu-io"
101 if [[ -z $QEMU_NBD_PROG && -x "$build_root/qemu-nbd" && ! -x './qemu-nbd' ]]
103 export QEMU_NBD_PROG="$build_root/qemu-nbd"
106 # we need common.config
107 if ! . "$source_iotests/common.config"
109 _init_error "failed to source common.config"
113 if ! . "$source_iotests/common.rc"
115 _init_error "failed to source common.rc"
119 . "$source_iotests/common"
121 #if [ `id -u` -ne 0 ]
123 # echo "check: QA must be run as root"
129 date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
141 # remove files that were used by hangcheck
143 [ -f /tmp/check.pid ] && rm -rf /tmp/check.pid
144 [ -f /tmp/check.sts ] && rm -rf /tmp/check.sts
151 if [ -f check.time -a -f $tmp.time ]
153 cat check.time $tmp.time \
157 for (i in t) print i " " t[i]
161 mv $tmp.out check.time
164 if [ -f $tmp.expunged ]
166 notrun=`wc -l <$tmp.expunged | sed -e 's/ *//g'`
167 try=`expr $try - $notrun`
168 list=`echo "$list" | sed -f $tmp.expunged`
173 echo $list | fmt | sed -e 's/^/ /' >>check.log
174 $interrupt && echo "Interrupted!" >>check.log
176 if [ ! -z "$notrun" ]
178 echo "Not run:$notrun"
179 echo "Not run:$notrun" >>check.log
181 if [ ! -z "$n_bad" -a $n_bad != 0 ]
184 echo "Failed $n_bad of $try tests"
185 echo "Failures:$bad" | fmt >>check.log
186 echo "Failed $n_bad of $try tests" >>check.log
188 echo "Passed all $try tests"
189 echo "Passed all $try tests" >>check.log
194 rm -f /tmp/*.out /tmp/*.err /tmp/*.time
195 rm -f /tmp/check.pid /tmp/check.sts
199 trap "_wrapup; exit \$status" 0 1 2 3 15
202 # Save pid of check in a well known place, so that hangcheck can be sure it
203 # has the right pid (getting the pid from ps output is not reliable enough).
205 rm -rf /tmp/check.pid
206 echo $$ >/tmp/check.pid
209 # Save the status of check in a well known place, so that hangcheck can be
210 # sure to know where check is up to (getting test number from ps output is
211 # not reliable enough since the trace stuff has been introduced).
213 rm -rf /tmp/check.sts
214 echo "preamble" >/tmp/check.sts
216 # don't leave old full output behind on a clean run
219 [ -f check.time ] || touch check.time
221 FULL_IMGFMT_DETAILS=`_full_imgfmt_details`
222 FULL_IMGPROTO_DETAILS=`_full_imgproto_details`
223 FULL_HOST_DETAILS=`_full_platform_details`
224 #FULL_MKFS_OPTIONS=`_scratch_mkfs_options`
225 #FULL_MOUNT_OPTIONS=`_scratch_mount_options`
229 QEMU_IMG -- $QEMU_IMG
231 QEMU_NBD -- $QEMU_NBD
232 IMGFMT -- $FULL_IMGFMT_DETAILS
233 IMGPROTO -- $FULL_IMGPROTO_DETAILS
234 PLATFORM -- $FULL_HOST_DETAILS
235 SOCKET_SCM_HELPER -- $SOCKET_SCM_HELPER
238 #MKFS_OPTIONS -- $FULL_MKFS_OPTIONS
239 #MOUNT_OPTIONS -- $FULL_MOUNT_OPTIONS
243 [ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG
249 if [ -n "$TESTS_REMAINING_LOG" ] ; then
250 sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp
251 mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG
259 elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null
263 echo "/^$seq\$/d" >>$tmp.expunged
264 elif [ ! -f "$source_iotests/$seq" ]
266 echo " - no such test?"
267 echo "/^$seq\$/d" >>$tmp.expunged
269 # really going to try and run this one
272 lasttime=`sed -n -e "/^$seq /s/.* //p" <check.time`
273 if [ "X$lasttime" != X ]; then
274 echo -n " ${lasttime}s ..."
276 echo -n " " # prettier output with timestamps.
278 rm -f core $seq.notrun
281 echo "$seq" >/tmp/check.sts
284 $timestamp && echo -n " ["`date "+%T"`"]"
285 export OUTPUT_DIR=$PWD
286 (cd "$source_iotests";
287 MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
288 ./$seq >$tmp.out 2>&1)
290 $timestamp && _timestamp
295 echo -n " [dumped core]"
300 if [ -f $seq.notrun ]
302 $timestamp || echo -n " [not run] "
303 $timestamp && echo " [not run]" && echo -n " $seq -- "
305 notrun="$notrun $seq"
309 echo -n " [failed, exit status $sts]"
313 reference="$source_iotests/$seq.out"
314 if [ "$CACHEMODE" = "none" ]; then
315 [ -f "$source_iotests/$seq.out.nocache" ] && reference="$source_iotests/$seq.out.nocache"
318 if [ ! -f "$reference" ]
320 echo " - no qualified output"
323 if diff -w "$reference" $tmp.out >/dev/null 2>&1
330 echo "$seq `expr $stop - $start`" >>$tmp.time
333 echo " - output mismatch (see $seq.out.bad)"
334 mv $tmp.out $seq.out.bad
335 $diff -w "$reference" $seq.out.bad
343 # come here for each test, except when $showme is true
348 n_bad=`expr $n_bad + 1`
351 [ -f $seq.notrun ] || try=`expr $try + 1`