aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2018-02-28 14:13:15 +0100
committerMax Reitz <mreitz@redhat.com>2018-04-03 17:39:37 +0200
commit733d1dce0f3c8ab7b79a173f6482781d3718f844 (patch)
treea2045d3068dd5899ae21cc7c80d68e3825fafaaa
parent82b45e0a0b824787bd79ce3f6453eaa2afddd138 (diff)
iotests: Test preallocated truncate of 2G image
Signed-off-by: Max Reitz <mreitz@redhat.com> Message-id: 20180228131315.30194-3-mreitz@redhat.com Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
-rwxr-xr-xtests/qemu-iotests/10624
-rw-r--r--tests/qemu-iotests/106.out10
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/qemu-iotests/106 b/tests/qemu-iotests/106
index bfe71f4e60..5e51f88a78 100755
--- a/tests/qemu-iotests/106
+++ b/tests/qemu-iotests/106
@@ -86,6 +86,30 @@ for growth_mode in falloc full off; do
$QEMU_IMG resize -f "$IMGFMT" --shrink --preallocation=$growth_mode "$TEST_IMG" -${GROWTH_SIZE}K
done
+echo
+echo '=== Testing image growth on 2G empty image ==='
+
+for growth_mode in falloc full; do
+ echo
+ echo "--- growth_mode=$growth_mode ---"
+
+ # Maybe we want to do an lseek() to the end of the file before the
+ # preallocation; if the file has a length of 2 GB, that would
+ # return an integer that overflows to negative when put into a
+ # plain int. We should use the correct type for the result, and
+ # this tests we do.
+
+ _make_test_img 2G
+ $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K
+
+ actual_size=$($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep 'disk size')
+ actual_size=$(echo "$actual_size" | sed -e 's/^[^0-9]*\([0-9]\+\).*$/\1/')
+
+ if [ $actual_size -lt $GROWTH_SIZE ]; then
+ echo "ERROR: Image should have at least ${GROWTH_SIZE}K, but has ${actual_size}K"
+ fi
+done
+
# success, all done
echo '*** done'
rm -f $seq.full
diff --git a/tests/qemu-iotests/106.out b/tests/qemu-iotests/106.out
index 0a42312301..c459957660 100644
--- a/tests/qemu-iotests/106.out
+++ b/tests/qemu-iotests/106.out
@@ -47,4 +47,14 @@ qemu-img: Preallocation can only be used for growing images
--- growth_mode=off ---
Image resized.
+
+=== Testing image growth on 2G empty image ===
+
+--- growth_mode=falloc ---
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
+Image resized.
+
+--- growth_mode=full ---
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
+Image resized.
*** done