common.config: Allow use of arbitrary qemu* paths
[qemu-iotests.git] / 026
blob33e7da6abe375198f6e26456c235ec0dc126a444
1 #!/bin/bash
3 # qcow2 error path testing
5 # Copyright (C) 2010 Red Hat, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # creator
22 owner=kwolf@redhat.com
24 seq=`basename $0`
25 echo "QA output created by $seq"
27 here=`pwd`
28 tmp=/tmp/$$
29 status=1 # failure is the default!
31 _cleanup()
33 _cleanup_test_img
34 rm $TEST_DIR/blkdebug.conf
36 trap "_cleanup; exit \$status" 0 1 2 3 15
38 # get standard environment, filters and checks
39 . ./common.rc
40 . ./common.filter
41 . ./common.pattern
43 # Currently only qcow2 supports rebasing
44 _supported_fmt qcow2
45 _supported_proto generic
46 _supported_os Linux
49 echo "Errors while writing 128 kB"
50 echo
52 CLUSTER_SIZE=1024
54 BLKDBG_TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG"
56 for event in \
57 l1_update \
59 l2_load \
60 l2_update \
61 l2_alloc.write \
63 write_aio \
65 refblock_load \
66 refblock_update_part \
67 refblock_alloc \
69 cluster_alloc \
73 for errno in 5 28; do
74 for imm in off; do
75 for once in on off; do
76 for vmstate in "" "-b"; do
78 cat > $TEST_DIR/blkdebug.conf <<EOF
79 [inject-error]
80 event = "$event"
81 errno = "$errno"
82 immediately = "$imm"
83 once ="$once"
84 EOF
86 _make_test_img 1G
88 echo
89 echo "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate"
90 $QEMU_IO -c "write $vmstate 0 128k " $BLKDBG_TEST_IMG | _filter_qemu_io
92 # l2_load is not called on allocation, so issue a second write
93 # Reads are another path to trigger l2_load, so do a read, too
94 if [ "$event" == "l2_load" ]; then
95 $QEMU_IO -c "write $vmstate 0 128k " $BLKDBG_TEST_IMG | _filter_qemu_io
96 $QEMU_IO -c "read $vmstate 0 128k " $BLKDBG_TEST_IMG | _filter_qemu_io
99 $QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0"
101 done
102 done
103 done
104 done
105 done
108 echo
109 echo === Refcout table growth tests ===
110 echo
111 CLUSTER_SIZE=512
114 for event in \
115 refblock_alloc.hookup \
116 refblock_alloc.write \
117 refblock_alloc.write_blocks \
118 refblock_alloc.write_table \
119 refblock_alloc.switch_table \
123 # This one takes a while, so let's test only one error code (ENOSPC should
124 # never be generated by qemu, so it's probably a good choice)
125 for errno in 28; do
126 for imm in off; do
127 for once in on off; do
128 for vmstate in "" "-b"; do
130 cat > $TEST_DIR/blkdebug.conf <<EOF
131 [inject-error]
132 event = "$event"
133 errno = "$errno"
134 immediately = "$imm"
135 once = "$once"
138 _make_test_img 1G
140 echo
141 echo "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate"
142 $QEMU_IO -c "write $vmstate 0 64M" $BLKDBG_TEST_IMG | _filter_qemu_io
144 $QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0"
146 done
147 done
148 done
149 done
150 done
152 echo
153 echo === L1 growth tests ===
154 echo
155 CLUSTER_SIZE=1024
158 for event in \
159 l1_grow.alloc_table \
160 l1_grow.write_table \
161 l1_grow.activate_table \
165 for errno in 5 28; do
166 for imm in off; do
167 for once in on off; do
169 cat > $TEST_DIR/blkdebug.conf <<EOF
170 [inject-error]
171 event = "$event"
172 errno = "$errno"
173 immediately = "$imm"
174 once = "$once"
177 _make_test_img 1G
179 echo
180 echo "Event: $event; errno: $errno; imm: $imm; once: $once"
181 $QEMU_IO -c "write -b 0 64k" $BLKDBG_TEST_IMG | _filter_qemu_io
183 $QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0"
185 done
186 done
187 done
188 done
190 # success, all done
191 echo "*** done"
192 rm -f $seq.full
193 status=0