]> git.proxmox.com Git - mirror_qemu.git/blob - tests/qapi-schema/qapi-schema-test.json
qapi: add qapi2texi script
[mirror_qemu.git] / tests / qapi-schema / qapi-schema-test.json
1 # *-*- Mode: Python -*-*
2
3 # This file is a stress test of supported qapi constructs that must
4 # parse and compile correctly.
5
6 ##
7 # = Section
8 # == subsection
9 #
10 # Some text foo with *strong* and _emphasis_
11 # 1. with a list
12 # 2. like that @foo
13 #
14 # And some code:
15 # | $ echo foo
16 # | -> do this
17 # | <- get that
18 #
19 # Note: is not a meta
20 ##
21
22 ##
23 # @TestStruct:
24 #
25 # body with @var
26 #
27 # @integer: foo
28 # blah
29 #
30 # bao
31 #
32 # @boolean: bar
33 # @string: baz
34 #
35 # Example:
36 #
37 # -> { "execute": ... }
38 # <- { "return": ... }
39 #
40 # Since: 2.3
41 # Note: a note
42 #
43 ##
44 { 'struct': 'TestStruct',
45 'data': { 'integer': 'int', 'boolean': 'bool', 'string': 'str' } }
46
47 ##
48 # @NestedEnumsOne:
49 # for testing enums
50 ##
51 { 'struct': 'NestedEnumsOne',
52 'data': { 'enum1': 'EnumOne', # Intentional forward reference
53 '*enum2': 'EnumOne', 'enum3': 'EnumOne', '*enum4': 'EnumOne' } }
54
55 ##
56 # @MyEnum:
57 # An empty enum, although unusual, is currently acceptable
58 ##
59 { 'enum': 'MyEnum', 'data': [ ] }
60
61 ##
62 # @Empty1:
63 # Likewise for an empty struct, including an empty base
64 ##
65 { 'struct': 'Empty1', 'data': { } }
66 ##
67 # @Empty2:
68 ##
69 { 'struct': 'Empty2', 'base': 'Empty1', 'data': { } }
70
71 ##
72 # @user_def_cmd0:
73 ##
74 { 'command': 'user_def_cmd0', 'data': 'Empty2', 'returns': 'Empty2' }
75
76 ##
77 # @QEnumTwo:
78 # for testing override of default naming heuristic
79 ##
80 { 'enum': 'QEnumTwo',
81 'prefix': 'QENUM_TWO',
82 'data': [ 'value1', 'value2' ] }
83
84 ##
85 # @UserDefOne:
86 # for testing nested structs
87 ##
88 { 'struct': 'UserDefOne',
89 'base': 'UserDefZero', # intentional forward reference
90 'data': { 'string': 'str',
91 '*enum1': 'EnumOne' } } # intentional forward reference
92
93 ##
94 # @EnumOne:
95 ##
96 { 'enum': 'EnumOne',
97 'data': [ 'value1', 'value2', 'value3' ] }
98
99 ##
100 # @UserDefZero:
101 ##
102 { 'struct': 'UserDefZero',
103 'data': { 'integer': 'int' } }
104
105 ##
106 # @UserDefTwoDictDict:
107 ##
108 { 'struct': 'UserDefTwoDictDict',
109 'data': { 'userdef': 'UserDefOne', 'string': 'str' } }
110
111 ##
112 # @UserDefTwoDict:
113 ##
114 { 'struct': 'UserDefTwoDict',
115 'data': { 'string1': 'str',
116 'dict2': 'UserDefTwoDictDict',
117 '*dict3': 'UserDefTwoDictDict' } }
118
119 ##
120 # @UserDefTwo:
121 ##
122 { 'struct': 'UserDefTwo',
123 'data': { 'string0': 'str',
124 'dict1': 'UserDefTwoDict' } }
125
126 ##
127 # @ForceArrays:
128 # dummy struct to force generation of array types not otherwise mentioned
129 ##
130 { 'struct': 'ForceArrays',
131 'data': { 'unused1':['UserDefOne'], 'unused2':['UserDefTwo'],
132 'unused3':['TestStruct'] } }
133
134 ##
135 # @UserDefA:
136 # for testing unions
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'
140 ##
141 { 'struct': 'UserDefA',
142 'data': { 'boolean': 'bool', '*a_b': 'int' } }
143
144 ##
145 # @UserDefB:
146 ##
147 { 'struct': 'UserDefB',
148 'data': { 'intb': 'int', '*a-b': 'bool' } }
149
150 ##
151 # @UserDefFlatUnion:
152 ##
153 { 'union': 'UserDefFlatUnion',
154 'base': 'UserDefUnionBase', # intentional forward reference
155 'discriminator': 'enum1',
156 'data': { 'value1' : 'UserDefA',
157 'value2' : 'UserDefB',
158 'value3' : 'UserDefB' } }
159
160 ##
161 # @UserDefUnionBase:
162 ##
163 { 'struct': 'UserDefUnionBase',
164 'base': 'UserDefZero',
165 'data': { 'string': 'str', 'enum1': 'EnumOne' } }
166
167 ##
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
171 ##
172 { 'union': 'UserDefFlatUnion2',
173 'base': { '*integer': 'int', 'string': 'str', 'enum1': 'QEnumTwo' },
174 'discriminator': 'enum1',
175 'data': { 'value1' : 'UserDefC', # intentional forward reference
176 'value2' : 'UserDefB' } }
177
178 ##
179 # @WrapAlternate:
180 ##
181 { 'struct': 'WrapAlternate',
182 'data': { 'alt': 'UserDefAlternate' } }
183 ##
184 # @UserDefAlternate:
185 ##
186 { 'alternate': 'UserDefAlternate',
187 'data': { 'udfu': 'UserDefFlatUnion', 's': 'str', 'i': 'int' } }
188
189 ##
190 # @UserDefC:
191 ##
192 { 'struct': 'UserDefC',
193 'data': { 'string1': 'str', 'string2': 'str' } }
194
195 # for testing use of 'number' within alternates
196 ##
197 # @AltStrBool:
198 ##
199 { 'alternate': 'AltStrBool', 'data': { 's': 'str', 'b': 'bool' } }
200 ##
201 # @AltStrNum:
202 ##
203 { 'alternate': 'AltStrNum', 'data': { 's': 'str', 'n': 'number' } }
204 ##
205 # @AltNumStr:
206 ##
207 { 'alternate': 'AltNumStr', 'data': { 'n': 'number', 's': 'str' } }
208 ##
209 # @AltStrInt:
210 ##
211 { 'alternate': 'AltStrInt', 'data': { 's': 'str', 'i': 'int' } }
212 ##
213 # @AltIntNum:
214 ##
215 { 'alternate': 'AltIntNum', 'data': { 'i': 'int', 'n': 'number' } }
216 ##
217 # @AltNumInt:
218 ##
219 { 'alternate': 'AltNumInt', 'data': { 'n': 'number', 'i': 'int' } }
220
221 ##
222 # @UserDefNativeListUnion:
223 # for testing native lists
224 ##
225 { 'union': 'UserDefNativeListUnion',
226 'data': { 'integer': ['int'],
227 's8': ['int8'],
228 's16': ['int16'],
229 's32': ['int32'],
230 's64': ['int64'],
231 'u8': ['uint8'],
232 'u16': ['uint16'],
233 'u32': ['uint32'],
234 'u64': ['uint64'],
235 'number': ['number'],
236 'boolean': ['bool'],
237 'string': ['str'],
238 'sizes': ['size'],
239 'any': ['any'] } }
240
241 # testing commands
242 ##
243 # @user_def_cmd:
244 ##
245 { 'command': 'user_def_cmd', 'data': {} }
246 ##
247 # @user_def_cmd1:
248 ##
249 { 'command': 'user_def_cmd1', 'data': {'ud1a': 'UserDefOne'} }
250 ##
251 # @user_def_cmd2:
252 ##
253 { 'command': 'user_def_cmd2',
254 'data': {'ud1a': 'UserDefOne', '*ud1b': 'UserDefOne'},
255 'returns': 'UserDefTwo' }
256
257 ##
258 # Another comment
259 ##
260
261 ##
262 # @guest-get-time:
263 #
264 # @guest-get-time body
265 #
266 # @a: an integer
267 # @b: #optional integer
268 #
269 # Returns: returns something
270 #
271 # Example:
272 #
273 # -> { "execute": "guest-get-time", ... }
274 # <- { "return": "42" }
275 #
276 ##
277
278 # Returning a non-dictionary requires a name from the whitelist
279 { 'command': 'guest-get-time', 'data': {'a': 'int', '*b': 'int' },
280 'returns': 'int' }
281 ##
282 # @guest-sync:
283 ##
284 { 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' }
285 ##
286 # @boxed-struct:
287 ##
288 { 'command': 'boxed-struct', 'boxed': true, 'data': 'UserDefZero' }
289 ##
290 # @boxed-union:
291 ##
292 { 'command': 'boxed-union', 'data': 'UserDefNativeListUnion', 'boxed': true }
293
294 ##
295 # @UserDefOptions:
296 #
297 # For testing integer range flattening in opts-visitor. The following schema
298 # corresponds to the option format:
299 #
300 # -userdef i64=3-6,i64=-5--1,u64=2,u16=1,u16=7-12
301 #
302 # For simplicity, this example doesn't use [type=]discriminator nor optargs
303 # specific to discriminator values.
304 ##
305 { 'struct': 'UserDefOptions',
306 'data': {
307 '*i64' : [ 'int' ],
308 '*u64' : [ 'uint64' ],
309 '*u16' : [ 'uint16' ],
310 '*i64x': 'int' ,
311 '*u64x': 'uint64' } }
312
313 # testing event
314 ##
315 # @EventStructOne:
316 ##
317 { 'struct': 'EventStructOne',
318 'data': { 'struct1': 'UserDefOne', 'string': 'str', '*enum2': 'EnumOne' } }
319
320 ##
321 # @EVENT_A:
322 ##
323 { 'event': 'EVENT_A' }
324 ##
325 # @EVENT_B:
326 ##
327 { 'event': 'EVENT_B',
328 'data': { } }
329 ##
330 # @EVENT_C:
331 ##
332 { 'event': 'EVENT_C',
333 'data': { '*a': 'int', '*b': 'UserDefOne', 'c': 'str' } }
334 ##
335 # @EVENT_D:
336 ##
337 { 'event': 'EVENT_D',
338 'data': { 'a' : 'EventStructOne', 'b' : 'str', '*c': 'str', '*enum3': 'EnumOne' } }
339 ##
340 # @EVENT_E:
341 ##
342 { 'event': 'EVENT_E', 'boxed': true, 'data': 'UserDefZero' }
343 ##
344 # @EVENT_F:
345 ##
346 { 'event': 'EVENT_F', 'boxed': true, 'data': 'UserDefAlternate' }
347
348 # test that we correctly compile downstream extensions, as well as munge
349 # ticklish names
350 ##
351 # @__org.qemu_x-Enum:
352 ##
353 { 'enum': '__org.qemu_x-Enum', 'data': [ '__org.qemu_x-value' ] }
354 ##
355 # @__org.qemu_x-Base:
356 ##
357 { 'struct': '__org.qemu_x-Base',
358 'data': { '__org.qemu_x-member1': '__org.qemu_x-Enum' } }
359 ##
360 # @__org.qemu_x-Struct:
361 ##
362 { 'struct': '__org.qemu_x-Struct', 'base': '__org.qemu_x-Base',
363 'data': { '__org.qemu_x-member2': 'str', '*wchar-t': 'int' } }
364 ##
365 # @__org.qemu_x-Union1:
366 ##
367 { 'union': '__org.qemu_x-Union1', 'data': { '__org.qemu_x-branch': 'str' } }
368 ##
369 # @__org.qemu_x-Struct2:
370 ##
371 { 'struct': '__org.qemu_x-Struct2',
372 'data': { 'array': ['__org.qemu_x-Union1'] } }
373 ##
374 # @__org.qemu_x-Union2:
375 ##
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' } }
379 ##
380 # @__org.qemu_x-Alt:
381 ##
382 { 'alternate': '__org.qemu_x-Alt',
383 'data': { '__org.qemu_x-branch': 'str', 'b': '__org.qemu_x-Base' } }
384 ##
385 # @__ORG.QEMU_X-EVENT:
386 ##
387 { 'event': '__ORG.QEMU_X-EVENT', 'data': '__org.qemu_x-Struct' }
388 ##
389 # @__org.qemu_x-command:
390 ##
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' }