target-arm: A64: fix unallocated test of scalar SQXTUN
[qemu/ar7.git] / tests / qemu-iotests / common
blob0aaf84d015dbfb5a6753761bbfb820dca63b10d4
1 #!/bin/bash
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
22 _setenvironment()
24 MSGVERB="text:action"
25 export MSGVERB
28 here=`pwd`
29 rm -f $here/$iam.out
30 _setenvironment
32 check=${check-true}
34 diff="diff -u"
35 verbose=false
36 group=false
37 xgroup=false
38 imgopts=false
39 showme=false
40 sortme=false
41 expunge=true
42 have_test_arg=false
43 randomize=false
44 valgrind=false
45 cachemode=false
46 rm -f $tmp.list $tmp.tmp $tmp.sed
48 export IMGFMT=raw
49 export IMGFMT_GENERIC=true
50 export IMGPROTO=file
51 export IMGOPTS=""
52 export CACHEMODE="writeback"
53 export QEMU_IO_OPTIONS=""
54 export CACHEMODE_IS_DEFAULT=true
56 for r
59 if $group
60 then
61 # arg after -g
62 group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
63 s/ .*//p
64 }'`
65 if [ -z "$group_list" ]
66 then
67 echo "Group \"$r\" is empty or not defined?"
68 exit 1
70 [ ! -s $tmp.list ] && touch $tmp.list
71 for t in $group_list
73 if grep -s "^$t\$" $tmp.list >/dev/null
74 then
76 else
77 echo "$t" >>$tmp.list
79 done
80 group=false
81 continue
83 elif $xgroup
84 then
85 # arg after -x
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 /"'{
88 s/ .*//p
89 }'`
90 if [ -z "$group_list" ]
91 then
92 echo "Group \"$r\" is empty or not defined?"
93 exit 1
95 numsed=0
96 rm -f $tmp.sed
97 for t in $group_list
99 if [ $numsed -gt 100 ]
100 then
101 sed -f $tmp.sed <$tmp.list >$tmp.tmp
102 mv $tmp.tmp $tmp.list
103 numsed=0
104 rm -f $tmp.sed
106 echo "/^$t\$/d" >>$tmp.sed
107 numsed=`expr $numsed + 1`
108 done
109 sed -f $tmp.sed <$tmp.list >$tmp.tmp
110 mv $tmp.tmp $tmp.list
111 xgroup=false
112 continue
114 elif $imgopts
115 then
116 IMGOPTS="$r"
117 imgopts=false
118 continue
119 elif $cachemode
120 then
121 CACHEMODE="$r"
122 CACHEMODE_IS_DEFAULT=false
123 cachemode=false
124 continue
127 xpand=true
128 case "$r"
131 -\? | -h | --help) # usage
132 echo "Usage: $0 [options] [testlist]"'
134 common options
135 -v verbose
137 check options
138 -raw test raw (default)
139 -bochs test bochs
140 -cow test cow
141 -cloop test cloop
142 -parallels test parallels
143 -qcow test qcow
144 -qcow2 test qcow2
145 -qed test qed
146 -vdi test vdi
147 -vpc test vpc
148 -vhdx test vhdx
149 -vmdk test vmdk
150 -file test file (default)
151 -rbd test rbd
152 -sheepdog test sheepdog
153 -nbd test nbd
154 -ssh test ssh
155 -nfs test nfs
156 -xdiff graphical mode diff
157 -nocache use O_DIRECT on backing file
158 -misalign misalign memory allocations
159 -n show me, do not run tests
160 -o options -o options to pass to qemu-img create/convert
161 -T output timestamps
162 -r randomize test order
163 -c mode cache mode
165 testlist options
166 -g group[,group...] include tests from these groups
167 -x group[,group...] exclude tests from these groups
168 NNN include test NNN
169 NNN-NNN include test range (eg. 012-021)
171 exit 0
174 -raw)
175 IMGFMT=raw
176 xpand=false
179 -bochs)
180 IMGFMT=bochs
181 IMGFMT_GENERIC=false
182 xpand=false
185 -cow)
186 IMGFMT=cow
187 xpand=false
190 -cloop)
191 IMGFMT=cloop
192 IMGFMT_GENERIC=false
193 xpand=false
196 -parallels)
197 IMGFMT=parallels
198 IMGFMT_GENERIC=false
199 xpand=false
202 -qcow)
203 IMGFMT=qcow
204 xpand=false
207 -qcow2)
208 IMGFMT=qcow2
209 xpand=false
212 -qed)
213 IMGFMT=qed
214 xpand=false
217 -vdi)
218 IMGFMT=vdi
219 xpand=false
222 -vmdk)
223 IMGFMT=vmdk
224 xpand=false
227 -vpc)
228 IMGFMT=vpc
229 xpand=false
232 -vhdx)
233 IMGFMT=vhdx
234 xpand=false
237 -file)
238 IMGPROTO=file
239 xpand=false
242 -rbd)
243 IMGPROTO=rbd
244 xpand=false
247 -sheepdog)
248 IMGPROTO=sheepdog
249 xpand=false
252 -nbd)
253 IMGPROTO=nbd
254 xpand=false
257 -ssh)
258 IMGPROTO=ssh
259 xpand=false
262 -nfs)
263 IMGPROTO=nfs
264 xpand=false
267 -nocache)
268 CACHEMODE="none"
269 CACHEMODE_IS_DEFAULT=false
270 xpand=false
273 -misalign)
274 QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --misalign"
275 xpand=false
278 -valgrind)
279 valgrind=true
280 xpand=false
283 -g) # -g group ... pick from group file
284 group=true
285 xpand=false
288 -xdiff) # graphical diff mode
289 xpand=false
291 if [ ! -z "$DISPLAY" ]
292 then
293 which xdiff >/dev/null 2>&1 && diff=xdiff
294 which gdiff >/dev/null 2>&1 && diff=gdiff
295 which tkdiff >/dev/null 2>&1 && diff=tkdiff
296 which xxdiff >/dev/null 2>&1 && diff=xxdiff
300 -n) # show me, don't do it
301 showme=true
302 xpand=false
305 imgopts=true
306 xpand=false
309 cachemode=true
310 xpand=false
312 -r) # randomize test order
313 randomize=true
314 xpand=false
317 -T) # turn on timestamp output
318 timestamp=true
319 xpand=false
323 verbose=true
324 xpand=false
326 -x) # -x group ... exclude from group file
327 xgroup=true
328 xpand=false
330 '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
331 echo "No tests?"
332 status=1
333 exit $status
336 [0-9]*-[0-9]*)
337 eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'`
340 [0-9]*-)
341 eval `echo $r | sed -e 's/^/start=/' -e 's/-//'`
342 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/.* //'`
343 if [ -z "$end" ]
344 then
345 echo "No tests in range \"$r\"?"
346 status=1
347 exit $status
352 start=$r
353 end=$r
356 esac
358 # get rid of leading 0s as can be interpreted as octal
359 start=`echo $start | sed 's/^0*//'`
360 end=`echo $end | sed 's/^0*//'`
362 if $xpand
363 then
364 have_test_arg=true
365 $AWK_PROG </dev/null '
366 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
367 | while read id
369 if grep -s "^$id " group >/dev/null
370 then
371 # in group file ... OK
372 echo $id >>$tmp.list
373 else
374 if [ -f expunged ] && $expunge && egrep "^$id([ ]|\$)" expunged >/dev/null
375 then
376 # expunged ... will be reported, but not run, later
377 echo $id >>$tmp.list
378 else
379 # oops
380 echo "$id - unknown test, ignored"
383 done
386 done
388 # Set qemu-io cache mode with $CACHEMODE we have
389 QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --cache $CACHEMODE"
391 # Set default options for qemu-img create -o if they were not specified
392 _set_default_imgopts
394 if [ -s $tmp.list ]
395 then
396 # found some valid test numbers ... this is good
398 else
399 if $have_test_arg
400 then
401 # had test numbers, but none in group file ... do nothing
402 touch $tmp.list
403 else
404 # no test numbers, do everything from group file
405 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list
409 # should be sort -n, but this did not work for Linux when this
410 # was ported from IRIX
412 list=`sort $tmp.list`
413 rm -f $tmp.list $tmp.tmp $tmp.sed
415 if $randomize
416 then
417 list=`echo $list | awk -f randomize.awk`
420 [ "$QEMU" = "" ] && _fatal "qemu not found"
421 [ "$QEMU_IMG" = "" ] && _fatal "qemu-img not found"
422 [ "$QEMU_IO" = "" ] && _fatal "qemu-io not found"
424 if [ "$IMGPROTO" = "nbd" ] ; then
425 [ "$QEMU_NBD" = "" ] && _fatal "qemu-nbd not found"
428 if $valgrind; then
429 export REAL_QEMU_IO="$QEMU_IO_PROG"
430 export QEMU_IO_PROG=valgrind_qemu_io