qemu/tests/qemu-iotests
Eric Blake cf923b783e utils: Improve qemu_strtosz() to have 64 bits of precision
We have multiple clients of qemu_strtosz (qemu-io, the opts visitor,
the keyval visitor), and it gets annoying that edge-case testing is
impacted by implicit rounding to 53 bits of precision due to parsing
with strtod().  As an example posted by Rich Jones:
 $ nbdkit memory $(( 2**63 - 2**30 )) --run \
   'build/qemu-io -f raw "$uri" -c "w -P 3 $(( 2**63 - 2**30 - 512 )) 512" '
 write failed: Input/output error

because 9223372035781033472 got rounded to 0x7fffffffc0000000 which is
out of bounds.

It is also worth noting that our existing parser, by virtue of using
strtod(), accepts decimal AND hex numbers, even though test-cutils
previously lacked any coverage of the latter until the previous patch.
We do have existing clients that expect a hex parse to work (for
example, iotest 33 using qemu-io -c "write -P 0xa 0x200 0x400"), but
strtod() parses "08" as 8 rather than as an invalid octal number, so
we know there are no clients that depend on octal.  Our use of
strtod() also means that "0x1.8k" would actually parse as 1536 (the
fraction is 8/16), rather than 1843 (if the fraction were 8/10); but
as this was not covered in the testsuite, I have no qualms forbidding
hex fractions as invalid, so this patch declares that the use of
fractions is only supported with decimal input, and enhances the
testsuite to document that.

Our previous use of strtod() meant that -1 parsed as a negative; now
that we parse with strtoull(), negative values can wrap around modulo
2^64, so we have to explicitly check whether the user passed in a '-';
and make it consistent to also reject '-0'.  This has the minor effect
of treating negative values as EINVAL (with no change to endptr)
rather than ERANGE (with endptr advanced to what was parsed), visible
in the updated iotest output.

We also had no testsuite coverage of "1.1e0k", which happened to parse
under strtod() but is unlikely to occur in practice; as long as we are
making things more robust, it is easy enough to reject the use of
exponents in a strtod parse.

