Blame SOURCES/kvm-qemu-iotests-Update-test-cases-for-commit-active.patch

0a122b
From 823ad14cd80063cf09ca5efc2c1d7c584f44a1be Mon Sep 17 00:00:00 2001
0a122b
From: Fam Zheng <famz@redhat.com>
0a122b
Date: Fri, 17 Jan 2014 03:08:02 +0100
0a122b
Subject: [PATCH 19/34] qemu-iotests: Update test cases for commit active
0a122b
0a122b
RH-Author: Fam Zheng <famz@redhat.com>
0a122b
Message-id: <1389928083-8921-18-git-send-email-famz@redhat.com>
0a122b
Patchwork-id: 56779
0a122b
O-Subject: [RHEL-7 qemu-kvm PATCH 17/18] qemu-iotests: Update test cases for commit active
0a122b
Bugzilla: 1041301
0a122b
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
0a122b
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
0a122b
Factor out commit test common logic into super class, and update test
0a122b
of committing the active image.
0a122b
0a122b
Signed-off-by: Fam Zheng <famz@redhat.com>
0a122b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
(cherry picked from commit 4de43470f2f35762b4b3e6a59b4aed55e239024a)
0a122b
Signed-off-by: Fam Zheng <famz@redhat.com>
0a122b
0a122b
Conflicts:
0a122b
	tests/qemu-iotests/040
0a122b
0a122b
Conflict because "b59b3d5 qemu-iotests: Make test case 030, 040 and 055
0a122b
deterministic" and "2499a09 qemu-iotests: make create_image() common"
0a122b
are not backported yet.
0a122b
0a122b
Signed-off-by: Fam Zheng <famz@redhat.com>
0a122b
---
0a122b
 tests/qemu-iotests/040 | 74 ++++++++++++++++++++++----------------------------
