qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, peter.maydell@linaro.org
Subject: [Qemu-devel] [PULL 04/13] iotests: Make 150 use qemu-img map instead of du
Date: Tue, 12 Apr 2016 18:18:59 +0200	[thread overview]
Message-ID: <1460477948-24686-5-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1460477948-24686-1-git-send-email-kwolf@redhat.com>

From: Max Reitz <mreitz@redhat.com>

The actual on-disk size of a file does not only depend on factors qemu
can control. Thus, we should not depend on this to determine whether a
file has indeed been fully allocated. Instead, use qemu-img map and hope
that if an area is referenced, it is indeed allocated, too.

Also, limit the supported image formats to raw and qcow2 because the
actual qemu-img map output may depend on the image format.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/150     | 41 +++++------------------------------------
 tests/qemu-iotests/150.out | 13 +++++--------
 2 files changed, 10 insertions(+), 44 deletions(-)

diff --git a/tests/qemu-iotests/150 b/tests/qemu-iotests/150
index 97d2a35..665373d 100755
--- a/tests/qemu-iotests/150
+++ b/tests/qemu-iotests/150
@@ -38,65 +38,34 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.rc
 . ./common.filter
 
-_supported_fmt generic
+_supported_fmt raw qcow2
 _supported_proto file
 _supported_os Linux
 
 
-on_disk_size()
-{
-    du "$@" | sed -e 's/\t\+.*//'
-}
-
-
 img_size=1048576
 
 
 echo
-echo '=== Comparing empty image against sparse conversion ==='
+echo '=== Mapping sparse conversion ==='
 echo
 
-_make_test_img $img_size
-
-empty_size=$(on_disk_size "$TEST_IMG")
-
-
 $QEMU_IMG_PROG convert -O "$IMGFMT" -S 512 \
     "json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \
     "$TEST_IMG"
 
-sparse_convert_size=$(on_disk_size "$TEST_IMG")
-
-
-if [ "$empty_size" -eq "$sparse_convert_size" ]; then
-    echo 'Equal image size'
-else
-    echo 'Different image size'
-fi
+$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map
 
 
 echo
-echo '=== Comparing full image against non-sparse conversion ==='
+echo '=== Mapping non-sparse conversion ==='
 echo
 
-_make_test_img $img_size
-$QEMU_IO -c "write 0 $img_size" "$TEST_IMG" | _filter_qemu_io
-
-full_size=$(on_disk_size "$TEST_IMG")
-
-
 $QEMU_IMG convert -O "$IMGFMT" -S 0 \
     "json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \
     "$TEST_IMG"
 
-non_sparse_convert_size=$(on_disk_size "$TEST_IMG")
-
-
-if [ "$full_size" -eq "$non_sparse_convert_size" ]; then
-    echo 'Equal image size'
-else
-    echo 'Different image size'
-fi
+$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map
 
 
 # success, all done
diff --git a/tests/qemu-iotests/150.out b/tests/qemu-iotests/150.out
index 2d29da1..2a54e8d 100644
--- a/tests/qemu-iotests/150.out
+++ b/tests/qemu-iotests/150.out
@@ -1,14 +1,11 @@
 QA output created by 150
 
-=== Comparing empty image against sparse conversion ===
+=== Mapping sparse conversion ===
 
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
-Equal image size
+Offset          Length          File
 
-=== Comparing full image against non-sparse conversion ===
+=== Mapping non-sparse conversion ===
 
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
-wrote 1048576/1048576 bytes at offset 0
-1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-Equal image size
+Offset          Length          File
+0               0x100000        TEST_DIR/t.IMGFMT
 *** done
-- 
1.8.3.1

  parent reply	other threads:[~2016-04-12 16:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-12 16:18 [Qemu-devel] [PULL 00/13] Block patches for 2.6 Kevin Wolf
2016-04-12 16:18 ` [Qemu-devel] [PULL 01/13] iotests: fix the broken 026.nocache output Kevin Wolf
2016-04-12 16:18 ` [Qemu-devel] [PULL 02/13] qemu-img: fix formatting of error message Kevin Wolf
2016-04-12 16:18 ` [Qemu-devel] [PULL 03/13] block: initialize qcrypto API at startup Kevin Wolf
2016-04-12 16:18 ` Kevin Wolf [this message]
2016-04-12 16:19 ` [Qemu-devel] [PULL 05/13] vpc: fix return value check for blk_pwrite Kevin Wolf
2016-04-12 16:19 ` [Qemu-devel] [PULL 06/13] qcow2: Prevent backing file names longer than 1023 Kevin Wolf
2016-04-12 16:19 ` [Qemu-devel] [PULL 07/13] MAINTAINERS: Block layer core, qcow2 and blkdebug Kevin Wolf
2016-04-12 16:19 ` [Qemu-devel] [PULL 08/13] qemu-iotests: check: don't place files with predictable names in /tmp Kevin Wolf
2016-04-12 16:19 ` [Qemu-devel] [PULL 09/13] qemu-iotests: fix 051 on non-PC architectures Kevin Wolf
2016-04-12 16:19 ` [Qemu-devel] [PULL 10/13] qemu-iotests: iotests.VM: remove qtest socket on error Kevin Wolf
2016-04-12 16:19 ` [Qemu-devel] [PULL 11/13] qemu-iotests: 148: properly skip test if quorum support is missing Kevin Wolf
2016-04-12 16:19 ` [Qemu-devel] [PULL 12/13] qemu-iotests: 068: don't require KVM Kevin Wolf
2016-04-12 16:19 ` [Qemu-devel] [PULL 13/13] qemu-iotests: iotests.py: get rid of __all__ Kevin Wolf
2016-04-13 15:32 ` [Qemu-devel] [PULL 00/13] Block patches for 2.6 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460477948-24686-5-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).