The fix is done by breaking the parse into an integer prefix (no loss
in precision), rejecting negative values (since we can no longer rely
on strtod() to do that), determining if a decimal or hexadecimal parse
was intended (with the new restriction that a fractional hex parse is
not allowed), and where appropriate, using a floating point fractional
parse (where we also scan to reject use of exponents in the fraction).
The bulk of the patch is then updates to the testsuite to match our
new precision, as well as adding new cases we reject (whether they
were rejected or inadvertently accepted before).

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20210211204438.1184395-3-eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-03-08 13:36:12 -06:00
..
sample_images
tests iotests: rename and move 169 and 199 tests 2021-01-27 20:53:14 +01:00
001
001.out
002
002.out
003
003.out
004
004.out
005
005.out
007
007.out
008
008.out
009
009.out
010
010.out
011
011.out
012
012.out
013
013.out
014
014.out
015
015.out
017
017.out
018
018.out
019
019.out
020
020.out
021
021.out
022
022.out
023
023.out
024
024.out
025
025.out
026
026.out
026.out.nocache
027
027.out
028
028.out
029
029.out
030 iotests: 30: drop from auto group (and effectively from make check) 2021-02-05 15:16:13 +00:00
030.out
031
031.out
032
032.out
033
033.out
034
034.out
035
035.out
036
036.out
037
037.out
038
038.out
039
039.out
040
040.out
041
041.out
042
042.out
043
043.out
044
044.out
045
045.out
046
046.out
047
047.out
048
048.out
049
049.out utils: Improve qemu_strtosz() to have 64 bits of precision 2021-03-08 13:36:12 -06:00
050
050.out
051
051.out
051.pc.out
052
052.out
053
053.out
054
054.out
055
055.out
056 iotests: 56: prepare for backup over block-copy 2021-01-26 14:36:37 +01:00
056.out
057
057.out
058
058.out
059
059.out
060
060.out
061
061.out
062
062.out
063
063.out
064
064.out
065
065.out
066
066.out
068
068.out
069
069.out
070
070.out
071
071.out
072
072.out
073
073.out
074
074.out
075
075.out
076
076.out
077
077.out
078
078.out
079
079.out
080
080.out
081
081.out
082
082.out
083
083.out
084
084.out
085
085.out
086
086.out
087
087.out
088
088.out
089
089.out
090
090.out
091
091.out
092
092.out
093
093.out
094
094.out
095
095.out
096
096.out
097
097.out
098
098.out
099
099.out
101
101.out
102
102.out
103
103.out
104
104.out
105
105.out
106
106.out
107
107.out
108
108.out
109
109.out job: call job_enter from job_pause 2021-01-26 14:36:37 +01:00
110
110.out
111
111.out
112
112.out
113
113.out
114
114.out
115
115.out
116
116.out
117
117.out
118 iotests/118: Drop 'change' test 2021-01-26 14:36:37 +01:00
118.out iotests/118: Drop 'change' test 2021-01-26 14:36:37 +01:00
119
119.out
120
120.out
121
121.out
122
122.out
123
123.out
124 iotests: Move try_remove to iotests.py 2021-01-26 14:36:37 +01:00
124.out
125
125.out
126
126.out
127
127.out
128
128.out
129 iotests/129: Limit backup's max-chunk/max-workers 2021-01-26 14:36:37 +01:00
129.out
130
130.out
131
131.out
132
132.out
133
133.out
134
134.out
135
135.out
136
136.out
137
137.out
138
138.out
139
139.out
140
140.out
141
141.out block: apply COR-filter to block-stream jobs 2021-01-26 14:36:37 +01:00
142
142.out
143
143.out
144
144.out
145
145.out
146
146.out iotests: 146: drop extra whitespaces from .out file 2021-01-27 20:53:02 +01:00
147
147.out
148
148.out
149
149.out
150
150.out.qcow2
150.out.raw
151
151.out
152
152.out
153
153.out
154
154.out
155
155.out
156
156.out
157
157.out
158
158.out
159
159.out
160
160.out
161
161.out
162
162.out
163
163.out
165
165.out
170
170.out
171
171.out
172
172.out hw/block/fdc: Remove the check_media_rate property 2021-02-20 12:36:19 +01:00
173
173.out
174
174.out
175
175.out
176
176.out
177
177.out
178 iotests/178: Pass value to invalid option 2021-01-26 14:36:37 +01:00
178.out.qcow2 utils: Improve qemu_strtosz() to have 64 bits of precision 2021-03-08 13:36:12 -06:00
178.out.raw utils: Improve qemu_strtosz() to have 64 bits of precision 2021-03-08 13:36:12 -06:00
179
179.out
181
181.out
182
182.out
183
183.out
184
184.out
185 iotests: 185: prepare for backup over block-copy 2021-01-26 14:36:37 +01:00
185.out iotests: Fix expected whitespace for 185 2021-02-03 08:00:33 -06:00
186
186.out
187
187.out
188
188.out
189
189.out
190
190.out
191
191.out
192
192.out
194
194.out
195
195.out
196
196.out
197
197.out
198
198.out
200
200.out
201
201.out
202
202.out
203
203.out
204
204.out
205
205.out
206
206.out block: refactor bdrv_check_request: add errp 2021-02-03 08:00:33 -06:00
207
207.out
208
208.out
209
209.out
210
210.out iotests/210: Fix reference output 2021-02-12 07:42:08 -06:00
211
211.out
212
212.out
213
213.out
214
214.out
215
215.out
216
216.out
217
217.out
218
218.out
219 iotests: 219: prepare for backup over block-copy 2021-01-26 14:36:37 +01:00
219.out
220
220.out
221
221.out
222
222.out
223
223.out
224
224.out
225
225.out
226
226.out
227
227.out
228
228.out
229
229.out
231
231.out
232
232.out
233 Prefer 'on' | 'off' over 'yes' | 'no' for bool options 2021-01-29 17:07:53 +00:00
233.out
234
234.out
235
235.out
236
236.out
237
237.out
238
238.out
239
239.out
240
240.out
241
241.out nbd: server: Report holes for raw images 2021-03-08 13:08:45 -06:00
242
242.out
243
243.out
244
244.out
245 block: apply COR-filter to block-stream jobs 2021-01-26 14:36:37 +01:00
245.out
246
246.out
247
247.out
248
248.out
249
249.out
250
250.out
251
251.out
252
252.out
253
253.out
254
254.out
255
255.out
256
256.out
257 iotests: 257: prepare for backup over block-copy 2021-01-26 14:36:37 +01:00
257.out iotests: 257: prepare for backup over block-copy 2021-01-26 14:36:37 +01:00
258
258.out
259 tests/qemu-iotests: Remove test 259 from the "auto" group 2021-02-15 15:10:14 +01:00
259.out
260
260.out
261
261.out
262
262.out
263
263.out
264 iotests/264: add backup-cancel test-case 2021-02-12 12:19:46 -06:00
264.out iotests/264: add backup-cancel test-case 2021-02-12 12:19:46 -06:00
265
265.out
266
266.out
267
267.out block: allow specifying name of block device for vmstate storage 2021-02-08 11:19:51 +00:00
268
268.out
270
270.out
271
271.out
272
272.out
273
273.out
274
274.out
277
277.out
279
279.out
280
280.out
281
281.out
282
282.out
283
283.out
284
284.out
286
286.out
287
287.out
288
288.out
289
289.out
290
290.out
291
291.out
292
292.out
293
293.out
294
294.out
295
295.out
296
296.out
297 iotests/300: Clean up pylint and mypy complaints 2021-01-26 14:36:37 +01:00
297.out iotests/297: Rewrite in Python and extend reach 2021-01-26 14:36:37 +01:00
298
298.out
299
299.out
300 qemu-iotests: 300: Add test case for modifying persistence of bitmap 2021-02-12 15:32:04 -06:00
300.out qemu-iotests: 300: Add test case for modifying persistence of bitmap 2021-02-12 15:32:04 -06:00
301
301.out
302
302.out
303
303.out
304
304.out
305
305.out
307
307.out
308
308.out
309
309.out
310
310.out
312
312.out
313 iotests: Add test for the regression fixed in c8bf9a9169 2021-01-26 14:36:37 +01:00
313.out iotests: Add test for the regression fixed in c8bf9a9169 2021-01-26 14:36:37 +01:00
check iotests: check: return 1 on failure 2021-02-02 17:05:38 +01:00
common.config
common.filter
common.nbd
common.pattern
common.qemu iotests: add support for capturing and matching QMP events 2021-02-08 11:19:51 +00:00
common.rc iotests: Consistent $IMGOPTS boundary matching 2021-02-15 15:10:14 +01:00
common.tls
findtests.py iotests: add findtests.py 2021-01-27 20:53:14 +01:00
iotests.py iotests.py: qemu_nbd_popen: remove pid file after use 2021-02-12 12:10:11 -06:00
Makefile
meson.build iotests: rewrite check into python 2021-01-27 20:53:14 +01:00
nbd-fault-injector.py
pylintrc iotests/297: pylint: ignore too many statements 2021-02-02 13:23:47 +01:00
qcow2_format.py
qcow2.py
qed.py
README
socket_scm_helper.c
testenv.py iotests: Revert emulator selection to old behaviour 2021-02-02 17:05:04 +01:00
testrunner.py iotests: Fix -makecheck output 2021-02-02 17:05:38 +01:00

=== This is the QEMU I/O test suite ===

* Intro

This package contains a simple test suite for the I/O layer of qemu.
It does not require a guest, but only the qemu, qemu-img and qemu-io
binaries.  This does limit it to exercise the low-level I/O path only
but no actual block drivers like ide, scsi or virtio.

* Usage

Just run ./check to run all tests for the raw image format, or ./check
-qcow2 to test the qcow2 image format.  The output of ./check -h explains
additional options to test further image formats or I/O methods.

* Feedback and patches

Please send improvements to the test suite, general feedback or just
reports of failing tests cases to qemu-devel@nongnu.org with a CC:
to qemu-block@nongnu.org.