From nobody Sun Feb 8 03:33:02 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1587456782; cv=none; d=zohomail.com; s=zohoarc; b=AUktEub3sWyHtPvjbd+luBzIq3vkbLC2iu33rOdsooF384dHM03XYLjWYgMFAvgyndU0IYAWVc4u51JNgJdg/yAwnHnwYL/xEngAz1GxIXNpdv1DFaT46DQOBUP8d6ZT1/CY58crYFuxMoppnWSxTu0p2EOJY/cR8PCMFFgWtbo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587456782; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=YshCaZrLNKl4Ve9jJ6TI9lYBwLRZOaSw2Z6j6DmGkMM=; b=Kz3qR52Z8csH0rlarI5qHX+ZCg1Y4nf+feu34J4MxD6Bwgs9YhT6FSEEh0QsmOX7Ms1teapET+zUXBNaaEjrRKHu0ug6cCPOuFJZV0iBmLmyI4X700TauBm45uACxthnRn3irGQvyC2deIHrRYnshcM4SPrsToAY29uPgzEsZWg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587456782694885.5577928240422; Tue, 21 Apr 2020 01:13:02 -0700 (PDT) Received: from localhost ([::1]:53104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQo1d-000506-EG for importer@patchew.org; Tue, 21 Apr 2020 04:13:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45956) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQo0l-0003fo-ML for qemu-devel@nongnu.org; Tue, 21 Apr 2020 04:12:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jQo0e-0001JF-6o for qemu-devel@nongnu.org; Tue, 21 Apr 2020 04:12:07 -0400 Received: from relay.sw.ru ([185.231.240.75]:37038) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jQo0d-0001HJ-Lf; Tue, 21 Apr 2020 04:11:59 -0400 Received: from dptest2.qa.sw.ru ([10.94.4.71]) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jQo0S-0005vI-9w; Tue, 21 Apr 2020 11:11:48 +0300 From: Denis Plotnikov To: qemu-devel@nongnu.org Subject: [PATCH v20 4/4] iotests: 287: add qcow2 compression type test Date: Tue, 21 Apr 2020 11:11:17 +0300 Message-Id: <20200421081117.7595-5-dplotnikov@virtuozzo.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20200421081117.7595-1-dplotnikov@virtuozzo.com> References: <20200421081117.7595-1-dplotnikov@virtuozzo.com> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=185.231.240.75; envelope-from=dplotnikov@virtuozzo.com; helo=relay.sw.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/21 04:11:56 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-block@nongnu.org, armbru@redhat.com, mreitz@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The test checks fulfilling qcow2 requirements for the compression type feature and zstd compression type operability. Signed-off-by: Denis Plotnikov Reviewed-by: Vladimir Sementsov-Ogievskiy Tested-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/287 | 146 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/287.out | 67 +++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 214 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..156acc40ad --- /dev/null +++ b/tests/qemu-iotests/287 @@ -0,0 +1,146 @@ +#!/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 . +# + +# creator +owner=3Ddplotnikov@virtuozzo.com + +seq=3D"$(basename $0)" +echo "QA output created by $seq" + +status=3D1 # 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=3D"$TEST_IMG.compressed" +RAND_FILE=3D"$TEST_DIR/rand_data" + +_cleanup() +{ + _cleanup_test_img + rm -f "$COMPR_IMG" + rm -f "$RAND_FILE" +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# for all the cases +CLUSTER_SIZE=3D65536 + +# Check if we can run this test. +if IMGOPTS=3D'compression_type=3Dzstd' _make_test_img 64M | + grep "Invalid parameter 'zstd'"; then + _notrun "ZSTD is disabled" +fi + +echo +echo "=3D=3D=3D Testing compression type incompatible bit setting for zlib= =3D=3D=3D" +echo +IMGOPTS=3D'compression_type=3Dzlib' _make_test_img 64M +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features + +echo +echo "=3D=3D=3D Testing compression type incompatible bit setting for zstd= =3D=3D=3D" +echo +IMGOPTS=3D'compression_type=3Dzstd' _make_test_img 64M +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features + +echo +echo "=3D=3D=3D Testing zlib with incompatible bit set =3D=3D=3D" +echo +IMGOPTS=3D'compression_type=3Dzlib' _make_test_img 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 open= ed." +fi + +echo +echo "=3D=3D=3D Testing zstd with incompatible bit unset =3D=3D=3D" +echo +IMGOPTS=3D'compression_type=3Dzstd' _make_test_img 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 open= ed." +fi + +echo +echo "=3D=3D=3D Testing compression type values =3D=3D=3D" +echo +# zlib=3D0 +IMGOPTS=3D'compression_type=3Dzlib' _make_test_img 64M +peek_file_be "$TEST_IMG" 104 1 +echo + +# zstd=3D1 +IMGOPTS=3D'compression_type=3Dzstd' _make_test_img 64M +peek_file_be "$TEST_IMG" 104 1 +echo + +echo +echo "=3D=3D=3D Testing simple reading and writing with zstd =3D=3D=3D" +echo +IMGOPTS=3D'compression_type=3Dzstd' _make_test_img 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 "=3D=3D=3D Testing adjacent clusters reading and writing with zstd = =3D=3D=3D" +echo +IMGOPTS=3D'compression_type=3Dzstd' _make_test_img 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 "=3D=3D=3D Testing incompressible cluster processing with zstd =3D=3D= =3D" +echo +# create a 2M image and fill it with 1M likely incompressible data +# and 1M compressible data +dd if=3D/dev/urandom of=3D"$RAND_FILE" bs=3D1M count=3D1 seek=3D1 +QEMU_IO_OPTIONS=3D"$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 "$RAND_FILE" "$TEST_IMG" | _filter_= qemu_io + +$QEMU_IMG convert -O $IMGFMT -c -o compression_type=3Dzstd \ + "$TEST_IMG" "$COMPR_IMG" +$QEMU_IMG compare "$TEST_IMG" "$COMPR_IMG" + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/287.out b/tests/qemu-iotests/287.out new file mode 100644 index 0000000000..6b9dfb4af0 --- /dev/null +++ b/tests/qemu-iotests/287.out @@ -0,0 +1,67 @@ +QA output created by 287 + +=3D=3D=3D Testing compression type incompatible bit setting for zlib =3D= =3D=3D + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +incompatible_features [] + +=3D=3D=3D Testing compression type incompatible bit setting for zstd =3D= =3D=3D + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +incompatible_features [3] + +=3D=3D=3D Testing zlib with incompatible bit set =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +incompatible_features [3] + +=3D=3D=3D Testing zstd with incompatible bit unset =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +incompatible_features [] + +=3D=3D=3D Testing compression type values =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 + 0 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 + 1 + +=3D=3D=3D Testing simple reading and writing with zstd =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +wrote 65536/65536 bytes at offset 65536 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 65536 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +0001fffe: ac ac 00 00 00 00 00 00 ........ +read 8/8 bytes at offset 131070 +8 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +0000fffe: 00 00 ac ac ac ac ac ac ........ +read 8/8 bytes at offset 65534 +8 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D=3D Testing adjacent clusters reading and writing with zstd =3D=3D= =3D + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 65536 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 131072 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 65536 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 131072 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D=3D Testing incompressible cluster processing with zstd =3D=3D=3D + +1+0 records in +1+0 records out +wrote 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Images are identical. +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 435dccd5af..3bbe02c88d 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -294,6 +294,7 @@ 283 auto quick 284 rw 286 rw quick +287 auto quick 288 quick 289 rw quick 290 rw auto quick --=20 2.17.0