root / tests / qemu-iotests / 026 @ 6ce2d77a
History | View | Annotate | Download (3.9 kB)
1 | 52280eac | Kevin Wolf | #!/bin/bash |
---|---|---|---|
2 | 52280eac | Kevin Wolf | # |
3 | 52280eac | Kevin Wolf | # qcow2 error path testing |
4 | 52280eac | Kevin Wolf | # |
5 | 52280eac | Kevin Wolf | # Copyright (C) 2010 Red Hat, Inc. |
6 | 52280eac | Kevin Wolf | # |
7 | 52280eac | Kevin Wolf | # This program is free software; you can redistribute it and/or modify |
8 | 52280eac | Kevin Wolf | # it under the terms of the GNU General Public License as published by |
9 | 52280eac | Kevin Wolf | # the Free Software Foundation; either version 2 of the License, or |
10 | 52280eac | Kevin Wolf | # (at your option) any later version. |
11 | 52280eac | Kevin Wolf | # |
12 | 52280eac | Kevin Wolf | # This program is distributed in the hope that it will be useful, |
13 | 52280eac | Kevin Wolf | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | 52280eac | Kevin Wolf | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | 52280eac | Kevin Wolf | # GNU General Public License for more details. |
16 | 52280eac | Kevin Wolf | # |
17 | 52280eac | Kevin Wolf | # You should have received a copy of the GNU General Public License |
18 | 52280eac | Kevin Wolf | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 52280eac | Kevin Wolf | # |
20 | 52280eac | Kevin Wolf | |
21 | 52280eac | Kevin Wolf | # creator |
22 | 52280eac | Kevin Wolf | owner=kwolf@redhat.com |
23 | 52280eac | Kevin Wolf | |
24 | 52280eac | Kevin Wolf | seq=`basename $0` |
25 | 52280eac | Kevin Wolf | echo "QA output created by $seq" |
26 | 52280eac | Kevin Wolf | |
27 | 52280eac | Kevin Wolf | here=`pwd` |
28 | 52280eac | Kevin Wolf | tmp=/tmp/$$ |
29 | 52280eac | Kevin Wolf | status=1 # failure is the default! |
30 | 52280eac | Kevin Wolf | |
31 | 52280eac | Kevin Wolf | _cleanup() |
32 | 52280eac | Kevin Wolf | { |
33 | 52280eac | Kevin Wolf | _cleanup_test_img |
34 | 52280eac | Kevin Wolf | rm $TEST_DIR/blkdebug.conf |
35 | 52280eac | Kevin Wolf | } |
36 | 52280eac | Kevin Wolf | trap "_cleanup; exit \$status" 0 1 2 3 15 |
37 | 52280eac | Kevin Wolf | |
38 | 52280eac | Kevin Wolf | # get standard environment, filters and checks |
39 | 52280eac | Kevin Wolf | . ./common.rc |
40 | 52280eac | Kevin Wolf | . ./common.filter |
41 | 52280eac | Kevin Wolf | . ./common.pattern |
42 | 52280eac | Kevin Wolf | |
43 | 52280eac | Kevin Wolf | # Currently only qcow2 supports rebasing |
44 | 52280eac | Kevin Wolf | _supported_fmt qcow2 |
45 | 9cdfa1b3 | MORITA Kazutaka | _supported_proto generic |
46 | 52280eac | Kevin Wolf | _supported_os Linux |
47 | 52280eac | Kevin Wolf | |
48 | 52280eac | Kevin Wolf | |
49 | 52280eac | Kevin Wolf | echo "Errors while writing 128 kB" |
50 | 52280eac | Kevin Wolf | echo |
51 | 52280eac | Kevin Wolf | |
52 | 52280eac | Kevin Wolf | CLUSTER_SIZE=1024 |
53 | 52280eac | Kevin Wolf | |
54 | 52280eac | Kevin Wolf | BLKDBG_TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG" |
55 | 52280eac | Kevin Wolf | |
56 | 52280eac | Kevin Wolf | for event in \ |
57 | 52280eac | Kevin Wolf | l1_update \ |
58 | 52280eac | Kevin Wolf | \ |
59 | 52280eac | Kevin Wolf | l2_load \ |
60 | 52280eac | Kevin Wolf | l2_update \ |
61 | 52280eac | Kevin Wolf | l2_alloc.write \ |
62 | 52280eac | Kevin Wolf | \ |
63 | 52280eac | Kevin Wolf | write_aio \ |
64 | 52280eac | Kevin Wolf | \ |
65 | 52280eac | Kevin Wolf | refblock_load \ |
66 | 52280eac | Kevin Wolf | refblock_update_part \ |
67 | 52280eac | Kevin Wolf | refblock_alloc \ |
68 | 52280eac | Kevin Wolf | \ |
69 | 52280eac | Kevin Wolf | cluster_alloc \ |
70 | 52280eac | Kevin Wolf | |
71 | 52280eac | Kevin Wolf | do |
72 | 52280eac | Kevin Wolf | |
73 | 52280eac | Kevin Wolf | for errno in 5 28; do |
74 | 52280eac | Kevin Wolf | for imm in off; do |
75 | 52280eac | Kevin Wolf | for once in on off; do |
76 | 52280eac | Kevin Wolf | for vmstate in "" "-b"; do |
77 | 52280eac | Kevin Wolf | |
78 | 52280eac | Kevin Wolf | cat > $TEST_DIR/blkdebug.conf <<EOF |
79 | 52280eac | Kevin Wolf | [inject-error] |
80 | 52280eac | Kevin Wolf | event = "$event" |
81 | 52280eac | Kevin Wolf | errno = "$errno" |
82 | 52280eac | Kevin Wolf | immediately = "$imm" |
83 | 52280eac | Kevin Wolf | once ="$once" |
84 | 52280eac | Kevin Wolf | EOF |
85 | 52280eac | Kevin Wolf | |
86 | 52280eac | Kevin Wolf | _make_test_img 1G |
87 | 52280eac | Kevin Wolf | |
88 | 52280eac | Kevin Wolf | echo |
89 | 52280eac | Kevin Wolf | echo "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate" |
90 | 92ab69b6 | Kevin Wolf | |
91 | 92ab69b6 | Kevin Wolf | # We want to catch a simple L2 update, not the allocation of the first L2 table |
92 | 92ab69b6 | Kevin Wolf | if [ "$event" == "l2_update" ]; then |
93 | 92ab69b6 | Kevin Wolf | $QEMU_IO -c "write $vmstate 0 512" $TEST_IMG > /dev/null 2>&1 |
94 | 92ab69b6 | Kevin Wolf | fi |
95 | 92ab69b6 | Kevin Wolf | |
96 | 52280eac | Kevin Wolf | $QEMU_IO -c "write $vmstate 0 128k " $BLKDBG_TEST_IMG | _filter_qemu_io |
97 | 52280eac | Kevin Wolf | |
98 | 52280eac | Kevin Wolf | # l2_load is not called on allocation, so issue a second write |
99 | 52280eac | Kevin Wolf | # Reads are another path to trigger l2_load, so do a read, too |
100 | 52280eac | Kevin Wolf | if [ "$event" == "l2_load" ]; then |
101 | 52280eac | Kevin Wolf | $QEMU_IO -c "write $vmstate 0 128k " $BLKDBG_TEST_IMG | _filter_qemu_io |
102 | 52280eac | Kevin Wolf | $QEMU_IO -c "read $vmstate 0 128k " $BLKDBG_TEST_IMG | _filter_qemu_io |
103 | 52280eac | Kevin Wolf | fi |
104 | 52280eac | Kevin Wolf | |
105 | 52280eac | Kevin Wolf | $QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0" |
106 | 52280eac | Kevin Wolf | |
107 | 52280eac | Kevin Wolf | done |
108 | 52280eac | Kevin Wolf | done |
109 | 52280eac | Kevin Wolf | done |
110 | 52280eac | Kevin Wolf | done |
111 | 52280eac | Kevin Wolf | done |
112 | 52280eac | Kevin Wolf | |
113 | 52280eac | Kevin Wolf | |
114 | 52280eac | Kevin Wolf | echo |
115 | 52280eac | Kevin Wolf | echo === Refcout table growth tests === |
116 | 52280eac | Kevin Wolf | echo |
117 | 52280eac | Kevin Wolf | CLUSTER_SIZE=512 |
118 | 52280eac | Kevin Wolf | |
119 | 52280eac | Kevin Wolf | |
120 | 52280eac | Kevin Wolf | for event in \ |
121 | 52280eac | Kevin Wolf | refblock_alloc.hookup \ |
122 | 52280eac | Kevin Wolf | refblock_alloc.write \ |
123 | 52280eac | Kevin Wolf | refblock_alloc.write_blocks \ |
124 | 52280eac | Kevin Wolf | refblock_alloc.write_table \ |
125 | 52280eac | Kevin Wolf | refblock_alloc.switch_table \ |
126 | 52280eac | Kevin Wolf | |
127 | 52280eac | Kevin Wolf | do |
128 | 52280eac | Kevin Wolf | |
129 | 52280eac | Kevin Wolf | # This one takes a while, so let's test only one error code (ENOSPC should |
130 | 52280eac | Kevin Wolf | # never be generated by qemu, so it's probably a good choice) |
131 | 52280eac | Kevin Wolf | for errno in 28; do |
132 | 52280eac | Kevin Wolf | for imm in off; do |
133 | 52280eac | Kevin Wolf | for once in on off; do |
134 | 52280eac | Kevin Wolf | for vmstate in "" "-b"; do |
135 | 52280eac | Kevin Wolf | |
136 | 52280eac | Kevin Wolf | cat > $TEST_DIR/blkdebug.conf <<EOF |
137 | 52280eac | Kevin Wolf | [inject-error] |
138 | 52280eac | Kevin Wolf | event = "$event" |
139 | 52280eac | Kevin Wolf | errno = "$errno" |
140 | 52280eac | Kevin Wolf | immediately = "$imm" |
141 | 52280eac | Kevin Wolf | once = "$once" |
142 | 52280eac | Kevin Wolf | EOF |
143 | 52280eac | Kevin Wolf | |
144 | 52280eac | Kevin Wolf | _make_test_img 1G |
145 | 52280eac | Kevin Wolf | |
146 | 52280eac | Kevin Wolf | echo |
147 | 52280eac | Kevin Wolf | echo "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate" |
148 | 52280eac | Kevin Wolf | $QEMU_IO -c "write $vmstate 0 64M" $BLKDBG_TEST_IMG | _filter_qemu_io |
149 | 52280eac | Kevin Wolf | |
150 | 52280eac | Kevin Wolf | $QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0" |
151 | 52280eac | Kevin Wolf | |
152 | 52280eac | Kevin Wolf | done |
153 | 52280eac | Kevin Wolf | done |
154 | 52280eac | Kevin Wolf | done |
155 | 52280eac | Kevin Wolf | done |
156 | 52280eac | Kevin Wolf | done |
157 | 52280eac | Kevin Wolf | |
158 | 52280eac | Kevin Wolf | echo |
159 | 52280eac | Kevin Wolf | echo === L1 growth tests === |
160 | 52280eac | Kevin Wolf | echo |
161 | 52280eac | Kevin Wolf | CLUSTER_SIZE=1024 |
162 | 52280eac | Kevin Wolf | |
163 | 52280eac | Kevin Wolf | |
164 | 52280eac | Kevin Wolf | for event in \ |
165 | 52280eac | Kevin Wolf | l1_grow.alloc_table \ |
166 | 52280eac | Kevin Wolf | l1_grow.write_table \ |
167 | 52280eac | Kevin Wolf | l1_grow.activate_table \ |
168 | 52280eac | Kevin Wolf | |
169 | 52280eac | Kevin Wolf | do |
170 | 52280eac | Kevin Wolf | |
171 | 52280eac | Kevin Wolf | for errno in 5 28; do |
172 | 52280eac | Kevin Wolf | for imm in off; do |
173 | 52280eac | Kevin Wolf | for once in on off; do |
174 | 52280eac | Kevin Wolf | |
175 | 52280eac | Kevin Wolf | cat > $TEST_DIR/blkdebug.conf <<EOF |
176 | 52280eac | Kevin Wolf | [inject-error] |
177 | 52280eac | Kevin Wolf | event = "$event" |
178 | 52280eac | Kevin Wolf | errno = "$errno" |
179 | 52280eac | Kevin Wolf | immediately = "$imm" |
180 | 52280eac | Kevin Wolf | once = "$once" |
181 | 52280eac | Kevin Wolf | EOF |
182 | 52280eac | Kevin Wolf | |
183 | 52280eac | Kevin Wolf | _make_test_img 1G |
184 | 52280eac | Kevin Wolf | |
185 | 52280eac | Kevin Wolf | echo |
186 | 52280eac | Kevin Wolf | echo "Event: $event; errno: $errno; imm: $imm; once: $once" |
187 | 52280eac | Kevin Wolf | $QEMU_IO -c "write -b 0 64k" $BLKDBG_TEST_IMG | _filter_qemu_io |
188 | 52280eac | Kevin Wolf | |
189 | 52280eac | Kevin Wolf | $QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0" |
190 | 52280eac | Kevin Wolf | |
191 | 52280eac | Kevin Wolf | done |
192 | 52280eac | Kevin Wolf | done |
193 | 52280eac | Kevin Wolf | done |
194 | 52280eac | Kevin Wolf | done |
195 | 52280eac | Kevin Wolf | |
196 | 52280eac | Kevin Wolf | # success, all done |
197 | 52280eac | Kevin Wolf | echo "*** done" |
198 | 52280eac | Kevin Wolf | rm -f $seq.full |
199 | 52280eac | Kevin Wolf | status=0 |