qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 6/6] iotests: test external backup api


From: Vladimir Sementsov-Ogievskiy
Subject: [Qemu-devel] [PATCH 6/6] iotests: test external backup api
Date: Sat, 30 Jan 2016 13:56:34 +0300

Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
 tests/qemu-iotests/151     | 77 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/151.out |  7 +++++
 tests/qemu-iotests/group   |  1 +
 3 files changed, 85 insertions(+)
 create mode 100755 tests/qemu-iotests/151
 create mode 100644 tests/qemu-iotests/151.out

diff --git a/tests/qemu-iotests/151 b/tests/qemu-iotests/151
new file mode 100755
index 0000000..d2fc2dc
--- /dev/null
+++ b/tests/qemu-iotests/151
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+#
+# Test external backup api
+#
+# (C) Vladimir Sementsov-Ogievskiy 2016
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+
+import os
+import iotests
+import time
+from iotests import qemu_img
+
+disk = os.path.join(iotests.test_dir, 'disk')
+
+size   = 0x40000000 # 1G
+sector_size = 512
+granularity = 0x10000
+regions = [
+    { 'start': 0,          'count': 0x100000 },
+    { 'start': 0x10000000, 'count': 0x20000  },
+    { 'start': 0x39990000, 'count': 0x10000  }
+    ]
+
+class TestExternalBackupApi(iotests.QMPTestCase):
+
+    def setUp(self):
+        qemu_img('create', '-f', iotests.imgfmt, disk, str(size))
+        self.vm = iotests.VM().add_drive(disk)
+        self.vm.launch()
+
+    def tearDown(self):
+        self.vm.shutdown()
+        os.remove(disk)
+
+    def printBitmap(self, block_io):
+        print self.vm.qmp('query-block-dirty-bitmap-ranges', node='drive0',
+                          name='bitmap', block_io=(block_io if 'on' else 
'off'),
+                          max_ranges=100);
+
+    def test_api(self):
+        result = self.vm.qmp('block-dirty-bitmap-add', node='drive0',
+                             name='bitmap', granularity=granularity)
+        self.assert_qmp(result, 'return', {});
+
+        for r in regions:
+            self.vm.hmp_qemu_io('drive0',
+                                'write %d %d' % (r['start'], r['count']))
+
+        result = self.vm.qmp('block-dirty-bitmap-create-successor',
+                                node='drive0', name='bitmap')
+        self.assert_qmp(result, 'return', {});
+
+        self.printBitmap(False)
+
+        result = self.vm.qmp('block-dirty-bitmap-abdicate',
+                              node='drive0', name='bitmap')
+        self.assert_qmp(result, 'return', {});
+
+        self.printBitmap(True)
+
+
+
+if __name__ == '__main__':
+    iotests.main()
diff --git a/tests/qemu-iotests/151.out b/tests/qemu-iotests/151.out
new file mode 100644
index 0000000..baed190
--- /dev/null
+++ b/tests/qemu-iotests/151.out
@@ -0,0 +1,7 @@
+.
+----------------------------------------------------------------------
+Ran 1 tests
+
+OK
+{u'return': [{u'count': 1048576, u'start': 0}, {u'count': 131072, u'start': 
268435456}, {u'count': 65536, u'start': 966328320}]}
+{u'return': []}
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index 84db670..9425a23 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -143,3 +143,4 @@
 139 rw auto quick
 142 auto
 150 auto
+151 auto
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]