qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"qemu-block@nongnu.org" <qemu-block@nongnu.org>
Cc: "kwolf@redhat.com" <kwolf@redhat.com>,
	Denis Lunev <den@virtuozzo.com>,
	"armbru@redhat.com" <armbru@redhat.com>,
	"mreitz@redhat.com" <mreitz@redhat.com>
Subject: Re: [PATCH v8 3/3] tests/qemu-iotests: add case to write compressed data of multiple clusters
Date: Mon, 18 Nov 2019 10:26:45 +0000	[thread overview]
Message-ID: <d15be06e-65fe-ff4f-e36d-c6c5f949137a@virtuozzo.com> (raw)
In-Reply-To: <1574056144-625164-4-git-send-email-andrey.shinkevich@virtuozzo.com>

18.11.2019 8:49, Andrey Shinkevich wrote:
> 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>
> ---
>   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 21ec8a2..5012112 100755
> --- a/tests/qemu-iotests/214
> +++ b/tests/qemu-iotests/214
> @@ -89,6 +89,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"

Could you make it
let offset="4 * $cluster_size + ($cluster_size / 4)"

To check both unaligned head and tail?
It should not change the output.

With or without this:
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

PS: ogh, bash is crazy, arithmetic in string o_O

> +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 0fcd8dc..4a2ec33 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 262144
> +224 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +"compressed-clusters": 8
>   *** done
> 


-- 
Best regards,
Vladimir

      reply	other threads:[~2019-11-18 10:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-18  5:49 [PATCH v8 0/3] qcow2: advanced compression options Andrey Shinkevich
2019-11-18  5:49 ` [PATCH v8 1/3] block: introduce compress filter driver Andrey Shinkevich
2019-11-18  9:52   ` Vladimir Sementsov-Ogievskiy
2019-11-18  5:49 ` [PATCH v8 2/3] qcow2: Allow writing compressed data of multiple clusters Andrey Shinkevich
2019-11-18  5:49 ` [PATCH v8 3/3] tests/qemu-iotests: add case to write " Andrey Shinkevich
2019-11-18 10:26   ` Vladimir Sementsov-Ogievskiy [this message]

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=d15be06e-65fe-ff4f-e36d-c6c5f949137a@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=andrey.shinkevich@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=den@virtuozzo.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --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).