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
159 -xdiff graphical mode diff
160 -nocache use O_DIRECT on backing file
161 -misalign misalign memory allocations
162 -n show me, do not run tests
163 -o options -o options to pass to qemu-img create/convert
165 -r randomize test order
169 -g group[,group...] include tests from these groups
170 -x group[,group...] exclude tests from these groups
172 NNN-NNN include test range (eg. 012-021)
272 CACHEMODE_IS_DEFAULT
=false
277 QEMU_IO_OPTIONS
="$QEMU_IO_OPTIONS --misalign"
286 -g) # -g group ... pick from group file
291 -xdiff) # graphical diff mode
294 if [ ! -z "$DISPLAY" ]
296 command -v xdiff
>/dev
/null
2>&1 && diff=xdiff
297 command -v gdiff
>/dev
/null
2>&1 && diff=gdiff
298 command -v tkdiff
>/dev
/null
2>&1 && diff=tkdiff
299 command -v xxdiff
>/dev
/null
2>&1 && diff=xxdiff
303 -n) # show me, don't do it
315 -r) # randomize test order
320 -T) # turn on timestamp output
333 -x) # -x group ... exclude from group file
337 '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
344 eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'`
348 eval `echo $r | sed -e 's/^/start=/' -e 's/-//'`
349 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/.* //'`
352 echo "No tests in range \"$r\"?"
365 # get rid of leading 0s as can be interpreted as octal
366 start
=`echo $start | sed 's/^0*//'`
367 end
=`echo $end | sed 's/^0*//'`
372 $AWK_PROG </dev
/null
'
373 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
376 if grep -s "^$id " "$source_iotests/group" >/dev
/null
378 # in group file ... OK
381 if [ -f expunged
] && $expunge && egrep "^$id([ ]|\$)" expunged
>/dev
/null
383 # expunged ... will be reported, but not run, later
387 if [ "$start" == "$end" -a "$id" == "$end" ]
389 echo "$id - unknown test"
392 echo "$id - unknown test, ignored"
401 # Set qemu-io cache mode with $CACHEMODE we have
402 QEMU_IO_OPTIONS
="$QEMU_IO_OPTIONS -f $IMGFMT --cache $CACHEMODE"
404 # Set default options for qemu-img create -o if they were not specified
409 # found some valid test numbers ... this is good
414 # had test numbers, but none in group file ... do nothing
417 # no test numbers, do everything from group file
418 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <"$source_iotests/group" >$tmp.list
422 # should be sort -n, but this did not work for Linux when this
423 # was ported from IRIX
425 list
=`sort $tmp.list`
426 rm -f $tmp.list
$tmp.tmp
$tmp.
sed
430 list
=`echo $list | awk -f randomize.awk`
433 [ "$QEMU" = "" ] && _fatal
"qemu not found"
434 [ "$QEMU_IMG" = "" ] && _fatal
"qemu-img not found"
435 [ "$QEMU_IO" = "" ] && _fatal
"qemu-io not found"
437 if [ "$IMGPROTO" = "nbd" ] ; then
438 [ "$QEMU_NBD" = "" ] && _fatal
"qemu-nbd not found"