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
54 export QEMU_OPTIONS
="-nodefaults"
63 group_list
=`sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
66 if [ -z "$group_list" ]
68 echo "Group \"$r\" is empty or not defined?"
71 [ ! -s $tmp.list
] && touch $tmp.list
74 if grep -s "^$t\$" $tmp.list
>/dev
/null
87 [ ! -s $tmp.list
] && ls [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] >$tmp.list
2>/dev
/null
88 group_list
=`sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
91 if [ -z "$group_list" ]
93 echo "Group \"$r\" is empty or not defined?"
100 if [ $numsed -gt 100 ]
102 sed -f $tmp.
sed <$tmp.list
>$tmp.tmp
103 mv $tmp.tmp
$tmp.list
107 echo "/^$t\$/d" >>$tmp.
sed
108 numsed
=`expr $numsed + 1`
110 sed -f $tmp.
sed <$tmp.list
>$tmp.tmp
111 mv $tmp.tmp
$tmp.list
123 CACHEMODE_IS_DEFAULT
=false
132 -\? |
-h |
--help) # usage
133 echo "Usage: $0 [options] [testlist]"'
140 -raw test raw (default)
143 -parallels test parallels
151 -file test file (default)
153 -sheepdog test sheepdog
157 -archipelago test archipelago
158 -xdiff graphical mode diff
159 -nocache use O_DIRECT on backing file
160 -misalign misalign memory allocations
161 -n show me, do not run tests
162 -o options -o options to pass to qemu-img create/convert
164 -r randomize test order
168 -g group[,group...] include tests from these groups
169 -x group[,group...] exclude tests from these groups
171 NNN-NNN include test range (eg. 012-021)
271 CACHEMODE_IS_DEFAULT
=false
276 QEMU_IO_OPTIONS
="$QEMU_IO_OPTIONS --misalign"
285 -g) # -g group ... pick from group file
290 -xdiff) # graphical diff mode
293 if [ ! -z "$DISPLAY" ]
295 command -v xdiff
>/dev
/null
2>&1 && diff=xdiff
296 command -v gdiff
>/dev
/null
2>&1 && diff=gdiff
297 command -v tkdiff
>/dev
/null
2>&1 && diff=tkdiff
298 command -v xxdiff
>/dev
/null
2>&1 && diff=xxdiff
302 -n) # show me, don't do it
314 -r) # randomize test order
319 -T) # turn on timestamp output
332 -x) # -x group ... exclude from group file
336 '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
343 eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'`
347 eval `echo $r | sed -e 's/^/start=/' -e 's/-//'`
348 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/.* //'`
351 echo "No tests in range \"$r\"?"
364 # get rid of leading 0s as can be interpreted as octal
365 start
=`echo $start | sed 's/^0*//'`
366 end
=`echo $end | sed 's/^0*//'`
371 $AWK_PROG </dev
/null
'
372 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
375 if grep -s "^$id " "$source_iotests/group" >/dev
/null
377 # in group file ... OK
380 if [ -f expunged
] && $expunge && egrep "^$id([ ]|\$)" expunged
>/dev
/null
382 # expunged ... will be reported, but not run, later
386 if [ "$start" == "$end" -a "$id" == "$end" ]
388 echo "$id - unknown test"
391 echo "$id - unknown test, ignored"
400 # Set qemu-io cache mode with $CACHEMODE we have
401 QEMU_IO_OPTIONS
="$QEMU_IO_OPTIONS -f $IMGFMT --cache $CACHEMODE"
403 # Set default options for qemu-img create -o if they were not specified
408 # found some valid test numbers ... this is good
413 # had test numbers, but none in group file ... do nothing
416 # no test numbers, do everything from group file
417 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <"$source_iotests/group" >$tmp.list
421 # should be sort -n, but this did not work for Linux when this
422 # was ported from IRIX
424 list
=`sort $tmp.list`
425 rm -f $tmp.list
$tmp.tmp
$tmp.
sed
429 list
=`echo $list | awk -f randomize.awk`
432 [ "$QEMU" = "" ] && _fatal
"qemu not found"
433 [ "$QEMU_IMG" = "" ] && _fatal
"qemu-img not found"
434 [ "$QEMU_IO" = "" ] && _fatal
"qemu-io not found"
436 if [ "$IMGPROTO" = "nbd" ] ; then
437 [ "$QEMU_NBD" = "" ] && _fatal
"qemu-nbd not found"