tcg: Search includes in the parent source directory
[qemu/ar7.git] / tests / qemu-iotests / 266
blobc353cf88ee82f9541658aafdc219a57527977fb0
1 #!/usr/bin/env python
3 # Test VPC and file image creation
5 # Copyright (C) 2019 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 iotests
22 from iotests import imgfmt
25 # Successful image creation (defaults)
26 def implicit_defaults(vm, file_path):
27 iotests.log("=== Successful image creation (defaults) ===")
28 iotests.log("")
30 # 8 heads, 964 cyls/head, 17 secs/cyl
31 # (Close to 64 MB)
32 size = 8 * 964 * 17 * 512
34 vm.blockdev_create({ 'driver': imgfmt,
35 'file': 'protocol-node',
36 'size': size })
39 # Successful image creation (explicit defaults)
40 def explicit_defaults(vm, file_path):
41 iotests.log("=== Successful image creation (explicit defaults) ===")
42 iotests.log("")
44 # 16 heads, 964 cyls/head, 17 secs/cyl
45 # (Close to 128 MB)
46 size = 16 * 964 * 17 * 512
48 vm.blockdev_create({ 'driver': imgfmt,
49 'file': 'protocol-node',
50 'size': size,
51 'subformat': 'dynamic',
52 'force-size': False })
55 # Successful image creation (non-default options)
56 def non_defaults(vm, file_path):
57 iotests.log("=== Successful image creation (non-default options) ===")
58 iotests.log("")
60 # Not representable in CHS (fine with force-size=True)
61 size = 1048576
63 vm.blockdev_create({ 'driver': imgfmt,
64 'file': 'protocol-node',
65 'size': size,
66 'subformat': 'fixed',
67 'force-size': True })
70 # Size not representable in CHS with force-size=False
71 def non_chs_size_without_force(vm, file_path):
72 iotests.log("=== Size not representable in CHS ===")
73 iotests.log("")
75 # Not representable in CHS (will not work with force-size=False)
76 size = 1048576
78 vm.blockdev_create({ 'driver': imgfmt,
79 'file': 'protocol-node',
80 'size': size,
81 'force-size': False })
84 # Zero size
85 def zero_size(vm, file_path):
86 iotests.log("=== Zero size===")
87 iotests.log("")
89 vm.blockdev_create({ 'driver': imgfmt,
90 'file': 'protocol-node',
91 'size': 0 })
94 # Maximum CHS size
95 def maximum_chs_size(vm, file_path):
96 iotests.log("=== Maximum CHS size===")
97 iotests.log("")
99 vm.blockdev_create({ 'driver': imgfmt,
100 'file': 'protocol-node',
101 'size': 16 * 65535 * 255 * 512 })
104 # Actual maximum size
105 def maximum_size(vm, file_path):
106 iotests.log("=== Actual maximum size===")
107 iotests.log("")
109 vm.blockdev_create({ 'driver': imgfmt,
110 'file': 'protocol-node',
111 'size': 0xff000000 * 512,
112 'force-size': True })
115 def main():
116 for test_func in [implicit_defaults, explicit_defaults, non_defaults,
117 non_chs_size_without_force, zero_size, maximum_chs_size,
118 maximum_size]:
120 with iotests.FilePath('t.vpc') as file_path, \
121 iotests.VM() as vm:
123 vm.launch()
125 iotests.log('--- Creating empty file ---')
126 vm.blockdev_create({ 'driver': 'file',
127 'filename': file_path,
128 'size': 0 })
130 vm.qmp_log('blockdev-add', driver='file', filename=file_path,
131 node_name='protocol-node',
132 filters=[iotests.filter_qmp_testfiles])
133 iotests.log('')
135 print_info = test_func(vm, file_path)
136 iotests.log('')
138 vm.shutdown()
139 iotests.img_info_log(file_path)
142 iotests.script_main(main,
143 supported_fmts=['vpc'],
144 supported_protocols=['file'])