From nobody Thu Nov 13 22:04:09 2025 Delivered-To: importer@patchew.org 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; 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=1582788758; cv=none; d=zohomail.com; s=zohoarc; b=AwQAfwq16ATmi5aNyQhjPufF4tzHXECTF0cm7e5g+MtssWBip+3OxNgaWtai5vCwF5U2aGARr25iY+oLKp+j3jjiKZoKC7E1CeedMLooBDcVyz/qybO1WgLm5L3ngPhIPFK6YVg+u2G5lVeR3Pz4SZaPaRFInr0BG9iKOKtJcTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582788758; 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=o0lyCl0YXIMX7drQKhBR0B23YlGlzO9C0SuaURkb99k=; b=TZNSf+hEo8KwnpPnnpE19MNfZ6KQon0jSHjwFg8dVgC2OHFUW7nyM21atpqYqFl/n3+/zYdZAio1mbrKvItOe+3dWfTmHN0NQ7W1yXXBukLwSvv52viM5q1tb3286qbZtYlbCqSAabDke2YHPiBSCZnzEH2Z2f7IHfVmiwe5/k4= 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 1582788758643883.973332104945; Wed, 26 Feb 2020 23:32:38 -0800 (PST) Received: from localhost ([::1]:54794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7Dev-0002Fo-I4 for importer@patchew.org; Thu, 27 Feb 2020 02:32:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42268) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7DcY-0000G2-Lf for qemu-devel@nongnu.org; Thu, 27 Feb 2020 02:30:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7DcV-000098-0F for qemu-devel@nongnu.org; Thu, 27 Feb 2020 02:30:10 -0500 Received: from relay.sw.ru ([185.231.240.75]:33960) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7DcU-00005a-1U; Thu, 27 Feb 2020 02:30:06 -0500 Received: from dptest2.qa.sw.ru ([10.94.4.71]) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1j7DcP-0003Tx-9R; Thu, 27 Feb 2020 10:30:01 +0300 From: Denis Plotnikov To: qemu-devel@nongnu.org Subject: [PATCH v1 8/8] iotests: 287: add qcow2 compression type test Date: Thu, 27 Feb 2020 10:29:53 +0300 Message-Id: <20200227072953.25445-9-dplotnikov@virtuozzo.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20200227072953.25445-1-dplotnikov@virtuozzo.com> References: <20200227072953.25445-1-dplotnikov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [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, qemu-block@nongnu.org, den@vrtuozzo.com, armbru@redhat.com, mreitz@redhat.com 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 requiriements for the compression type feature and zstd compression type operability. Signed-off-by: Denis Plotnikov --- tests/qemu-iotests/287 | 123 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/287.out | 41 +++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 165 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..41b916f690 --- /dev/null +++ b/tests/qemu-iotests/287 @@ -0,0 +1,123 @@ +#!/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! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# standard environment +. ./common.rc +. ./common.filter + +# This tests qocw2-specific low-level functionality +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +P=3D`echo "$QEMU_PROG" | sed "s/qemu-system-x86_64//"` + +grep "CONFIG_ZSTD=3Dy" "$P"../config-host.mak >/dev/null +RES=3D$? +if (($RES)); then + _notrun "ZSTD is disabled in the current configuration" +fi + +# Test: when compression is zlib the incompatible is unset +echo +echo "=3D=3D=3D Testing compression type incompatible bit setting for zlib= =3D=3D=3D" +echo + +_make_test_img 64M +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features + +# Test: when compression differs from zlib the incompatible bit is set +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 + +# Test: an image can't be openned if compression type is zlib and +# incompatible feature compression type is set +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 +$QEMU_IMG info "$TEST_IMG" 2>1 1>/dev/null +if (($?=3D=3D0)); then + echo "Error: The image openned successfully. The image must not be ope= nned" +fi + +# Test: an image can't be openned if compression type is NOT zlib and +# incompatible feature compression type is UNSET +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 +$QEMU_IMG info "$TEST_IMG" 2>1 1>/dev/null +if (($?=3D=3D0)); then + echo "Error: The image openned successfully. The image must not be ope= nned" +fi +# Test: check compression type values +echo +echo "=3D=3D=3D Testing compression type values =3D=3D=3D" +echo +# zlib=3D0 +IMGOPTS=3D'compression_type=3Dzlib' _make_test_img 64M +od -j104 -N1 -An -vtu1 "$TEST_IMG" + +# zstd=3D1 +IMGOPTS=3D'compression_type=3Dzstd' _make_test_img 64M +od -j104 -N1 -An -vtu1 "$TEST_IMG" + +# Test: using zstd compression, write to and read from an image +echo +echo "=3D=3D=3D Testing reading and writing with zstd =3D=3D=3D" +echo + +CLUSTER_SIZE=3D65536 +IMGOPTS=3D'compression_type=3Dzstd' _make_test_img 64M +$QEMU_IO -c "write -c 0 64k " "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -v 0 10 " "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -v 65530 8" "$TEST_IMG" | _filter_qemu_io + +# 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..4218254ce0 --- /dev/null +++ b/tests/qemu-iotests/287.out @@ -0,0 +1,41 @@ +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 compression_t= ype=3Dzstd +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 compression_t= ype=3Dzstd +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 compression_t= ype=3Dzstd + 1 + +=3D=3D=3D Testing reading and writing with zstd =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 compression_t= ype=3Dzstd +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +00000000: cd cd cd cd cd cd cd cd cd cd .......... +read 10/10 bytes at offset 0 +10 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +0000fffa: cd cd cd cd cd cd 00 00 ........ +read 8/8 bytes at offset 65530 +8 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 0317667695..5edbadef40 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -293,3 +293,4 @@ 283 auto quick 284 rw 286 rw quick +287 auto quick --=20 2.17.0