From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO13e-0000cD-Rx for qemu-devel@nongnu.org; Tue, 26 Jan 2016 05:41:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aO13a-0007hc-Gm for qemu-devel@nongnu.org; Tue, 26 Jan 2016 05:41:10 -0500 From: Fam Zheng Date: Tue, 26 Jan 2016 18:38:25 +0800 Message-Id: <1453804705-7205-17-git-send-email-famz@redhat.com> In-Reply-To: <1453804705-7205-1-git-send-email-famz@redhat.com> References: <1453804705-7205-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [RFC PATCH 16/16] iotests: Add persistent bitmap test case 141 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, jsnow@redhat.com, Markus Armbruster , mreitz@redhat.com, vsementsov@parallels.com, Stefan Hajnoczi For now it merely invokes block-dirty-bitmap-{add,set-persistent}. Verification of the bitmap data and user data to be added in the future. Signed-off-by: Fam Zheng --- tests/qemu-iotests/141 | 62 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/141.out | 5 ++++ tests/qemu-iotests/group | 1 + 3 files changed, 68 insertions(+) create mode 100644 tests/qemu-iotests/141 create mode 100644 tests/qemu-iotests/141.out diff --git a/tests/qemu-iotests/141 b/tests/qemu-iotests/141 new file mode 100644 index 0000000..434c7ce --- /dev/null +++ b/tests/qemu-iotests/141 @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# +# Tests for persistent dirty bitmap +# +# Copyright (C) 2016 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 . +# + +import os +import iotests +from iotests import qemu_img, qemu_io + +test_img = os.path.join(iotests.test_dir, 'test.img') + +class TestPersistentDirtyBitmap(iotests.QMPTestCase): + image_len = 64 * 1024 * 1024 # MB + def setUp(self): + # Write data to the image so we can compare later + qemu_img('create', '-f', iotests.imgfmt, test_img, str(self.image_len)) + self.vm = iotests.VM().add_drive(test_img) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + os.remove(test_img) + + def do_test_create(self, n): + def make_range(k): + return (k * 65536, 512) + r = range(n) + for i in r: + result = self.vm.qmp('block-dirty-bitmap-add', node='drive0', + name='bitmap-%d' % i, + persistent=True) + self.assert_qmp(result, 'return', {}) + self.vm.hmp_qemu_io('drive0', 'write -P %d %d %d' % ((i % 255,) + make_range(i))) + for i in r: + result = self.vm.qmp('block-dirty-bitmap-set-persistent', + node='drive0', name='bitmap-%d' % i, + persistent=False) + self.assert_qmp(result, 'return', {}) + + def test_simple_one(self): + self.do_test_create(1) + + def test_simple_multiple(self): + self.do_test_create(10) + +if __name__ == '__main__': + iotests.main(supported_fmts=['qbm']) diff --git a/tests/qemu-iotests/141.out b/tests/qemu-iotests/141.out new file mode 100644 index 0000000..fbc63e6 --- /dev/null +++ b/tests/qemu-iotests/141.out @@ -0,0 +1,5 @@ +.. +---------------------------------------------------------------------- +Ran 2 tests + +OK diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index e220a00..877bdbb 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -142,4 +142,5 @@ 138 rw auto quick 139 rw auto quick 140 rw auto quick +141 rw auto quick 142 auto -- 2.4.3