From patchwork Tue Mar 29 16:24:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 8688891 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7FC8AC0553 for ; Tue, 29 Mar 2016 16:24:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D586A202EB for ; Tue, 29 Mar 2016 16:24:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 22B8320165 for ; Tue, 29 Mar 2016 16:24:52 +0000 (UTC) Received: from localhost ([::1]:48616 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akwRn-0006eE-9v for patchwork-qemu-devel@patchwork.kernel.org; Tue, 29 Mar 2016 12:24:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akwRY-0006YR-AF for qemu-devel@nongnu.org; Tue, 29 Mar 2016 12:24:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1akwRV-0005Zy-3q for qemu-devel@nongnu.org; Tue, 29 Mar 2016 12:24:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akwRJ-0005XD-O0; Tue, 29 Mar 2016 12:24:21 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 37F68811D2; Tue, 29 Mar 2016 16:24:21 +0000 (UTC) Received: from localhost (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2TGOJOR011179 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Mar 2016 12:24:20 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 29 Mar 2016 18:24:17 +0200 Message-Id: <1459268657-14181-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-devel] [PATCH] iotests: Make 150 use qemu-img map instead of du X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The actual on-disk size of a file does not only depend on factors qemu can control. Thus, we should not depend on this to determine whether a file has indeed been fully allocated. Instead, use qemu-img map and hope that if an area is referenced, it is indeed allocated, too. Also, limit the supported image formats to raw and qcow2 because the actual qemu-img map output may depend on the image format. Signed-off-by: Max Reitz Tested-by: Paolo Bonzini --- tests/qemu-iotests/150 | 41 +++++------------------------------------ tests/qemu-iotests/150.out | 13 +++++-------- 2 files changed, 10 insertions(+), 44 deletions(-) diff --git a/tests/qemu-iotests/150 b/tests/qemu-iotests/150 index 97d2a35..665373d 100755 --- a/tests/qemu-iotests/150 +++ b/tests/qemu-iotests/150 @@ -38,65 +38,34 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.rc . ./common.filter -_supported_fmt generic +_supported_fmt raw qcow2 _supported_proto file _supported_os Linux -on_disk_size() -{ - du "$@" | sed -e 's/\t\+.*//' -} - - img_size=1048576 echo -echo '=== Comparing empty image against sparse conversion ===' +echo '=== Mapping sparse conversion ===' echo -_make_test_img $img_size - -empty_size=$(on_disk_size "$TEST_IMG") - - $QEMU_IMG_PROG convert -O "$IMGFMT" -S 512 \ "json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \ "$TEST_IMG" -sparse_convert_size=$(on_disk_size "$TEST_IMG") - - -if [ "$empty_size" -eq "$sparse_convert_size" ]; then - echo 'Equal image size' -else - echo 'Different image size' -fi +$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map echo -echo '=== Comparing full image against non-sparse conversion ===' +echo '=== Mapping non-sparse conversion ===' echo -_make_test_img $img_size -$QEMU_IO -c "write 0 $img_size" "$TEST_IMG" | _filter_qemu_io - -full_size=$(on_disk_size "$TEST_IMG") - - $QEMU_IMG convert -O "$IMGFMT" -S 0 \ "json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \ "$TEST_IMG" -non_sparse_convert_size=$(on_disk_size "$TEST_IMG") - - -if [ "$full_size" -eq "$non_sparse_convert_size" ]; then - echo 'Equal image size' -else - echo 'Different image size' -fi +$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map # success, all done diff --git a/tests/qemu-iotests/150.out b/tests/qemu-iotests/150.out index 2d29da1..2a54e8d 100644 --- a/tests/qemu-iotests/150.out +++ b/tests/qemu-iotests/150.out @@ -1,14 +1,11 @@ QA output created by 150 -=== Comparing empty image against sparse conversion === +=== Mapping sparse conversion === -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 -Equal image size +Offset Length File -=== Comparing full image against non-sparse conversion === +=== Mapping non-sparse conversion === -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 -wrote 1048576/1048576 bytes at offset 0 -1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Equal image size +Offset Length File +0 0x100000 TEST_DIR/t.IMGFMT *** done