hw: megasas: consider 'iov_count=0' is an error in megasas_map_sgl
[qemu/ar7.git] / tests / qemu-iotests / 152
blobcc2ea09654fbc87d641eae4d7cb069acddb7f334
1 #!/usr/bin/env python3
3 # Tests for drive-mirror with source size unaligned to granularity
5 # Copyright (C) 2016 Red Hat, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 import os
22 import iotests
23 from iotests import qemu_img
25 test_img = os.path.join(iotests.test_dir, 'test.img')
26 target_img = os.path.join(iotests.test_dir, 'target.img')
28 class TestUnaligned(iotests.QMPTestCase):
29     def setUp(self):
30         qemu_img('create', '-f', iotests.imgfmt, test_img, '512')
31         self.vm = iotests.VM().add_drive(test_img)
32         self.vm.launch()
34     def tearDown(self):
35         self.vm.shutdown()
36         os.remove(test_img)
37         try:
38             os.remove(target_img)
39         except OSError:
40             pass
42     def test_unaligned(self):
43         result = self.vm.qmp('drive-mirror', device='drive0', sync='full',
44                              granularity=65536, target=target_img)
45         self.complete_and_wait()
46         self.vm.shutdown()
47         self.assertEqual(iotests.image_size(test_img), iotests.image_size(target_img),
48                          "Target size doesn't match source when granularity when unaligend")
50     def test_unaligned_with_update(self):
51         result = self.vm.qmp('drive-mirror', device='drive0', sync='full',
52                              granularity=65536, target=target_img)
53         self.wait_ready()
54         self.vm.hmp_qemu_io('drive0', 'write 0 512')
55         self.complete_and_wait(wait_ready=False)
56         self.vm.shutdown()
57         self.assertEqual(iotests.image_size(test_img), iotests.image_size(target_img),
58                          "Target size doesn't match source when granularity when unaligend")
61 if __name__ == '__main__':
62     iotests.main(supported_fmts=['raw', 'qcow2'],
63                  supported_protocols=['file'])