]>
git.proxmox.com Git - qemu.git/blob - tests/qemu-iotests/common
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
45 rm -f $tmp.list
$tmp.tmp
$tmp.
sed
48 export IMGFMT_GENERIC
=true
51 export QEMU_IO_OPTIONS
=""
59 group_list
=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
62 if [ -z "$group_list" ]
64 echo "Group \"$r\" is empty or not defined?"
67 [ ! -s $tmp.list
] && touch $tmp.list
70 if grep -s "^$t\$" $tmp.list
>/dev
/null
83 [ ! -s $tmp.list
] && ls [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] >$tmp.list
2>/dev
/null
84 group_list
=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
87 if [ -z "$group_list" ]
89 echo "Group \"$r\" is empty or not defined?"
96 if [ $numsed -gt 100 ]
98 sed -f $tmp.
sed <$tmp.list
>$tmp.tmp
103 echo "/^$t\$/d" >>$tmp.
sed
104 numsed
=`expr $numsed + 1`
106 sed -f $tmp.
sed <$tmp.list
>$tmp.tmp
107 mv $tmp.tmp
$tmp.list
123 -\? |
-h |
--help) # usage
124 echo "Usage: $0 [options] [testlist]"'
130 -raw test raw (default)
140 -sheepdog test sheepdog
143 -xdiff graphical mode diff
144 -nocache use O_DIRECT on backing file
145 -misalign misalign memory allocations
146 -n show me, do not run tests
147 -o options -o options to pass to qemu-img create/convert
149 -r randomize test order
152 -g group[,group...] include tests from these groups
153 -x group[,group...] exclude tests from these groups
155 NNN-NNN include test range (eg. 012-021)
223 QEMU_IO_OPTIONS
="$QEMU_IO_OPTIONS --nocache"
228 QEMU_IO_OPTIONS
="$QEMU_IO_OPTIONS --misalign"
237 -g) # -g group ... pick from group file
242 -xdiff) # graphical diff mode
245 if [ ! -z "$DISPLAY" ]
247 which xdiff
>/dev
/null
2>&1 && diff=xdiff
248 which gdiff
>/dev
/null
2>&1 && diff=gdiff
249 which tkdiff
>/dev
/null
2>&1 && diff=tkdiff
250 which xxdiff
>/dev
/null
2>&1 && diff=xxdiff
254 -n) # show me, don't do it
262 -r) # randomize test order
267 -T) # turn on timestamp output
276 -x) # -x group ... exclude from group file
280 '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
287 eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'`
291 eval `echo $r | sed -e 's/^/start=/' -e 's/-//'`
292 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/.* //'`
295 echo "No tests in range \"$r\"?"
308 # get rid of leading 0s as can be interpreted as octal
309 start
=`echo $start | sed 's/^0*//'`
310 end
=`echo $end | sed 's/^0*//'`
315 $AWK_PROG </dev
/null
'
316 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
319 if grep -s "^$id " group
>/dev
/null
321 # in group file ... OK
324 if [ -f expunged
] && $expunge && egrep "^$id([ ]|\$)" expunged
>/dev
/null
326 # expunged ... will be reported, but not run, later
330 echo "$id - unknown test, ignored"
338 # Set default options for qemu-img create -o if they were not specified
343 # found some valid test numbers ... this is good
348 # had test numbers, but none in group file ... do nothing
351 # no test numbers, do everything from group file
352 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group
>$tmp.list
356 # should be sort -n, but this did not work for Linux when this
357 # was ported from IRIX
359 list
=`sort $tmp.list`
360 rm -f $tmp.list
$tmp.tmp
$tmp.
sed
364 list
=`echo $list | awk -f randomize.awk`
367 [ "$QEMU" = "" ] && _fatal
"qemu not found"
368 [ "$QEMU_IMG" = "" ] && _fatal
"qemu-img not found"
369 [ "$QEMU_IO" = "" ] && _fatal
"qemu-io not found"
371 if [ "$IMGPROTO" = "nbd" ] ; then
372 [ "$QEMU_NBD" = "" ] && _fatal
"qemu-nbd not found"
376 export REAL_QEMU_IO
="$QEMU_IO_PROG"
377 export QEMU_IO_PROG
=valgrind_qemu_io