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
46 rm -f $tmp.list
$tmp.tmp
$tmp.
sed
49 export IMGFMT_GENERIC
=true
52 export CACHEMODE
="writeback"
53 export QEMU_IO_OPTIONS
=""
54 export CACHEMODE_IS_DEFAULT
=true
62 group_list
=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
65 if [ -z "$group_list" ]
67 echo "Group \"$r\" is empty or not defined?"
70 [ ! -s $tmp.list
] && touch $tmp.list
73 if grep -s "^$t\$" $tmp.list
>/dev
/null
86 [ ! -s $tmp.list
] && ls [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] >$tmp.list
2>/dev
/null
87 group_list
=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
90 if [ -z "$group_list" ]
92 echo "Group \"$r\" is empty or not defined?"
99 if [ $numsed -gt 100 ]
101 sed -f $tmp.
sed <$tmp.list
>$tmp.tmp
102 mv $tmp.tmp
$tmp.list
106 echo "/^$t\$/d" >>$tmp.
sed
107 numsed
=`expr $numsed + 1`
109 sed -f $tmp.
sed <$tmp.list
>$tmp.tmp
110 mv $tmp.tmp
$tmp.list
122 CACHEMODE_IS_DEFAULT
=false
131 -\? |
-h |
--help) # usage
132 echo "Usage: $0 [options] [testlist]"'
138 -raw test raw (default)
147 -file test file (default)
149 -sheepdog test sheepdog
153 -xdiff graphical mode diff
154 -nocache use O_DIRECT on backing file
155 -misalign misalign memory allocations
156 -n show me, do not run tests
157 -o options -o options to pass to qemu-img create/convert
159 -r randomize test order
163 -g group[,group...] include tests from these groups
164 -x group[,group...] exclude tests from these groups
166 NNN-NNN include test range (eg. 012-021)
248 CACHEMODE_IS_DEFAULT
=false
253 QEMU_IO_OPTIONS
="$QEMU_IO_OPTIONS --misalign"
262 -g) # -g group ... pick from group file
267 -xdiff) # graphical diff mode
270 if [ ! -z "$DISPLAY" ]
272 which xdiff
>/dev
/null
2>&1 && diff=xdiff
273 which gdiff
>/dev
/null
2>&1 && diff=gdiff
274 which tkdiff
>/dev
/null
2>&1 && diff=tkdiff
275 which xxdiff
>/dev
/null
2>&1 && diff=xxdiff
279 -n) # show me, don't do it
291 -r) # randomize test order
296 -T) # turn on timestamp output
305 -x) # -x group ... exclude from group file
309 '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
316 eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'`
320 eval `echo $r | sed -e 's/^/start=/' -e 's/-//'`
321 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/.* //'`
324 echo "No tests in range \"$r\"?"
337 # get rid of leading 0s as can be interpreted as octal
338 start
=`echo $start | sed 's/^0*//'`
339 end
=`echo $end | sed 's/^0*//'`
344 $AWK_PROG </dev
/null
'
345 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
348 if grep -s "^$id " group
>/dev
/null
350 # in group file ... OK
353 if [ -f expunged
] && $expunge && egrep "^$id([ ]|\$)" expunged
>/dev
/null
355 # expunged ... will be reported, but not run, later
359 echo "$id - unknown test, ignored"
367 # Set qemu-io cache mode with $CACHEMODE we have
368 QEMU_IO_OPTIONS
="$QEMU_IO_OPTIONS --cache $CACHEMODE"
370 # Set default options for qemu-img create -o if they were not specified
375 # found some valid test numbers ... this is good
380 # had test numbers, but none in group file ... do nothing
383 # no test numbers, do everything from group file
384 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group
>$tmp.list
388 # should be sort -n, but this did not work for Linux when this
389 # was ported from IRIX
391 list
=`sort $tmp.list`
392 rm -f $tmp.list
$tmp.tmp
$tmp.
sed
396 list
=`echo $list | awk -f randomize.awk`
399 [ "$QEMU" = "" ] && _fatal
"qemu not found"
400 [ "$QEMU_IMG" = "" ] && _fatal
"qemu-img not found"
401 [ "$QEMU_IO" = "" ] && _fatal
"qemu-io not found"
403 if [ "$IMGPROTO" = "nbd" ] ; then
404 [ "$QEMU_NBD" = "" ] && _fatal
"qemu-nbd not found"
408 export REAL_QEMU_IO
="$QEMU_IO_PROG"
409 export QEMU_IO_PROG
=valgrind_qemu_io