diff options
author | Denis Plotnikov <dplotnikov@virtuozzo.com> | 2020-05-07 11:25:21 +0300 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2020-05-13 14:20:31 +0200 |
commit | dd488fc1c000700741355426198d240c6f25ccb7 (patch) | |
tree | a119fca5461ee49d7a770fee834f34caf1bccc1c /tests/qemu-iotests/287 | |
parent | d298ac10add95e2b7f8850332f3b755c8a23d925 (diff) | |
download | qemu-dd488fc1c000700741355426198d240c6f25ccb7.zip qemu-dd488fc1c000700741355426198d240c6f25ccb7.tar.gz qemu-dd488fc1c000700741355426198d240c6f25ccb7.tar.bz2 |
iotests: 287: add qcow2 compression type test
The test checks fulfilling qcow2 requirements for the compression
type feature and zstd compression type operability.
Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Tested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200507082521.29210-5-dplotnikov@virtuozzo.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/287')
-rwxr-xr-x | tests/qemu-iotests/287 | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/tests/qemu-iotests/287 b/tests/qemu-iotests/287 new file mode 100755 index 0000000..f98a4ca --- /dev/null +++ b/tests/qemu-iotests/287 @@ -0,0 +1,152 @@ +#!/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=dplotnikov@virtuozzo.com + +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 +_unsupported_imgopts 'compat=0.10' data_file + +COMPR_IMG="$TEST_IMG.compressed" +RAND_FILE="$TEST_DIR/rand_data" + +_cleanup() +{ + _cleanup_test_img + _rm_test_img "$COMPR_IMG" + rm -f "$RAND_FILE" +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# for all the cases +CLUSTER_SIZE=65536 + +# Check if we can run this test. +if IMGOPTS='compression_type=zstd' _make_test_img 64M | + grep "Invalid parameter 'zstd'"; then + _notrun "ZSTD is disabled" +fi + +echo +echo "=== Testing compression type incompatible bit setting for zlib ===" +echo +_make_test_img -o compression_type=zlib 64M +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features + +echo +echo "=== Testing compression type incompatible bit setting for zstd ===" +echo +_make_test_img -o compression_type=zstd 64M +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features + +echo +echo "=== Testing zlib with incompatible bit set ===" +echo +_make_test_img -o compression_type=zlib 64M +$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 3 +# to make sure the bit was actually set +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features + +if $QEMU_IMG info "$TEST_IMG" >/dev/null 2>&1 ; then + echo "Error: The image opened successfully. The image must not be opened." +fi + +echo +echo "=== Testing zstd with incompatible bit unset ===" +echo +_make_test_img -o compression_type=zstd 64M +$PYTHON qcow2.py "$TEST_IMG" set-header incompatible_features 0 +# to make sure the bit was actually unset +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features + +if $QEMU_IMG info "$TEST_IMG" >/dev/null 2>&1 ; then + echo "Error: The image opened successfully. The image must not be opened." +fi + +echo +echo "=== Testing compression type values ===" +echo +# zlib=0 +_make_test_img -o compression_type=zlib 64M +peek_file_be "$TEST_IMG" 104 1 +echo + +# zstd=1 +_make_test_img -o compression_type=zstd 64M +peek_file_be "$TEST_IMG" 104 1 +echo + +echo +echo "=== Testing simple reading and writing with zstd ===" +echo +_make_test_img -o compression_type=zstd 64M +$QEMU_IO -c "write -c -P 0xAC 64K 64K " "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 0xAC 64K 64K " "$TEST_IMG" | _filter_qemu_io +# read on the cluster boundaries +$QEMU_IO -c "read -v 131070 8 " "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -v 65534 8" "$TEST_IMG" | _filter_qemu_io + +echo +echo "=== Testing adjacent clusters reading and writing with zstd ===" +echo +_make_test_img -o compression_type=zstd 64M +$QEMU_IO -c "write -c -P 0xAB 0 64K " "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -c -P 0xAC 64K 64K " "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -c -P 0xAD 128K 64K " "$TEST_IMG" | _filter_qemu_io + +$QEMU_IO -c "read -P 0xAB 0 64k " "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 0xAC 64K 64k " "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 0xAD 128K 64k " "$TEST_IMG" | _filter_qemu_io + +echo +echo "=== Testing incompressible cluster processing with zstd ===" +echo +# create a 2M image and fill it with 1M likely incompressible data +# and 1M compressible data +dd if=/dev/urandom of="$RAND_FILE" bs=1M count=1 seek=1 +QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS_NO_FMT" \ +$QEMU_IO -f raw -c "write -P 0xFA 0 1M" "$RAND_FILE" | _filter_qemu_io + +$QEMU_IMG convert -f raw -O $IMGFMT -c \ +-o "$(_optstr_add "$IMGOPTS" "compression_type=zlib")" "$RAND_FILE" \ +"$TEST_IMG" | _filter_qemu_io + +$QEMU_IMG convert -O $IMGFMT -c \ +-o "$(_optstr_add "$IMGOPTS" "compression_type=zstd")" "$TEST_IMG" \ +"$COMPR_IMG" | _filter_qemu_io + +$QEMU_IMG compare "$TEST_IMG" "$COMPR_IMG" + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 |