qcow2 error path tests
[qemu-iotests/stefanha.git] / 026
blobad109f743e9bab97f1c38b8744e376de97a30424
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_os Linux
48 echo "Errors while writing 128 kB"
49 echo
51 CLUSTER_SIZE=1024
53 BLKDBG_TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG"
55 for event in \
56 l1_update \
58 l2_load \
59 l2_update \
60 l2_alloc.write \
62 write_aio \
64 refblock_load \
65 refblock_update_part \
66 refblock_alloc \
68 cluster_alloc \
72 for errno in 5 28; do
73 for imm in off; do
74 for once in on off; do
75 for vmstate in "" "-b"; do
77 cat > $TEST_DIR/blkdebug.conf <<EOF
78 [inject-error]
79 event = "$event"
80 errno = "$errno"
81 immediately = "$imm"
82 once ="$once"
83 EOF
85 _make_test_img 1G
87 echo
88 echo "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate"
89 $QEMU_IO -c "write $vmstate 0 128k " $BLKDBG_TEST_IMG | _filter_qemu_io
91 # l2_load is not called on allocation, so issue a second write
92 # Reads are another path to trigger l2_load, so do a read, too
93 if [ "$event" == "l2_load" ]; then
94 $QEMU_IO -c "write $vmstate 0 128k " $BLKDBG_TEST_IMG | _filter_qemu_io
95 $QEMU_IO -c "read $vmstate 0 128k " $BLKDBG_TEST_IMG | _filter_qemu_io
98 $QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0"
100 done
101 done
102 done
103 done
104 done
107 echo
108 echo === Refcout table growth tests ===
109 echo
110 CLUSTER_SIZE=512
113 for event in \
114 refblock_alloc.hookup \
115 refblock_alloc.write \
116 refblock_alloc.write_blocks \
117 refblock_alloc.write_table \
118 refblock_alloc.switch_table \
122 # This one takes a while, so let's test only one error code (ENOSPC should
123 # never be generated by qemu, so it's probably a good choice)
124 for errno in 28; do
125 for imm in off; do
126 for once in on off; do
127 for vmstate in "" "-b"; do
129 cat > $TEST_DIR/blkdebug.conf <<EOF
130 [inject-error]
131 event = "$event"
132 errno = "$errno"
133 immediately = "$imm"
134 once = "$once"
137 _make_test_img 1G
139 echo
140 echo "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate"
141 $QEMU_IO -c "write $vmstate 0 64M" $BLKDBG_TEST_IMG | _filter_qemu_io
143 $QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0"
145 done
146 done
147 done
148 done
149 done
151 echo
152 echo === L1 growth tests ===
153 echo
154 CLUSTER_SIZE=1024
157 for event in \
158 l1_grow.alloc_table \
159 l1_grow.write_table \
160 l1_grow.activate_table \
164 for errno in 5 28; do
165 for imm in off; do
166 for once in on off; do
168 cat > $TEST_DIR/blkdebug.conf <<EOF
169 [inject-error]
170 event = "$event"
171 errno = "$errno"
172 immediately = "$imm"
173 once = "$once"
176 _make_test_img 1G
178 echo
179 echo "Event: $event; errno: $errno; imm: $imm; once: $once"
180 $QEMU_IO -c "write -b 0 64k" $BLKDBG_TEST_IMG | _filter_qemu_io
182 $QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0"
184 done
185 done
186 done
187 done
189 # success, all done
190 echo "*** done"
191 rm -f $seq.full
192 status=0