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
44 rm -f $tmp.list $tmp.tmp $tmp.sed
49 export QEMU_IO_OPTIONS=""
57 group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
60 if [ -z "$group_list" ]
62 echo "Group \"$r\" is empty or not defined?"
65 [ ! -s $tmp.list ] && touch $tmp.list
68 if grep -s "^$t\$" $tmp.list >/dev/null
81 [ ! -s $tmp.list ] && ls [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] >$tmp.list 2>/dev/null
82 group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
85 if [ -z "$group_list" ]
87 echo "Group \"$r\" is empty or not defined?"
94 if [ $numsed -gt 100 ]
96 sed -f $tmp.sed <$tmp.list >$tmp.tmp
101 echo "/^$t\$/d" >>$tmp.sed
102 numsed=`expr $numsed + 1`
104 sed -f $tmp.sed <$tmp.list >$tmp.tmp
105 mv $tmp.tmp $tmp.list
121 -\? | -h | --help) # usage
122 echo "Usage: $0 [options] [testlist]"'
128 -raw test raw (default)
137 -sheepdog test sheepdog
138 -xdiff graphical mode diff
139 -nocache use O_DIRECT on backing file
140 -misalign misalign memory allocations
141 -n show me, do not run tests
142 -o options -o options to pass to qemu-img create/convert
144 -r randomize test order
147 -g group[,group...] include tests from these groups
148 -x group[,group...] exclude tests from these groups
150 NNN-NNN include test range (eg. 012-021)
206 QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --nocache"
211 QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --misalign"
215 -g) # -g group ... pick from group file
220 -xdiff) # graphical diff mode
223 if [ ! -z "$DISPLAY" ]
225 which xdiff >/dev/null 2>&1 && diff=xdiff
226 which gdiff >/dev/null 2>&1 && diff=gdiff
227 which tkdiff >/dev/null 2>&1 && diff=tkdiff
228 which xxdiff >/dev/null 2>&1 && diff=xxdiff
232 -n) # show me, don't do it
240 -r) # randomize test order
245 -T) # turn on timestamp output
254 -x) # -x group ... exclude from group file
258 '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
265 eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'`
269 eval `echo $r | sed -e 's/^/start=/' -e 's/-//'`
270 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/.* //'`
273 echo "No tests in range \"$r\"?"
286 # get rid of leading 0s as can be interpreted as octal
287 start=`echo $start | sed 's/^0*//'`
288 end=`echo $end | sed 's/^0*//'`
293 $AWK_PROG </dev/null '
294 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
297 if grep -s "^$id " group >/dev/null
299 # in group file ... OK
302 if [ -f expunged ] && $expunge && egrep "^$id([ ]|\$)" expunged >/dev/null
304 # expunged ... will be reported, but not run, later
308 echo "$id - unknown test, ignored"
316 # Set default options for qemu-img create -o if they were not specified
321 # found some valid test numbers ... this is good
326 # had test numbers, but none in group file ... do nothing
329 # no test numbers, do everything from group file
330 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list
334 # should be sort -n, but this did not work for Linux when this
335 # was ported from IRIX
337 list=`sort $tmp.list`
338 rm -f $tmp.list $tmp.tmp $tmp.sed
342 list=`echo $list | awk -f randomize.awk`
345 [ "$QEMU" = "" ] && _fatal "qemu not found"
346 [ "$QEMU_IMG" = "" ] && _fatal "qemu-img not found"
347 [ "$QEMU_IO" = "" ] && _fatal "qemu-img not found"