vt82c686: Make vt82c686b-pm an abstract base class and add vt8231-pm based on it
[qemu/ar7.git] / tests / qemu-iotests / 266
blob71ce81d0df767805bed480592c9967426d8525e5
1 #!/usr/bin/env python3
2 # group: rw quick
4 # Test VPC and file image creation
6 # Copyright (C) 2019 Red Hat, Inc.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 import iotests
23 from iotests import imgfmt
26 # Successful image creation (defaults)
27 def implicit_defaults(vm, file_path):
28     iotests.log("=== Successful image creation (defaults) ===")
29     iotests.log("")
31     # 8 heads, 964 cyls/head, 17 secs/cyl
32     # (Close to 64 MB)
33     size = 8 * 964 * 17 * 512
35     vm.blockdev_create({ 'driver': imgfmt,
36                          'file': 'protocol-node',
37                          'size': size })
40 # Successful image creation (explicit defaults)
41 def explicit_defaults(vm, file_path):
42     iotests.log("=== Successful image creation (explicit defaults) ===")
43     iotests.log("")
45     # 16 heads, 964 cyls/head, 17 secs/cyl
46     # (Close to 128 MB)
47     size = 16 * 964 * 17 * 512
49     vm.blockdev_create({ 'driver': imgfmt,
50                          'file': 'protocol-node',
51                          'size': size,
52                          'subformat': 'dynamic',
53                          'force-size': False })
56 # Successful image creation (non-default options)
57 def non_defaults(vm, file_path):
58     iotests.log("=== Successful image creation (non-default options) ===")
59     iotests.log("")
61     # Not representable in CHS (fine with force-size=True)
62     size = 1048576
64     vm.blockdev_create({ 'driver': imgfmt,
65                          'file': 'protocol-node',
66                          'size': size,
67                          'subformat': 'fixed',
68                          'force-size': True })
71 # Size not representable in CHS with force-size=False
72 def non_chs_size_without_force(vm, file_path):
73     iotests.log("=== Size not representable in CHS ===")
74     iotests.log("")
76     # Not representable in CHS (will not work with force-size=False)
77     size = 1048576
79     vm.blockdev_create({ 'driver': imgfmt,
80                          'file': 'protocol-node',
81                          'size': size,
82                          'force-size': False })
85 # Zero size
86 def zero_size(vm, file_path):
87     iotests.log("=== Zero size===")
88     iotests.log("")
90     vm.blockdev_create({ 'driver': imgfmt,
91                          'file': 'protocol-node',
92                          'size': 0 })
95 # Maximum CHS size
96 def maximum_chs_size(vm, file_path):
97     iotests.log("=== Maximum CHS size===")
98     iotests.log("")
100     vm.blockdev_create({ 'driver': imgfmt,
101                          'file': 'protocol-node',
102                          'size': 16 * 65535 * 255 * 512 })
105 # Actual maximum size
106 def maximum_size(vm, file_path):
107     iotests.log("=== Actual maximum size===")
108     iotests.log("")
110     vm.blockdev_create({ 'driver': imgfmt,
111                          'file': 'protocol-node',
112                          'size': 0xff000000 * 512,
113                          'force-size': True })
116 def main():
117     for test_func in [implicit_defaults, explicit_defaults, non_defaults,
118                       non_chs_size_without_force, zero_size, maximum_chs_size,
119                       maximum_size]:
121         with iotests.FilePath('t.vpc') as file_path, \
122              iotests.VM() as vm:
124             vm.launch()
126             iotests.log('--- Creating empty file ---')
127             vm.blockdev_create({ 'driver': 'file',
128                                  'filename': file_path,
129                                  'size': 0 })
131             vm.qmp_log('blockdev-add', driver='file', filename=file_path,
132                        node_name='protocol-node',
133                        filters=[iotests.filter_qmp_testfiles])
134             iotests.log('')
136             print_info = test_func(vm, file_path)
137             iotests.log('')
139             vm.shutdown()
140             iotests.img_info_log(file_path)
143 iotests.script_main(main,
144                     supported_fmts=['vpc'],
145                     supported_protocols=['file'])