[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v16 4/4] iotests: 287: add qcow2 compression type test
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
Re: [PATCH v16 4/4] iotests: 287: add qcow2 compression type test |
Date: |
Wed, 1 Apr 2020 19:11:18 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 |
01.04.2020 17:37, Denis Plotnikov wrote:
The test checks fulfilling qcow2 requiriements for the compression
type feature and zstd compression type operability.
Signed-off-by: Denis Plotnikov <address@hidden>
---
tests/qemu-iotests/287 | 162 +++++++++++++++++++++++++++++++++++++
tests/qemu-iotests/287.out | 70 ++++++++++++++++
tests/qemu-iotests/group | 1 +
3 files changed, 233 insertions(+)
create mode 100755 tests/qemu-iotests/287
create mode 100644 tests/qemu-iotests/287.out
diff --git a/tests/qemu-iotests/287 b/tests/qemu-iotests/287
new file mode 100755
index 0000000000..699dccd72c
--- /dev/null
+++ b/tests/qemu-iotests/287
@@ -0,0 +1,162 @@
+#!/usr/bin/env bash
+#
+# Test case for an image using zstd compression
+#
+# Copyright (c) 2020 Virtuozzo International GmbH
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+# creator
+owner=address@hidden
+
+seq="$(basename $0)"
+echo "QA output created by $seq"
+
+status=1 # failure is the default!
+
+# standard environment
+. ./common.rc
+. ./common.filter
+
+# This tests qocw2-specific low-level functionality
+_supported_fmt qcow2
+_supported_proto file
+_supported_os Linux
+
+COMPR_IMG=$TEST_IMG.compressed
+RAND_FILE=$TEST_DIR/rand_data
Always quote file paths, to don't worry about whitespaces.
+
+_cleanup()
+{
+ _cleanup_test_img
+ rm -f $COMPR_IMG
+ rm -f $RAND_FILE
+}
[..]
data should be identical
+echo
+echo "=== Testing incompressible cluster processing with zstd ==="
+echo
+
+dd if=/dev/urandom of=$RAND_FILE bs=1M count=1
+
+_make_test_img 64M
+# fill the image with likely incompressible and compressible clusters
+$QEMU_IO -c "write -c -s "$RAND_FILE" 0 1M " "$TEST_IMG" | _filter_qemu_io
hmm quotes around RAND_FILE here doesn't make things better: if RAND_FILE
variable has
whitespace inside, the argemunt after -c will be split into two arguments.
What we need here is to support quotes inside the string argument for qemu-io.
It's a
separate thing to do. Let's just don't worry about whitespaces here now.
With the following squashed in:
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
--- a/tests/qemu-iotests/287
+++ b/tests/qemu-iotests/287
@@ -35,14 +35,14 @@ _supported_fmt qcow2
_supported_proto file
_supported_os Linux
-COMPR_IMG=$TEST_IMG.compressed
-RAND_FILE=$TEST_DIR/rand_data
+COMPR_IMG="$TEST_IMG.compressed"
+RAND_FILE="$TEST_DIR/rand_data"
_cleanup()
{
_cleanup_test_img
- rm -f $COMPR_IMG
- rm -f $RAND_FILE
+ rm -f "$COMPR_IMG"
+ rm -f "$RAND_FILE"
}
trap "_cleanup; exit \$status" 0 1 2 3 15
@@ -146,11 +146,14 @@ echo
echo "=== Testing incompressible cluster processing with zstd ==="
echo
-dd if=/dev/urandom of=$RAND_FILE bs=1M count=1
+dd if=/dev/urandom of="$RAND_FILE" bs=1M count=1
_make_test_img 64M
# fill the image with likely incompressible and compressible clusters
-$QEMU_IO -c "write -c -s "$RAND_FILE" 0 1M " "$TEST_IMG" | _filter_qemu_io
+# TODO: if RAND_FILE variable contain a whitespace, the following will fail.
+# We need to support some kind of quotes to make possible file paths with
+# white spaces for -s option
+$QEMU_IO -c "write -c -s $RAND_FILE 0 1M " "$TEST_IMG" | _filter_qemu_io
$QEMU_IO -c "write -c -P 0xFA 1M 1M " "$TEST_IMG" | _filter_qemu_io
$QEMU_IMG convert -O $IMGFMT -c -o compression_type=zstd \
"$TEST_IMG" "$COMPR_IMG"
--
Best regards,
Vladimir