From patchwork Wed Oct 21 07:33:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: likejun6@huawei.com X-Patchwork-Id: 1385435 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CGP8t4cLgz9sSG for ; Wed, 21 Oct 2020 19:41:02 +1100 (AEDT) Received: from localhost ([::1]:50492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kV9g4-0006wK-I0 for incoming@patchwork.ozlabs.org; Wed, 21 Oct 2020 04:41:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV8dp-0002ni-2n; Wed, 21 Oct 2020 03:34:37 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5197 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kV8dm-0004LO-RU; Wed, 21 Oct 2020 03:34:36 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 166D8F0BEA3EAEAD8D1B; Wed, 21 Oct 2020 15:34:24 +0800 (CST) Received: from DESKTOP-IB00AOP.china.huawei.com (10.174.184.163) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Wed, 21 Oct 2020 15:34:13 +0800 From: To: Subject: [PATCH 3/4] qemu-iotest: add 310 testcase Date: Wed, 21 Oct 2020 15:33:54 +0800 Message-ID: <20201021073355.2499-4-likejun6@huawei.com> X-Mailer: git-send-email 2.22.0.windows.1 In-Reply-To: <20201021073355.2499-1-likejun6@huawei.com> References: <20201021073355.2499-1-likejun6@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.184.163] X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.190; envelope-from=likejun6@huawei.com; helo=huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 03:34:24 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 21 Oct 2020 04:40:16 -0400 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, zhang.zhanghailiang@huawei.com, qemu-devel@nongnu.org, xiexiangyou@huawei.com, mreitz@redhat.com, likejun Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: likejun Test falloc image creation, size and rw Signed-off-by: likejun --- tests/qemu-iotests/310 | 104 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/310.out | 21 ++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 126 insertions(+) create mode 100755 tests/qemu-iotests/310 create mode 100644 tests/qemu-iotests/310.out diff --git a/tests/qemu-iotests/310 b/tests/qemu-iotests/310 new file mode 100755 index 0000000000..af9f03e91f --- /dev/null +++ b/tests/qemu-iotests/310 @@ -0,0 +1,104 @@ +#!/bin/bash +# +# Test falloc image creation, size and rw +# +# Copyright (C) 2020 Huawei, 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=zhangshuai13@huawei.com + +seq=`basename $0` +echo "QA output created by $seq" + +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc >/dev/null 2>&1 +. ./common.filter + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +_img_info_tmp() +{ + if [[ "$1" == "--format-specific" ]]; then + local format_specific=1 + shift + else + local format_specific=0 + fi + + discard=0 + regex_json_spec_start='^ *"format-specific": \{' + $QEMU_IMG info "$@" "$TEST_IMG" 2>&1 | \ + sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ + -e "s#$TEST_DIR#TEST_DIR#g" \ + -e "s#$IMGFMT#IMGFMT#g" \ + -e "/actual-size/ D" | \ + while IFS='' read line; do + if [[ $format_specific == 1 ]]; then + discard=0 + elif [[ $line == "Format specific information:" ]]; then + discard=1 + elif [[ $line =~ $regex_json_spec_start ]]; then + discard=2 + regex_json_spec_end="^${line%%[^ ]*}\\},? *$" + fi + if [[ $discard == 0 ]]; then + echo "$line" + elif [[ $discard == 1 && ! $line ]]; then + echo + discard=0 + elif [[ $discard == 2 && $line =~ $regex_json_spec_end ]]; then + discard=0 + fi + done +} + +IMGOPTS="preallocation=falloc" + +echo "=== Check qemu-img info output ===" +echo +size=64M + +_make_test_img $size +_img_info_tmp | _filter_img_info + +echo +echo "== reading whole image ==" +$QEMU_IO -c "read 0 $size" "$TEST_IMG" | _filter_qemu_io + +echo +echo "== rewriting whole image ==" +$QEMU_IO -c "write -P 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io + +echo +echo "== verify pattern ==" +$QEMU_IO -c "read -P 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io + + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/310.out b/tests/qemu-iotests/310.out new file mode 100644 index 0000000000..dcca649360 --- /dev/null +++ b/tests/qemu-iotests/310.out @@ -0,0 +1,21 @@ +QA output created by 310 +=== Check qemu-img info output === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 preallocation=falloc +image: TEST_DIR/t.IMGFMT +file format: IMGFMT +virtual size: 64 MiB (67108864 bytes) +disk size: 64.3 MiB + +== reading whole image == +read 67108864/67108864 bytes at offset 0 +64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== rewriting whole image == +wrote 67108864/67108864 bytes at offset 0 +64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== verify pattern == +read 67108864/67108864 bytes at offset 0 +64 MiB, 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 632a05b25e..e8b6480890 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -317,3 +317,4 @@ 307 rw quick export 308 rw auto quick 309 rw auto quick +310 rw auto quick