]> Git Repo - qemu.git/blob - tests/qemu-iotests/common
iotests: Remove a few tests from 'quick' group
[qemu.git] / tests / qemu-iotests / common
1 #!/bin/bash
2 #
3 # Copyright (C) 2009 Red Hat, Inc.
4 # Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
5 #
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.
9 #
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.
14 #
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/>.
17 #
18 #
19 # common procedures for QA scripts
20 #
21
22 _setenvironment()
23 {
24     MSGVERB="text:action"
25     export MSGVERB
26 }
27
28 rm -f "$OUTPUT_DIR/$iam.out"
29 _setenvironment
30
31 check=${check-true}
32
33 diff="diff -u"
34 verbose=false
35 debug=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 cachemode=false
45 rm -f $tmp.list $tmp.tmp $tmp.sed
46
47 export IMGFMT=raw
48 export IMGFMT_GENERIC=true
49 export IMGPROTO=file
50 export IMGOPTS=""
51 export CACHEMODE="writeback"
52 export QEMU_IO_OPTIONS=""
53 export QEMU_IO_OPTIONS_NO_FMT=""
54 export CACHEMODE_IS_DEFAULT=true
55 export QEMU_OPTIONS="-nodefaults -machine accel=qtest"
56 export VALGRIND_QEMU=
57 export IMGKEYSECRET=
58 export IMGOPTSSYNTAX=false
59
60 for r
61 do
62
63     if $group
64     then
65         # arg after -g
66         group_list=`sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
67 s/ .*//p
68 }'`
69         if [ -z "$group_list" ]
70         then
71             echo "Group \"$r\" is empty or not defined?"
72             exit 1
73         fi
74         [ ! -s $tmp.list ] && touch $tmp.list
75         for t in $group_list
76         do
77             if grep -s "^$t\$" $tmp.list >/dev/null
78             then
79                 :
80             else
81                 echo "$t" >>$tmp.list
82             fi
83         done
84         group=false
85         continue
86
87     elif $xgroup
88     then
89         # arg after -x
90         # Populate $tmp.list with all tests
91         awk '/^[0-9]{3,}/ {print $1}' "${source_iotests}/group" > $tmp.list 2>/dev/null
92         group_list=`sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
93 s/ .*//p
94 }'`
95         if [ -z "$group_list" ]
96         then
97             echo "Group \"$r\" is empty or not defined?"
98             exit 1
99         fi
100         numsed=0
101         rm -f $tmp.sed
102         for t in $group_list
103         do
104             if [ $numsed -gt 100 ]
105             then
106                 sed -f $tmp.sed <$tmp.list >$tmp.tmp
107                 mv $tmp.tmp $tmp.list
108                 numsed=0
109                 rm -f $tmp.sed
110             fi
111             echo "/^$t\$/d" >>$tmp.sed
112             numsed=`expr $numsed + 1`
113         done
114         sed -f $tmp.sed <$tmp.list >$tmp.tmp
115         mv $tmp.tmp $tmp.list
116         xgroup=false
117         continue
118
119     elif $imgopts
120     then
121         IMGOPTS="$r"
122         imgopts=false
123         continue
124     elif $cachemode
125     then
126         CACHEMODE="$r"
127         CACHEMODE_IS_DEFAULT=false
128         cachemode=false
129         continue
130     fi
131
132     xpand=true
133     case "$r"
134     in
135
136         -\? | -h | --help)        # usage
137             echo "Usage: $0 [options] [testlist]"'
138
139 common options
140     -v                  verbose
141     -d                  debug
142
143 image format options
144     -raw                test raw (default)
145     -bochs              test bochs
146     -cloop              test cloop
147     -parallels          test parallels
148     -qcow               test qcow
149     -qcow2              test qcow2
150     -qed                test qed
151     -vdi                test vdi
152     -vpc                test vpc
153     -vhdx               test vhdx
154     -vmdk               test vmdk
155     -luks               test luks
156
157 image protocol options
158     -file               test file (default)
159     -rbd                test rbd
160     -sheepdog           test sheepdog
161     -nbd                test nbd
162     -ssh                test ssh
163     -nfs                test nfs
164     -vxhs               test vxhs
165
166 other options
167     -xdiff              graphical mode diff
168     -nocache            use O_DIRECT on backing file
169     -misalign           misalign memory allocations
170     -n                  show me, do not run tests
171     -o options          -o options to pass to qemu-img create/convert
172     -T                  output timestamps
173     -r                  randomize test order
174     -c mode             cache mode
175
176 testlist options
177     -g group[,group...]        include tests from these groups
178     -x group[,group...]        exclude tests from these groups
179     NNN                        include test NNN
180     NNN-NNN                    include test range (eg. 012-021)
181 '
182             exit 0
183             ;;
184
185         -raw)
186             IMGFMT=raw
187             xpand=false
188             ;;
189
190         -bochs)
191             IMGFMT=bochs
192             IMGFMT_GENERIC=false
193             xpand=false
194             ;;
195
196         -cloop)
197             IMGFMT=cloop
198             IMGFMT_GENERIC=false
199             xpand=false
200             ;;
201
202         -parallels)
203             IMGFMT=parallels
204             IMGFMT_GENERIC=false
205             xpand=false
206             ;;
207
208         -qcow)
209             IMGFMT=qcow
210             xpand=false
211             ;;
212
213         -qcow2)
214             IMGFMT=qcow2
215             xpand=false
216             ;;
217
218         -luks)
219             IMGOPTSSYNTAX=true
220             IMGFMT=luks
221             IMGKEYSECRET=123456
222             xpand=false
223             ;;
224
225         -qed)
226             IMGFMT=qed
227             xpand=false
228             ;;
229
230         -vdi)
231             IMGFMT=vdi
232             xpand=false
233             ;;
234
235         -vmdk)
236             IMGFMT=vmdk
237             xpand=false
238             ;;
239
240         -vpc)
241             IMGFMT=vpc
242             xpand=false
243             ;;
244
245         -vhdx)
246             IMGFMT=vhdx
247             xpand=false
248             ;;
249
250         -file)
251             IMGPROTO=file
252             xpand=false
253             ;;
254
255         -rbd)
256             IMGPROTO=rbd
257             xpand=false
258             ;;
259
260         -sheepdog)
261             IMGPROTO=sheepdog
262             xpand=false
263             ;;
264
265         -nbd)
266             IMGPROTO=nbd
267             xpand=false
268             ;;
269
270         -vxhs)
271             IMGPROTO=vxhs
272             xpand=false
273             ;;
274
275         -ssh)
276             IMGPROTO=ssh
277             xpand=false
278             ;;
279
280         -nfs)
281             IMGPROTO=nfs
282             xpand=false
283             ;;
284
285         -nocache)
286             CACHEMODE="none"
287             CACHEMODE_IS_DEFAULT=false
288             xpand=false
289             ;;
290
291         -misalign)
292             QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --misalign"
293             xpand=false
294             ;;
295
296         -valgrind)
297             VALGRIND_QEMU='y'
298             xpand=false
299             ;;
300
301         -g)        # -g group ... pick from group file
302             group=true
303             xpand=false
304             ;;
305
306         -xdiff)        # graphical diff mode
307             xpand=false
308
309             if [ ! -z "$DISPLAY" ]
310             then
311                 command -v xdiff >/dev/null 2>&1 && diff=xdiff
312                 command -v gdiff >/dev/null 2>&1 && diff=gdiff
313                 command -v tkdiff >/dev/null 2>&1 && diff=tkdiff
314                 command -v xxdiff >/dev/null 2>&1 && diff=xxdiff
315             fi
316             ;;
317
318         -n)        # show me, don't do it
319             showme=true
320             xpand=false
321             ;;
322         -o)
323             imgopts=true
324             xpand=false
325             ;;
326         -c)
327             cachemode=true
328             xpand=false
329             ;;
330         -r)        # randomize test order
331             randomize=true
332             xpand=false
333             ;;
334
335         -T)        # turn on timestamp output
336             timestamp=true
337             xpand=false
338             ;;
339
340         -v)
341             verbose=true
342             xpand=false
343             ;;
344         -d)
345             debug=true
346             xpand=false
347             ;;
348         -x)        # -x group ... exclude from group file
349             xgroup=true
350             xpand=false
351             ;;
352         '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
353             echo "No tests?"
354             status=1
355             exit $status
356             ;;
357
358         [0-9]*-[0-9]*)
359             eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'`
360             ;;
361
362         [0-9]*-)
363             eval `echo $r | sed -e 's/^/start=/' -e 's/-//'`
364             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/.* //'`
365             if [ -z "$end" ]
366             then
367                 echo "No tests in range \"$r\"?"
368                 status=1
369                 exit $status
370             fi
371             ;;
372
373         *)
374             start=$r
375             end=$r
376             ;;
377
378     esac
379
380     # get rid of leading 0s as can be interpreted as octal
381     start=`echo $start | sed 's/^0*//'`
382     end=`echo $end | sed 's/^0*//'`
383
384     if $xpand
385     then
386         have_test_arg=true
387         $AWK_PROG </dev/null '
388 BEGIN        { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
389         | while read id
390         do
391             if grep -s "^$id " "$source_iotests/group" >/dev/null
392             then
393                 # in group file ... OK
394                 echo $id >>$tmp.list
395             else
396                 if [ -f expunged ] && $expunge && egrep "^$id([         ]|\$)" expunged >/dev/null
397                 then
398                     # expunged ... will be reported, but not run, later
399                     echo $id >>$tmp.list
400                 else
401                     # oops
402                     if [ "$start" == "$end" -a "$id" == "$end" ]
403                     then
404                         echo "$id - unknown test"
405                         exit 1
406                     else
407                         echo "$id - unknown test, ignored"
408                     fi
409                 fi
410             fi
411         done || exit 1
412     fi
413
414 done
415
416 # Set qemu-io cache mode with $CACHEMODE we have
417 QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --cache $CACHEMODE"
418
419 QEMU_IO_OPTIONS_NO_FMT="$QEMU_IO_OPTIONS"
420 if [ "$IMGOPTSSYNTAX" != "true" ]; then
421     QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS -f $IMGFMT"
422 fi
423
424 # Set default options for qemu-img create -o if they were not specified
425 _set_default_imgopts
426
427 if [ -s $tmp.list ]
428 then
429     # found some valid test numbers ... this is good
430     :
431 else
432     if $have_test_arg
433     then
434         # had test numbers, but none in group file ... do nothing
435         touch $tmp.list
436     else
437         # no test numbers, do everything from group file
438         sed -n -e '/^[0-9][0-9][0-9]*/s/[         ].*//p' <"$source_iotests/group" >$tmp.list
439     fi
440 fi
441
442 # should be sort -n, but this did not work for Linux when this
443 # was ported from IRIX
444 #
445 list=`sort $tmp.list`
446 rm -f $tmp.list $tmp.tmp $tmp.sed
447
448 if $randomize
449 then
450     list=`echo $list | awk -f randomize.awk`
451 fi
452
453 [ "$QEMU" = "" ] && _fatal "qemu not found"
454 [ "$QEMU_IMG" = "" ] && _fatal "qemu-img not found"
455 [ "$QEMU_IO" = "" ] && _fatal "qemu-io not found"
456
457 if [ "$IMGPROTO" = "nbd" ] ; then
458     [ "$QEMU_NBD" = "" ] && _fatal "qemu-nbd not found"
459 fi
This page took 0.050023 seconds and 4 git commands to generate.