iotests: Give access to the qemu-storage-daemon
[qemu.git] / tests / qemu-iotests / check
blob3c1fa4435a9e2d386601ce69d32c7027b2d0ccd7
1 #!/usr/bin/env bash
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
22 status=0
23 needwrap=true
24 try=0
25 n_bad=0
26 bad=""
27 notrun=""
28 casenotrun=""
29 interrupt=true
30 makecheck=false
32 _init_error()
34 echo "check: $1" >&2
35 exit 1
38 if [ -L "$0" ]
39 then
40 # called from the build tree
41 source_iotests=$(dirname "$(readlink "$0")")
42 if [ -z "$source_iotests" ]
43 then
44 _init_error "failed to obtain source tree name from check symlink"
46 source_iotests=$(cd "$source_iotests"; pwd) || _init_error "failed to enter source tree"
47 build_iotests=$(cd "$(dirname "$0")"; pwd)
48 else
49 # called from the source tree
50 source_iotests=$PWD
51 # this may be an in-tree build (note that in the following code we may not
52 # assume that it truly is and have to test whether the build results
53 # actually exist)
54 build_iotests=$PWD
57 build_root="$build_iotests/../.."
59 # we need common.env
60 if ! . "$build_iotests/common.env"
61 then
62 _init_error "failed to source common.env (make sure the qemu-iotests are run from tests/qemu-iotests in the build tree)"
65 # we need common.config
66 if ! . "$source_iotests/common.config"
67 then
68 _init_error "failed to source common.config"
71 _full_imgfmt_details()
73 if [ -n "$IMGOPTS" ]; then
74 echo "$IMGFMT ($IMGOPTS)"
75 else
76 echo "$IMGFMT"
80 _full_platform_details()
82 os=$(uname -s)
83 host=$(hostname -s)
84 kernel=$(uname -r)
85 platform=$(uname -m)
86 echo "$os/$platform $host $kernel"
89 _full_env_details()
91 cat <<EOF
92 QEMU -- "$QEMU_PROG" $QEMU_OPTIONS
93 QEMU_IMG -- "$QEMU_IMG_PROG" $QEMU_IMG_OPTIONS
94 QEMU_IO -- "$QEMU_IO_PROG" $QEMU_IO_OPTIONS
95 QEMU_NBD -- "$QEMU_NBD_PROG" $QEMU_NBD_OPTIONS
96 IMGFMT -- $FULL_IMGFMT_DETAILS
97 IMGPROTO -- $IMGPROTO
98 PLATFORM -- $FULL_HOST_DETAILS
99 TEST_DIR -- $TEST_DIR
100 SOCK_DIR -- $SOCK_DIR
101 SOCKET_SCM_HELPER -- $SOCKET_SCM_HELPER
106 # $1 = prog to look for
107 set_prog_path()
109 p=$(command -v $1 2> /dev/null)
110 if [ -n "$p" -a -x "$p" ]; then
111 type -p "$p"
112 else
113 return 1
117 if [ -z "$TEST_DIR" ]; then
118 TEST_DIR=$PWD/scratch
120 mkdir -p "$TEST_DIR" || _init_error 'Failed to create TEST_DIR'
122 tmp_sock_dir=false
123 if [ -z "$SOCK_DIR" ]; then
124 SOCK_DIR=$(mktemp -d)
125 tmp_sock_dir=true
127 mkdir -p "$SOCK_DIR" || _init_error 'Failed to create SOCK_DIR'
129 diff="diff -u"
130 verbose=false
131 debug=false
132 group=false
133 xgroup=false
134 imgopts=false
135 showme=false
136 sortme=false
137 expunge=true
138 have_test_arg=false
139 cachemode=false
140 aiomode=false
142 tmp="${TEST_DIR}"/$$
143 rm -f $tmp.list $tmp.tmp $tmp.sed
145 export IMGFMT=raw
146 export IMGFMT_GENERIC=true
147 export IMGPROTO=file
148 export IMGOPTS=""
149 export CACHEMODE="writeback"
150 export AIOMODE="threads"
151 export QEMU_IO_OPTIONS=""
152 export QEMU_IO_OPTIONS_NO_FMT=""
153 export CACHEMODE_IS_DEFAULT=true
154 export VALGRIND_QEMU=
155 export IMGKEYSECRET=
156 export IMGOPTSSYNTAX=false
158 # Save current tty settings, since an aborting qemu call may leave things
159 # screwed up
160 STTY_RESTORE=
161 if test -t 0; then
162 STTY_RESTORE=$(stty -g)
165 for r
168 if $group
169 then
170 # arg after -g
171 group_list=$(sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
172 s/ .*//p
174 if [ -z "$group_list" ]
175 then
176 echo "Group \"$r\" is empty or not defined?"
177 exit 1
179 [ ! -s $tmp.list ] && touch $tmp.list
180 for t in $group_list
182 if grep -s "^$t\$" $tmp.list >/dev/null
183 then
185 else
186 echo "$t" >>$tmp.list
188 done
189 group=false
190 continue
192 elif $xgroup
193 then
194 # arg after -x
195 # Populate $tmp.list with all tests
196 awk '/^[0-9]{3,}/ {print $1}' "${source_iotests}/group" > $tmp.list 2>/dev/null
197 group_list=$(sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
198 s/ .*//p
200 if [ -z "$group_list" ]
201 then
202 echo "Group \"$r\" is empty or not defined?"
203 exit 1
205 numsed=0
206 rm -f $tmp.sed
207 for t in $group_list
209 if [ $numsed -gt 100 ]
210 then
211 sed -f $tmp.sed <$tmp.list >$tmp.tmp
212 mv $tmp.tmp $tmp.list
213 numsed=0
214 rm -f $tmp.sed
216 echo "/^$t\$/d" >>$tmp.sed
217 numsed=$(expr $numsed + 1)
218 done
219 sed -f $tmp.sed <$tmp.list >$tmp.tmp
220 mv $tmp.tmp $tmp.list
221 xgroup=false
222 continue
224 elif $imgopts
225 then
226 IMGOPTS="$r"
227 imgopts=false
228 continue
229 elif $cachemode
230 then
231 CACHEMODE="$r"
232 CACHEMODE_IS_DEFAULT=false
233 cachemode=false
234 continue
235 elif $aiomode
236 then
237 AIOMODE="$r"
238 aiomode=false
239 continue
242 xpand=true
243 case "$r"
246 -\? | -h | --help) # usage
247 echo "Usage: $0 [options] [testlist]"'
249 common options
250 -v verbose
251 -d debug
253 image format options
254 -raw test raw (default)
255 -bochs test bochs
256 -cloop test cloop
257 -parallels test parallels
258 -qcow test qcow
259 -qcow2 test qcow2
260 -qed test qed
261 -vdi test vdi
262 -vpc test vpc
263 -vhdx test vhdx
264 -vmdk test vmdk
265 -luks test luks
266 -dmg test dmg
268 image protocol options
269 -file test file (default)
270 -rbd test rbd
271 -sheepdog test sheepdog
272 -nbd test nbd
273 -ssh test ssh
274 -nfs test nfs
276 other options
277 -xdiff graphical mode diff
278 -nocache use O_DIRECT on backing file
279 -misalign misalign memory allocations
280 -n show me, do not run tests
281 -o options -o options to pass to qemu-img create/convert
282 -c mode cache mode
283 -i mode AIO mode
284 -makecheck pretty print output for make check
286 testlist options
287 -g group[,group...] include tests from these groups
288 -x group[,group...] exclude tests from these groups
289 NNN include test NNN
290 NNN-NNN include test range (eg. 012-021)
292 exit 0
295 -raw)
296 IMGFMT=raw
297 xpand=false
300 -bochs)
301 IMGFMT=bochs
302 IMGFMT_GENERIC=false
303 xpand=false
306 -cloop)
307 IMGFMT=cloop
308 IMGFMT_GENERIC=false
309 xpand=false
312 -parallels)
313 IMGFMT=parallels
314 xpand=false
317 -qcow)
318 IMGFMT=qcow
319 xpand=false
322 -qcow2)
323 IMGFMT=qcow2
324 xpand=false
327 -luks)
328 IMGOPTSSYNTAX=true
329 IMGFMT=luks
330 IMGKEYSECRET=123456
331 xpand=false
334 -dmg)
335 IMGFMT=dmg
336 IMGFMT_GENERIC=false
337 xpand=false
340 -qed)
341 IMGFMT=qed
342 xpand=false
345 -vdi)
346 IMGFMT=vdi
347 xpand=false
350 -vmdk)
351 IMGFMT=vmdk
352 xpand=false
355 -vpc)
356 IMGFMT=vpc
357 xpand=false
360 -vhdx)
361 IMGFMT=vhdx
362 xpand=false
365 -file)
366 IMGPROTO=file
367 xpand=false
370 -rbd)
371 IMGPROTO=rbd
372 xpand=false
375 -sheepdog)
376 IMGPROTO=sheepdog
377 xpand=false
380 -nbd)
381 IMGPROTO=nbd
382 xpand=false
385 -ssh)
386 IMGPROTO=ssh
387 xpand=false
390 -nfs)
391 IMGPROTO=nfs
392 xpand=false
395 -nocache)
396 CACHEMODE="none"
397 CACHEMODE_IS_DEFAULT=false
398 xpand=false
401 -misalign)
402 QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --misalign"
403 xpand=false
406 -valgrind)
407 VALGRIND_QEMU='y'
408 xpand=false
411 -g) # -g group ... pick from group file
412 group=true
413 xpand=false
416 -xdiff) # graphical diff mode
417 xpand=false
419 if [ ! -z "$DISPLAY" ]
420 then
421 command -v xdiff >/dev/null 2>&1 && diff=xdiff
422 command -v gdiff >/dev/null 2>&1 && diff=gdiff
423 command -v tkdiff >/dev/null 2>&1 && diff=tkdiff
424 command -v xxdiff >/dev/null 2>&1 && diff=xxdiff
427 -makecheck) # makecheck friendly output
428 makecheck=true
429 xpand=false
431 -n) # show me, don't do it
432 showme=true
433 xpand=false
436 imgopts=true
437 xpand=false
440 cachemode=true
441 xpand=false
444 aiomode=true
445 xpand=false
447 -T) # deprecated timestamp option
448 xpand=false
451 verbose=true
452 xpand=false
455 debug=true
456 xpand=false
458 -x) # -x group ... exclude from group file
459 xgroup=true
460 xpand=false
462 '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
463 echo "No tests?"
464 status=1
465 exit $status
468 [0-9]*-[0-9]*)
469 eval $(echo $r | sed -e 's/^/start=/' -e 's/-/ end=/')
472 [0-9]*-)
473 eval $(echo $r | sed -e 's/^/start=/' -e 's/-//')
474 end=$(echo [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] | sed -e 's/\[0-9]//g' -e 's/ *$//' -e 's/.* //')
475 if [ -z "$end" ]
476 then
477 echo "No tests in range \"$r\"?"
478 status=1
479 exit $status
484 start=$r
485 end=$r
488 esac
490 # get rid of leading 0s as can be interpreted as octal
491 start=$(echo $start | sed 's/^0*//')
492 end=$(echo $end | sed 's/^0*//')
494 if $xpand
495 then
496 have_test_arg=true
497 awk </dev/null '
498 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
499 | while read id
501 if grep -s "^$id\( \|\$\)" "$source_iotests/group" >/dev/null
502 then
503 # in group file ... OK
504 echo $id >>$tmp.list
505 else
506 if [ -f expunged ] && $expunge && egrep "^$id([ ]|\$)" expunged >/dev/null
507 then
508 # expunged ... will be reported, but not run, later
509 echo $id >>$tmp.list
510 else
511 # oops
512 if [ "$start" == "$end" -a "$id" == "$end" ]
513 then
514 echo "$id - unknown test"
515 exit 1
516 else
517 echo "$id - unknown test, ignored"
521 done || exit 1
524 done
526 # Set qemu-io cache mode with $CACHEMODE we have
527 QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --cache $CACHEMODE"
528 # Set qemu-io aio mode with $AIOMODE we have
529 QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --aio $AIOMODE"
531 QEMU_IO_OPTIONS_NO_FMT="$QEMU_IO_OPTIONS"
532 if [ "$IMGOPTSSYNTAX" != "true" ]; then
533 QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS -f $IMGFMT"
536 # Set default options for qemu-img create -o if they were not specified
537 if [ "$IMGFMT" == "qcow2" ] && ! (echo "$IMGOPTS" | grep "compat=" > /dev/null); then
538 IMGOPTS=$(_optstr_add "$IMGOPTS" "compat=1.1")
540 if [ "$IMGFMT" == "luks" ] && ! (echo "$IMGOPTS" | grep "iter-time=" > /dev/null); then
541 IMGOPTS=$(_optstr_add "$IMGOPTS" "iter-time=10")
543 if [ "$IMGFMT" == "vmdk" ] && ! (echo "$IMGOPTS" | grep "zeroed_grain=" > /dev/null); then
544 IMGOPTS=$(_optstr_add "$IMGOPTS" "zeroed_grain=on")
547 if [ -z "$SAMPLE_IMG_DIR" ]; then
548 SAMPLE_IMG_DIR="$source_iotests/sample_images"
551 export TEST_DIR
552 export SOCK_DIR
553 export SAMPLE_IMG_DIR
555 if [ -s $tmp.list ]
556 then
557 # found some valid test numbers ... this is good
559 else
560 if $have_test_arg
561 then
562 # had test numbers, but none in group file ... do nothing
563 touch $tmp.list
564 else
565 # no test numbers, do everything from group file
566 sed -n -e '/^[0-9][0-9][0-9]*/s/^\([0-9]*\).*/\1/p' <"$source_iotests/group" >$tmp.list
570 # should be sort -n, but this did not work for Linux when this
571 # was ported from IRIX
573 list=$(sort $tmp.list)
574 rm -f $tmp.list $tmp.tmp $tmp.sed
576 if [ -z "$QEMU_PROG" ]
577 then
578 if [ -x "$build_iotests/qemu" ]; then
579 export QEMU_PROG="$build_iotests/qemu"
580 elif [ -x "$build_root/qemu-system-${qemu_arch}" ]; then
581 export QEMU_PROG="$build_root/qemu-system-${qemu_arch}"
582 else
583 pushd "$build_root" > /dev/null
584 for binary in qemu-system-*
586 if [ -x "$binary" ]
587 then
588 export QEMU_PROG="$build_root/$binary"
589 break
591 done
592 popd > /dev/null
593 [ "$QEMU_PROG" = "" ] && _init_error "qemu not found"
596 export QEMU_PROG="$(type -p "$QEMU_PROG")"
598 export QEMU_OPTIONS="-nodefaults -display none -accel qtest"
599 case "$QEMU_PROG" in
600 *qemu-system-arm|*qemu-system-aarch64)
601 export QEMU_OPTIONS="$QEMU_OPTIONS -machine virt"
603 *qemu-system-avr)
604 export QEMU_OPTIONS="$QEMU_OPTIONS -machine mega2560"
606 *qemu-system-rx)
607 export QEMU_OPTIONS="$QEMU_OPTIONS -machine gdbsim-r5f562n8"
609 *qemu-system-tricore)
610 export QEMU_OPTIONS="-$QEMU_OPTIONS -machine tricore_testboard"
612 esac
614 if [ -z "$QEMU_IMG_PROG" ]; then
615 if [ -x "$build_iotests/qemu-img" ]; then
616 export QEMU_IMG_PROG="$build_iotests/qemu-img"
617 elif [ -x "$build_root/qemu-img" ]; then
618 export QEMU_IMG_PROG="$build_root/qemu-img"
619 else
620 _init_error "qemu-img not found"
623 export QEMU_IMG_PROG="$(type -p "$QEMU_IMG_PROG")"
625 if [ -z "$QEMU_IO_PROG" ]; then
626 if [ -x "$build_iotests/qemu-io" ]; then
627 export QEMU_IO_PROG="$build_iotests/qemu-io"
628 elif [ -x "$build_root/qemu-io" ]; then
629 export QEMU_IO_PROG="$build_root/qemu-io"
630 else
631 _init_error "qemu-io not found"
634 export QEMU_IO_PROG="$(type -p "$QEMU_IO_PROG")"
636 if [ -z $QEMU_NBD_PROG ]; then
637 if [ -x "$build_iotests/qemu-nbd" ]; then
638 export QEMU_NBD_PROG="$build_iotests/qemu-nbd"
639 elif [ -x "$build_root/qemu-nbd" ]; then
640 export QEMU_NBD_PROG="$build_root/qemu-nbd"
641 else
642 _init_error "qemu-nbd not found"
645 export QEMU_NBD_PROG="$(type -p "$QEMU_NBD_PROG")"
647 if [ -z "$QSD_PROG" ]; then
648 if [ -x "$build_iotests/qemu-storage-daemon" ]; then
649 export QSD_PROG="$build_iotests/qemu-storage-daemon"
650 elif [ -x "$build_root/storage-daemon/qemu-storage-daemon" ]; then
651 export QSD_PROG="$build_root/storage-daemon/qemu-storage-daemon"
652 else
653 _init_error "qemu-storage-daemon not found"
656 export QSD_PROG="$(type -p "$QSD_PROG")"
658 if [ -x "$build_iotests/socket_scm_helper" ]
659 then
660 export SOCKET_SCM_HELPER="$build_iotests/socket_scm_helper"
663 python_usable=false
664 if $PYTHON -c 'import sys; sys.exit(0 if sys.version_info >= (3,6) else 1)'
665 then
666 # Our python framework also requires virtio-blk
667 if "$QEMU_PROG" -M none -device help | grep -q virtio-blk >/dev/null 2>&1
668 then
669 python_usable=true
670 else
671 python_unusable_because="Missing virtio-blk in QEMU binary"
673 else
674 python_unusable_because="Unsupported Python version"
677 default_machine=$($QEMU_PROG -machine help | sed -n '/(default)/ s/ .*//p')
678 default_alias_machine=$($QEMU_PROG -machine help | \
679 sed -n "/(alias of $default_machine)/ { s/ .*//p; q; }")
680 if [[ "$default_alias_machine" ]]; then
681 default_machine="$default_alias_machine"
684 export QEMU_DEFAULT_MACHINE="$default_machine"
686 TIMESTAMP_FILE=check.time-$IMGPROTO-$IMGFMT
688 _wallclock()
690 date "+%H %M %S" | awk '{ print $1*3600 + $2*60 + $3 }'
693 _wrapup()
695 if $showme
696 then
698 elif $needwrap
699 then
700 if [ -f $TIMESTAMP_FILE -a -f $tmp.time ]
701 then
702 cat $TIMESTAMP_FILE $tmp.time \
703 | awk '
704 { t[$1] = $2 }
705 END { if (NR > 0) {
706 for (i in t) print i " " t[i]
708 }' \
709 | sort -n >$tmp.out
710 mv $tmp.out $TIMESTAMP_FILE
713 if [ -f $tmp.expunged ]
714 then
715 notrun=$(wc -l <$tmp.expunged | sed -e 's/ *//g')
716 try=$(expr $try - $notrun)
717 list=$(echo "$list" | sed -f $tmp.expunged)
720 echo "" >>check.log
721 date >>check.log
722 echo $list | fmt | sed -e 's/^/ /' >>check.log
723 $interrupt && echo "Interrupted!" >>check.log
725 if [ ! -z "$notrun" ]
726 then
727 echo "Not run:$notrun"
728 echo "Not run:$notrun" >>check.log
730 if [ ! -z "$casenotrun" ]
731 then
732 echo "Some cases not run in:$casenotrun"
733 echo "Some cases not run in:$casenotrun" >>check.log
735 if [ ! -z "$n_bad" -a $n_bad != 0 ]
736 then
737 echo "Failures:$bad"
738 echo "Failed $n_bad of $try iotests"
739 echo "Failures:$bad" | fmt >>check.log
740 echo "Failed $n_bad of $try iotests" >>check.log
741 else
742 echo "Passed all $try iotests"
743 echo "Passed all $try iotests" >>check.log
745 needwrap=false
748 if test -n "$STTY_RESTORE"; then
749 stty $STTY_RESTORE
751 rm -f "${TEST_DIR}"/*.out "${TEST_DIR}"/*.err "${TEST_DIR}"/*.time
752 rm -f "${TEST_DIR}"/check.pid "${TEST_DIR}"/check.sts
753 rm -f $tmp.*
755 if $tmp_sock_dir
756 then
757 rm -rf "$SOCK_DIR"
761 trap "_wrapup; exit \$status" 0 1 2 3 15
763 # Report the test start and results. For makecheck we want to pretty
764 # print the whole report at the end of the execution.
765 # args: $seq, $starttime, $lasttime
766 _report_test_start()
768 if ! $makecheck; then
769 if [ -n "$3" ]; then
770 local lasttime=" (last: $3s)"
772 printf "%-8s %-10s [%s] %4s%-14s\r" "$1" "..." "$2" "..." "$lasttime"
775 # args:$seq $status $starttime $lasttime $thistime $details
776 _report_test_result()
778 local status lasttime thistime
779 if $makecheck; then
780 if [ -n "$2" ] && [ "$2" != "pass" ]; then
781 status=" [$2]"
783 printf " TEST iotest-$IMGFMT: %s%s\n" "$1" "$status"
784 return
787 if [ -n "$4" ]; then
788 lasttime=" (last: $4s)"
790 if [ -n "$5" ]; then
791 thistime=" $5s"
793 case "$2" in
794 "pass") status=$(printf "\e[32m%-10s\e[0m" "$2") ;;
795 "fail") status=$(printf "\e[1m\e[31m%-10s\e[0m" "$2") ;;
796 "not run") status=$(printf "\e[33m%-10s\e[0m" "$2") ;;
797 *) status=$(printf "%-10s" "$2") ;;
798 esac
800 printf "%-8s %s [%s] [%s] %4s%-14s %s\n" "$1" "$status" "$3" "$(date '+%T')" "$thistime" "$lasttime" "$6"
803 [ -f $TIMESTAMP_FILE ] || touch $TIMESTAMP_FILE
805 FULL_IMGFMT_DETAILS=$(_full_imgfmt_details)
806 FULL_HOST_DETAILS=$(_full_platform_details)
808 if ! $makecheck; then
809 _full_env_details
812 seq="check"
814 [ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG
816 for seq in $list
818 err=false # error flag
819 printdiff=false # show diff to reference output?
820 status="" # test result summary
821 results="" # test result details
822 thistime="" # time the test took
824 if [ -n "$TESTS_REMAINING_LOG" ] ; then
825 sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp
826 mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG
827 sync
830 lasttime=$(sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE)
831 starttime=$(date "+%T")
832 _report_test_start $seq $starttime $lasttime
834 if $showme
835 then
836 status="not run"
837 elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null
838 then
839 status="not run"
840 results="expunged"
841 rm -f $seq.out.bad
842 echo "/^$seq\$/d" >>$tmp.expunged
843 elif [ ! -f "$source_iotests/$seq" ]
844 then
845 status="not run"
846 results="no such test?"
847 echo "/^$seq\$/d" >>$tmp.expunged
848 else
849 # really going to try and run this one
851 rm -f $seq.out.bad
852 rm -f core $seq.notrun
853 rm -f $seq.casenotrun
855 start=$(_wallclock)
857 if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python3" ]; then
858 if $python_usable; then
859 run_command="$PYTHON $seq"
860 else
861 run_command="false"
862 echo "$python_unusable_because" > $seq.notrun
864 else
865 run_command="./$seq"
867 export OUTPUT_DIR=$PWD
868 if $debug; then
869 (cd "$source_iotests";
870 MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
871 $run_command -d 2>&1 | tee $tmp.out)
872 else
873 (cd "$source_iotests";
874 MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
875 $run_command >$tmp.out 2>&1)
877 sts=$?
878 stop=$(_wallclock)
880 if [ -f core ]
881 then
882 mv core $seq.core
883 status="fail"
884 results="[dumped core] $seq.core"
885 err=true
888 if [ -f $seq.notrun ]
889 then
890 # overwrites timestamp output
891 status="not run"
892 results="$(cat $seq.notrun)"
893 else
894 if [ $sts -ne 0 ]
895 then
896 status="fail"
897 results=$(printf %s "[failed, exit status $sts]")
898 err=true
901 reference="$source_iotests/$seq.out"
902 reference_machine="$source_iotests/$seq.$QEMU_DEFAULT_MACHINE.out"
903 if [ -f "$reference_machine" ]; then
904 reference="$reference_machine"
907 reference_format="$source_iotests/$seq.out.$IMGFMT"
908 if [ -f "$reference_format" ]; then
909 reference="$reference_format"
912 if [ "$CACHEMODE" = "none" ]; then
913 [ -f "$source_iotests/$seq.out.nocache" ] && reference="$source_iotests/$seq.out.nocache"
916 if [ ! -f "$reference" ]
917 then
918 status="fail"
919 results="no qualified output"
920 err=true
921 else
922 if diff -w "$reference" $tmp.out >/dev/null 2>&1
923 then
924 if ! $err; then
925 status="pass"
926 thistime=$(expr $stop - $start)
927 echo "$seq $thistime" >>$tmp.time
929 else
930 mv $tmp.out $seq.out.bad
931 status="fail"
932 results="output mismatch (see $seq.out.bad)"
933 printdiff=true
934 err=true
938 if [ -f $seq.casenotrun ]
939 then
940 cat $seq.casenotrun
941 casenotrun="$casenotrun $seq"
945 # come here for each test, except when $showme is true
947 _report_test_result $seq "$status" "$starttime" "$lasttime" "$thistime" "$results"
948 case "$status" in
949 "pass")
950 try=$(expr $try + 1)
952 "fail")
953 try=$(expr $try + 1)
954 if $makecheck; then
955 _full_env_details
957 if $printdiff; then
958 $diff -w "$reference" "$PWD"/$seq.out.bad
960 bad="$bad $seq"
961 n_bad=$(expr $n_bad + 1)
962 quick=false
964 "not run")
965 notrun="$notrun $seq"
967 esac
969 seq="after_$seq"
970 done
972 interrupt=false
973 status=$(expr $n_bad)
974 exit