All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: [PULL 32/34] tests/qemu-iotests: add case to write compressed data of multiple clusters
Date: Mon,  6 Jan 2020 15:42:04 +0100	[thread overview]
Message-ID: <20200106144206.698920-33-mreitz@redhat.com> (raw)
In-Reply-To: <20200106144206.698920-1-mreitz@redhat.com>

From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>

Add the case to the iotest #214 that checks possibility of writing
compressed data of more than one cluster size. The test case involves
the compress filter driver showing a sample usage of that.

Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 1575288906-551879-4-git-send-email-andrey.shinkevich@virtuozzo.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/214     | 43 ++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/214.out | 14 +++++++++++++
 2 files changed, 57 insertions(+)

diff --git a/tests/qemu-iotests/214 b/tests/qemu-iotests/214
index 0f2e61280a..3500e0c47a 100755
--- a/tests/qemu-iotests/214
+++ b/tests/qemu-iotests/214
@@ -90,6 +90,49 @@ _check_test_img -r all
 $QEMU_IO -c "read  -P 0x11  0 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir
 $QEMU_IO -c "read  -P 0x22 4M 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir
 
+echo
+echo "=== Write compressed data of multiple clusters ==="
+echo
+cluster_size=0x10000
+_make_test_img 2M -o cluster_size=$cluster_size
+
+echo "Write uncompressed data:"
+let data_size="8 * $cluster_size"
+$QEMU_IO -c "write -P 0xaa 0 $data_size" "$TEST_IMG" \
+         2>&1 | _filter_qemu_io | _filter_testdir
+sizeA=$($QEMU_IMG info --output=json "$TEST_IMG" |
+        sed -n '/"actual-size":/ s/[^0-9]//gp')
+
+_make_test_img 2M -o cluster_size=$cluster_size
+echo "Write compressed data:"
+let data_size="3 * $cluster_size + $cluster_size / 2"
+# Set compress on. That will align the written data
+# by the cluster size and will write them compressed.
+QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT \
+$QEMU_IO -c "write -P 0xbb 0 $data_size" --image-opts \
+         "driver=compress,file.driver=$IMGFMT,file.file.driver=file,file.file.filename=$TEST_IMG" \
+         2>&1 | _filter_qemu_io | _filter_testdir
+
+let offset="4 * $cluster_size + $cluster_size / 4"
+QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT \
+$QEMU_IO -c "write -P 0xcc $offset $data_size" "json:{\
+    'driver': 'compress',
+    'file': {'driver': '$IMGFMT',
+             'file': {'driver': 'file',
+                      'filename': '$TEST_IMG'}}}" | \
+                          _filter_qemu_io | _filter_testdir
+
+sizeB=$($QEMU_IMG info --output=json "$TEST_IMG" |
+        sed -n '/"actual-size":/ s/[^0-9]//gp')
+
+if [ $sizeA -le $sizeB ]
+then
+    echo "Compression ERROR"
+fi
+
+$QEMU_IMG check --output=json "$TEST_IMG" |
+          sed -n 's/,$//; /"compressed-clusters":/ s/^ *//p'
+
 # success, all done
 echo '*** done'
 rm -f $seq.full
diff --git a/tests/qemu-iotests/214.out b/tests/qemu-iotests/214.out
index 0fcd8dc051..9fc67287f8 100644
--- a/tests/qemu-iotests/214.out
+++ b/tests/qemu-iotests/214.out
@@ -32,4 +32,18 @@ read 4194304/4194304 bytes at offset 0
 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 read 4194304/4194304 bytes at offset 4194304
 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+=== Write compressed data of multiple clusters ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2097152
+Write uncompressed data:
+wrote 524288/524288 bytes at offset 0
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2097152
+Write compressed data:
+wrote 229376/229376 bytes at offset 0
+224 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 229376/229376 bytes at offset 278528
+224 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+"compressed-clusters": 8
 *** done