0a122b
 1 file changed, 32 insertions(+), 42 deletions(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 tests/qemu-iotests/040 |   74 ++++++++++++++++++++---------------------------
0a122b
 1 files changed, 32 insertions(+), 42 deletions(-)
0a122b
0a122b
diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
0a122b
index aad535a..f210fb7 100755
0a122b
--- a/tests/qemu-iotests/040
0a122b
+++ b/tests/qemu-iotests/040
0a122b
@@ -63,6 +63,28 @@ class ImageCommitTestCase(iotests.QMPTestCase):
0a122b
             i = i + 512
0a122b
         file.close()
0a122b
 
0a122b
+    def run_commit_test(self, top, base):
0a122b
+        self.assert_no_active_commit()
0a122b
+        result = self.vm.qmp('block-commit', device='drive0', top=top, base=base)
0a122b
+        self.assert_qmp(result, 'return', {})
0a122b
+
0a122b
+        completed = False
0a122b
+        while not completed:
0a122b
+            for event in self.vm.get_qmp_events(wait=True):
0a122b
+                if event['event'] == 'BLOCK_JOB_COMPLETED':
0a122b
+                    self.assert_qmp(event, 'data/type', 'commit')
0a122b
+                    self.assert_qmp(event, 'data/device', 'drive0')
0a122b
+                    self.assert_qmp(event, 'data/offset', self.image_len)
0a122b
+                    self.assert_qmp(event, 'data/len', self.image_len)
0a122b
+                    completed = True
0a122b
+                elif event['event'] == 'BLOCK_JOB_READY':
0a122b
+                    self.assert_qmp(event, 'data/type', 'commit')
0a122b
+                    self.assert_qmp(event, 'data/device', 'drive0')
0a122b
+                    self.assert_qmp(event, 'data/len', self.image_len)
0a122b
+                    self.vm.qmp('block-job-complete', device='drive0')
0a122b
+
0a122b
+        self.assert_no_active_commit()
0a122b
+        self.vm.shutdown()
0a122b
 
0a122b
 class TestSingleDrive(ImageCommitTestCase):
0a122b
     image_len = 1 * 1024 * 1024
0a122b
@@ -84,23 +106,7 @@ class TestSingleDrive(ImageCommitTestCase):
0a122b
         os.remove(backing_img)
0a122b
 
0a122b
     def test_commit(self):
0a122b
-        self.assert_no_active_commit()
0a122b
-        result = self.vm.qmp('block-commit', device='drive0', top='%s' % mid_img)
0a122b
-        self.assert_qmp(result, 'return', {})
0a122b
-
0a122b
-        completed = False
0a122b
-        while not completed:
0a122b
-            for event in self.vm.get_qmp_events(wait=True):
0a122b
-                if event['event'] == 'BLOCK_JOB_COMPLETED':
0a122b
-                    self.assert_qmp(event, 'data/type', 'commit')
0a122b
-                    self.assert_qmp(event, 'data/device', 'drive0')
0a122b
-                    self.assert_qmp(event, 'data/offset', self.image_len)
0a122b
-                    self.assert_qmp(event, 'data/len', self.image_len)
0a122b
-                    completed = True
0a122b
-
0a122b
-        self.assert_no_active_commit()
0a122b
-        self.vm.shutdown()
0a122b
-
0a122b
+        self.run_commit_test(mid_img, backing_img)
0a122b
         self.assertEqual(-1, qemu_io('-c', 'read -P 0xab 0 524288', backing_img).find("verification failed"))
0a122b
         self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed"))
0a122b
 
0a122b
@@ -127,10 +133,9 @@ class TestSingleDrive(ImageCommitTestCase):
0a122b
         self.assert_qmp(result, 'error/desc', 'Base \'badfile\' not found')
0a122b
 
0a122b
     def test_top_is_active(self):
0a122b
-        self.assert_no_active_commit()
0a122b
-        result = self.vm.qmp('block-commit', device='drive0', top='%s' % test_img, base='%s' % backing_img)
0a122b
-        self.assert_qmp(result, 'error/class', 'GenericError')
0a122b
-        self.assert_qmp(result, 'error/desc', 'Top image as the active layer is currently unsupported')
0a122b
+        self.run_commit_test(test_img, backing_img)
0a122b
+        self.assertEqual(-1, qemu_io('-c', 'read -P 0xab 0 524288', backing_img).find("verification failed"))
0a122b
+        self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed"))
0a122b
 
0a122b
     def test_top_and_base_reversed(self):
0a122b
         self.assert_no_active_commit()
0a122b
@@ -191,23 +196,7 @@ class TestRelativePaths(ImageCommitTestCase):
0a122b
                 raise
0a122b
 
0a122b
     def test_commit(self):
0a122b
-        self.assert_no_active_commit()
0a122b
-        result = self.vm.qmp('block-commit', device='drive0', top='%s' % self.mid_img)
0a122b
-        self.assert_qmp(result, 'return', {})
0a122b
-
0a122b
-        completed = False
0a122b
-        while not completed:
0a122b
-            for event in self.vm.get_qmp_events(wait=True):
0a122b
-                if event['event'] == 'BLOCK_JOB_COMPLETED':
0a122b
-                    self.assert_qmp(event, 'data/type', 'commit')
0a122b
-                    self.assert_qmp(event, 'data/device', 'drive0')
0a122b
-                    self.assert_qmp(event, 'data/offset', self.image_len)
0a122b
-                    self.assert_qmp(event, 'data/len', self.image_len)
0a122b
-                    completed = True
0a122b
-
0a122b
-        self.assert_no_active_commit()
0a122b
-        self.vm.shutdown()
0a122b
-
0a122b
+        self.run_commit_test(self.mid_img, self.backing_img)
0a122b
         self.assertEqual(-1, qemu_io('-c', 'read -P 0xab 0 524288', self.backing_img_abs).find("verification failed"))
0a122b
         self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', self.backing_img_abs).find("verification failed"))
0a122b
 
0a122b
@@ -234,10 +223,9 @@ class TestRelativePaths(ImageCommitTestCase):
0a122b
         self.assert_qmp(result, 'error/desc', 'Base \'badfile\' not found')
0a122b
 
0a122b
     def test_top_is_active(self):
0a122b
-        self.assert_no_active_commit()
0a122b
-        result = self.vm.qmp('block-commit', device='drive0', top='%s' % self.test_img, base='%s' % self.backing_img)
0a122b
-        self.assert_qmp(result, 'error/class', 'GenericError')
0a122b
-        self.assert_qmp(result, 'error/desc', 'Top image as the active layer is currently unsupported')
0a122b
+        self.run_commit_test(self.test_img, self.backing_img)
0a122b
+        self.assertEqual(-1, qemu_io('-c', 'read -P 0xab 0 524288', self.backing_img_abs).find("verification failed"))
0a122b
+        self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', self.backing_img_abs).find("verification failed"))
0a122b
 
0a122b
     def test_top_and_base_reversed(self):
0a122b
         self.assert_no_active_commit()
0a122b
@@ -253,6 +241,8 @@ class TestSetSpeed(ImageCommitTestCase):
0a122b
         qemu_img('create', backing_img, str(TestSetSpeed.image_len))
0a122b
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, mid_img)
0a122b
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % mid_img, test_img)
0a122b
+        qemu_io('-c', 'write -P 0x1 0 512', test_img)
0a122b
+        qemu_io('-c', 'write -P 0xef 524288 524288', mid_img)
0a122b
         self.vm = iotests.VM().add_drive(test_img)
0a122b
         self.vm.launch()
0a122b
 
0a122b
-- 
0a122b
1.7.1
0a122b