1 # *-*- Mode: Python -*-*
4 # This file is a stress test of supported qapi constructs that must
5 # parse and compile correctly.
7 # Whitelists to permit QAPI rule violations
9 # Types whose member names may use '_'
10 'member-name-exceptions': [
13 # Commands allowed to return a non-dictionary:
14 'command-returns-exceptions': [
18 { 'struct': 'TestStruct',
19 'data': { 'integer': {'type': 'int'}, 'boolean': 'bool', 'string': 'str' } }
22 { 'struct': 'NestedEnumsOne',
23 'data': { 'enum1': 'EnumOne', # Intentional forward reference
24 '*enum2': 'EnumOne', 'enum3': 'EnumOne', '*enum4': 'EnumOne' } }
26 # An empty enum, although unusual, is currently acceptable
27 { 'enum': 'MyEnum', 'data': [ ] }
29 # Likewise for an empty struct, including an empty base
30 { 'struct': 'Empty1', 'data': { } }
31 { 'struct': 'Empty2', 'base': 'Empty1', 'data': { } }
33 # Likewise for an empty flat union
35 'base': { 'type': 'EnumOne' }, 'discriminator': 'type',
38 { 'command': 'user-def-cmd0', 'data': 'Empty2', 'returns': 'Empty2' }
40 # for testing override of default naming heuristic
42 'prefix': 'QENUM_TWO',
43 'data': [ 'value1', 'value2' ] }
45 # for testing nested structs
46 { 'struct': 'UserDefOne',
47 'base': 'UserDefZero', # intentional forward reference
48 'data': { 'string': 'str',
49 '*enum1': 'EnumOne' } } # intentional forward reference
52 'data': [ 'value1', 'value2', 'value3', 'value4' ] }
54 { 'struct': 'UserDefZero',
55 'data': { 'integer': 'int' } }
57 { 'struct': 'UserDefTwoDictDict',
58 'data': { 'userdef': 'UserDefOne', 'string': 'str' } }
60 { 'struct': 'UserDefTwoDict',
61 'data': { 'string1': 'str',
62 'dict2': 'UserDefTwoDictDict',
63 '*dict3': 'UserDefTwoDictDict' } }
65 { 'struct': 'UserDefTwo',
66 'data': { 'string0': 'str',
67 'dict1': 'UserDefTwoDict' } }
69 { 'struct': 'UserDefThree',
70 'data': { 'string0': 'str' } }
72 # dummy struct to force generation of array types not otherwise mentioned
73 { 'struct': 'ForceArrays',
74 'data': { 'unused1':['UserDefOne'], 'unused2':['UserDefTwo'],
75 'unused3':['TestStruct'] } }
78 # Among other things, test that a name collision between branches does
79 # not cause any problems (since only one branch can be in use at a time),
80 # by intentionally using two branches that both have a C member 'a_b'
81 { 'struct': 'UserDefA',
82 'data': { 'boolean': 'bool', '*a_b': 'int' } }
84 { 'struct': 'UserDefB',
85 'data': { 'intb': 'int', '*a-b': 'bool' } }
87 { 'union': 'UserDefFlatUnion',
88 'base': 'UserDefUnionBase', # intentional forward reference
89 'discriminator': 'enum1',
90 'data': { 'value1' : {'type': 'UserDefA'},
91 'value2' : 'UserDefB',
93 # 'value4' defaults to empty
96 { 'struct': 'UserDefUnionBase',
97 'base': 'UserDefZero',
98 'data': { 'string': 'str', 'enum1': 'EnumOne' } }
100 # this variant of UserDefFlatUnion defaults to a union that uses members with
101 # allocated types to test corner cases in the cleanup/dealloc visitor
102 { 'union': 'UserDefFlatUnion2',
103 'base': { '*integer': 'int', 'string': 'str', 'enum1': 'QEnumTwo' },
104 'discriminator': 'enum1',
105 'data': { 'value1' : 'UserDefC', # intentional forward reference
106 'value2' : 'UserDefB' } }
108 { 'struct': 'WrapAlternate',
109 'data': { 'alt': 'UserDefAlternate' } }
110 { 'alternate': 'UserDefAlternate',
111 'data': { 'udfu': {'type': 'UserDefFlatUnion'}, 'e': 'EnumOne', 'i': 'int',
114 { 'struct': 'UserDefC',
115 'data': { 'string1': 'str', 'string2': 'str' } }
117 # for testing use of 'number' within alternates
118 { 'alternate': 'AltEnumBool', 'data': { 'e': 'EnumOne', 'b': 'bool' } }
119 { 'alternate': 'AltEnumNum', 'data': { 'e': 'EnumOne', 'n': 'number' } }
120 { 'alternate': 'AltNumEnum', 'data': { 'n': 'number', 'e': 'EnumOne' } }
121 { 'alternate': 'AltEnumInt', 'data': { 'e': 'EnumOne', 'i': 'int' } }
123 # for testing use of 'str' within alternates
124 { 'alternate': 'AltStrObj', 'data': { 's': 'str', 'o': 'TestStruct' } }
127 { 'union': 'UserDefListUnion',
128 'data': { 'integer': ['int'],
137 'number': ['number'],
142 'user': ['Status'] } } # intentional forward ref. to sub-module
144 # for testing sub-modules
145 { 'include': 'include/sub-module.json' }
148 { 'command': 'user-def-cmd', 'data': {} }
149 { 'command': 'user-def-cmd1', 'data': {'ud1a': 'UserDefOne'} }
150 { 'command': 'user-def-cmd2',
151 'data': {'ud1a': {'type': 'UserDefOne'}, '*ud1b': 'UserDefOne'},
152 'returns': 'UserDefTwo' }
154 { 'command': 'cmd-success-response', 'data': {}, 'success-response': false }
155 { 'command': 'coroutine-cmd', 'data': {}, 'coroutine': true }
157 # Returning a non-dictionary requires a name from the whitelist
158 { 'command': 'guest-get-time', 'data': {'a': 'int', '*b': 'int' },
160 { 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' }
161 { 'command': 'boxed-struct', 'boxed': true, 'data': 'UserDefZero' }
162 { 'command': 'boxed-union', 'data': 'UserDefListUnion', 'boxed': true }
163 { 'command': 'boxed-empty', 'boxed': true, 'data': 'Empty1' }
165 # Smoke test on out-of-band and allow-preconfig-test
166 { 'command': 'test-flags-command', 'allow-oob': true, 'allow-preconfig': true }
168 # For testing integer range flattening in opts-visitor. The following schema
169 # corresponds to the option format:
171 # -userdef i64=3-6,i64=-5--1,u64=2,u16=1,u16=7-12
173 # For simplicity, this example doesn't use [type=]discriminator nor optargs
174 # specific to discriminator values.
175 { 'struct': 'UserDefOptions',
178 '*u64' : [ 'uint64' ],
179 '*u16' : [ 'uint16' ],
181 '*u64x': 'uint64' } }
184 { 'struct': 'EventStructOne',
185 'data': { 'struct1': {'type': 'UserDefOne'}, 'string': 'str', '*enum2': 'EnumOne' } }
187 { 'event': 'EVENT_A' }
188 { 'event': 'EVENT_B',
190 { 'event': 'EVENT_C',
191 'data': { '*a': 'int', '*b': 'UserDefOne', 'c': 'str' } }
192 { 'event': 'EVENT_D',
193 'data': { 'a' : 'EventStructOne', 'b' : 'str', '*c': 'str', '*enum3': 'EnumOne' } }
194 { 'event': 'EVENT_E', 'boxed': true, 'data': 'UserDefZero' }
195 { 'event': 'EVENT_F', 'boxed': true, 'data': 'UserDefFlatUnion' }
196 { 'event': 'EVENT_G', 'boxed': true, 'data': 'Empty1' }
198 # test that we correctly compile downstream extensions, as well as munge
200 # also test union and alternate with just one branch
201 { 'enum': '__org.qemu_x-Enum', 'data': [ '__org.qemu_x-value' ] }
202 { 'struct': '__org.qemu_x-Base',
203 'data': { '__org.qemu_x-member1': '__org.qemu_x-Enum' } }
204 { 'struct': '__org.qemu_x-Struct', 'base': '__org.qemu_x-Base',
205 'data': { '__org.qemu_x-member2': 'str', '*wchar-t': 'int' } }
206 { 'union': '__org.qemu_x-Union1', 'data': { '__org.qemu_x-branch': 'str' } }
207 { 'alternate': '__org.qemu_x-Alt1', 'data': { '__org.qemu_x-branch': 'str' } }
208 { 'struct': '__org.qemu_x-Struct2',
209 'data': { 'array': ['__org.qemu_x-Union1'] } }
210 { 'union': '__org.qemu_x-Union2', 'base': '__org.qemu_x-Base',
211 'discriminator': '__org.qemu_x-member1',
212 'data': { '__org.qemu_x-value': '__org.qemu_x-Struct2' } }
213 { 'alternate': '__org.qemu_x-Alt',
214 'data': { '__org.qemu_x-branch': '__org.qemu_x-Base' } }
215 { 'event': '__ORG.QEMU_X-EVENT', 'data': '__org.qemu_x-Struct' }
216 { 'command': '__org.qemu_x-command',
217 'data': { 'a': ['__org.qemu_x-Enum'], 'b': ['__org.qemu_x-Struct'],
218 'c': '__org.qemu_x-Union2', 'd': '__org.qemu_x-Alt' },
219 'returns': '__org.qemu_x-Union1' }
221 # test 'if' condition handling
223 { 'struct': 'TestIfStruct', 'data':
225 'bar': { 'type': 'int', 'if': 'defined(TEST_IF_STRUCT_BAR)'} },
226 'if': 'defined(TEST_IF_STRUCT)' }
228 { 'enum': 'TestIfEnum', 'data':
229 [ 'foo', { 'name' : 'bar', 'if': 'defined(TEST_IF_ENUM_BAR)' } ],
230 'if': 'defined(TEST_IF_ENUM)' }
232 { 'union': 'TestIfUnion', 'data':
233 { 'foo': 'TestStruct',
234 'bar': { 'type': 'str', 'if': 'defined(TEST_IF_UNION_BAR)'} },
235 'if': 'defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)' }
237 { 'command': 'test-if-union-cmd',
238 'data': { 'union-cmd-arg': 'TestIfUnion' },
239 'if': 'defined(TEST_IF_UNION)' }
241 { 'alternate': 'TestIfAlternate', 'data':
243 'bar': { 'type': 'TestStruct', 'if': 'defined(TEST_IF_ALT_BAR)'} },
244 'if': 'defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT)' }
246 { 'command': 'test-if-alternate-cmd',
247 'data': { 'alt-cmd-arg': 'TestIfAlternate' },
248 'if': 'defined(TEST_IF_ALT)' }
250 { 'command': 'test-if-cmd',
252 'foo': 'TestIfStruct',
253 'bar': { 'type': 'TestIfEnum', 'if': 'defined(TEST_IF_CMD_BAR)' } },
254 'returns': 'UserDefThree',
255 'if': ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'] }
257 { 'command': 'test-cmd-return-def-three', 'returns': 'UserDefThree' }
259 { 'event': 'TEST_IF_EVENT', 'data':
260 { 'foo': 'TestIfStruct',
261 'bar': { 'type': ['TestIfEnum'], 'if': 'defined(TEST_IF_EVT_BAR)' } },
262 'if': 'defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)' }
266 { 'struct': 'FeatureStruct0',
267 'data': { 'foo': 'int' },
269 { 'struct': 'FeatureStruct1',
270 'data': { 'foo': { 'type': 'int', 'features': [ 'deprecated' ] } },
271 'features': [ 'feature1' ] }
272 { 'struct': 'FeatureStruct2',
273 'data': { 'foo': 'int' },
274 'features': [ { 'name': 'feature1' } ] }
275 { 'struct': 'FeatureStruct3',
276 'data': { 'foo': 'int' },
277 'features': [ 'feature1', 'feature2' ] }
278 { 'struct': 'FeatureStruct4',
279 'data': { 'namespace-test': 'int' },
280 'features': [ 'namespace-test', 'int', 'name', 'if' ] }
282 { 'struct': 'CondFeatureStruct1',
283 'data': { 'foo': 'int' },
284 'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'} ] }
285 { 'struct': 'CondFeatureStruct2',
286 'data': { 'foo': 'int' },
287 'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'},
288 { 'name': 'feature2', 'if': 'defined(TEST_IF_FEATURE_2)'} ] }
289 { 'struct': 'CondFeatureStruct3',
290 'data': { 'foo': 'int' },
291 'features': [ { 'name': 'feature1', 'if': [ 'defined(TEST_IF_COND_1)',
292 'defined(TEST_IF_COND_2)'] } ] }
294 { 'enum': 'FeatureEnum1',
295 'data': [ 'eins', 'zwei', 'drei' ],
296 'features': [ 'feature1' ] }
298 { 'union': 'FeatureUnion1',
299 'base': { 'tag': 'FeatureEnum1' },
300 'discriminator': 'tag',
301 'data': { 'eins': 'FeatureStruct1' },
302 'features': [ 'feature1' ] }
304 { 'alternate': 'FeatureAlternate1',
305 'data': { 'eins': 'FeatureStruct1' },
306 'features': [ 'feature1' ] }
308 { 'command': 'test-features0',
309 'data': { '*fs0': 'FeatureStruct0',
310 '*fs1': 'FeatureStruct1',
311 '*fs2': 'FeatureStruct2',
312 '*fs3': 'FeatureStruct3',
313 '*fs4': 'FeatureStruct4',
314 '*cfs1': 'CondFeatureStruct1',
315 '*cfs2': 'CondFeatureStruct2',
316 '*cfs3': 'CondFeatureStruct3' },
317 'returns': 'FeatureStruct1',
320 { 'command': 'test-command-features1',
321 'features': [ 'deprecated' ] }
322 { 'command': 'test-command-features3',
323 'features': [ 'feature1', 'feature2' ] }
325 { 'command': 'test-command-cond-features1',
326 'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'} ] }
327 { 'command': 'test-command-cond-features2',
328 'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'},
329 { 'name': 'feature2', 'if': 'defined(TEST_IF_FEATURE_2)'} ] }
330 { 'command': 'test-command-cond-features3',
331 'features': [ { 'name': 'feature1', 'if': [ 'defined(TEST_IF_COND_1)',
332 'defined(TEST_IF_COND_2)'] } ] }
334 { 'event': 'TEST_EVENT_FEATURES0',
335 'data': 'FeatureStruct1' }
337 { 'event': 'TEST_EVENT_FEATURES1',
338 'features': [ 'deprecated' ] }