-- 
2.24.1



  parent reply	other threads:[~2020-01-06 15:13 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-06 14:41 [PULL 00/34] Block patches Max Reitz
2020-01-06 14:41 ` [PULL 01/34] block: Add bdrv_qapi_perm_to_blk_perm() Max Reitz
2020-01-06 14:41 ` [PULL 02/34] block: Use bdrv_qapi_perm_to_blk_perm() Max Reitz
2020-01-06 14:41 ` [PULL 03/34] blkdebug: Allow taking/unsharing permissions Max Reitz
2020-01-06 14:41 ` [PULL 04/34] iotests: Add @error to wait_until_completed Max Reitz
2020-01-06 14:41 ` [PULL 05/34] iotests: Add test for failing mirror complete Max Reitz
2020-01-06 14:41 ` [PULL 06/34] throttle-groups: fix memory leak in throttle_group_set_limit: Max Reitz
2020-01-06 14:41 ` [PULL 07/34] qcow2-bitmaps: fix qcow2_can_store_new_dirty_bitmap Max Reitz
2020-01-06 14:41 ` [PULL 08/34] iotests: s/qocw2/qcow2/ Max Reitz
2020-01-06 14:41 ` [PULL 09/34] iotests/qcow2.py: Add dump-header-exts Max Reitz
2020-01-06 14:41 ` [PULL 10/34] iotests/qcow2.py: Split feature fields into bits Max Reitz
2020-01-06 14:41 ` [PULL 11/34] iotests: Add _filter_json_filename Max Reitz
2020-01-06 14:41 ` [PULL 12/34] iotests: Filter refcount_order in 036 Max Reitz
2020-01-06 14:41 ` [PULL 13/34] iotests: Replace IMGOPTS by _unsupported_imgopts Max Reitz
2020-01-06 14:41 ` [PULL 14/34] iotests: Drop compat=1.1 in 050 Max Reitz
2020-01-06 14:41 ` [PULL 15/34] iotests: Let _make_test_img parse its parameters Max Reitz
2020-01-06 14:41 ` [PULL 16/34] iotests: Add -o and --no-opts to _make_test_img Max Reitz
2020-01-06 14:41 ` [PULL 17/34] iotests: Inject space into -ocompat=0.10 in 051 Max Reitz
2020-01-06 14:41 ` [PULL 18/34] iotests: Replace IMGOPTS= by -o Max Reitz
2020-01-06 14:41 ` [PULL 19/34] iotests: Replace IMGOPTS='' by --no-opts Max Reitz
2020-01-06 14:41 ` [PULL 20/34] iotests: Drop IMGOPTS use in 267 Max Reitz
2020-01-06 14:41 ` [PULL 21/34] iotests: Avoid qemu-img create Max Reitz
2020-01-06 14:41 ` [PULL 22/34] iotests: Use _rm_test_img for deleting test images Max Reitz
2020-01-06 14:41 ` [PULL 23/34] iotests: Avoid cp/mv of " Max Reitz
2020-01-06 14:41 ` [PULL 24/34] iotests: Make 091 work with data_file Max Reitz
2020-01-06 14:41 ` [PULL 25/34] iotests: Make 110 " Max Reitz
2020-01-06 14:41 ` [PULL 26/34] iotests: Make 137 " Max Reitz
2020-01-06 14:41 ` [PULL 27/34] iotests: Make 198 " Max Reitz
2020-01-06 14:42 ` [PULL 28/34] iotests: Disable data_file where it cannot be used Max Reitz
2020-01-06 14:42 ` [PULL 29/34] iotests: Allow check -o data_file Max Reitz
2020-01-06 14:42 ` [PULL 30/34] block: introduce compress filter driver Max Reitz
2020-01-06 14:42 ` [PULL 31/34] qcow2: Allow writing compressed data of multiple clusters Max Reitz
2020-01-06 14:42 ` Max Reitz [this message]
2020-01-06 14:42 ` [PULL 33/34] tests/qemu-iotests: Update tests to recent desugarized -accel option Max Reitz
2020-01-06 14:42 ` [PULL 34/34] backup-top: Begin drain earlier Max Reitz
2020-01-06 18:22 ` [PULL 00/34] Block patches 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=20200106144206.698920-33-mreitz@redhat.com \
    --to=mreitz@redhat.com \
    --cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.