]>
git.proxmox.com Git - mirror_qemu.git/blob - tests/qemu-iotests/check
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
30 # by default don't output timestamps
31 timestamp
=${TIMESTAMP:=false}
33 # generic initialization
44 # called from the build tree
45 source_iotests
=$
(dirname "$(readlink "$0")")
46 if [ -z "$source_iotests" ]
48 _init_error
"failed to obtain source tree name from check symlink"
50 source_iotests
=$
(cd "$source_iotests"; pwd) || _init_error
"failed to enter source tree"
53 # called from the source tree
55 # this may be an in-tree build (note that in the following code we may not
56 # assume that it truly is and have to test whether the build results
61 build_root
="$build_iotests/../.."
63 if [ -x "$build_iotests/socket_scm_helper" ]
65 export SOCKET_SCM_HELPER
="$build_iotests/socket_scm_helper"
68 # if ./qemu exists, it should be prioritized and will be chosen by common.config
69 if [[ -z "$QEMU_PROG" && ! -x './qemu' ]]
71 arch
=$
(uname
-m 2> /dev
/null
)
73 if [[ -n $arch && -x "$build_root/$arch-softmmu/qemu-system-$arch" ]]
75 export QEMU_PROG
="$build_root/$arch-softmmu/qemu-system-$arch"
77 pushd "$build_root" > /dev
/null
78 for binary
in *-softmmu/qemu-system-
*
82 export QEMU_PROG
="$build_root/$binary"
90 if [[ -z $QEMU_IMG_PROG && -x "$build_root/qemu-img" && ! -x './qemu-img' ]]
92 export QEMU_IMG_PROG
="$build_root/qemu-img"
95 if [[ -z $QEMU_IO_PROG && -x "$build_root/qemu-io" && ! -x './qemu-io' ]]
97 export QEMU_IO_PROG
="$build_root/qemu-io"
100 if [[ -z $QEMU_NBD_PROG && -x "$build_root/qemu-nbd" && ! -x './qemu-nbd' ]]
102 export QEMU_NBD_PROG
="$build_root/qemu-nbd"
106 if ! .
"$build_iotests/common.env"
108 _init_error
"failed to source common.env (make sure the qemu-iotests are run from tests/qemu-iotests in the build tree)"
111 # we need common.config
112 if ! .
"$source_iotests/common.config"
114 _init_error
"failed to source common.config"
118 if ! .
"$source_iotests/common.rc"
120 _init_error
"failed to source common.rc"
124 .
"$source_iotests/common"
126 #if [ `id -u` -ne 0 ]
128 # echo "check: QA must be run as root"
132 TIMESTAMP_FILE
=check.time-
$IMGPROTO-$IMGFMT
138 date "+%H %M %S" |
$AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
150 # remove files that were used by hangcheck
152 [ -f "${TEST_DIR}"/check.pid
] && rm -rf "${TEST_DIR}"/check.pid
153 [ -f "${TEST_DIR}"/check.sts
] && rm -rf "${TEST_DIR}"/check.sts
160 if [ -f $TIMESTAMP_FILE -a -f $tmp.
time ]
162 cat $TIMESTAMP_FILE $tmp.
time \
166 for (i in t) print i " " t[i]
170 mv $tmp.out
$TIMESTAMP_FILE
173 if [ -f $tmp.expunged
]
175 notrun
=`wc -l <$tmp.expunged | sed -e 's/ *//g'`
176 try
=`expr $try - $notrun`
177 list
=`echo "$list" | sed -f $tmp.expunged`
182 echo $list |
fmt |
sed -e 's/^/ /' >>check.log
183 $interrupt && echo "Interrupted!" >>check.log
185 if [ ! -z "$notrun" ]
187 echo "Not run:$notrun"
188 echo "Not run:$notrun" >>check.log
190 if [ ! -z "$n_bad" -a $n_bad != 0 ]
193 echo "Failed $n_bad of $try tests"
194 echo "Failures:$bad" |
fmt >>check.log
195 echo "Failed $n_bad of $try tests" >>check.log
197 echo "Passed all $try tests"
198 echo "Passed all $try tests" >>check.log
203 rm -f "${TEST_DIR}"/*.out "${TEST_DIR}"/*.err "${TEST_DIR}"/*.
time
204 rm -f "${TEST_DIR}"/check.pid
"${TEST_DIR}"/check.sts
208 trap "_wrapup; exit \$status" 0 1 2 3 15
211 # Save pid of check in a well known place, so that hangcheck can be sure it
212 # has the right pid (getting the pid from ps output is not reliable enough).
214 rm -rf "${TEST_DIR}"/check.pid
215 echo $$
> "${TEST_DIR}"/check.pid
218 # Save the status of check in a well known place, so that hangcheck can be
219 # sure to know where check is up to (getting test number from ps output is
220 # not reliable enough since the trace stuff has been introduced).
222 rm -rf "${TEST_DIR}"/check.sts
223 echo "preamble" > "${TEST_DIR}"/check.sts
225 # don't leave old full output behind on a clean run
228 [ -f $TIMESTAMP_FILE ] ||
touch $TIMESTAMP_FILE
230 FULL_IMGFMT_DETAILS
=`_full_imgfmt_details`
231 FULL_IMGPROTO_DETAILS
=`_full_imgproto_details`
232 FULL_HOST_DETAILS
=`_full_platform_details`
233 #FULL_MKFS_OPTIONS=`_scratch_mkfs_options`
234 #FULL_MOUNT_OPTIONS=`_scratch_mount_options`
237 QEMU -- "$QEMU_PROG" $QEMU_OPTIONS
238 QEMU_IMG -- "$QEMU_IMG_PROG" $QEMU_IMG_OPTIONS
239 QEMU_IO -- "$QEMU_IO_PROG" $QEMU_IO_OPTIONS
240 QEMU_NBD -- "$QEMU_NBD_PROG" $QEMU_NBD_OPTIONS
241 IMGFMT -- $FULL_IMGFMT_DETAILS
242 IMGPROTO -- $FULL_IMGPROTO_DETAILS
243 PLATFORM -- $FULL_HOST_DETAILS
244 TEST_DIR -- $TEST_DIR
245 SOCKET_SCM_HELPER -- $SOCKET_SCM_HELPER
248 #MKFS_OPTIONS -- $FULL_MKFS_OPTIONS
249 #MOUNT_OPTIONS -- $FULL_MOUNT_OPTIONS
253 [ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG
259 if [ -n "$TESTS_REMAINING_LOG" ] ; then
260 sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp
261 mv $TESTS_REMAINING_LOG.tmp
$TESTS_REMAINING_LOG
269 elif [ -f expunged
] && $expunge && egrep "^$seq([ ]|\$)" expunged
>/dev
/null
273 echo "/^$seq\$/d" >>$tmp.expunged
274 elif [ ! -f "$source_iotests/$seq" ]
276 echo " - no such test?"
277 echo "/^$seq\$/d" >>$tmp.expunged
279 # really going to try and run this one
282 lasttime
=`sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE`
283 if [ "X$lasttime" != X
]; then
284 echo -n " ${lasttime}s ..."
286 echo -n " " # prettier output with timestamps.
288 rm -f core
$seq.notrun
291 echo "$seq" > "${TEST_DIR}"/check.sts
294 $timestamp && echo -n " ["`date "+%T"`"]"
296 if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then
297 run_command
="$PYTHON $seq"
301 export OUTPUT_DIR
=$PWD
303 (cd "$source_iotests";
304 MALLOC_PERTURB_
=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
305 $run_command -d 2>&1 |
tee $tmp.out
)
307 (cd "$source_iotests";
308 MALLOC_PERTURB_
=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
309 $run_command >$tmp.out
2>&1)
312 $timestamp && _timestamp
317 echo -n " [dumped core]"
322 if [ -f $seq.notrun
]
324 $timestamp ||
echo -n " [not run] "
325 $timestamp && echo " [not run]" && echo -n " $seq -- "
327 notrun
="$notrun $seq"
331 echo -n " [failed, exit status $sts]"
335 reference
="$source_iotests/$seq.out"
336 reference_machine
="$source_iotests/$seq.$QEMU_DEFAULT_MACHINE.out"
337 if [ -f "$reference_machine" ]; then
338 reference
="$reference_machine"
341 if [ "$CACHEMODE" = "none" ]; then
342 [ -f "$source_iotests/$seq.out.nocache" ] && reference
="$source_iotests/$seq.out.nocache"
345 if [ ! -f "$reference" ]
347 echo " - no qualified output"
350 if diff -w "$reference" $tmp.out
>/dev
/null
2>&1
357 echo "$seq `expr $stop - $start`" >>$tmp.
time
360 echo " - output mismatch (see $seq.out.bad)"
361 mv $tmp.out
$seq.out.bad
362 $diff -w "$reference" $seq.out.bad
370 # come here for each test, except when $showme is true
375 n_bad
=`expr $n_bad + 1`
378 [ -f $seq.notrun
] || try
=`expr $try + 1`