s390x/tcg: Fix VECTOR MULTIPLY LOGICAL ODD
[qemu/ar7.git] / tests / qapi-schema / qapi-schema-test.json
blob75c42eb0e3e9eb122c452ed2e9c520dcbd76051f
1 # *-*- Mode: Python -*-*
3 # This file is a stress test of supported qapi constructs that must
4 # parse and compile correctly.
6 # Whitelists to permit QAPI rule violations
7 { 'pragma': {
8     # Commands allowed to return a non-dictionary:
9     'returns-whitelist': [
10         'guest-get-time',
11         'guest-sync' ] } }
13 { 'struct': 'TestStruct',
14   'data': { 'integer': {'type': 'int'}, 'boolean': 'bool', 'string': 'str' } }
16 # for testing enums
17 { 'struct': 'NestedEnumsOne',
18   'data': { 'enum1': 'EnumOne',   # Intentional forward reference
19             '*enum2': 'EnumOne', 'enum3': 'EnumOne', '*enum4': 'EnumOne' } }
21 # An empty enum, although unusual, is currently acceptable
22 { 'enum': 'MyEnum', 'data': [ ] }
24 # Likewise for an empty struct, including an empty base
25 { 'struct': 'Empty1', 'data': { } }
26 { 'struct': 'Empty2', 'base': 'Empty1', 'data': { } }
28 # Likewise for an empty flat union
29 { 'union': 'Union',
30   'base': { 'type': 'EnumOne' }, 'discriminator': 'type',
31   'data': { } }
33 { 'command': 'user_def_cmd0', 'data': 'Empty2', 'returns': 'Empty2' }
35 # for testing override of default naming heuristic
36 { 'enum': 'QEnumTwo',
37   'prefix': 'QENUM_TWO',
38   'data': [ 'value1', 'value2' ] }
40 # for testing nested structs
41 { 'struct': 'UserDefOne',
42   'base': 'UserDefZero',        # intentional forward reference
43   'data': { 'string': 'str',
44             '*enum1': 'EnumOne' } }   # intentional forward reference
46 { 'enum': 'EnumOne',
47   'data': [ 'value1', 'value2', 'value3', 'value4' ] }
49 { 'struct': 'UserDefZero',
50   'data': { 'integer': 'int' } }
52 { 'struct': 'UserDefTwoDictDict',
53   'data': { 'userdef': 'UserDefOne', 'string': 'str' } }
55 { 'struct': 'UserDefTwoDict',
56   'data': { 'string1': 'str',
57             'dict2': 'UserDefTwoDictDict',
58             '*dict3': 'UserDefTwoDictDict' } }
60 { 'struct': 'UserDefTwo',
61   'data': { 'string0': 'str',
62             'dict1': 'UserDefTwoDict' } }
64 { 'struct': 'UserDefThree',
65   'data': { 'string0': 'str' } }
67 # dummy struct to force generation of array types not otherwise mentioned
68 { 'struct': 'ForceArrays',
69   'data': { 'unused1':['UserDefOne'], 'unused2':['UserDefTwo'],
70             'unused3':['TestStruct'] } }
72 # for testing unions
73 # Among other things, test that a name collision between branches does
74 # not cause any problems (since only one branch can be in use at a time),
75 # by intentionally using two branches that both have a C member 'a_b'
76 { 'struct': 'UserDefA',
77   'data': { 'boolean': 'bool', '*a_b': 'int' } }
79 { 'struct': 'UserDefB',
80   'data': { 'intb': 'int', '*a-b': 'bool' } }
82 { 'union': 'UserDefFlatUnion',
83   'base': 'UserDefUnionBase',   # intentional forward reference
84   'discriminator': 'enum1',
85   'data': { 'value1' : {'type': 'UserDefA'},
86             'value2' : 'UserDefB',
87             'value3' : 'UserDefB'
88             # 'value4' defaults to empty
89   } }
91 { 'struct': 'UserDefUnionBase',
92   'base': 'UserDefZero',
93   'data': { 'string': 'str', 'enum1': 'EnumOne' } }
95 # this variant of UserDefFlatUnion defaults to a union that uses members with
96 # allocated types to test corner cases in the cleanup/dealloc visitor
97 { 'union': 'UserDefFlatUnion2',
98   'base': { '*integer': 'int', 'string': 'str', 'enum1': 'QEnumTwo' },
99   'discriminator': 'enum1',
100   'data': { 'value1' : 'UserDefC', # intentional forward reference
101             'value2' : 'UserDefB' } }
103 { 'struct': 'WrapAlternate',
104   'data': { 'alt': 'UserDefAlternate' } }
105 { 'alternate': 'UserDefAlternate',
106   'data': { 'udfu': {'type': 'UserDefFlatUnion'}, 'e': 'EnumOne', 'i': 'int',
107             'n': 'null' } }
109 { 'struct': 'UserDefC',
110   'data': { 'string1': 'str', 'string2': 'str' } }
112 # for testing use of 'number' within alternates
113 { 'alternate': 'AltEnumBool', 'data': { 'e': 'EnumOne', 'b': 'bool' } }
114 { 'alternate': 'AltEnumNum', 'data': { 'e': 'EnumOne', 'n': 'number' } }
115 { 'alternate': 'AltNumEnum', 'data': { 'n': 'number', 'e': 'EnumOne' } }
116 { 'alternate': 'AltEnumInt', 'data': { 'e': 'EnumOne', 'i': 'int' } }
118 # for testing use of 'str' within alternates
119 { 'alternate': 'AltStrObj', 'data': { 's': 'str', 'o': 'TestStruct' } }
121 # for testing lists
122 { 'union': 'UserDefListUnion',
123   'data': { 'integer': ['int'],
124             's8': ['int8'],
125             's16': ['int16'],
126             's32': ['int32'],
127             's64': ['int64'],
128             'u8': ['uint8'],
129             'u16': ['uint16'],
130             'u32': ['uint32'],
131             'u64': ['uint64'],
132             'number': ['number'],
133             'boolean': ['bool'],
134             'string': ['str'],
135             'sizes': ['size'],
136             'any': ['any'],
137             'user': ['Status'] } } # intentional forward ref. to sub-module
139 # for testing sub-modules
140 { 'include': 'include/sub-module.json' }
142 # testing commands
143 { 'command': 'user_def_cmd', 'data': {} }
144 { 'command': 'user_def_cmd1', 'data': {'ud1a': 'UserDefOne'} }
145 { 'command': 'user_def_cmd2',
146   'data': {'ud1a': {'type': 'UserDefOne'}, '*ud1b': 'UserDefOne'},
147   'returns': 'UserDefTwo' }
149 { 'command': 'cmd-success-response', 'data': {}, 'success-response': false }
151 # Returning a non-dictionary requires a name from the whitelist
152 { 'command': 'guest-get-time', 'data': {'a': 'int', '*b': 'int' },
153   'returns': 'int' }
154 { 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' }
155 { 'command': 'boxed-struct', 'boxed': true, 'data': 'UserDefZero' }
156 { 'command': 'boxed-union', 'data': 'UserDefListUnion', 'boxed': true }
157 { 'command': 'boxed-empty', 'boxed': true, 'data': 'Empty1' }
159 # Smoke test on out-of-band and allow-preconfig-test
160 { 'command': 'test-flags-command', 'allow-oob': true, 'allow-preconfig': true }
162 # For testing integer range flattening in opts-visitor. The following schema
163 # corresponds to the option format:
165 # -userdef i64=3-6,i64=-5--1,u64=2,u16=1,u16=7-12
167 # For simplicity, this example doesn't use [type=]discriminator nor optargs
168 # specific to discriminator values.
169 { 'struct': 'UserDefOptions',
170   'data': {
171     '*i64' : [ 'int'    ],
172     '*u64' : [ 'uint64' ],
173     '*u16' : [ 'uint16' ],
174     '*i64x':   'int'     ,
175     '*u64x':   'uint64'  } }
177 # testing event
178 { 'struct': 'EventStructOne',
179   'data': { 'struct1': {'type': 'UserDefOne'}, 'string': 'str', '*enum2': 'EnumOne' } }
181 { 'event': 'EVENT_A' }
182 { 'event': 'EVENT_B',
183   'data': { } }
184 { 'event': 'EVENT_C',
185   'data': { '*a': 'int', '*b': 'UserDefOne', 'c': 'str' } }
186 { 'event': 'EVENT_D',
187   'data': { 'a' : 'EventStructOne', 'b' : 'str', '*c': 'str', '*enum3': 'EnumOne' } }
188 { 'event': 'EVENT_E', 'boxed': true, 'data': 'UserDefZero' }
189 { 'event': 'EVENT_F', 'boxed': true, 'data': 'UserDefFlatUnion' }
190 { 'event': 'EVENT_G', 'boxed': true, 'data': 'Empty1' }
192 # test that we correctly compile downstream extensions, as well as munge
193 # ticklish names
194 # also test union and alternate with just one branch
195 { 'enum': '__org.qemu_x-Enum', 'data': [ '__org.qemu_x-value' ] }
196 { 'struct': '__org.qemu_x-Base',
197   'data': { '__org.qemu_x-member1': '__org.qemu_x-Enum' } }
198 { 'struct': '__org.qemu_x-Struct', 'base': '__org.qemu_x-Base',
199   'data': { '__org.qemu_x-member2': 'str', '*wchar-t': 'int' } }
200 { 'union': '__org.qemu_x-Union1', 'data': { '__org.qemu_x-branch': 'str' } }
201 { 'alternate': '__org.qemu_x-Alt1', 'data': { '__org.qemu_x-branch': 'str' } }
202 { 'struct': '__org.qemu_x-Struct2',
203   'data': { 'array': ['__org.qemu_x-Union1'] } }
204 { 'union': '__org.qemu_x-Union2', 'base': '__org.qemu_x-Base',
205   'discriminator': '__org.qemu_x-member1',
206   'data': { '__org.qemu_x-value': '__org.qemu_x-Struct2' } }
207 { 'alternate': '__org.qemu_x-Alt',
208   'data': { '__org.qemu_x-branch': '__org.qemu_x-Base' } }
209 { 'event': '__ORG.QEMU_X-EVENT', 'data': '__org.qemu_x-Struct' }
210 { 'command': '__org.qemu_x-command',
211   'data': { 'a': ['__org.qemu_x-Enum'], 'b': ['__org.qemu_x-Struct'],
212             'c': '__org.qemu_x-Union2', 'd': '__org.qemu_x-Alt' },
213   'returns': '__org.qemu_x-Union1' }
215 # test 'if' condition handling
217 { 'struct': 'TestIfStruct', 'data':
218   { 'foo': 'int',
219     'bar': { 'type': 'int', 'if': 'defined(TEST_IF_STRUCT_BAR)'} },
220   'if': 'defined(TEST_IF_STRUCT)' }
222 { 'enum': 'TestIfEnum', 'data':
223   [ 'foo', { 'name' : 'bar', 'if': 'defined(TEST_IF_ENUM_BAR)' } ],
224   'if': 'defined(TEST_IF_ENUM)' }
226 { 'union': 'TestIfUnion', 'data':
227   { 'foo': 'TestStruct',
228     'union_bar': { 'type': 'str', 'if': 'defined(TEST_IF_UNION_BAR)'} },
229   'if': 'defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)' }
231 { 'command': 'TestIfUnionCmd', 'data': { 'union_cmd_arg': 'TestIfUnion' },
232   'if': 'defined(TEST_IF_UNION)' }
234 { 'alternate': 'TestIfAlternate', 'data':
235   { 'foo': 'int',
236     'bar': { 'type': 'TestStruct', 'if': 'defined(TEST_IF_ALT_BAR)'} },
237   'if': 'defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT)' }
239 { 'command': 'TestIfAlternateCmd', 'data': { 'alt_cmd_arg': 'TestIfAlternate' },
240   'if': 'defined(TEST_IF_ALT)' }
242 { 'command': 'TestIfCmd', 'data':
243   { 'foo': 'TestIfStruct',
244     'bar': { 'type': 'TestIfEnum', 'if': 'defined(TEST_IF_CMD_BAR)' } },
245   'returns': 'UserDefThree',
246   'if': ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'] }
248 { 'command': 'TestCmdReturnDefThree', 'returns': 'UserDefThree' }
250 { 'event': 'TestIfEvent', 'data':
251   { 'foo': 'TestIfStruct',
252     'bar': { 'type': ['TestIfEnum'], 'if': 'defined(TEST_IF_EVT_BAR)' } },
253   'if': 'defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)' }
255 # test 'features' for structs
257 { 'struct': 'FeatureStruct0',
258   'data': { 'foo': 'int' },
259   'features': [] }
260 { 'struct': 'FeatureStruct1',
261   'data': { 'foo': 'int' },
262   'features': [ 'feature1' ] }
263 { 'struct': 'FeatureStruct2',
264   'data': { 'foo': 'int' },
265   'features': [ { 'name': 'feature1' } ] }
266 { 'struct': 'FeatureStruct3',
267   'data': { 'foo': 'int' },
268   'features': [ 'feature1', 'feature2' ] }
269 { 'struct': 'FeatureStruct4',
270   'data': { 'namespace-test': 'int' },
271   'features': [ 'namespace-test', 'int', 'name', 'if' ] }
273 { 'struct': 'CondFeatureStruct1',
274   'data': { 'foo': 'int' },
275   'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'} ] }
276 { 'struct': 'CondFeatureStruct2',
277   'data': { 'foo': 'int' },
278   'features': [ { 'name': 'feature1', 'if': 'defined(TEST_IF_FEATURE_1)'},
279                 { 'name': 'feature2', 'if': 'defined(TEST_IF_FEATURE_2)'} ] }
280 { 'struct': 'CondFeatureStruct3',
281   'data': { 'foo': 'int' },
282   'features': [ { 'name': 'feature1', 'if': [ 'defined(TEST_IF_COND_1)',
283                                               'defined(TEST_IF_COND_2)'] } ] }
284 { 'command': 'test-features',
285   'data': { 'fs0': 'FeatureStruct0',
286             'fs1': 'FeatureStruct1',
287             'fs2': 'FeatureStruct2',
288             'fs3': 'FeatureStruct3',
289             'fs4': 'FeatureStruct4',
290             'cfs1': 'CondFeatureStruct1',
291             'cfs2': 'CondFeatureStruct2',
292             'cfs3': 'CondFeatureStruct3' } }