[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 3/3] iotests: Add test for external image truncat
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v3 3/3] iotests: Add test for external image truncation |
Date: |
Wed, 22 Oct 2014 17:57:14 +0200 |
It should not be happening, but it is possible to truncate an image
outside of qemu while qemu is running (or any of the qemu tools using
the block layer. raw_co_get_block_status() should not break then.
Signed-off-by: Max Reitz <address@hidden>
---
tests/qemu-iotests/102 | 15 +++++++++++++++
tests/qemu-iotests/102.out | 9 +++++++++
2 files changed, 24 insertions(+)
diff --git a/tests/qemu-iotests/102 b/tests/qemu-iotests/102
index 34b363f..027198b 100755
--- a/tests/qemu-iotests/102
+++ b/tests/qemu-iotests/102
@@ -58,6 +58,21 @@ truncate -s $((5 * 64 * 1024)) "$TEST_IMG"
$QEMU_IO -c map "$TEST_IMG"
$QEMU_IMG map "$TEST_IMG"
+echo
+echo '=== Testing map on an image file truncated outside of qemu ==='
+echo
+
+# Same as above, only now we concurrently truncate and map the image
+_make_test_img $IMG_SIZE
+$QEMU_IO -c 'write 0 64k' "$TEST_IMG" | _filter_qemu_io
+
+(sleep 0.2; $QEMU_IO -c map "$TEST_IMG"; $QEMU_IMG map "$TEST_IMG") &
+truncate -s $((5 * 64 * 1024)) "$TEST_IMG"
+# To be sure the image has been truncated before $QEMU_IO and $QEMU_IMG run
+echo '--- truncated ---'
+
+sleep 0.3
+
# success, all done
echo '*** done'
rm -f $seq.full
diff --git a/tests/qemu-iotests/102.out b/tests/qemu-iotests/102.out
index e0e9cdc..96f4a33 100644
--- a/tests/qemu-iotests/102.out
+++ b/tests/qemu-iotests/102.out
@@ -7,4 +7,13 @@ wrote 65536/65536 bytes at offset 0
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
[ 0] 128/ 128 sectors allocated at offset 0
bytes (1)
Offset Length Mapped to File
+
+=== Testing map on an image file truncated outside of qemu ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65536
+wrote 65536/65536 bytes at offset 0
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+--- truncated ---
+[ 0] 128/ 128 sectors allocated at offset 0
bytes (1)
+Offset Length Mapped to File
*** done
--
1.9.3