From patchwork Tue Jun 13 12:16:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Butsykin X-Patchwork-Id: 9783755 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B8BED602DC for ; Tue, 13 Jun 2017 12:23:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9F7128635 for ; Tue, 13 Jun 2017 12:23:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CBA428651; Tue, 13 Jun 2017 12:23:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id A2A3A28635 for ; Tue, 13 Jun 2017 12:23:42 +0000 (UTC) Received: from localhost ([::1]:43022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKkrF-0004Cq-OV for patchwork-qemu-devel@patchwork.kernel.org; Tue, 13 Jun 2017 08:23:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKkmP-00011u-QU for qemu-devel@nongnu.org; Tue, 13 Jun 2017 08:18:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKkmL-0007Fg-Pp for qemu-devel@nongnu.org; Tue, 13 Jun 2017 08:18:41 -0400 Received: from mail-db5eur01on0116.outbound.protection.outlook.com ([104.47.2.116]:28736 helo=EUR01-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dKkmD-00077Y-2k; Tue, 13 Jun 2017 08:18:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=jc5juBKW4wtPWnhD+WO5jwVaF90yS/gbHm8mFmNxUlE=; b=WWeeQQ41hWAP4EBBZjenqxk0ftVdzmg0GEmeuVaIscehGPVX49uwl8uyFYMFT3AuyeSXm0lMDmBKysi4lgXonegoPqCj4yQdUQMH6lYb6u2NOmLGmV4VXOI87G5Bzt1fghyXOjFWLcDa0qTj8yDWS4KAyojaIlepwyjK8GWYXxg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=pbutsykin@virtuozzo.com; Received: from pavelb-Z68P-DS3.sw.ru (195.214.232.6) by HE1PR0802MB2555.eurprd08.prod.outlook.com (2603:10a6:3:e1::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1157.12; Tue, 13 Jun 2017 12:18:20 +0000 From: Pavel Butsykin To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Tue, 13 Jun 2017 15:16:39 +0300 Message-Id: <20170613121639.17853-5-pbutsykin@virtuozzo.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170613121639.17853-1-pbutsykin@virtuozzo.com> References: <20170613121639.17853-1-pbutsykin@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HK2PR02CA0136.apcprd02.prod.outlook.com (2603:1096:202:16::20) To HE1PR0802MB2555.eurprd08.prod.outlook.com (2603:10a6:3:e1::20) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0802MB2555: X-MS-Office365-Filtering-Correlation-Id: 7364990b-1b03-4618-df38-08d4b2564b0e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:HE1PR0802MB2555; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2555; 3:lMWIUDAU9gGVPXpmF/TsJ8wPK/wk2gFwoeV7UluNZZIPiDKaz3xM7JH88begDKkkJNbYA51xzeKQQe5oyu34TBKq7zNlp8Q61FvWUP/FkHQmt6BW6m6SzgRRCR1cCu5+BtaOc7/LDt7LBxVuj8q3mCMUXqVUJf5Xk+RZrDzSAVWh61IqQo7eDqRcuKisDMGjwvY8srhRDA8WLCby+15KC7WYlsZfzY5nTJXWiSkkReK17zLlte71NeNHxSBagy99JuZlJwEqod8UrgXB1eR6DHGHfyFYTYCB0Ef8XNfFG7eNq1FhOTjL9jSo04ckddDYDWfD/m7/ejH9vsuBM3NDFQ==; 25:nNvgQx3WtA/bqBQjyKCJsEe1tXN7RP5f41uOqRhLaMJQcZrmd9rc6V8Q/4ocyGfgwuAWbiTYiPbIrCkTWEHZvRmDeGL7mCuedNu06sbz3IQXo+Hl0QwrqWP4K5uEKItWe/gdDqawwTC0dBTX0Ks3SYffy7HXXc5pzp6hqa4ln/M2m+j3tgIYtfpChvfOhq7YWHMG0r5nqFJMHfqPVNbGuUbQOpubSguN3g4vwDBlJ5EOYp7QBcYFusFlcV8fAn6mwT1RCazc3kLdK2LhylMNcjfvqWFyh4g/v5BH58X2No/lVf60ihR42jWvLodiwM4x7TTIMvNXgcgi1YjygncrxkiCJ74ZbENEHc8P2cK2aJV8FhAV2EgxvY/eJPpO/4S4x7ivhz1+R8Gss5NC7rlfwy4oKNY4LiXF7CWC3ghSLgs7GGhf3nOC+QlAGZOb5k6HRcR7ez9Jl99Vv1ZYO2oilrhzVzJMNK6HaAEsELyX3gQ= X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2555; 31:/1iQ3Qt2vqHV5Zj6erZyisN4DYSqsFBr4xmgPHtBFFzugdXb7056u+23lLYBG/vDqL7vaJlfEC4KxILPOiseKmJV07J/UGWjFBKmRvRYFlBsyFIvte6wi+jLvBrDDeXEN/Z+3q1xKY53HfiTIAYSfJfgxwjIvlFi5CijKBfZBhtGtYc5PFMOmhavhKLH7vKdfYiPNSri7TM3P6mLUDWBaA9yJ9LIZ89lR/uEixrrf8A=; 20:ZNjNcuTUpDyPwoRJdJvnf9NPTo+1ge4TwvTTxmj+Fcf6UCTIdHv4LOxuAfrFu/ToY1//sATGEWzOq1tLYcTdApOWuyYzOcV2FdQ7cbpdm5saUdAk219F0d82bKRgtMCtpNK4PoUUVuxpnZgw4M0aKvKHIJIeowkwY+66W0f7lwmjVp81NS6a0RVWySP2wEPq2vApLtz619qStkl0I1G3EgAK+veA/zzA3yN7mcBIaV4FijPZk8kbTsRkCB6uJeRSLo/4Yvt9EwhI2vhX7rcVmIg4Yxw1EThnCd3SIVrB0ogMnPc9+5vLdRKj3YRw6n+3177aAdrvSlYBgUwFPduLcnwS/VLVTO+sMnrVg10ZVEIE018fq/7gETuMW2g0yiV7/NtQ9qhVpNRN+VNkWo8ArbI/AxJwquMz0JQJff+9hYk= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(100000703101)(100105400095)(6041248)(20161123560025)(20161123562025)(20161123564025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:HE1PR0802MB2555; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:HE1PR0802MB2555; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0802MB2555; 4:P9rRW/EWvjY36aa55E1CSQuF37yZgbTUdkGCKRrf?= =?us-ascii?Q?kyKreH+Ye/Ht4bvt8onhm6M+Wlg2CWH4bF8PjVic56PjAmRXEOMXN8PN0CKd?= =?us-ascii?Q?gzi2pgRNkfjOXera2nGi/TmMVQq4jo6dS0MTmZghI8kTm4IMMuEziYqELZU8?= =?us-ascii?Q?ypfj7hA/7MMtcKLPrwtgRx/wU5Dbzfw+TLa+4ipOCBjlisqqe3tC51P92L5I?= =?us-ascii?Q?Bd2cON4OpnhPEqze1BW/z4QxM/M4+G5VtwwVblj7zvtCvRaUOQN2dYJ/zyzr?= =?us-ascii?Q?dAceHIUQ9W/CSNY4FyGYBlG3eY54qk21xRp0q1Wv7QzMEZpsXmatlnL0e+5L?= =?us-ascii?Q?v8bzERfc7IJmzkAzJoY0VRzbOsMQap93FKvjewwrhhwK4Q3PKOvg4v9Wv61G?= =?us-ascii?Q?vwl6ZAlxvxo0j2bYmSuUIADmmPS1vq3BPjCL6my+Ugsy7gyGqITbcHO9X4YE?= =?us-ascii?Q?PG/astKCpCBVpc8MYJP9X8aGIBA7q1FXfCrPFTdiks2CREf4ckt2dWWwhJoe?= =?us-ascii?Q?o2HcROsIkeWesifEQJGNGWyNSb+Mrvu3SX0OtM1DWMgV+y8KyVxhAiJPERbx?= =?us-ascii?Q?KI9QlKHglYpbWqixuxKeshfmrH65P7GcBagKN2EO4PE0mTxxDAphNedmRwkD?= =?us-ascii?Q?9+QggW7uMZ9W2VbjmBM3xlor+P8kftIC6AcDxdF7xysgBySH/DP+DZFC5lVv?= =?us-ascii?Q?mBSc6RtGzvu16QxfahdvMgWom5vW8VGN9T3bijzsBRry4kf2GZj6RId3Qk8E?= =?us-ascii?Q?V2/ewZ37mRmAr07JBh0+dLpyxYGOUGr3lIKPEr41FhpRLcd197QmU8sZW4EU?= =?us-ascii?Q?i4EtloNiIxljhCgFVpITfOezIEgE7flW0J0DshFR6eqXvNEAZM02bsbswyAr?= =?us-ascii?Q?WmhQoim/Glfbox028aFGzfq/D95k4c239DgiDK0K0sdWfiB5YChqEI3YFcAG?= =?us-ascii?Q?m3IDAhMIlkt1ddnvDGf+gNiOkspRZYGtV1bQGje9o+QBdS09z/W02Ov6OO2U?= =?us-ascii?Q?NTzkx1xUlEc0PAudJfugUKzG3dfraUIuYA/5wV3j27v0LkI+Ht4og5HzOa+0?= =?us-ascii?Q?qUdzdTEP4uz2Y0S1J7HY2KTZXskP7MYZ0Zyk6GK8c1NFmqPj9f4IO/Kti/7T?= =?us-ascii?Q?ciPxYhVw4Vu+AHxP2jn8pMRhmmaokcSciVBDOv/fJxTvAAuFGP3c1iQWPM2G?= =?us-ascii?Q?mQ9Yj/EkC6wmeoJQqGpSr0ThgE9LXf8TsDR6X3de3mkLuhYrAiy9+AporA?= =?us-ascii?Q?=3D=3D?= X-Forefront-PRVS: 0337AFFE9A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39450400003)(39400400002)(39410400002)(39830400002)(189002)(199003)(6506006)(25786009)(53936002)(50226002)(107886003)(110136004)(4326008)(53416004)(42186005)(6512007)(33646002)(6486002)(106356001)(38730400002)(5660300001)(105586002)(50466002)(5003940100001)(101416001)(305945005)(6306002)(48376002)(69596002)(81156014)(189998001)(47776003)(66066001)(8676002)(81166006)(6116002)(36756003)(3846002)(97736004)(6666003)(68736007)(575784001)(86362001)(1076002)(50986999)(76176999)(2950100002)(478600001)(2906002)(7736002)(2004002); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0802MB2555; H:pavelb-Z68P-DS3.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0802MB2555; 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Z9FFzNsVlQp0Yr5a8rOE34W1jWJPPWJuO5Z3shLe0qYmlAZ0apsA==; 20:lr12tmPzwAPbAQtVGYJfy/iO1kdglpor/toa43CsB7l7/B4nfp2/4ACOO20q0hTY1DF53NkdkWbXnflKm4BPFzAToZ/blT8TfhjSXL/QbFPqD61knINKsxFLVyfn5kAW07YqwELMUK8ERCowCF/IGunqEFLBs/v/i49rXiRAZyY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2017 12:18:20.9966 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2555 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.2.116 Subject: [Qemu-devel] [PATCH v2 4/4] qemu-iotests: add shrinking image test 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: kwolf@redhat.com, pbutsykin@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Pavel Butsykin --- tests/qemu-iotests/163 | 113 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/163.out | 5 ++ tests/qemu-iotests/group | 1 + 3 files changed, 119 insertions(+) create mode 100644 tests/qemu-iotests/163 create mode 100644 tests/qemu-iotests/163.out diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163 new file mode 100644 index 0000000000..2cb0116173 --- /dev/null +++ b/tests/qemu-iotests/163 @@ -0,0 +1,113 @@ +#!/usr/bin/env python +# +# Tests for shrinking images +# +# Copyright (c) 2016-2017 Parallels 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 . +# + +import os, random, iotests +from iotests import qemu_img, qemu_io, image_size + +test_img = os.path.join(iotests.test_dir, 'test.img') +check_img = os.path.join(iotests.test_dir, 'check.img') + +def size_to_int(str): + suff = ['B', 'K', 'M', 'G', 'T'] + return int(str[:-1]) * 1024**suff.index(str[-1:]) + +class TestShrink(iotests.QMPTestCase): + image_len = '1G' + shrink_size = '128M' + chank_size = '256M' + + def setUp(self): + qemu_img('create', '-f', iotests.imgfmt, test_img, TestShrink.image_len) + qemu_img('create', '-f', iotests.imgfmt, check_img, + TestShrink.shrink_size) + + def tearDown(self): + os.remove(test_img) + os.remove(check_img) + + def image_verify(self): + self.assertEqual(image_size(test_img), image_size(check_img), + "Verifying image size") + + if iotests.imgfmt == 'raw': + return + + self.assertEqual(qemu_img('check', test_img), + qemu_img('check', check_img), + "Verifying image corruption") + + def test_empty_image(self): + qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img, + TestShrink.shrink_size) + + self.assertEqual( + qemu_io('-c', 'read -P 0x00 %s'%TestShrink.shrink_size, test_img), + qemu_io('-c', 'read -P 0x00 %s'%TestShrink.shrink_size, check_img), + "Verifying image content") + + TestShrink.image_verify(self) + + def test_sequential_write(self): + for offs in range(0, size_to_int(TestShrink.image_len), + size_to_int(TestShrink.chank_size)): + qemu_io('-c', 'write -P 0xff %d %s' % (offs, TestShrink.chank_size), + test_img) + + qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img, + TestShrink.shrink_size) + + self.assertEqual( + qemu_io('-c', 'read -P 0xff %s'%TestShrink.image_len, test_img), + qemu_io('-c', 'read -P 0xff %s'%TestShrink.image_len, check_img), + "Verifying image content") + + self.assertEqual( + qemu_io('-c', 'read -P 0xff %s'%TestShrink.shrink_size, test_img), + qemu_io('-c', 'read -P 0xff %s'%TestShrink.shrink_size, check_img), + "Verifying image content") + + TestShrink.image_verify(self) + + def test_random_write(self): + offs_list = range(0, size_to_int(TestShrink.image_len), + size_to_int(TestShrink.chank_size)) + random.shuffle(offs_list) + for offs in offs_list: + qemu_io('-c', 'write -P 0xff %d %s' % (offs, TestShrink.chank_size), + test_img) + + qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img, + TestShrink.shrink_size) + + self.assertEqual( + qemu_io('-c', 'read -P 0xff %s'%TestShrink.image_len, test_img), + qemu_io('-c', 'read -P 0xff %s'%TestShrink.image_len, check_img), + "Verifying image content") + + self.assertEqual( + qemu_io('-c', 'read -P 0xff %s'%TestShrink.shrink_size, test_img), + qemu_io('-c', 'read -P 0xff %s'%TestShrink.shrink_size, check_img), + "Verifying image content") + + TestShrink.image_verify(self) + + +if __name__ == '__main__': + iotests.main(supported_fmts=['raw', 'qcow2']) diff --git a/tests/qemu-iotests/163.out b/tests/qemu-iotests/163.out new file mode 100644 index 0000000000..8d7e996700 --- /dev/null +++ b/tests/qemu-iotests/163.out @@ -0,0 +1,5 @@ +... +---------------------------------------------------------------------- +Ran 3 tests + +OK diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 5c8ea0f95c..a2f42e7165 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -163,6 +163,7 @@ 159 rw auto quick 160 rw auto quick 162 auto quick +163 rw auto quick 170 rw auto quick 171 rw auto quick 172 auto