From nobody Wed Apr 16 03:55:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499792606960691.3460304781612; Tue, 11 Jul 2017 10:03:26 -0700 (PDT) Received: from localhost ([::1]:47632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUyZG-0007gN-Lr for importer@patchew.org; Tue, 11 Jul 2017 13:03:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUxmp-0002fT-QP for qemu-devel@nongnu.org; Tue, 11 Jul 2017 12:13:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUxmo-0007ZX-JS for qemu-devel@nongnu.org; Tue, 11 Jul 2017 12:13:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59320) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dUxmk-0007XR-MH; Tue, 11 Jul 2017 12:13:14 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AFEFB267D2; Tue, 11 Jul 2017 16:13:13 +0000 (UTC) Received: from localhost (ovpn-204-123.brq.redhat.com [10.40.204.123]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1165D19157; Tue, 11 Jul 2017 16:13:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AFEFB267D2 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AFEFB267D2 From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 11 Jul 2017 18:08:13 +0200 Message-Id: <20170711160814.20941-85-mreitz@redhat.com> In-Reply-To: <20170711160814.20941-1-mreitz@redhat.com> References: <20170711160814.20941-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 11 Jul 2017 16:13:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 84/85] iotests: Add preallocated resize test for raw X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Max Reitz Reviewed-by: Stefan Hajnoczi Message-id: 20170613202107.10125-16-mreitz@redhat.com Signed-off-by: Max Reitz --- tests/qemu-iotests/106 | 92 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/106.out | 50 +++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 143 insertions(+) create mode 100755 tests/qemu-iotests/106 create mode 100644 tests/qemu-iotests/106.out diff --git a/tests/qemu-iotests/106 b/tests/qemu-iotests/106 new file mode 100755 index 0000000..3264957 --- /dev/null +++ b/tests/qemu-iotests/106 @@ -0,0 +1,92 @@ +#!/bin/bash +# +# Test preallocated resize of raw images +# +# Copyright (C) 2017 Red Hat, Inc. +# +# 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=3Dmreitz@redhat.com + +seq=3D$(basename $0) +echo "QA output created by $seq" + +here=3D$PWD +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment and filters +. ./common.rc +. ./common.filter + +_supported_fmt raw +_supported_proto file +_supported_os Linux + +# in kB +CREATION_SIZE=3D128 +GROWTH_SIZE=3D256 + +echo '=3D=3D=3D Testing image growth =3D=3D=3D' + +for create_mode in off falloc full; do + for growth_mode in off falloc full; do + echo + echo "--- create_mode=3D$create_mode growth_mode=3D$growth_mode --= -" + + IMGOPTS=3D"preallocation=3D$create_mode" _make_test_img ${CREATION= _SIZE}K + $QEMU_IMG resize -f "$IMGFMT" --preallocation=3D$growth_mode "$TES= T_IMG" +${GROWTH_SIZE}K + + expected_size=3D0 + if [ $create_mode !=3D off ]; then + expected_size=3D$CREATION_SIZE + fi + if [ $growth_mode !=3D off ]; then + expected_size=3D$((expected_size + $GROWTH_SIZE)) + fi + + actual_size=3D$($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep 'di= sk size') + actual_size=3D$(echo "$actual_size" | sed -e 's/^[^0-9]*\([0-9]\+\= ).*$/\1/') + + # The actual size may exceed the expected size, depending on the f= ile + # system. Therefore we just test that the actual size is at least = what + # we expect. + if [ $actual_size -lt $expected_size ]; then + echo "ERROR: Image should have at least ${expected_size}K, but= has ${actual_size}K" + fi + done +done + +echo +echo '=3D=3D=3D Testing image shrinking =3D=3D=3D' + +# None of this should work except for "off", because other modes cannot be= used +# for shrinking +for growth_mode in falloc full off; do + echo + echo "--- growth_mode=3D$growth_mode ---" + $QEMU_IMG resize -f "$IMGFMT" --preallocation=3D$growth_mode "$TEST_IM= G" -${GROWTH_SIZE}K +done + +# success, all done +echo '*** done' +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/106.out b/tests/qemu-iotests/106.out new file mode 100644 index 0000000..0a42312 --- /dev/null +++ b/tests/qemu-iotests/106.out @@ -0,0 +1,50 @@ +QA output created by 106 +=3D=3D=3D Testing image growth =3D=3D=3D + +--- create_mode=3Doff growth_mode=3Doff --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Doff +Image resized. + +--- create_mode=3Doff growth_mode=3Dfalloc --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Doff +Image resized. + +--- create_mode=3Doff growth_mode=3Dfull --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Doff +Image resized. + +--- create_mode=3Dfalloc growth_mode=3Doff --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Dfalloc +Image resized. + +--- create_mode=3Dfalloc growth_mode=3Dfalloc --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Dfalloc +Image resized. + +--- create_mode=3Dfalloc growth_mode=3Dfull --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Dfalloc +Image resized. + +--- create_mode=3Dfull growth_mode=3Doff --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Dfull +Image resized. + +--- create_mode=3Dfull growth_mode=3Dfalloc --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Dfull +Image resized. + +--- create_mode=3Dfull growth_mode=3Dfull --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Dfull +Image resized. + +=3D=3D=3D Testing image shrinking =3D=3D=3D + +--- growth_mode=3Dfalloc --- +qemu-img: Preallocation can only be used for growing images + +--- growth_mode=3Dfull --- +qemu-img: Preallocation can only be used for growing images + +--- growth_mode=3Doff --- +Image resized. +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 8f883f7..de14091 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -112,6 +112,7 @@ 103 rw auto quick 104 rw auto 105 rw auto quick +106 rw auto quick 107 rw auto quick 108 rw auto quick 109 rw auto --=20 2.9.4