tests: Fix gcov paths for relocated device sources
[qemu/qmp-unstable.git] / tests / qemu-iotests / 077
blob4dd1bdde20e03442808900bafe073c08a1954951
1 #!/bin/bash
3 # Test concurrent pread/pwrite
5 # Copyright (C) 2014 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
35 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
38 . ./common.rc
39 . ./common.filter
41 _supported_fmt raw
42 _supported_proto generic
43 _supported_os Linux
45 CLUSTER_SIZE=4k
46 size=128M
48 _make_test_img $size
50 echo
51 echo "== Some concurrent requests involving RMW =="
53 function test_io()
55 echo "open -o file.align=4k blkdebug::$TEST_IMG"
56 # A simple RMW request
57 cat <<EOF
58 aio_write -P 10 0x200 0x200
59 aio_flush
60 EOF
62 # Sequential RMW requests on the same physical sector
63 off=0x1000
64 for ev in "head" "after_head" "tail" "after_tail"; do
65 cat <<EOF
66 break pwritev_rmw.$ev A
67 aio_write -P 10 $((off + 0x200)) 0x200
68 wait_break A
69 aio_write -P 11 $((off + 0x400)) 0x200
70 sleep 100
71 resume A
72 aio_flush
73 EOF
74 off=$((off + 0x1000))
75 done
77 # Chained dependencies
78 cat <<EOF
79 break pwritev_rmw.after_tail A
80 aio_write -P 10 0x5000 0x200
81 wait_break A
82 aio_write -P 11 0x5200 0x200
83 aio_write -P 12 0x5400 0x200
84 aio_write -P 13 0x5600 0x200
85 aio_write -P 14 0x5800 0x200
86 aio_write -P 15 0x5a00 0x200
87 aio_write -P 16 0x5c00 0x200
88 aio_write -P 17 0x5e00 0x200
89 sleep 100
90 resume A
91 aio_flush
92 EOF
94 # Overlapping multiple requests
95 cat <<EOF
96 break pwritev_rmw.after_tail A
97 aio_write -P 10 0x6000 0x200
98 wait_break A
99 break pwritev_rmw.after_head B
100 aio_write -P 10 0x7e00 0x200
101 wait_break B
102 aio_write -P 11 0x6800 0x1000
103 resume A
104 sleep 100
105 resume B
106 aio_flush
109 cat <<EOF
110 break pwritev_rmw.after_tail A
111 aio_write -P 10 0x8000 0x200
112 wait_break A
113 break pwritev_rmw.after_head B
114 aio_write -P 10 0x9e00 0x200
115 wait_break B
116 aio_write -P 11 0x8800 0x1000
117 resume B
118 sleep 100
119 resume A
120 aio_flush
123 cat <<EOF
124 break pwritev_rmw.after_tail A
125 aio_write -P 10 0xa000 0x200
126 wait_break A
127 aio_write -P 11 0xa800 0x1000
128 break pwritev_rmw.after_head B
129 aio_write -P 10 0xbe00 0x200
130 wait_break B
131 resume A
132 sleep 100
133 resume B
134 aio_flush
137 cat <<EOF
138 break pwritev_rmw.after_tail A
139 aio_write -P 10 0xc000 0x200
140 wait_break A
141 aio_write -P 11 0xc800 0x1000
142 break pwritev_rmw.after_head B
143 aio_write -P 10 0xde00 0x200
144 wait_break B
145 resume B
146 sleep 100
147 resume A
148 aio_flush
151 # Only RMW for the tail part
152 cat <<EOF
153 break pwritev_rmw.after_tail A
154 aio_write -P 10 0xe000 0x1800
155 wait_break A
156 aio_write -P 11 0xf000 0xc00
157 sleep 100
158 resume A
159 aio_flush
162 cat <<EOF
163 break pwritev A
164 aio_write -P 10 0x10000 0x800
165 wait_break A
166 break pwritev_rmw.after_tail B
167 aio_write -P 11 0x10000 0x400
168 break pwritev_done C
169 resume A
170 wait_break C
171 resume C
172 sleep 100
173 wait_break B
174 resume B
175 aio_flush
178 cat <<EOF
179 break pwritev A
180 aio_write -P 10 0x11000 0x800
181 wait_break A
182 aio_write -P 11 0x11000 0x1000
183 sleep 100
184 resume A
185 aio_flush
189 test_io | $QEMU_IO | _filter_qemu_io | \
190 sed -e 's,[0-9/]* bytes at offset [0-9]*,XXX/XXX bytes at offset XXX,g' \
191 -e 's/^[0-9]* \(bytes\|KiB\)/XXX bytes/' \
192 -e '/Suspended/d'
194 echo
195 echo "== Verify image content =="
197 function verify_io()
199 # A simple RMW request
200 echo read -P 0 0 0x200
201 echo read -P 10 0x200 0x200
202 echo read -P 0 0x400 0xc00
204 # Sequential RMW requests on the same physical sector
205 echo read -P 0 0x1000 0x200
206 echo read -P 10 0x1200 0x200
207 echo read -P 11 0x1400 0x200
208 echo read -P 0 0x1600 0xa00
210 echo read -P 0 0x2000 0x200
211 echo read -P 10 0x2200 0x200
212 echo read -P 11 0x2400 0x200
213 echo read -P 0 0x2600 0xa00
215 echo read -P 0 0x3000 0x200
216 echo read -P 10 0x3200 0x200
217 echo read -P 11 0x3400 0x200
218 echo read -P 0 0x3600 0xa00
220 echo read -P 0 0x4000 0x200
221 echo read -P 10 0x4200 0x200
222 echo read -P 11 0x4400 0x200
223 echo read -P 0 0x4600 0xa00
225 # Chained dependencies
226 echo read -P 10 0x5000 0x200
227 echo read -P 11 0x5200 0x200
228 echo read -P 12 0x5400 0x200
229 echo read -P 13 0x5600 0x200
230 echo read -P 14 0x5800 0x200
231 echo read -P 15 0x5a00 0x200
232 echo read -P 16 0x5c00 0x200
233 echo read -P 17 0x5e00 0x200
235 # Overlapping multiple requests
236 echo read -P 10 0x6000 0x200
237 echo read -P 0 0x6200 0x600
238 echo read -P 11 0x6800 0x1000
239 echo read -P 0 0x7800 0x600
240 echo read -P 10 0x7e00 0x200
242 echo read -P 10 0x8000 0x200
243 echo read -P 0 0x8200 0x600
244 echo read -P 11 0x8800 0x1000
245 echo read -P 0 0x9800 0x600
246 echo read -P 10 0x9e00 0x200
248 echo read -P 10 0xa000 0x200
249 echo read -P 0 0xa200 0x600
250 echo read -P 11 0xa800 0x1000
251 echo read -P 0 0xb800 0x600
252 echo read -P 10 0xbe00 0x200
254 echo read -P 10 0xc000 0x200
255 echo read -P 0 0xc200 0x600
256 echo read -P 11 0xc800 0x1000
257 echo read -P 0 0xd800 0x600
258 echo read -P 10 0xde00 0x200
260 # Only RMW for the tail part
261 echo read -P 10 0xe000 0x1000
262 echo read -P 11 0xf800 0x400
263 echo read -P 0 0xfc00 0x400
265 echo read -P 11 0x10000 0x400
266 echo read -P 10 0x10400 0x400
268 echo read -P 11 0x11800 0x800
271 verify_io | $QEMU_IO "$TEST_IMG" | _filter_qemu_io
273 _check_test_img
275 # success, all done
276 echo "*** done"
277 rm -f $seq.full
278 status=0