3 # Copyright (C) 2009 Red Hat, Inc.
4 # Copyright (c) 2000-2005 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 # common procedures for QA scripts
28 rm -f "$OUTPUT_DIR/$iam.out"
45 rm -f $tmp.list
$tmp.tmp
$tmp.
sed
48 export IMGFMT_GENERIC
=true
51 export CACHEMODE
="writeback"
52 export QEMU_IO_OPTIONS
=""
53 export CACHEMODE_IS_DEFAULT
=true
61 group_list
=`sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
64 if [ -z "$group_list" ]
66 echo "Group \"$r\" is empty or not defined?"
69 [ ! -s $tmp.list
] && touch $tmp.list
72 if grep -s "^$t\$" $tmp.list
>/dev
/null
85 [ ! -s $tmp.list
] && ls [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] >$tmp.list
2>/dev
/null
86 group_list
=`sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
89 if [ -z "$group_list" ]
91 echo "Group \"$r\" is empty or not defined?"
98 if [ $numsed -gt 100 ]
100 sed -f $tmp.
sed <$tmp.list
>$tmp.tmp
101 mv $tmp.tmp
$tmp.list
105 echo "/^$t\$/d" >>$tmp.
sed
106 numsed
=`expr $numsed + 1`
108 sed -f $tmp.
sed <$tmp.list
>$tmp.tmp
109 mv $tmp.tmp
$tmp.list
121 CACHEMODE_IS_DEFAULT
=false
130 -\? |
-h |
--help) # usage
131 echo "Usage: $0 [options] [testlist]"'
137 -raw test raw (default)
140 -parallels test parallels
148 -file test file (default)
150 -sheepdog test sheepdog
154 -archipelago test archipelago
155 -xdiff graphical mode diff
156 -nocache use O_DIRECT on backing file
157 -misalign misalign memory allocations
158 -n show me, do not run tests
159 -o options -o options to pass to qemu-img create/convert
161 -r randomize test order
165 -g group[,group...] include tests from these groups
166 -x group[,group...] exclude tests from these groups
168 NNN-NNN include test range (eg. 012-021)
268 CACHEMODE_IS_DEFAULT
=false
273 QEMU_IO_OPTIONS
="$QEMU_IO_OPTIONS --misalign"
282 -g) # -g group ... pick from group file
287 -xdiff) # graphical diff mode
290 if [ ! -z "$DISPLAY" ]
292 which xdiff
>/dev
/null
2>&1 && diff=xdiff
293 which gdiff
>/dev
/null
2>&1 && diff=gdiff
294 which tkdiff
>/dev
/null
2>&1 && diff=tkdiff
295 which xxdiff
>/dev
/null
2>&1 && diff=xxdiff
299 -n) # show me, don't do it
311 -r) # randomize test order
316 -T) # turn on timestamp output
325 -x) # -x group ... exclude from group file
329 '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
336 eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'`
340 eval `echo $r | sed -e 's/^/start=/' -e 's/-//'`
341 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/.* //'`
344 echo "No tests in range \"$r\"?"
357 # get rid of leading 0s as can be interpreted as octal
358 start
=`echo $start | sed 's/^0*//'`
359 end
=`echo $end | sed 's/^0*//'`
364 $AWK_PROG </dev
/null
'
365 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
368 if grep -s "^$id " "$source_iotests/group" >/dev
/null
370 # in group file ... OK
373 if [ -f expunged
] && $expunge && egrep "^$id([ ]|\$)" expunged
>/dev
/null
375 # expunged ... will be reported, but not run, later
379 if [ "$start" == "$end" -a "$id" == "$end" ]
381 echo "$id - unknown test"
384 echo "$id - unknown test, ignored"
393 # Set qemu-io cache mode with $CACHEMODE we have
394 QEMU_IO_OPTIONS
="$QEMU_IO_OPTIONS --cache $CACHEMODE"
396 # Set default options for qemu-img create -o if they were not specified
401 # found some valid test numbers ... this is good
406 # had test numbers, but none in group file ... do nothing
409 # no test numbers, do everything from group file
410 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <"$source_iotests/group" >$tmp.list
414 # should be sort -n, but this did not work for Linux when this
415 # was ported from IRIX
417 list
=`sort $tmp.list`
418 rm -f $tmp.list
$tmp.tmp
$tmp.
sed
422 list
=`echo $list | awk -f randomize.awk`
425 [ "$QEMU" = "" ] && _fatal
"qemu not found"
426 [ "$QEMU_IMG" = "" ] && _fatal
"qemu-img not found"
427 [ "$QEMU_IO" = "" ] && _fatal
"qemu-io not found"
429 if [ "$IMGPROTO" = "nbd" ] ; then
430 [ "$QEMU_NBD" = "" ] && _fatal
"qemu-nbd not found"
434 export REAL_QEMU_IO
="$QEMU_IO_PROG"
435 export QEMU_IO_PROG
=valgrind_qemu_io