1 # *-*- Mode: Python -*-*
3 # This file is a stress test of supported qapi constructs that must
4 # parse and compile correctly.
10 # Some text foo with *strong* and _emphasis_
37 # -> { "execute": ... }
38 # <- { "return": ... }
44 { 'struct': 'TestStruct',
45 'data': { 'integer': 'int', 'boolean': 'bool', 'string': 'str' } }
51 { 'struct': 'NestedEnumsOne',
52 'data': { 'enum1': 'EnumOne', # Intentional forward reference
53 '*enum2': 'EnumOne', 'enum3': 'EnumOne', '*enum4': 'EnumOne' } }
57 # An empty enum, although unusual, is currently acceptable
59 { 'enum': 'MyEnum', 'data': [ ] }
63 # Likewise for an empty struct, including an empty base
65 { 'struct': 'Empty1', 'data': { } }
69 { 'struct': 'Empty2', 'base': 'Empty1', 'data': { } }
74 { 'command': 'user_def_cmd0', 'data': 'Empty2', 'returns': 'Empty2' }
78 # for testing override of default naming heuristic
81 'prefix': 'QENUM_TWO',
82 'data': [ 'value1', 'value2' ] }
86 # for testing nested structs
88 { 'struct': 'UserDefOne',
89 'base': 'UserDefZero', # intentional forward reference
90 'data': { 'string': 'str',
91 '*enum1': 'EnumOne' } } # intentional forward reference
97 'data': [ 'value1', 'value2', 'value3' ] }
102 { 'struct': 'UserDefZero',
103 'data': { 'integer': 'int' } }
106 # @UserDefTwoDictDict:
108 { 'struct': 'UserDefTwoDictDict',
109 'data': { 'userdef': 'UserDefOne', 'string': 'str' } }
114 { 'struct': 'UserDefTwoDict',
115 'data': { 'string1': 'str',
116 'dict2': 'UserDefTwoDictDict',
117 '*dict3': 'UserDefTwoDictDict' } }
122 { 'struct': 'UserDefTwo',
123 'data': { 'string0': 'str',
124 'dict1': 'UserDefTwoDict' } }
128 # dummy struct to force generation of array types not otherwise mentioned
130 { 'struct': 'ForceArrays',
131 'data': { 'unused1':['UserDefOne'], 'unused2':['UserDefTwo'],
132 'unused3':['TestStruct'] } }
137 # Among other things, test that a name collision between branches does
138 # not cause any problems (since only one branch can be in use at a time),
139 # by intentionally using two branches that both have a C member 'a_b'
141 { 'struct': 'UserDefA',
142 'data': { 'boolean': 'bool', '*a_b': 'int' } }
147 { 'struct': 'UserDefB',
148 'data': { 'intb': 'int', '*a-b': 'bool' } }
153 { 'union': 'UserDefFlatUnion',
154 'base': 'UserDefUnionBase', # intentional forward reference
155 'discriminator': 'enum1',
156 'data': { 'value1' : 'UserDefA',
157 'value2' : 'UserDefB',
158 'value3' : 'UserDefB' } }
163 { 'struct': 'UserDefUnionBase',
164 'base': 'UserDefZero',
165 'data': { 'string': 'str', 'enum1': 'EnumOne' } }
168 # @UserDefFlatUnion2:
169 # this variant of UserDefFlatUnion defaults to a union that uses members with
170 # allocated types to test corner cases in the cleanup/dealloc visitor
172 { 'union': 'UserDefFlatUnion2',
173 'base': { '*integer': 'int', 'string': 'str', 'enum1': 'QEnumTwo' },
174 'discriminator': 'enum1',
175 'data': { 'value1' : 'UserDefC', # intentional forward reference
176 'value2' : 'UserDefB' } }
181 { 'struct': 'WrapAlternate',
182 'data': { 'alt': 'UserDefAlternate' } }
186 { 'alternate': 'UserDefAlternate',
187 'data': { 'udfu': 'UserDefFlatUnion', 's': 'str', 'i': 'int' } }
192 { 'struct': 'UserDefC',
193 'data': { 'string1': 'str', 'string2': 'str' } }
195 # for testing use of 'number' within alternates
199 { 'alternate': 'AltStrBool', 'data': { 's': 'str', 'b': 'bool' } }
203 { 'alternate': 'AltStrNum', 'data': { 's': 'str', 'n': 'number' } }
207 { 'alternate': 'AltNumStr', 'data': { 'n': 'number', 's': 'str' } }
211 { 'alternate': 'AltStrInt', 'data': { 's': 'str', 'i': 'int' } }
215 { 'alternate': 'AltIntNum', 'data': { 'i': 'int', 'n': 'number' } }
219 { 'alternate': 'AltNumInt', 'data': { 'n': 'number', 'i': 'int' } }
222 # @UserDefNativeListUnion:
223 # for testing native lists
225 { 'union': 'UserDefNativeListUnion',
226 'data': { 'integer': ['int'],
235 'number': ['number'],
245 { 'command': 'user_def_cmd', 'data': {} }
249 { 'command': 'user_def_cmd1', 'data': {'ud1a': 'UserDefOne'} }
253 { 'command': 'user_def_cmd2',
254 'data': {'ud1a': 'UserDefOne', '*ud1b': 'UserDefOne'},
255 'returns': 'UserDefTwo' }
264 # @guest-get-time body
267 # @b: #optional integer
269 # Returns: returns something
273 # -> { "execute": "guest-get-time", ... }
274 # <- { "return": "42" }
278 # Returning a non-dictionary requires a name from the whitelist
279 { 'command': 'guest-get-time', 'data': {'a': 'int', '*b': 'int' },
284 { 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' }
288 { 'command': 'boxed-struct', 'boxed': true, 'data': 'UserDefZero' }
292 { 'command': 'boxed-union', 'data': 'UserDefNativeListUnion', 'boxed': true }
297 # For testing integer range flattening in opts-visitor. The following schema
298 # corresponds to the option format:
300 # -userdef i64=3-6,i64=-5--1,u64=2,u16=1,u16=7-12
302 # For simplicity, this example doesn't use [type=]discriminator nor optargs
303 # specific to discriminator values.
305 { 'struct': 'UserDefOptions',
308 '*u64' : [ 'uint64' ],
309 '*u16' : [ 'uint16' ],
311 '*u64x': 'uint64' } }
317 { 'struct': 'EventStructOne',
318 'data': { 'struct1': 'UserDefOne', 'string': 'str', '*enum2': 'EnumOne' } }
323 { 'event': 'EVENT_A' }
327 { 'event': 'EVENT_B',
332 { 'event': 'EVENT_C',
333 'data': { '*a': 'int', '*b': 'UserDefOne', 'c': 'str' } }
337 { 'event': 'EVENT_D',
338 'data': { 'a' : 'EventStructOne', 'b' : 'str', '*c': 'str', '*enum3': 'EnumOne' } }
342 { 'event': 'EVENT_E', 'boxed': true, 'data': 'UserDefZero' }
346 { 'event': 'EVENT_F', 'boxed': true, 'data': 'UserDefAlternate' }
348 # test that we correctly compile downstream extensions, as well as munge
351 # @__org.qemu_x-Enum:
353 { 'enum': '__org.qemu_x-Enum', 'data': [ '__org.qemu_x-value' ] }
355 # @__org.qemu_x-Base:
357 { 'struct': '__org.qemu_x-Base',
358 'data': { '__org.qemu_x-member1': '__org.qemu_x-Enum' } }
360 # @__org.qemu_x-Struct:
362 { 'struct': '__org.qemu_x-Struct', 'base': '__org.qemu_x-Base',
363 'data': { '__org.qemu_x-member2': 'str', '*wchar-t': 'int' } }
365 # @__org.qemu_x-Union1:
367 { 'union': '__org.qemu_x-Union1', 'data': { '__org.qemu_x-branch': 'str' } }
369 # @__org.qemu_x-Struct2:
371 { 'struct': '__org.qemu_x-Struct2',
372 'data': { 'array': ['__org.qemu_x-Union1'] } }
374 # @__org.qemu_x-Union2:
376 { 'union': '__org.qemu_x-Union2', 'base': '__org.qemu_x-Base',
377 'discriminator': '__org.qemu_x-member1',
378 'data': { '__org.qemu_x-value': '__org.qemu_x-Struct2' } }
382 { 'alternate': '__org.qemu_x-Alt',
383 'data': { '__org.qemu_x-branch': 'str', 'b': '__org.qemu_x-Base' } }
385 # @__ORG.QEMU_X-EVENT:
387 { 'event': '__ORG.QEMU_X-EVENT', 'data': '__org.qemu_x-Struct' }
389 # @__org.qemu_x-command:
391 { 'command': '__org.qemu_x-command',
392 'data': { 'a': ['__org.qemu_x-Enum'], 'b': ['__org.qemu_x-Struct'],
393 'c': '__org.qemu_x-Union2', 'd': '__org.qemu_x-Alt' },
394 'returns': '__org.qemu_x-Union1' }