Skip to content

Commit 4a01e27

Browse files
committed
iotests: Test sparseness for qemu-img convert -n
Signed-off-by: Kevin Wolf <[email protected]> Message-Id: <[email protected]> Reviewed-by: Max Reitz <[email protected]> Signed-off-by: Kevin Wolf <[email protected]>
1 parent 61b3043 commit 4a01e27

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

tests/qemu-iotests/122

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,36 @@ $QEMU_IMG convert -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG".orig
281281

282282
$QEMU_IMG compare "$TEST_IMG" "$TEST_IMG".orig
283283

284+
echo
285+
echo '=== -n to an empty image ==='
286+
echo
287+
288+
TEST_IMG="$TEST_IMG".orig _make_test_img 64M
289+
290+
# Convert with -n, which should not result in a fully allocated image, not even
291+
# with compat=0.10 (because the target doesn't have a backing file)
292+
for compat in "1.1" "0.10"; do
293+
IMGOPTS="compat=$compat" _make_test_img 64M
294+
$QEMU_IMG convert -O $IMGFMT -n "$TEST_IMG".orig "$TEST_IMG"
295+
$QEMU_IMG map --output=json "$TEST_IMG"
296+
done
297+
298+
echo
299+
echo '=== -n to an empty image with a backing file ==='
300+
echo
301+
302+
TEST_IMG="$TEST_IMG".orig _make_test_img 64M
303+
TEST_IMG="$TEST_IMG".base _make_test_img 64M
304+
305+
# Convert with -n, which should still not result in a fully allocated image for
306+
# compat=1.1 (because it can use zero clusters), but it should be fully
307+
# allocated with compat=0.10
308+
for compat in "1.1" "0.10"; do
309+
IMGOPTS="compat=$compat" _make_test_img -b "$TEST_IMG".base -F $IMGFMT 64M
310+
$QEMU_IMG convert -O $IMGFMT -n "$TEST_IMG".orig "$TEST_IMG"
311+
$QEMU_IMG map --output=json "$TEST_IMG"
312+
done
313+
284314
echo
285315
echo '=== -n -B to an image without a backing file ==='
286316
echo

tests/qemu-iotests/122.out

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,23 @@ wrote 65536/65536 bytes at offset 0
229229
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
230230
Images are identical.
231231

232+
=== -n to an empty image ===
233+
234+
Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=IMGFMT size=67108864
235+
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
236+
[{ "start": 0, "length": 67108864, "depth": 0, "zero": true, "data": false}]
237+
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
238+
[{ "start": 0, "length": 67108864, "depth": 0, "zero": true, "data": false}]
239+
240+
=== -n to an empty image with a backing file ===
241+
242+
Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=IMGFMT size=67108864
243+
Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864
244+
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=IMGFMT
245+
[{ "start": 0, "length": 67108864, "depth": 0, "zero": true, "data": false}]
246+
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=IMGFMT
247+
[{ "start": 0, "length": 67108864, "depth": 0, "zero": false, "data": true, "offset": 327680}]
248+
232249
=== -n -B to an image without a backing file ===
233250

234251
Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864

0 commit comments

Comments
 (0)