]> Git Repo - qemu.git/blob - tests/qemu-iotests/071
iotests: log messages from notrun()
[qemu.git] / tests / qemu-iotests / 071
1 #!/usr/bin/env bash
2 #
3 # Test case for the QMP blkdebug and blkverify interfaces
4 #
5 # Copyright (C) 2013 Red Hat, Inc.
6 #
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.
11 #
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.
16 #
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/>.
19 #
20
21 # creator
22 [email protected]
23
24 seq="$(basename $0)"
25 echo "QA output created by $seq"
26
27 status=1        # failure is the default!
28
29 _cleanup()
30 {
31         _cleanup_test_img
32 }
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
38
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
45
46 do_run_qemu()
47 {
48     echo Testing: "$@" | _filter_imgfmt
49     $QEMU -nographic -qmp stdio -serial none "$@"
50     echo
51 }
52
53 run_qemu()
54 {
55     do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp | _filter_qemu_io
56 }
57
58 IMG_SIZE=64M
59
60 echo
61 echo "=== Testing blkverify through filename ==="
62 echo
63
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
69
70 $QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
71
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
74
75 echo
76 echo "=== Testing blkverify through file blockref ==="
77 echo
78
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
84
85 $QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
86
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
89
90 echo
91 echo "=== Testing blkdebug through filename ==="
92 echo
93
94 $QEMU_IO -c "open -o file.driver=blkdebug,file.inject-error.event=l2_load $TEST_IMG" \
95          -c 'read -P 42 0x38000 512'
96
97 echo
98 echo "=== Testing blkdebug through file blockref ==="
99 echo
100
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'
103
104 echo
105 echo "=== Testing blkdebug on existing block device ==="
106 echo
107
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"
115     }
116 }
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"
126             }]
127         }
128     }
129 }
130 { "execute": "human-monitor-command",
131     "arguments": {
132         "command-line": 'qemu-io drive0-debug "read 0 512"'
133     }
134 }
135 { "execute": "quit" }
136 EOF
137
138 echo
139 echo "=== Testing blkverify on existing block device ==="
140 echo
141
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"
151         }
152     }
153 }
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"
162         }
163     }
164 }
165 { "execute": "human-monitor-command",
166     "arguments": {
167         "command-line": 'qemu-io drive0-verify "read 0 512"'
168     }
169 }
170 { "execute": "quit" }
171 EOF
172
173 echo
174 echo "=== Testing blkverify on existing raw block device ==="
175 echo
176
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"
184     }
185 }
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"
195             }
196         },
197         "raw": "drive0"
198     }
199 }
200 { "execute": "human-monitor-command",
201     "arguments": {
202         "command-line": 'qemu-io drive0-verify "read 0 512"'
203     }
204 }
205 { "execute": "quit" }
206 EOF
207
208 echo
209 echo "=== Testing blkdebug's set-state through QMP ==="
210 echo
211
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"
219     }
220 }
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
231             }],
232             "set-state": [{
233                 "event": "write_aio",
234                 "new_state": 42
235             }]
236         }
237     }
238 }
239 { "execute": "human-monitor-command",
240     "arguments": {
241         "command-line": 'qemu-io drive0-debug "read 0 512"'
242     }
243 }
244 { "execute": "human-monitor-command",
245     "arguments": {
246         "command-line": 'qemu-io drive0-debug "write 0 512"'
247     }
248 }
249 { "execute": "human-monitor-command",
250     "arguments": {
251         "command-line": 'qemu-io drive0-debug "read 0 512"'
252     }
253 }
254 { "execute": "quit" }
255 EOF
256
257 # success, all done
258 echo "*** done"
259 rm -f $seq.full
260 status=0
This page took 0.040731 seconds and 4 git commands to generate.