1#!/usr/bin/env 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 22status=0 23needwrap=true 24try=0 25n_bad=0 26bad="" 27notrun="" 28casenotrun="" 29interrupt=true 30makecheck=false 31 32_init_error() 33{ 34 echo "check: $1" >&2 35 exit 1 36} 37 38if [ -L "$0" ] 39then 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" 45 fi 46 source_iotests=$(cd "$source_iotests"; pwd) || _init_error "failed to enter source tree" 47 build_iotests=$PWD 48else 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 55fi 56 57build_root="$build_iotests/../.." 58 59# we need common.env 60if ! . "$build_iotests/common.env" 61then 62 _init_error "failed to source common.env (make sure the qemu-iotests are run from tests/qemu-iotests in the build tree)" 63fi 64 65# we need common.config 66if ! . "$source_iotests/common.config" 67then 68 _init_error "failed to source common.config" 69fi 70 71_full_imgfmt_details() 72{ 73 if [ -n "$IMGOPTS" ]; then 74 echo "$IMGFMT ($IMGOPTS)" 75 else 76 echo "$IMGFMT" 77 fi 78} 79 80_full_platform_details() 81{ 82 os=$(uname -s) 83 host=$(hostname -s) 84 kernel=$(uname -r) 85 platform=$(uname -m) 86 echo "$os/$platform $host $kernel" 87} 88 89_full_env_details() 90{ 91 cat <<EOF 92QEMU -- "$QEMU_PROG" $QEMU_OPTIONS 93QEMU_IMG -- "$QEMU_IMG_PROG" $QEMU_IMG_OPTIONS 94QEMU_IO -- "$QEMU_IO_PROG" $QEMU_IO_OPTIONS 95QEMU_NBD -- "$QEMU_NBD_PROG" $QEMU_NBD_OPTIONS 96IMGFMT -- $FULL_IMGFMT_DETAILS 97IMGPROTO -- $IMGPROTO 98PLATFORM -- $FULL_HOST_DETAILS 99TEST_DIR -- $TEST_DIR 100SOCKET_SCM_HELPER -- $SOCKET_SCM_HELPER 101 102EOF 103} 104 105# $1 = prog to look for 106set_prog_path() 107{ 108 p=$(command -v $1 2> /dev/null) 109 if [ -n "$p" -a -x "$p" ]; then 110 type -p "$p" 111 else 112 return 1 113 fi 114} 115 116if [ -z "$TEST_DIR" ]; then 117 TEST_DIR=$PWD/scratch 118fi 119 120if [ ! -e "$TEST_DIR" ]; then 121 mkdir "$TEST_DIR" 122fi 123 124diff="diff -u" 125verbose=false 126debug=false 127group=false 128xgroup=false 129imgopts=false 130showme=false 131sortme=false 132expunge=true 133have_test_arg=false 134cachemode=false 135 136tmp="${TEST_DIR}"/$$ 137rm -f $tmp.list $tmp.tmp $tmp.sed 138 139export IMGFMT=raw 140export IMGFMT_GENERIC=true 141export IMGPROTO=file 142export IMGOPTS="" 143export CACHEMODE="writeback" 144export QEMU_IO_OPTIONS="" 145export QEMU_IO_OPTIONS_NO_FMT="" 146export CACHEMODE_IS_DEFAULT=true 147export VALGRIND_QEMU= 148export IMGKEYSECRET= 149export IMGOPTSSYNTAX=false 150 151# Save current tty settings, since an aborting qemu call may leave things 152# screwed up 153STTY_RESTORE= 154if test -t 0; then 155 STTY_RESTORE=$(stty -g) 156fi 157 158for r 159do 160 161 if $group 162 then 163 # arg after -g 164 group_list=$(sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{ 165s/ .*//p 166}') 167 if [ -z "$group_list" ] 168 then 169 echo "Group \"$r\" is empty or not defined?" 170 exit 1 171 fi 172 [ ! -s $tmp.list ] && touch $tmp.list 173 for t in $group_list 174 do 175 if grep -s "^$t\$" $tmp.list >/dev/null 176 then 177 : 178 else 179 echo "$t" >>$tmp.list 180 fi 181 done 182 group=false 183 continue 184 185 elif $xgroup 186 then 187 # arg after -x 188 # Populate $tmp.list with all tests 189 awk '/^[0-9]{3,}/ {print $1}' "${source_iotests}/group" > $tmp.list 2>/dev/null 190 group_list=$(sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{ 191s/ .*//p 192}') 193 if [ -z "$group_list" ] 194 then 195 echo "Group \"$r\" is empty or not defined?" 196 exit 1 197 fi 198 numsed=0 199 rm -f $tmp.sed 200 for t in $group_list 201 do 202 if [ $numsed -gt 100 ] 203 then 204 sed -f $tmp.sed <$tmp.list >$tmp.tmp 205 mv $tmp.tmp $tmp.list 206 numsed=0 207 rm -f $tmp.sed 208 fi 209 echo "/^$t\$/d" >>$tmp.sed 210 numsed=$(expr $numsed + 1) 211 done 212 sed -f $tmp.sed <$tmp.list >$tmp.tmp 213 mv $tmp.tmp $tmp.list 214 xgroup=false 215 continue 216 217 elif $imgopts 218 then 219 IMGOPTS="$r" 220 imgopts=false 221 continue 222 elif $cachemode 223 then 224 CACHEMODE="$r" 225 CACHEMODE_IS_DEFAULT=false 226 cachemode=false 227 continue 228 fi 229 230 xpand=true 231 case "$r" 232 in 233 234 -\? | -h | --help) # usage 235 echo "Usage: $0 [options] [testlist]"' 236 237common options 238 -v verbose 239 -d debug 240 241image format options 242 -raw test raw (default) 243 -bochs test bochs 244 -cloop test cloop 245 -parallels test parallels 246 -qcow test qcow 247 -qcow2 test qcow2 248 -qed test qed 249 -vdi test vdi 250 -vpc test vpc 251 -vhdx test vhdx 252 -vmdk test vmdk 253 -luks test luks 254 -dmg test dmg 255 256image protocol options 257 -file test file (default) 258 -rbd test rbd 259 -sheepdog test sheepdog 260 -nbd test nbd 261 -ssh test ssh 262 -nfs test nfs 263 -vxhs test vxhs 264 265other options 266 -xdiff graphical mode diff 267 -nocache use O_DIRECT on backing file 268 -misalign misalign memory allocations 269 -n show me, do not run tests 270 -o options -o options to pass to qemu-img create/convert 271 -c mode cache mode 272 -makecheck pretty print output for make check 273 274testlist options 275 -g group[,group...] include tests from these groups 276 -x group[,group...] exclude tests from these groups 277 NNN include test NNN 278 NNN-NNN include test range (eg. 012-021) 279' 280 exit 0 281 ;; 282 283 -raw) 284 IMGFMT=raw 285 xpand=false 286 ;; 287 288 -bochs) 289 IMGFMT=bochs 290 IMGFMT_GENERIC=false 291 xpand=false 292 ;; 293 294 -cloop) 295 IMGFMT=cloop 296 IMGFMT_GENERIC=false 297 xpand=false 298 ;; 299 300 -parallels) 301 IMGFMT=parallels 302 xpand=false 303 ;; 304 305 -qcow) 306 IMGFMT=qcow 307 xpand=false 308 ;; 309 310 -qcow2) 311 IMGFMT=qcow2 312 xpand=false 313 ;; 314 315 -luks) 316 IMGOPTSSYNTAX=true 317 IMGFMT=luks 318 IMGKEYSECRET=123456 319 xpand=false 320 ;; 321 322 -dmg) 323 IMGFMT=dmg 324 IMGFMT_GENERIC=false 325 xpand=false 326 ;; 327 328 -qed) 329 IMGFMT=qed 330 xpand=false 331 ;; 332 333 -vdi) 334 IMGFMT=vdi 335 xpand=false 336 ;; 337 338 -vmdk) 339 IMGFMT=vmdk 340 xpand=false 341 ;; 342 343 -vpc) 344 IMGFMT=vpc 345 xpand=false 346 ;; 347 348 -vhdx) 349 IMGFMT=vhdx 350 xpand=false 351 ;; 352 353 -file) 354 IMGPROTO=file 355 xpand=false 356 ;; 357 358 -rbd) 359 IMGPROTO=rbd 360 xpand=false 361 ;; 362 363 -sheepdog) 364 IMGPROTO=sheepdog 365 xpand=false 366 ;; 367 368 -nbd) 369 IMGPROTO=nbd 370 xpand=false 371 ;; 372 373 -vxhs) 374 IMGPROTO=vxhs 375 xpand=false 376 ;; 377 378 -ssh) 379 IMGPROTO=ssh 380 xpand=false 381 ;; 382 383 -nfs) 384 IMGPROTO=nfs 385 xpand=false 386 ;; 387 388 -nocache) 389 CACHEMODE="none" 390 CACHEMODE_IS_DEFAULT=false 391 xpand=false 392 ;; 393 394 -misalign) 395 QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --misalign" 396 xpand=false 397 ;; 398 399 -valgrind) 400 VALGRIND_QEMU='y' 401 xpand=false 402 ;; 403 404 -g) # -g group ... pick from group file 405 group=true 406 xpand=false 407 ;; 408 409 -xdiff) # graphical diff mode 410 xpand=false 411 412 if [ ! -z "$DISPLAY" ] 413 then 414 command -v xdiff >/dev/null 2>&1 && diff=xdiff 415 command -v gdiff >/dev/null 2>&1 && diff=gdiff 416 command -v tkdiff >/dev/null 2>&1 && diff=tkdiff 417 command -v xxdiff >/dev/null 2>&1 && diff=xxdiff 418 fi 419 ;; 420 -makecheck) # makecheck friendly output 421 makecheck=true 422 xpand=false 423 ;; 424 -n) # show me, don't do it 425 showme=true 426 xpand=false 427 ;; 428 -o) 429 imgopts=true 430 xpand=false 431 ;; 432 -c) 433 cachemode=true 434 xpand=false 435 ;; 436 -T) # deprecated timestamp option 437 xpand=false 438 ;; 439 440 -v) 441 verbose=true 442 xpand=false 443 ;; 444 -d) 445 debug=true 446 xpand=false 447 ;; 448 -x) # -x group ... exclude from group file 449 xgroup=true 450 xpand=false 451 ;; 452 '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]') 453 echo "No tests?" 454 status=1 455 exit $status 456 ;; 457 458 [0-9]*-[0-9]*) 459 eval $(echo $r | sed -e 's/^/start=/' -e 's/-/ end=/') 460 ;; 461 462 [0-9]*-) 463 eval $(echo $r | sed -e 's/^/start=/' -e 's/-//') 464 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/.* //') 465 if [ -z "$end" ] 466 then 467 echo "No tests in range \"$r\"?" 468 status=1 469 exit $status 470 fi 471 ;; 472 473 *) 474 start=$r 475 end=$r 476 ;; 477 478 esac 479 480 # get rid of leading 0s as can be interpreted as octal 481 start=$(echo $start | sed 's/^0*//') 482 end=$(echo $end | sed 's/^0*//') 483 484 if $xpand 485 then 486 have_test_arg=true 487 awk </dev/null ' 488BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \ 489 | while read id 490 do 491 if grep -s "^$id\( \|\$\)" "$source_iotests/group" >/dev/null 492 then 493 # in group file ... OK 494 echo $id >>$tmp.list 495 else 496 if [ -f expunged ] && $expunge && egrep "^$id([ ]|\$)" expunged >/dev/null 497 then 498 # expunged ... will be reported, but not run, later 499 echo $id >>$tmp.list 500 else 501 # oops 502 if [ "$start" == "$end" -a "$id" == "$end" ] 503 then 504 echo "$id - unknown test" 505 exit 1 506 else 507 echo "$id - unknown test, ignored" 508 fi 509 fi 510 fi 511 done || exit 1 512 fi 513 514done 515 516# Set qemu-io cache mode with $CACHEMODE we have 517QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --cache $CACHEMODE" 518 519QEMU_IO_OPTIONS_NO_FMT="$QEMU_IO_OPTIONS" 520if [ "$IMGOPTSSYNTAX" != "true" ]; then 521 QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS -f $IMGFMT" 522fi 523 524# Set default options for qemu-img create -o if they were not specified 525if [ "$IMGFMT" == "qcow2" ] && ! (echo "$IMGOPTS" | grep "compat=" > /dev/null); then 526 IMGOPTS=$(_optstr_add "$IMGOPTS" "compat=1.1") 527fi 528if [ "$IMGFMT" == "luks" ] && ! (echo "$IMGOPTS" | grep "iter-time=" > /dev/null); then 529 IMGOPTS=$(_optstr_add "$IMGOPTS" "iter-time=10") 530fi 531 532if [ -z "$SAMPLE_IMG_DIR" ]; then 533 SAMPLE_IMG_DIR="$source_iotests/sample_images" 534fi 535 536export TEST_DIR 537export SAMPLE_IMG_DIR 538 539if [ -s $tmp.list ] 540then 541 # found some valid test numbers ... this is good 542 : 543else 544 if $have_test_arg 545 then 546 # had test numbers, but none in group file ... do nothing 547 touch $tmp.list 548 else 549 # no test numbers, do everything from group file 550 sed -n -e '/^[0-9][0-9][0-9]*/s/^\([0-9]*\).*/\1/p' <"$source_iotests/group" >$tmp.list 551 fi 552fi 553 554# should be sort -n, but this did not work for Linux when this 555# was ported from IRIX 556# 557list=$(sort $tmp.list) 558rm -f $tmp.list $tmp.tmp $tmp.sed 559 560if [ -z "$QEMU_PROG" ] 561then 562 if [ -x "$build_iotests/qemu" ]; then 563 export QEMU_PROG="$build_iotests/qemu" 564 elif [ -x "$build_root/${qemu_arch}-softmmu/qemu-system-${qemu_arch}" ]; then 565 export QEMU_PROG="$build_root/${qemu_arch}-softmmu/qemu-system-${qemu_arch}" 566 else 567 pushd "$build_root" > /dev/null 568 for binary in *-softmmu/qemu-system-* 569 do 570 if [ -x "$binary" ] 571 then 572 export QEMU_PROG="$build_root/$binary" 573 break 574 fi 575 done 576 popd > /dev/null 577 [ "$QEMU_PROG" = "" ] && _init_error "qemu not found" 578 fi 579fi 580export QEMU_PROG="$(type -p "$QEMU_PROG")" 581 582case "$QEMU_PROG" in 583 *qemu-system-arm|*qemu-system-aarch64) 584 export QEMU_OPTIONS="-nodefaults -display none -machine virt,accel=qtest" 585 ;; 586 *qemu-system-tricore) 587 export QEMU_OPTIONS="-nodefaults -display none -machine tricore_testboard,accel=qtest" 588 ;; 589 *) 590 export QEMU_OPTIONS="-nodefaults -display none -machine accel=qtest" 591 ;; 592esac 593 594if [ -z "$QEMU_IMG_PROG" ]; then 595 if [ -x "$build_iotests/qemu-img" ]; then 596 export QEMU_IMG_PROG="$build_iotests/qemu-img" 597 elif [ -x "$build_root/qemu-img" ]; then 598 export QEMU_IMG_PROG="$build_root/qemu-img" 599 else 600 _init_error "qemu-img not found" 601 fi 602fi 603export QEMU_IMG_PROG="$(type -p "$QEMU_IMG_PROG")" 604 605if [ -z "$QEMU_IO_PROG" ]; then 606 if [ -x "$build_iotests/qemu-io" ]; then 607 export QEMU_IO_PROG="$build_iotests/qemu-io" 608 elif [ -x "$build_root/qemu-io" ]; then 609 export QEMU_IO_PROG="$build_root/qemu-io" 610 else 611 _init_error "qemu-io not found" 612 fi 613fi 614export QEMU_IO_PROG="$(type -p "$QEMU_IO_PROG")" 615 616if [ -z $QEMU_NBD_PROG ]; then 617 if [ -x "$build_iotests/qemu-nbd" ]; then 618 export QEMU_NBD_PROG="$build_iotests/qemu-nbd" 619 elif [ -x "$build_root/qemu-nbd" ]; then 620 export QEMU_NBD_PROG="$build_root/qemu-nbd" 621 else 622 _init_error "qemu-nbd not found" 623 fi 624fi 625export QEMU_NBD_PROG="$(type -p "$QEMU_NBD_PROG")" 626 627if [ -z "$QEMU_VXHS_PROG" ]; then 628 export QEMU_VXHS_PROG="$(set_prog_path qnio_server)" 629fi 630 631if [ -x "$build_iotests/socket_scm_helper" ] 632then 633 export SOCKET_SCM_HELPER="$build_iotests/socket_scm_helper" 634fi 635 636default_machine=$($QEMU_PROG -machine help | sed -n '/(default)/ s/ .*//p') 637default_alias_machine=$($QEMU_PROG -machine help | \ 638 sed -n "/(alias of $default_machine)/ { s/ .*//p; q; }") 639if [[ "$default_alias_machine" ]]; then 640 default_machine="$default_alias_machine" 641fi 642 643export QEMU_DEFAULT_MACHINE="$default_machine" 644 645TIMESTAMP_FILE=check.time-$IMGPROTO-$IMGFMT 646 647_wallclock() 648{ 649 date "+%H %M %S" | awk '{ print $1*3600 + $2*60 + $3 }' 650} 651 652_wrapup() 653{ 654 if $showme 655 then 656 : 657 elif $needwrap 658 then 659 if [ -f $TIMESTAMP_FILE -a -f $tmp.time ] 660 then 661 cat $TIMESTAMP_FILE $tmp.time \ 662 | awk ' 663 { t[$1] = $2 } 664END { if (NR > 0) { 665 for (i in t) print i " " t[i] 666 } 667 }' \ 668 | sort -n >$tmp.out 669 mv $tmp.out $TIMESTAMP_FILE 670 fi 671 672 if [ -f $tmp.expunged ] 673 then 674 notrun=$(wc -l <$tmp.expunged | sed -e 's/ *//g') 675 try=$(expr $try - $notrun) 676 list=$(echo "$list" | sed -f $tmp.expunged) 677 fi 678 679 echo "" >>check.log 680 date >>check.log 681 echo $list | fmt | sed -e 's/^/ /' >>check.log 682 $interrupt && echo "Interrupted!" >>check.log 683 684 if [ ! -z "$notrun" ] 685 then 686 echo "Not run:$notrun" 687 echo "Not run:$notrun" >>check.log 688 fi 689 if [ ! -z "$casenotrun" ] 690 then 691 echo "Some cases not run in:$casenotrun" 692 echo "Some cases not run in:$casenotrun" >>check.log 693 fi 694 if [ ! -z "$n_bad" -a $n_bad != 0 ] 695 then 696 echo "Failures:$bad" 697 echo "Failed $n_bad of $try tests" 698 echo "Failures:$bad" | fmt >>check.log 699 echo "Failed $n_bad of $try tests" >>check.log 700 else 701 echo "Passed all $try tests" 702 echo "Passed all $try tests" >>check.log 703 fi 704 needwrap=false 705 fi 706 707 if test -n "$STTY_RESTORE"; then 708 stty $STTY_RESTORE 709 fi 710 rm -f "${TEST_DIR}"/*.out "${TEST_DIR}"/*.err "${TEST_DIR}"/*.time 711 rm -f "${TEST_DIR}"/check.pid "${TEST_DIR}"/check.sts 712 rm -f $tmp.* 713} 714 715trap "_wrapup; exit \$status" 0 1 2 3 15 716 717# Report the test start and results. For makecheck we want to pretty 718# print the whole report at the end of the execution. 719# args: $seq, $starttime, $lasttime 720_report_test_start() 721{ 722 if ! $makecheck; then 723 if [ -n "$3" ]; then 724 local lasttime=" (last: $3s)" 725 fi 726 printf "%-8s %-10s [%s] %4s%-14s\r" "$1" "..." "$2" "..." "$lasttime" 727 fi 728} 729# args:$seq $status $starttime $lasttime $thistime $details 730_report_test_result() 731{ 732 local status lasttime thistime 733 if $makecheck; then 734 if [ -n "$2" ] && [ "$2" != "pass" ]; then 735 status=" [$2]" 736 fi 737 printf " TEST iotest-$IMGFMT: %s%s\n" "$1" "$status" 738 return 739 fi 740 741 if [ -n "$4" ]; then 742 lasttime=" (last: $4s)" 743 fi 744 if [ -n "$5" ]; then 745 thistime=" $5s" 746 fi 747 case "$2" in 748 "pass") status=$(printf "\e[32m%-10s\e[0m" "$2") ;; 749 "fail") status=$(printf "\e[1m\e[31m%-10s\e[0m" "$2") ;; 750 "not run") status=$(printf "\e[33m%-10s\e[0m" "$2") ;; 751 *) status=$(printf "%-10s" "$2") ;; 752 esac 753 754 printf "%-8s %s [%s] [%s] %4s%-14s %s\n" "$1" "$status" "$3" "$(date '+%T')" "$thistime" "$lasttime" "$6" 755} 756 757[ -f $TIMESTAMP_FILE ] || touch $TIMESTAMP_FILE 758 759FULL_IMGFMT_DETAILS=$(_full_imgfmt_details) 760FULL_HOST_DETAILS=$(_full_platform_details) 761 762if ! $makecheck; then 763 _full_env_details 764fi 765 766seq="check" 767 768[ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG 769 770for seq in $list 771do 772 err=false # error flag 773 printdiff=false # show diff to reference output? 774 status="" # test result summary 775 results="" # test result details 776 thistime="" # time the test took 777 778 if [ -n "$TESTS_REMAINING_LOG" ] ; then 779 sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp 780 mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG 781 sync 782 fi 783 784 lasttime=$(sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE) 785 starttime=$(date "+%T") 786 _report_test_start $seq $starttime $lasttime 787 788 if $showme 789 then 790 status="not run" 791 elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null 792 then 793 status="not run" 794 results="expunged" 795 rm -f $seq.out.bad 796 echo "/^$seq\$/d" >>$tmp.expunged 797 elif [ ! -f "$source_iotests/$seq" ] 798 then 799 status="not run" 800 results="no such test?" 801 echo "/^$seq\$/d" >>$tmp.expunged 802 else 803 # really going to try and run this one 804 # 805 rm -f $seq.out.bad 806 rm -f core $seq.notrun 807 rm -f $seq.casenotrun 808 809 start=$(_wallclock) 810 811 if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then 812 run_command="$PYTHON $seq" 813 else 814 run_command="./$seq" 815 fi 816 export OUTPUT_DIR=$PWD 817 if $debug; then 818 (cd "$source_iotests"; 819 MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \ 820 $run_command -d 2>&1 | tee $tmp.out) 821 else 822 (cd "$source_iotests"; 823 MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \ 824 $run_command >$tmp.out 2>&1) 825 fi 826 sts=$? 827 stop=$(_wallclock) 828 829 if [ -f core ] 830 then 831 mv core $seq.core 832 status="fail" 833 results="[dumped core] $seq.core" 834 err=true 835 fi 836 837 if [ -f $seq.notrun ] 838 then 839 # overwrites timestamp output 840 status="not run" 841 results="$(cat $seq.notrun)" 842 else 843 if [ $sts -ne 0 ] 844 then 845 status="fail" 846 results=$(printf %s "[failed, exit status $sts]") 847 err=true 848 fi 849 850 reference="$source_iotests/$seq.out" 851 reference_machine="$source_iotests/$seq.$QEMU_DEFAULT_MACHINE.out" 852 if [ -f "$reference_machine" ]; then 853 reference="$reference_machine" 854 fi 855 856 reference_format="$source_iotests/$seq.out.$IMGFMT" 857 if [ -f "$reference_format" ]; then 858 reference="$reference_format" 859 fi 860 861 if [ "$CACHEMODE" = "none" ]; then 862 [ -f "$source_iotests/$seq.out.nocache" ] && reference="$source_iotests/$seq.out.nocache" 863 fi 864 865 if [ ! -f "$reference" ] 866 then 867 status="fail" 868 reason="no qualified output" 869 err=true 870 else 871 if diff -w "$reference" $tmp.out >/dev/null 2>&1 872 then 873 if ! $err; then 874 status="pass" 875 thistime=$(expr $stop - $start) 876 echo "$seq $thistime" >>$tmp.time 877 fi 878 else 879 mv $tmp.out $seq.out.bad 880 status="fail" 881 results="output mismatch (see $seq.out.bad)" 882 printdiff=true 883 err=true 884 fi 885 fi 886 fi 887 if [ -f $seq.casenotrun ] 888 then 889 cat $seq.casenotrun 890 casenotrun="$casenotrun $seq" 891 fi 892 fi 893 894 # come here for each test, except when $showme is true 895 # 896 _report_test_result $seq "$status" "$starttime" "$lasttime" "$thistime" "$results" 897 case "$status" in 898 "pass") 899 try=$(expr $try + 1) 900 ;; 901 "fail") 902 try=$(expr $try + 1) 903 if $makecheck; then 904 _full_env_details 905 fi 906 if $printdiff; then 907 $diff -w "$reference" "$PWD"/$seq.out.bad 908 fi 909 bad="$bad $seq" 910 n_bad=$(expr $n_bad + 1) 911 quick=false 912 ;; 913 "not run") 914 notrun="$notrun $seq" 915 ;; 916 esac 917 918 seq="after_$seq" 919done 920 921interrupt=false 922status=$(expr $n_bad) 923exit 924