qapi/error: Check format string argument in error_*prepend()
[qemu/armbru.git] / tests / qemu-iotests / 071
blob88faebcc1d960aa1616f14064a1bcdeb1819abc4
1 #!/usr/bin/env bash
3 # Test case for the QMP blkdebug and blkverify interfaces
5 # Copyright (C) 2013 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=mreitz@redhat.com
24 seq="$(basename $0)"
25 echo "QA output created by $seq"
27 status=1 # failure is the default!
29 _cleanup()
31 _cleanup_test_img
33 trap "_cleanup; exit \$status" 0 1 2 3 15
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
39 _supported_fmt qcow2
40 _supported_proto file
41 _require_drivers blkdebug blkverify
42 # blkdebug can only inject errors on bs->file, not on the data_file,
43 # so thie test does not work with external data files
44 _unsupported_imgopts data_file
46 do_run_qemu()
48 echo Testing: "$@" | _filter_imgfmt
49 $QEMU -nographic -qmp stdio -serial none "$@"
50 echo
53 run_qemu()
55 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp | _filter_qemu_io
58 IMG_SIZE=64M
60 echo
61 echo "=== Testing blkverify through filename ==="
62 echo
64 TEST_IMG="$TEST_IMG.base" IMGFMT="raw" _make_test_img --no-opts $IMG_SIZE |\
65 _filter_imgfmt
66 _make_test_img $IMG_SIZE
67 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
68 -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x38000 512' | _filter_qemu_io
70 $QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
72 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
73 -c 'read -P 42 0 512' | _filter_qemu_io
75 echo
76 echo "=== Testing blkverify through file blockref ==="
77 echo
79 TEST_IMG="$TEST_IMG.base" IMGFMT="raw" _make_test_img --no-opts $IMG_SIZE |\
80 _filter_imgfmt
81 _make_test_img $IMG_SIZE
82 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base,file.test.driver=$IMGFMT,file.test.file.filename=$TEST_IMG" \
83 -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x38000 512' | _filter_qemu_io
85 $QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
87 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
88 -c 'read -P 42 0 512' | _filter_qemu_io
90 echo
91 echo "=== Testing blkdebug through filename ==="
92 echo
94 $QEMU_IO -c "open -o file.driver=blkdebug,file.inject-error.event=l2_load $TEST_IMG" \
95 -c 'read -P 42 0x38000 512'
97 echo
98 echo "=== Testing blkdebug through file blockref ==="
99 echo
101 $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.inject-error.event=l2_load,file.image.filename=$TEST_IMG" \
102 -c 'read -P 42 0x38000 512'
104 echo
105 echo "=== Testing blkdebug on existing block device ==="
106 echo
108 run_qemu <<EOF
109 { "execute": "qmp_capabilities" }
110 { "execute": "blockdev-add",
111 "arguments": {
112 "node-name": "drive0",
113 "driver": "file",
114 "filename": "$TEST_IMG"
117 { "execute": "blockdev-add",
118 "arguments": {
119 "driver": "$IMGFMT",
120 "node-name": "drive0-debug",
121 "file": {
122 "driver": "blkdebug",
123 "image": "drive0",
124 "inject-error": [{
125 "event": "l2_load"
130 { "execute": "human-monitor-command",
131 "arguments": {
132 "command-line": 'qemu-io drive0-debug "read 0 512"'
135 { "execute": "quit" }
138 echo
139 echo "=== Testing blkverify on existing block device ==="
140 echo
142 run_qemu <<EOF
143 { "execute": "qmp_capabilities" }
144 { "execute": "blockdev-add",
145 "arguments": {
146 "node-name": "drive0",
147 "driver": "$IMGFMT",
148 "file": {
149 "driver": "file",
150 "filename": "$TEST_IMG"
154 { "execute": "blockdev-add",
155 "arguments": {
156 "driver": "blkverify",
157 "node-name": "drive0-verify",
158 "test": "drive0",
159 "raw": {
160 "driver": "file",
161 "filename": "$TEST_IMG.base"
165 { "execute": "human-monitor-command",
166 "arguments": {
167 "command-line": 'qemu-io drive0-verify "read 0 512"'
170 { "execute": "quit" }
173 echo
174 echo "=== Testing blkverify on existing raw block device ==="
175 echo
177 run_qemu <<EOF
178 { "execute": "qmp_capabilities" }
179 { "execute": "blockdev-add",
180 "arguments": {
181 "node-name": "drive0",
182 "driver": "file",
183 "filename": "$TEST_IMG.base"
186 { "execute": "blockdev-add",
187 "arguments": {
188 "driver": "blkverify",
189 "node-name": "drive0-verify",
190 "test": {
191 "driver": "$IMGFMT",
192 "file": {
193 "driver": "file",
194 "filename": "$TEST_IMG"
197 "raw": "drive0"
200 { "execute": "human-monitor-command",
201 "arguments": {
202 "command-line": 'qemu-io drive0-verify "read 0 512"'
205 { "execute": "quit" }
208 echo
209 echo "=== Testing blkdebug's set-state through QMP ==="
210 echo
212 run_qemu <<EOF
213 { "execute": "qmp_capabilities" }
214 { "execute": "blockdev-add",
215 "arguments": {
216 "node-name": "drive0",
217 "driver": "file",
218 "filename": "$TEST_IMG"
221 { "execute": "blockdev-add",
222 "arguments": {
223 "driver": "$IMGFMT",
224 "node-name": "drive0-debug",
225 "file": {
226 "driver": "blkdebug",
227 "image": "drive0",
228 "inject-error": [{
229 "event": "read_aio",
230 "state": 42
232 "set-state": [{
233 "event": "write_aio",
234 "new_state": 42
239 { "execute": "human-monitor-command",
240 "arguments": {
241 "command-line": 'qemu-io drive0-debug "read 0 512"'
244 { "execute": "human-monitor-command",
245 "arguments": {
246 "command-line": 'qemu-io drive0-debug "write 0 512"'
249 { "execute": "human-monitor-command",
250 "arguments": {
251 "command-line": 'qemu-io drive0-debug "read 0 512"'
254 { "execute": "quit" }
257 # success, all done
258 echo "*** done"
259 rm -f $seq.full
260 status=0