]> git.proxmox.com Git - mirror_qemu.git/blame - tests/qemu-iotests/check
iotest 134: test cluster-misaligned encrypted write
[mirror_qemu.git] / tests / qemu-iotests / check
CommitLineData
11a82d14 1#!/usr/bin/env bash
6bf19c94
CH
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
e8c212d6 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
6bf19c94
CH
17#
18#
19# Control script for QA
20#
21
6bf19c94
CH
22status=0
23needwrap=true
24try=0
25n_bad=0
26bad=""
27notrun=""
57ed557f 28casenotrun=""
6bf19c94 29interrupt=true
70ff5b07 30makecheck=false
6bf19c94 31
e8f8624d
HR
32_init_error()
33{
4e670492 34 echo "check: $1" >&2
e8f8624d
HR
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
7fed1a49
HR
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
6bf19c94 65# we need common.config
e8f8624d 66if ! . "$source_iotests/common.config"
6bf19c94 67then
e8f8624d 68 _init_error "failed to source common.config"
6bf19c94
CH
69fi
70
09d653e6
PB
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{
4a9e751f
MZ
82 os=$(uname -s)
83 host=$(hostname -s)
84 kernel=$(uname -r)
85 platform=$(uname -m)
09d653e6
PB
86 echo "$os/$platform $host $kernel"
87}
88
70ff5b07
AB
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
09d653e6
PB
105# $1 = prog to look for
106set_prog_path()
107{
4a9e751f 108 p=$(command -v $1 2> /dev/null)
09d653e6 109 if [ -n "$p" -a -x "$p" ]; then
63ca8406 110 type -p "$p"
09d653e6
PB
111 else
112 return 1
113 fi
114}
115
116if [ -z "$TEST_DIR" ]; then
e8d81a61 117 TEST_DIR=$PWD/scratch
09d653e6
PB
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
09d653e6
PB
147export VALGRIND_QEMU=
148export IMGKEYSECRET=
149export IMGOPTSSYNTAX=false
150
8803714b
EB
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
09d653e6
PB
158for r
159do
160
161 if $group
162 then
163 # arg after -g
4a9e751f 164 group_list=$(sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
09d653e6 165s/ .*//p
4a9e751f 166}')
09d653e6
PB
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
4a9e751f 190 group_list=$(sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
09d653e6 191s/ .*//p
4a9e751f 192}')
09d653e6
PB
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
4a9e751f 210 numsed=$(expr $numsed + 1)
09d653e6
PB
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
76f1cf0a 254 -dmg test dmg
09d653e6
PB
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
09d653e6 271 -c mode cache mode
70ff5b07 272 -makecheck pretty print output for make check
09d653e6
PB
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
09d653e6
PB
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
76f1cf0a
YCL
322 -dmg)
323 IMGFMT=dmg
324 IMGFMT_GENERIC=false
325 xpand=false
326 ;;
327
09d653e6
PB
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 ;;
70ff5b07
AB
420 -makecheck) # makecheck friendly output
421 makecheck=true
422 xpand=false
423 ;;
09d653e6
PB
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 ;;
70ff5b07 436 -T) # deprecated timestamp option
09d653e6
PB
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]*)
4a9e751f 459 eval $(echo $r | sed -e 's/^/start=/' -e 's/-/ end=/')
09d653e6
PB
460 ;;
461
462 [0-9]*-)
4a9e751f
MZ
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/.* //')
09d653e6
PB
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
4a9e751f
MZ
481 start=$(echo $start | sed 's/^0*//')
482 end=$(echo $end | sed 's/^0*//')
09d653e6
PB
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/[ ].*//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#
4a9e751f 557list=$(sort $tmp.list)
09d653e6
PB
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"
96914159
LD
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}"
09d653e6
PB
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
63ca8406 580export QEMU_PROG="$(type -p "$QEMU_PROG")"
09d653e6 581
4a715461
TH
582case "$QEMU_PROG" in
583 *qemu-system-arm|*qemu-system-aarch64)
584 export QEMU_OPTIONS="-nodefaults -machine virt,accel=qtest"
585 ;;
586 *qemu-system-tricore)
587 export QEMU_OPTIONS="-nodefaults -machine tricore_testboard,accel=qtest"
588 ;;
589 *)
590 export QEMU_OPTIONS="-nodefaults -machine accel=qtest"
591 ;;
592esac
593
09d653e6
PB
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
63ca8406 603export QEMU_IMG_PROG="$(type -p "$QEMU_IMG_PROG")"
09d653e6
PB
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
63ca8406 614export QEMU_IO_PROG="$(type -p "$QEMU_IO_PROG")"
09d653e6
PB
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
63ca8406 625export QEMU_NBD_PROG="$(type -p "$QEMU_NBD_PROG")"
09d653e6
PB
626
627if [ -z "$QEMU_VXHS_PROG" ]; then
4a9e751f 628 export QEMU_VXHS_PROG="$(set_prog_path qnio_server)"
09d653e6
PB
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"
89004368 644
36bd4228
DB
645TIMESTAMP_FILE=check.time-$IMGPROTO-$IMGFMT
646
6bf19c94
CH
647_wallclock()
648{
9ee4b6f8 649 date "+%H %M %S" | awk '{ print $1*3600 + $2*60 + $3 }'
6bf19c94
CH
650}
651
6bf19c94
CH
652_wrapup()
653{
6bf19c94
CH
654 if $showme
655 then
79e40ab1 656 :
6bf19c94
CH
657 elif $needwrap
658 then
36bd4228 659 if [ -f $TIMESTAMP_FILE -a -f $tmp.time ]
79e40ab1 660 then
36bd4228 661 cat $TIMESTAMP_FILE $tmp.time \
9ee4b6f8 662 | awk '
79e40ab1
KW
663 { t[$1] = $2 }
664END { if (NR > 0) {
665 for (i in t) print i " " t[i]
666 }
667 }' \
668 | sort -n >$tmp.out
36bd4228 669 mv $tmp.out $TIMESTAMP_FILE
79e40ab1
KW
670 fi
671
672 if [ -f $tmp.expunged ]
673 then
4a9e751f
MZ
674 notrun=$(wc -l <$tmp.expunged | sed -e 's/ *//g')
675 try=$(expr $try - $notrun)
676 list=$(echo "$list" | sed -f $tmp.expunged)
79e40ab1
KW
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
57ed557f
AS
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
6bf19c94 694 if [ ! -z "$n_bad" -a $n_bad != 0 ]
79e40ab1
KW
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
6bf19c94
CH
705 fi
706
8803714b
EB
707 if test -n "$STTY_RESTORE"; then
708 stty $STTY_RESTORE
709 fi
0145b4e1
SS
710 rm -f "${TEST_DIR}"/*.out "${TEST_DIR}"/*.err "${TEST_DIR}"/*.time
711 rm -f "${TEST_DIR}"/check.pid "${TEST_DIR}"/check.sts
6bf19c94
CH
712 rm -f $tmp.*
713}
714
715trap "_wrapup; exit \$status" 0 1 2 3 15
716
70ff5b07
AB
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
36bd4228 757[ -f $TIMESTAMP_FILE ] || touch $TIMESTAMP_FILE
6bf19c94 758
4a9e751f
MZ
759FULL_IMGFMT_DETAILS=$(_full_imgfmt_details)
760FULL_HOST_DETAILS=$(_full_platform_details)
6bf19c94 761
70ff5b07
AB
762if ! $makecheck; then
763 _full_env_details
764fi
6bf19c94
CH
765
766seq="check"
767
768[ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG
769
770for seq in $list
771do
70ff5b07
AB
772 err=false # error flag
773 printdiff=false # show diff to reference output?
774 status="" # test result summary
775 results="" # test result details
835d689d 776 thistime="" # time the test took
70ff5b07 777
6bf19c94
CH
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
70ff5b07
AB
784 lasttime=$(sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE)
785 starttime=$(date "+%T")
786 _report_test_start $seq $starttime $lasttime
787
6bf19c94
CH
788 if $showme
789 then
70ff5b07 790 status="not run"
79e40ab1 791 elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null
6bf19c94 792 then
70ff5b07
AB
793 status="not run"
794 results="expunged"
79e40ab1
KW
795 rm -f $seq.out.bad
796 echo "/^$seq\$/d" >>$tmp.expunged
e8f8624d 797 elif [ ! -f "$source_iotests/$seq" ]
6bf19c94 798 then
70ff5b07
AB
799 status="not run"
800 results="no such test?"
79e40ab1 801 echo "/^$seq\$/d" >>$tmp.expunged
6bf19c94 802 else
79e40ab1
KW
803 # really going to try and run this one
804 #
805 rm -f $seq.out.bad
79e40ab1 806 rm -f core $seq.notrun
57ed557f 807 rm -f $seq.casenotrun
79e40ab1 808
4a9e751f 809 start=$(_wallclock)
ea81ca9d
HR
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
e8f8624d 816 export OUTPUT_DIR=$PWD
aa4f592a
FZ
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
79e40ab1 826 sts=$?
4a9e751f 827 stop=$(_wallclock)
79e40ab1
KW
828
829 if [ -f core ]
830 then
79e40ab1 831 mv core $seq.core
70ff5b07
AB
832 status="fail"
833 results="[dumped core] $seq.core"
79e40ab1
KW
834 err=true
835 fi
836
837 if [ -f $seq.notrun ]
838 then
70ff5b07
AB
839 # overwrites timestamp output
840 status="not run"
841 results="$(cat $seq.notrun)"
79e40ab1
KW
842 else
843 if [ $sts -ne 0 ]
844 then
70ff5b07
AB
845 status="fail"
846 results=$(printf %s "[failed, exit status $sts]")
79e40ab1
KW
847 err=true
848 fi
8f94b077 849
e8f8624d 850 reference="$source_iotests/$seq.out"
e166b414
BT
851 reference_machine="$source_iotests/$seq.$QEMU_DEFAULT_MACHINE.out"
852 if [ -f "$reference_machine" ]; then
853 reference="$reference_machine"
854 fi
855
217a0683
SH
856 reference_format="$source_iotests/$seq.out.$IMGFMT"
857 if [ -f "$reference_format" ]; then
858 reference="$reference_format"
859 fi
860
3baa8449 861 if [ "$CACHEMODE" = "none" ]; then
e8f8624d 862 [ -f "$source_iotests/$seq.out.nocache" ] && reference="$source_iotests/$seq.out.nocache"
8f94b077
KW
863 fi
864
e8f8624d 865 if [ ! -f "$reference" ]
79e40ab1 866 then
70ff5b07
AB
867 status="fail"
868 reason="no qualified output"
79e40ab1
KW
869 err=true
870 else
e8f8624d 871 if diff -w "$reference" $tmp.out >/dev/null 2>&1
79e40ab1 872 then
70ff5b07
AB
873 if ! $err; then
874 status="pass"
875 thistime=$(expr $stop - $start)
876 echo "$seq $thistime" >>$tmp.time
79e40ab1
KW
877 fi
878 else
79e40ab1 879 mv $tmp.out $seq.out.bad
70ff5b07
AB
880 status="fail"
881 results="output mismatch (see $seq.out.bad)"
882 printdiff=true
79e40ab1
KW
883 err=true
884 fi
885 fi
886 fi
57ed557f
AS
887 if [ -f $seq.casenotrun ]
888 then
889 cat $seq.casenotrun
890 casenotrun="$casenotrun $seq"
891 fi
6bf19c94
CH
892 fi
893
894 # come here for each test, except when $showme is true
895 #
70ff5b07
AB
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
79e40ab1 917
6bf19c94
CH
918 seq="after_$seq"
919done
920
921interrupt=false
4a9e751f 922status=$(expr $n_bad)
6bf19c94 923exit