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
50 export QEMU_IO_OPTIONS
=""
58 group_list
=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
61 if [ -z "$group_list" ]
63 echo "Group \"$r\" is empty or not defined?"
66 [ ! -s $tmp.list
] && touch $tmp.list
69 if grep -s "^$t\$" $tmp.list
>/dev
/null
82 [ ! -s $tmp.list
] && ls [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] >$tmp.list
2>/dev
/null
83 group_list
=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
86 if [ -z "$group_list" ]
88 echo "Group \"$r\" is empty or not defined?"
95 if [ $numsed -gt 100 ]
97 sed -f $tmp.
sed <$tmp.list
>$tmp.tmp
102 echo "/^$t\$/d" >>$tmp.
sed
103 numsed
=`expr $numsed + 1`
105 sed -f $tmp.
sed <$tmp.list
>$tmp.tmp
106 mv $tmp.tmp
$tmp.list
122 -\? |
-h |
--help) # usage
123 echo "Usage: $0 [options] [testlist]"'
129 -raw test raw (default)
138 -sheepdog test sheepdog
139 -xdiff graphical mode diff
140 -nocache use O_DIRECT on backing file
141 -misalign misalign memory allocations
142 -n show me, do not run tests
143 -o options -o options to pass to qemu-img create/convert
145 -r randomize test order
148 -g group[,group...] include tests from these groups
149 -x group[,group...] exclude tests from these groups
151 NNN-NNN include test range (eg. 012-021)
207 QEMU_IO_OPTIONS
="$QEMU_IO_OPTIONS --nocache"
212 QEMU_IO_OPTIONS
="$QEMU_IO_OPTIONS --misalign"
221 -g) # -g group ... pick from group file
226 -xdiff) # graphical diff mode
229 if [ ! -z "$DISPLAY" ]
231 which xdiff
>/dev
/null
2>&1 && diff=xdiff
232 which gdiff
>/dev
/null
2>&1 && diff=gdiff
233 which tkdiff
>/dev
/null
2>&1 && diff=tkdiff
234 which xxdiff
>/dev
/null
2>&1 && diff=xxdiff
238 -n) # show me, don't do it
246 -r) # randomize test order
251 -T) # turn on timestamp output
260 -x) # -x group ... exclude from group file
264 '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
271 eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'`
275 eval `echo $r | sed -e 's/^/start=/' -e 's/-//'`
276 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/.* //'`
279 echo "No tests in range \"$r\"?"
292 # get rid of leading 0s as can be interpreted as octal
293 start
=`echo $start | sed 's/^0*//'`
294 end
=`echo $end | sed 's/^0*//'`
299 $AWK_PROG </dev
/null
'
300 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
303 if grep -s "^$id " group
>/dev
/null
305 # in group file ... OK
308 if [ -f expunged
] && $expunge && egrep "^$id([ ]|\$)" expunged
>/dev
/null
310 # expunged ... will be reported, but not run, later
314 echo "$id - unknown test, ignored"
322 # Set default options for qemu-img create -o if they were not specified
327 # found some valid test numbers ... this is good
332 # had test numbers, but none in group file ... do nothing
335 # no test numbers, do everything from group file
336 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group
>$tmp.list
340 # should be sort -n, but this did not work for Linux when this
341 # was ported from IRIX
343 list
=`sort $tmp.list`
344 rm -f $tmp.list
$tmp.tmp
$tmp.
sed
348 list
=`echo $list | awk -f randomize.awk`
351 [ "$QEMU" = "" ] && _fatal
"qemu not found"
352 [ "$QEMU_IMG" = "" ] && _fatal
"qemu-img not found"
353 [ "$QEMU_IO" = "" ] && _fatal
"qemu-img not found"
356 export REAL_QEMU_IO
="$QEMU_IO_PROG"
357 export QEMU_IO_PROG
=valgrind_qemu_io