]> git.proxmox.com Git - mirror_qemu.git/blame - tests/test-qobject-input-visitor.c
test-qobject-input-visitor: Cover missing nested struct member
[mirror_qemu.git] / tests / test-qobject-input-visitor.c
CommitLineData
d88f5fd1 1/*
b3db211f 2 * QObject Input Visitor unit-tests.
d88f5fd1 3 *
68d07839 4 * Copyright (C) 2011-2016 Red Hat Inc.
d88f5fd1
LC
5 *
6 * Authors:
7 * Luiz Capitulino <lcapitulino@redhat.com>
77c47de2 8 * Paolo Bonzini <pbonzini@redhat.com>
d88f5fd1
LC
9 *
10 * This work is licensed under the terms of the GNU GPL, version 2 or later.
11 * See the COPYING file in the top-level directory.
12 */
13
681c28a3 14#include "qemu/osdep.h"
d88f5fd1 15
79ee7df8 16#include "qemu-common.h"
da34e65c 17#include "qapi/error.h"
b3db211f 18#include "qapi/qobject-input-visitor.h"
d88f5fd1
LC
19#include "test-qapi-types.h"
20#include "test-qapi-visit.h"
7b1b5d19 21#include "qapi/qmp/types.h"
c7eb39cb 22#include "qapi/qmp/qjson.h"
77c47de2
MA
23#include "test-qmp-introspect.h"
24#include "qmp-introspect.h"
25#include "qapi-visit.h"
d88f5fd1
LC
26
27typedef struct TestInputVisitorData {
28 QObject *obj;
b70ce101 29 Visitor *qiv;
d88f5fd1
LC
30} TestInputVisitorData;
31
32static void visitor_input_teardown(TestInputVisitorData *data,
33 const void *unused)
34{
35 qobject_decref(data->obj);
36 data->obj = NULL;
37
38 if (data->qiv) {
b70ce101 39 visit_free(data->qiv);
d88f5fd1
LC
40 data->qiv = NULL;
41 }
42}
43
0920a171
EB
44/* The various test_init functions are provided instead of a test setup
45 function so that the JSON string used by the tests are kept in the test
46 functions (and not in main()). */
47static Visitor *visitor_input_test_init_internal(TestInputVisitorData *data,
48 const char *json_string,
49 va_list *ap)
50{
b18f1141
EB
51 visitor_input_teardown(data, NULL);
52
0920a171
EB
53 data->obj = qobject_from_jsonv(json_string, ap);
54 g_assert(data->obj);
55
048abb7b 56 data->qiv = qobject_input_visitor_new(data->obj);
0920a171 57 g_assert(data->qiv);
b70ce101 58 return data->qiv;
0920a171
EB
59}
60
aba2107a
SW
61static GCC_FMT_ATTR(2, 3)
62Visitor *visitor_input_test_init(TestInputVisitorData *data,
63 const char *json_string, ...)
d88f5fd1
LC
64{
65 Visitor *v;
66 va_list ap;
67
68 va_start(ap, json_string);
0920a171 69 v = visitor_input_test_init_internal(data, json_string, &ap);
d88f5fd1 70 va_end(ap);
d88f5fd1
LC
71 return v;
72}
73
199e0f17
MR
74/* similar to visitor_input_test_init(), but does not expect a string
75 * literal/format json_string argument and so can be used for
76 * programatically generated strings (and we can't pass in programatically
77 * generated strings via %s format parameters since qobject_from_jsonv()
78 * will wrap those in double-quotes and treat the entire object as a
79 * string)
80 */
81static Visitor *visitor_input_test_init_raw(TestInputVisitorData *data,
82 const char *json_string)
83{
0920a171 84 return visitor_input_test_init_internal(data, json_string, NULL);
199e0f17
MR
85}
86
d88f5fd1
LC
87static void test_visitor_in_int(TestInputVisitorData *data,
88 const void *unused)
89{
29a6731a
EB
90 int64_t res = 0;
91 int value = -42;
d88f5fd1
LC
92 Visitor *v;
93
29a6731a 94 v = visitor_input_test_init(data, "%d", value);
d88f5fd1 95
51e72bc1 96 visit_type_int(v, NULL, &res, &error_abort);
d88f5fd1
LC
97 g_assert_cmpint(res, ==, value);
98}
99
e92cfa0d
MR
100static void test_visitor_in_int_overflow(TestInputVisitorData *data,
101 const void *unused)
102{
103 int64_t res = 0;
e940f543 104 Error *err = NULL;
e92cfa0d
MR
105 Visitor *v;
106
107 /* this will overflow a Qint/int64, so should be deserialized into
108 * a QFloat/double field instead, leading to an error if we pass it
109 * to visit_type_int. confirm this.
110 */
111 v = visitor_input_test_init(data, "%f", DBL_MAX);
112
51e72bc1 113 visit_type_int(v, NULL, &res, &err);
a12a5a1a 114 error_free_or_abort(&err);
e92cfa0d
MR
115}
116
d88f5fd1
LC
117static void test_visitor_in_bool(TestInputVisitorData *data,
118 const void *unused)
119{
d88f5fd1
LC
120 bool res = false;
121 Visitor *v;
122
123 v = visitor_input_test_init(data, "true");
124
51e72bc1 125 visit_type_bool(v, NULL, &res, &error_abort);
d88f5fd1
LC
126 g_assert_cmpint(res, ==, true);
127}
128
129static void test_visitor_in_number(TestInputVisitorData *data,
130 const void *unused)
131{
132 double res = 0, value = 3.14;
d88f5fd1
LC
133 Visitor *v;
134
135 v = visitor_input_test_init(data, "%f", value);
136
51e72bc1 137 visit_type_number(v, NULL, &res, &error_abort);
d88f5fd1
LC
138 g_assert_cmpfloat(res, ==, value);
139}
140
141static void test_visitor_in_string(TestInputVisitorData *data,
142 const void *unused)
143{
144 char *res = NULL, *value = (char *) "Q E M U";
d88f5fd1
LC
145 Visitor *v;
146
147 v = visitor_input_test_init(data, "%s", value);
148
51e72bc1 149 visit_type_str(v, NULL, &res, &error_abort);
d88f5fd1
LC
150 g_assert_cmpstr(res, ==, value);
151
152 g_free(res);
153}
154
155static void test_visitor_in_enum(TestInputVisitorData *data,
156 const void *unused)
157{
d88f5fd1
LC
158 Visitor *v;
159 EnumOne i;
160
161 for (i = 0; EnumOne_lookup[i]; i++) {
162 EnumOne res = -1;
163
164 v = visitor_input_test_init(data, "%s", EnumOne_lookup[i]);
165
51e72bc1 166 visit_type_EnumOne(v, NULL, &res, &error_abort);
d88f5fd1 167 g_assert_cmpint(i, ==, res);
d88f5fd1 168 }
d88f5fd1
LC
169}
170
d88f5fd1
LC
171
172static void test_visitor_in_struct(TestInputVisitorData *data,
173 const void *unused)
174{
175 TestStruct *p = NULL;
d88f5fd1
LC
176 Visitor *v;
177
178 v = visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }");
179
51e72bc1 180 visit_type_TestStruct(v, NULL, &p, &error_abort);
d88f5fd1
LC
181 g_assert_cmpint(p->integer, ==, -42);
182 g_assert(p->boolean == true);
183 g_assert_cmpstr(p->string, ==, "foo");
184
185 g_free(p->string);
186 g_free(p);
187}
188
d88f5fd1
LC
189static void test_visitor_in_struct_nested(TestInputVisitorData *data,
190 const void *unused)
191{
b6fcf32d 192 UserDefTwo *udp = NULL;
d88f5fd1
LC
193 Visitor *v;
194
b6fcf32d
EB
195 v = visitor_input_test_init(data, "{ 'string0': 'string0', "
196 "'dict1': { 'string1': 'string1', "
197 "'dict2': { 'userdef': { 'integer': 42, "
198 "'string': 'string' }, 'string': 'string2'}}}");
d88f5fd1 199
51e72bc1 200 visit_type_UserDefTwo(v, NULL, &udp, &error_abort);
d88f5fd1 201
b18f1141
EB
202 g_assert_cmpstr(udp->string0, ==, "string0");
203 g_assert_cmpstr(udp->dict1->string1, ==, "string1");
ddf21908 204 g_assert_cmpint(udp->dict1->dict2->userdef->integer, ==, 42);
b18f1141
EB
205 g_assert_cmpstr(udp->dict1->dict2->userdef->string, ==, "string");
206 g_assert_cmpstr(udp->dict1->dict2->string, ==, "string2");
6446a592
EB
207 g_assert(udp->dict1->has_dict3 == false);
208
b18f1141 209 qapi_free_UserDefTwo(udp);
d88f5fd1
LC
210}
211
212static void test_visitor_in_list(TestInputVisitorData *data,
213 const void *unused)
214{
215 UserDefOneList *item, *head = NULL;
d88f5fd1
LC
216 Visitor *v;
217 int i;
218
219 v = visitor_input_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44 } ]");
220
51e72bc1 221 visit_type_UserDefOneList(v, NULL, &head, &error_abort);
d88f5fd1
LC
222 g_assert(head != NULL);
223
224 for (i = 0, item = head; item; item = item->next, i++) {
225 char string[12];
226
227 snprintf(string, sizeof(string), "string%d", i);
228 g_assert_cmpstr(item->value->string, ==, string);
ddf21908 229 g_assert_cmpint(item->value->integer, ==, 42 + i);
d88f5fd1
LC
230 }
231
232 qapi_free_UserDefOneList(head);
2533377c
EB
233 head = NULL;
234
235 /* An empty list is valid */
236 v = visitor_input_test_init(data, "[]");
51e72bc1 237 visit_type_UserDefOneList(v, NULL, &head, &error_abort);
2533377c 238 g_assert(!head);
d88f5fd1
LC
239}
240
28770e05
MA
241static void test_visitor_in_any(TestInputVisitorData *data,
242 const void *unused)
243{
244 QObject *res = NULL;
28770e05
MA
245 Visitor *v;
246 QInt *qint;
247 QBool *qbool;
248 QString *qstring;
249 QDict *qdict;
250 QObject *qobj;
251
252 v = visitor_input_test_init(data, "-42");
51e72bc1 253 visit_type_any(v, NULL, &res, &error_abort);
28770e05
MA
254 qint = qobject_to_qint(res);
255 g_assert(qint);
256 g_assert_cmpint(qint_get_int(qint), ==, -42);
257 qobject_decref(res);
258
259 v = visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }");
51e72bc1 260 visit_type_any(v, NULL, &res, &error_abort);
28770e05
MA
261 qdict = qobject_to_qdict(res);
262 g_assert(qdict && qdict_size(qdict) == 3);
263 qobj = qdict_get(qdict, "integer");
264 g_assert(qobj);
265 qint = qobject_to_qint(qobj);
266 g_assert(qint);
267 g_assert_cmpint(qint_get_int(qint), ==, -42);
268 qobj = qdict_get(qdict, "boolean");
269 g_assert(qobj);
270 qbool = qobject_to_qbool(qobj);
271 g_assert(qbool);
272 g_assert(qbool_get_bool(qbool) == true);
273 qobj = qdict_get(qdict, "string");
274 g_assert(qobj);
275 qstring = qobject_to_qstring(qobj);
276 g_assert(qstring);
277 g_assert_cmpstr(qstring_get_str(qstring), ==, "foo");
278 qobject_decref(res);
279}
280
3df016f1
EB
281static void test_visitor_in_null(TestInputVisitorData *data,
282 const void *unused)
283{
284 Visitor *v;
285 Error *err = NULL;
286 char *tmp;
287
288 /*
289 * FIXME: Since QAPI doesn't know the 'null' type yet, we can't
290 * test visit_type_null() by reading into a QAPI struct then
291 * checking that it was populated correctly. The best we can do
292 * for now is ensure that we consumed null from the input, proven
293 * by the fact that we can't re-read the key; and that we detect
294 * when input is not null.
295 */
296
ec95f614 297 v = visitor_input_test_init(data, "{ 'a': null, 'b': '', 'c': null }");
3df016f1
EB
298 visit_start_struct(v, NULL, NULL, 0, &error_abort);
299 visit_type_null(v, "a", &error_abort);
3df016f1
EB
300 visit_type_null(v, "b", &err);
301 error_free_or_abort(&err);
ec95f614
MA
302 visit_type_str(v, "c", &tmp, &err);
303 g_assert(!tmp);
304 error_free_or_abort(&err);
15c2f669 305 visit_check_struct(v, &error_abort);
1158bb2a 306 visit_end_struct(v, NULL);
3df016f1
EB
307}
308
2fc00432
MA
309static void test_visitor_in_union_flat(TestInputVisitorData *data,
310 const void *unused)
311{
312 Visitor *v;
2fc00432 313 UserDefFlatUnion *tmp;
30594fe1 314 UserDefUnionBase *base;
2fc00432 315
5223070c
WX
316 v = visitor_input_test_init(data,
317 "{ 'enum1': 'value1', "
441cbac0 318 "'integer': 41, "
5223070c
WX
319 "'string': 'str', "
320 "'boolean': true }");
2fc00432 321
51e72bc1 322 visit_type_UserDefFlatUnion(v, NULL, &tmp, &error_abort);
0f61af3e 323 g_assert_cmpint(tmp->enum1, ==, ENUM_ONE_VALUE1);
5223070c 324 g_assert_cmpstr(tmp->string, ==, "str");
441cbac0 325 g_assert_cmpint(tmp->integer, ==, 41);
544a3731 326 g_assert_cmpint(tmp->u.value1.boolean, ==, true);
30594fe1
EB
327
328 base = qapi_UserDefFlatUnion_base(tmp);
329 g_assert(&base->enum1 == &tmp->enum1);
330
2fc00432
MA
331 qapi_free_UserDefFlatUnion(tmp);
332}
333
ab045267
EB
334static void test_visitor_in_alternate(TestInputVisitorData *data,
335 const void *unused)
2c38b600
MA
336{
337 Visitor *v;
338 Error *err = NULL;
ab045267 339 UserDefAlternate *tmp;
68d07839 340 WrapAlternate *wrap;
2c38b600
MA
341
342 v = visitor_input_test_init(data, "42");
51e72bc1 343 visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort);
0426d53c 344 g_assert_cmpint(tmp->type, ==, QTYPE_QINT);
c363acef 345 g_assert_cmpint(tmp->u.i, ==, 42);
ab045267 346 qapi_free_UserDefAlternate(tmp);
9c51b441
EB
347
348 v = visitor_input_test_init(data, "'string'");
51e72bc1 349 visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort);
0426d53c 350 g_assert_cmpint(tmp->type, ==, QTYPE_QSTRING);
c363acef 351 g_assert_cmpstr(tmp->u.s, ==, "string");
9c51b441 352 qapi_free_UserDefAlternate(tmp);
9c51b441 353
68d07839
EB
354 v = visitor_input_test_init(data, "{'integer':1, 'string':'str', "
355 "'enum1':'value1', 'boolean':true}");
356 visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort);
357 g_assert_cmpint(tmp->type, ==, QTYPE_QDICT);
becceedc
EB
358 g_assert_cmpint(tmp->u.udfu.integer, ==, 1);
359 g_assert_cmpstr(tmp->u.udfu.string, ==, "str");
360 g_assert_cmpint(tmp->u.udfu.enum1, ==, ENUM_ONE_VALUE1);
544a3731
EB
361 g_assert_cmpint(tmp->u.udfu.u.value1.boolean, ==, true);
362 g_assert_cmpint(tmp->u.udfu.u.value1.has_a_b, ==, false);
68d07839
EB
363 qapi_free_UserDefAlternate(tmp);
364
9c51b441 365 v = visitor_input_test_init(data, "false");
51e72bc1 366 visit_type_UserDefAlternate(v, NULL, &tmp, &err);
a12a5a1a 367 error_free_or_abort(&err);
9c51b441 368 qapi_free_UserDefAlternate(tmp);
68d07839
EB
369
370 v = visitor_input_test_init(data, "{ 'alt': 42 }");
371 visit_type_WrapAlternate(v, NULL, &wrap, &error_abort);
372 g_assert_cmpint(wrap->alt->type, ==, QTYPE_QINT);
373 g_assert_cmpint(wrap->alt->u.i, ==, 42);
374 qapi_free_WrapAlternate(wrap);
375
376 v = visitor_input_test_init(data, "{ 'alt': 'string' }");
377 visit_type_WrapAlternate(v, NULL, &wrap, &error_abort);
378 g_assert_cmpint(wrap->alt->type, ==, QTYPE_QSTRING);
379 g_assert_cmpstr(wrap->alt->u.s, ==, "string");
380 qapi_free_WrapAlternate(wrap);
381
382 v = visitor_input_test_init(data, "{ 'alt': {'integer':1, 'string':'str', "
383 "'enum1':'value1', 'boolean':true} }");
384 visit_type_WrapAlternate(v, NULL, &wrap, &error_abort);
385 g_assert_cmpint(wrap->alt->type, ==, QTYPE_QDICT);
becceedc
EB
386 g_assert_cmpint(wrap->alt->u.udfu.integer, ==, 1);
387 g_assert_cmpstr(wrap->alt->u.udfu.string, ==, "str");
388 g_assert_cmpint(wrap->alt->u.udfu.enum1, ==, ENUM_ONE_VALUE1);
544a3731
EB
389 g_assert_cmpint(wrap->alt->u.udfu.u.value1.boolean, ==, true);
390 g_assert_cmpint(wrap->alt->u.udfu.u.value1.has_a_b, ==, false);
68d07839 391 qapi_free_WrapAlternate(wrap);
9c51b441
EB
392}
393
394static void test_visitor_in_alternate_number(TestInputVisitorData *data,
395 const void *unused)
396{
397 Visitor *v;
398 Error *err = NULL;
399 AltStrBool *asb;
400 AltStrNum *asn;
401 AltNumStr *ans;
402 AltStrInt *asi;
403 AltIntNum *ain;
404 AltNumInt *ani;
405
406 /* Parsing an int */
407
408 v = visitor_input_test_init(data, "42");
51e72bc1 409 visit_type_AltStrBool(v, NULL, &asb, &err);
a12a5a1a 410 error_free_or_abort(&err);
9c51b441 411 qapi_free_AltStrBool(asb);
9c51b441 412
9c51b441 413 v = visitor_input_test_init(data, "42");
51e72bc1 414 visit_type_AltStrNum(v, NULL, &asn, &error_abort);
d00341af
EB
415 g_assert_cmpint(asn->type, ==, QTYPE_QFLOAT);
416 g_assert_cmpfloat(asn->u.n, ==, 42);
9c51b441 417 qapi_free_AltStrNum(asn);
9c51b441
EB
418
419 v = visitor_input_test_init(data, "42");
51e72bc1 420 visit_type_AltNumStr(v, NULL, &ans, &error_abort);
d00341af
EB
421 g_assert_cmpint(ans->type, ==, QTYPE_QFLOAT);
422 g_assert_cmpfloat(ans->u.n, ==, 42);
9c51b441 423 qapi_free_AltNumStr(ans);
9c51b441
EB
424
425 v = visitor_input_test_init(data, "42");
51e72bc1 426 visit_type_AltStrInt(v, NULL, &asi, &error_abort);
0426d53c 427 g_assert_cmpint(asi->type, ==, QTYPE_QINT);
c363acef 428 g_assert_cmpint(asi->u.i, ==, 42);
9c51b441 429 qapi_free_AltStrInt(asi);
9c51b441
EB
430
431 v = visitor_input_test_init(data, "42");
51e72bc1 432 visit_type_AltIntNum(v, NULL, &ain, &error_abort);
0426d53c 433 g_assert_cmpint(ain->type, ==, QTYPE_QINT);
c363acef 434 g_assert_cmpint(ain->u.i, ==, 42);
9c51b441 435 qapi_free_AltIntNum(ain);
9c51b441
EB
436
437 v = visitor_input_test_init(data, "42");
51e72bc1 438 visit_type_AltNumInt(v, NULL, &ani, &error_abort);
0426d53c 439 g_assert_cmpint(ani->type, ==, QTYPE_QINT);
c363acef 440 g_assert_cmpint(ani->u.i, ==, 42);
9c51b441 441 qapi_free_AltNumInt(ani);
9c51b441
EB
442
443 /* Parsing a double */
444
445 v = visitor_input_test_init(data, "42.5");
51e72bc1 446 visit_type_AltStrBool(v, NULL, &asb, &err);
a12a5a1a 447 error_free_or_abort(&err);
9c51b441 448 qapi_free_AltStrBool(asb);
9c51b441
EB
449
450 v = visitor_input_test_init(data, "42.5");
51e72bc1 451 visit_type_AltStrNum(v, NULL, &asn, &error_abort);
0426d53c 452 g_assert_cmpint(asn->type, ==, QTYPE_QFLOAT);
c363acef 453 g_assert_cmpfloat(asn->u.n, ==, 42.5);
9c51b441 454 qapi_free_AltStrNum(asn);
9c51b441
EB
455
456 v = visitor_input_test_init(data, "42.5");
51e72bc1 457 visit_type_AltNumStr(v, NULL, &ans, &error_abort);
0426d53c 458 g_assert_cmpint(ans->type, ==, QTYPE_QFLOAT);
c363acef 459 g_assert_cmpfloat(ans->u.n, ==, 42.5);
9c51b441 460 qapi_free_AltNumStr(ans);
9c51b441
EB
461
462 v = visitor_input_test_init(data, "42.5");
51e72bc1 463 visit_type_AltStrInt(v, NULL, &asi, &err);
a12a5a1a 464 error_free_or_abort(&err);
9c51b441 465 qapi_free_AltStrInt(asi);
9c51b441
EB
466
467 v = visitor_input_test_init(data, "42.5");
51e72bc1 468 visit_type_AltIntNum(v, NULL, &ain, &error_abort);
0426d53c 469 g_assert_cmpint(ain->type, ==, QTYPE_QFLOAT);
c363acef 470 g_assert_cmpfloat(ain->u.n, ==, 42.5);
9c51b441 471 qapi_free_AltIntNum(ain);
9c51b441
EB
472
473 v = visitor_input_test_init(data, "42.5");
51e72bc1 474 visit_type_AltNumInt(v, NULL, &ani, &error_abort);
0426d53c 475 g_assert_cmpint(ani->type, ==, QTYPE_QFLOAT);
c363acef 476 g_assert_cmpfloat(ani->u.n, ==, 42.5);
9c51b441 477 qapi_free_AltNumInt(ani);
2c38b600
MA
478}
479
199e0f17
MR
480static void test_native_list_integer_helper(TestInputVisitorData *data,
481 const void *unused,
482 UserDefNativeListUnionKind kind)
483{
484 UserDefNativeListUnion *cvalue = NULL;
199e0f17
MR
485 Visitor *v;
486 GString *gstr_list = g_string_new("");
487 GString *gstr_union = g_string_new("");
488 int i;
489
490 for (i = 0; i < 32; i++) {
491 g_string_append_printf(gstr_list, "%d", i);
492 if (i != 31) {
493 g_string_append(gstr_list, ", ");
494 }
495 }
496 g_string_append_printf(gstr_union, "{ 'type': '%s', 'data': [ %s ] }",
497 UserDefNativeListUnionKind_lookup[kind],
498 gstr_list->str);
499 v = visitor_input_test_init_raw(data, gstr_union->str);
500
51e72bc1 501 visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);
199e0f17 502 g_assert(cvalue != NULL);
c363acef 503 g_assert_cmpint(cvalue->type, ==, kind);
199e0f17
MR
504
505 switch (kind) {
506 case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: {
507 intList *elem = NULL;
32bafa8f
EB
508 for (i = 0, elem = cvalue->u.integer.data;
509 elem; elem = elem->next, i++) {
199e0f17
MR
510 g_assert_cmpint(elem->value, ==, i);
511 }
512 break;
513 }
514 case USER_DEF_NATIVE_LIST_UNION_KIND_S8: {
515 int8List *elem = NULL;
32bafa8f 516 for (i = 0, elem = cvalue->u.s8.data; elem; elem = elem->next, i++) {
199e0f17
MR
517 g_assert_cmpint(elem->value, ==, i);
518 }
519 break;
520 }
521 case USER_DEF_NATIVE_LIST_UNION_KIND_S16: {
522 int16List *elem = NULL;
32bafa8f 523 for (i = 0, elem = cvalue->u.s16.data; elem; elem = elem->next, i++) {
199e0f17
MR
524 g_assert_cmpint(elem->value, ==, i);
525 }
526 break;
527 }
528 case USER_DEF_NATIVE_LIST_UNION_KIND_S32: {
529 int32List *elem = NULL;
32bafa8f 530 for (i = 0, elem = cvalue->u.s32.data; elem; elem = elem->next, i++) {
199e0f17
MR
531 g_assert_cmpint(elem->value, ==, i);
532 }
533 break;
534 }
535 case USER_DEF_NATIVE_LIST_UNION_KIND_S64: {
536 int64List *elem = NULL;
32bafa8f 537 for (i = 0, elem = cvalue->u.s64.data; elem; elem = elem->next, i++) {
199e0f17
MR
538 g_assert_cmpint(elem->value, ==, i);
539 }
540 break;
541 }
542 case USER_DEF_NATIVE_LIST_UNION_KIND_U8: {
543 uint8List *elem = NULL;
32bafa8f 544 for (i = 0, elem = cvalue->u.u8.data; elem; elem = elem->next, i++) {
199e0f17
MR
545 g_assert_cmpint(elem->value, ==, i);
546 }
547 break;
548 }
549 case USER_DEF_NATIVE_LIST_UNION_KIND_U16: {
550 uint16List *elem = NULL;
32bafa8f 551 for (i = 0, elem = cvalue->u.u16.data; elem; elem = elem->next, i++) {
199e0f17
MR
552 g_assert_cmpint(elem->value, ==, i);
553 }
554 break;
555 }
556 case USER_DEF_NATIVE_LIST_UNION_KIND_U32: {
557 uint32List *elem = NULL;
32bafa8f 558 for (i = 0, elem = cvalue->u.u32.data; elem; elem = elem->next, i++) {
199e0f17
MR
559 g_assert_cmpint(elem->value, ==, i);
560 }
561 break;
562 }
563 case USER_DEF_NATIVE_LIST_UNION_KIND_U64: {
564 uint64List *elem = NULL;
32bafa8f 565 for (i = 0, elem = cvalue->u.u64.data; elem; elem = elem->next, i++) {
199e0f17
MR
566 g_assert_cmpint(elem->value, ==, i);
567 }
568 break;
569 }
570 default:
dfc6f865 571 g_assert_not_reached();
199e0f17
MR
572 }
573
574 g_string_free(gstr_union, true);
575 g_string_free(gstr_list, true);
576 qapi_free_UserDefNativeListUnion(cvalue);
577}
578
579static void test_visitor_in_native_list_int(TestInputVisitorData *data,
580 const void *unused)
581{
582 test_native_list_integer_helper(data, unused,
583 USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER);
584}
585
586static void test_visitor_in_native_list_int8(TestInputVisitorData *data,
587 const void *unused)
588{
589 test_native_list_integer_helper(data, unused,
590 USER_DEF_NATIVE_LIST_UNION_KIND_S8);
591}
592
593static void test_visitor_in_native_list_int16(TestInputVisitorData *data,
594 const void *unused)
595{
596 test_native_list_integer_helper(data, unused,
597 USER_DEF_NATIVE_LIST_UNION_KIND_S16);
598}
599
600static void test_visitor_in_native_list_int32(TestInputVisitorData *data,
601 const void *unused)
602{
603 test_native_list_integer_helper(data, unused,
604 USER_DEF_NATIVE_LIST_UNION_KIND_S32);
605}
606
607static void test_visitor_in_native_list_int64(TestInputVisitorData *data,
608 const void *unused)
609{
610 test_native_list_integer_helper(data, unused,
611 USER_DEF_NATIVE_LIST_UNION_KIND_S64);
612}
613
614static void test_visitor_in_native_list_uint8(TestInputVisitorData *data,
615 const void *unused)
616{
617 test_native_list_integer_helper(data, unused,
618 USER_DEF_NATIVE_LIST_UNION_KIND_U8);
619}
620
621static void test_visitor_in_native_list_uint16(TestInputVisitorData *data,
622 const void *unused)
623{
624 test_native_list_integer_helper(data, unused,
625 USER_DEF_NATIVE_LIST_UNION_KIND_U16);
626}
627
628static void test_visitor_in_native_list_uint32(TestInputVisitorData *data,
629 const void *unused)
630{
631 test_native_list_integer_helper(data, unused,
632 USER_DEF_NATIVE_LIST_UNION_KIND_U32);
633}
634
635static void test_visitor_in_native_list_uint64(TestInputVisitorData *data,
636 const void *unused)
637{
638 test_native_list_integer_helper(data, unused,
639 USER_DEF_NATIVE_LIST_UNION_KIND_U64);
640}
641
642static void test_visitor_in_native_list_bool(TestInputVisitorData *data,
643 const void *unused)
644{
645 UserDefNativeListUnion *cvalue = NULL;
646 boolList *elem = NULL;
199e0f17
MR
647 Visitor *v;
648 GString *gstr_list = g_string_new("");
649 GString *gstr_union = g_string_new("");
650 int i;
651
652 for (i = 0; i < 32; i++) {
653 g_string_append_printf(gstr_list, "%s",
654 (i % 3 == 0) ? "true" : "false");
655 if (i != 31) {
656 g_string_append(gstr_list, ", ");
657 }
658 }
659 g_string_append_printf(gstr_union, "{ 'type': 'boolean', 'data': [ %s ] }",
660 gstr_list->str);
661 v = visitor_input_test_init_raw(data, gstr_union->str);
662
51e72bc1 663 visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);
199e0f17 664 g_assert(cvalue != NULL);
c363acef 665 g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN);
199e0f17 666
32bafa8f 667 for (i = 0, elem = cvalue->u.boolean.data; elem; elem = elem->next, i++) {
199e0f17
MR
668 g_assert_cmpint(elem->value, ==, (i % 3 == 0) ? 1 : 0);
669 }
670
671 g_string_free(gstr_union, true);
672 g_string_free(gstr_list, true);
673 qapi_free_UserDefNativeListUnion(cvalue);
674}
675
676static void test_visitor_in_native_list_string(TestInputVisitorData *data,
677 const void *unused)
678{
679 UserDefNativeListUnion *cvalue = NULL;
680 strList *elem = NULL;
199e0f17
MR
681 Visitor *v;
682 GString *gstr_list = g_string_new("");
683 GString *gstr_union = g_string_new("");
684 int i;
685
686 for (i = 0; i < 32; i++) {
687 g_string_append_printf(gstr_list, "'%d'", i);
688 if (i != 31) {
689 g_string_append(gstr_list, ", ");
690 }
691 }
692 g_string_append_printf(gstr_union, "{ 'type': 'string', 'data': [ %s ] }",
693 gstr_list->str);
694 v = visitor_input_test_init_raw(data, gstr_union->str);
695
51e72bc1 696 visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);
199e0f17 697 g_assert(cvalue != NULL);
c363acef 698 g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING);
199e0f17 699
32bafa8f 700 for (i = 0, elem = cvalue->u.string.data; elem; elem = elem->next, i++) {
199e0f17
MR
701 gchar str[8];
702 sprintf(str, "%d", i);
703 g_assert_cmpstr(elem->value, ==, str);
704 }
705
706 g_string_free(gstr_union, true);
707 g_string_free(gstr_list, true);
708 qapi_free_UserDefNativeListUnion(cvalue);
709}
710
711#define DOUBLE_STR_MAX 16
712
713static void test_visitor_in_native_list_number(TestInputVisitorData *data,
714 const void *unused)
715{
716 UserDefNativeListUnion *cvalue = NULL;
717 numberList *elem = NULL;
199e0f17
MR
718 Visitor *v;
719 GString *gstr_list = g_string_new("");
720 GString *gstr_union = g_string_new("");
721 int i;
722
723 for (i = 0; i < 32; i++) {
724 g_string_append_printf(gstr_list, "%f", (double)i / 3);
725 if (i != 31) {
726 g_string_append(gstr_list, ", ");
727 }
728 }
729 g_string_append_printf(gstr_union, "{ 'type': 'number', 'data': [ %s ] }",
730 gstr_list->str);
731 v = visitor_input_test_init_raw(data, gstr_union->str);
732
51e72bc1 733 visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);
199e0f17 734 g_assert(cvalue != NULL);
c363acef 735 g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER);
199e0f17 736
32bafa8f 737 for (i = 0, elem = cvalue->u.number.data; elem; elem = elem->next, i++) {
199e0f17
MR
738 GString *double_expected = g_string_new("");
739 GString *double_actual = g_string_new("");
740
741 g_string_printf(double_expected, "%.6f", (double)i / 3);
742 g_string_printf(double_actual, "%.6f", elem->value);
743 g_assert_cmpstr(double_expected->str, ==, double_actual->str);
744
745 g_string_free(double_expected, true);
746 g_string_free(double_actual, true);
747 }
748
749 g_string_free(gstr_union, true);
750 g_string_free(gstr_list, true);
751 qapi_free_UserDefNativeListUnion(cvalue);
752}
753
d88f5fd1 754static void input_visitor_test_add(const char *testpath,
b1d2e5f1
DB
755 const void *user_data,
756 void (*test_func)(TestInputVisitorData *data,
757 const void *user_data))
d88f5fd1 758{
b1d2e5f1 759 g_test_add(testpath, TestInputVisitorData, user_data, NULL, test_func,
d88f5fd1
LC
760 visitor_input_teardown);
761}
762
3dcf71f6
PB
763static void test_visitor_in_errors(TestInputVisitorData *data,
764 const void *unused)
765{
766 TestStruct *p = NULL;
e940f543 767 Error *err = NULL;
3dcf71f6 768 Visitor *v;
dd5ee2c2 769 strList *q = NULL;
9b4e38fe
EB
770 UserDefTwo *r = NULL;
771 WrapAlternate *s = NULL;
3dcf71f6 772
dd5ee2c2
EB
773 v = visitor_input_test_init(data, "{ 'integer': false, 'boolean': 'foo', "
774 "'string': -42 }");
3dcf71f6 775
51e72bc1 776 visit_type_TestStruct(v, NULL, &p, &err);
a12a5a1a 777 error_free_or_abort(&err);
68ab47e4 778 g_assert(!p);
dd5ee2c2
EB
779
780 v = visitor_input_test_init(data, "[ '1', '2', false, '3' ]");
51e72bc1 781 visit_type_strList(v, NULL, &q, &err);
dd5ee2c2 782 error_free_or_abort(&err);
68ab47e4 783 assert(!q);
9b4e38fe
EB
784
785 v = visitor_input_test_init(data, "{ 'str':'hi' }");
786 visit_type_UserDefTwo(v, NULL, &r, &err);
787 error_free_or_abort(&err);
788 assert(!r);
789
790 v = visitor_input_test_init(data, "{ }");
791 visit_type_WrapAlternate(v, NULL, &s, &err);
792 error_free_or_abort(&err);
793 assert(!s);
3dcf71f6
PB
794}
795
2533377c
EB
796static void test_visitor_in_wrong_type(TestInputVisitorData *data,
797 const void *unused)
798{
799 TestStruct *p = NULL;
800 Visitor *v;
801 strList *q = NULL;
802 int64_t i;
803 Error *err = NULL;
804
805 /* Make sure arrays and structs cannot be confused */
806
807 v = visitor_input_test_init(data, "[]");
51e72bc1 808 visit_type_TestStruct(v, NULL, &p, &err);
2533377c
EB
809 error_free_or_abort(&err);
810 g_assert(!p);
811
812 v = visitor_input_test_init(data, "{}");
51e72bc1 813 visit_type_strList(v, NULL, &q, &err);
2533377c
EB
814 error_free_or_abort(&err);
815 assert(!q);
816
817 /* Make sure primitives and struct cannot be confused */
818
819 v = visitor_input_test_init(data, "1");
51e72bc1 820 visit_type_TestStruct(v, NULL, &p, &err);
2533377c
EB
821 error_free_or_abort(&err);
822 g_assert(!p);
823
824 v = visitor_input_test_init(data, "{}");
51e72bc1 825 visit_type_int(v, NULL, &i, &err);
2533377c
EB
826 error_free_or_abort(&err);
827
828 /* Make sure primitives and arrays cannot be confused */
829
830 v = visitor_input_test_init(data, "1");
51e72bc1 831 visit_type_strList(v, NULL, &q, &err);
2533377c
EB
832 error_free_or_abort(&err);
833 assert(!q);
834
835 v = visitor_input_test_init(data, "[]");
51e72bc1 836 visit_type_int(v, NULL, &i, &err);
2533377c
EB
837 error_free_or_abort(&err);
838}
839
77c47de2
MA
840static void test_visitor_in_fail_struct(TestInputVisitorData *data,
841 const void *unused)
842{
843 TestStruct *p = NULL;
844 Error *err = NULL;
845 Visitor *v;
846
847 v = visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo', 'extra': 42 }");
848
849 visit_type_TestStruct(v, NULL, &p, &err);
850 error_free_or_abort(&err);
851 g_assert(!p);
852}
853
854static void test_visitor_in_fail_struct_nested(TestInputVisitorData *data,
855 const void *unused)
856{
857 UserDefTwo *udp = NULL;
858 Error *err = NULL;
859 Visitor *v;
860
861 v = visitor_input_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string', 'extra': [42, 23, {'foo':'bar'}] }, 'string2': 'string2'}}}");
862
863 visit_type_UserDefTwo(v, NULL, &udp, &err);
864 error_free_or_abort(&err);
865 g_assert(!udp);
866}
867
868static void test_visitor_in_fail_struct_in_list(TestInputVisitorData *data,
869 const void *unused)
870{
871 UserDefOneList *head = NULL;
872 Error *err = NULL;
873 Visitor *v;
874
875 v = visitor_input_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44, 'extra': 'ggg' } ]");
876
877 visit_type_UserDefOneList(v, NULL, &head, &err);
878 error_free_or_abort(&err);
879 g_assert(!head);
880}
881
882static void test_visitor_in_fail_struct_missing(TestInputVisitorData *data,
883 const void *unused)
884{
885 Error *err = NULL;
886 Visitor *v;
887 QObject *any;
888 GenericAlternate *alt;
889 bool present;
890 int en;
891 int64_t i64;
892 uint32_t u32;
893 int8_t i8;
894 char *str;
895 double dbl;
896
86ca0dbe 897 v = visitor_input_test_init(data, "{ 'sub': [ {} ] }");
77c47de2
MA
898 visit_start_struct(v, NULL, NULL, 0, &error_abort);
899 visit_start_struct(v, "struct", NULL, 0, &err);
900 error_free_or_abort(&err);
901 visit_start_list(v, "list", NULL, 0, &err);
902 error_free_or_abort(&err);
903 visit_start_alternate(v, "alternate", &alt, sizeof(*alt), false, &err);
904 error_free_or_abort(&err);
905 visit_optional(v, "optional", &present);
906 g_assert(!present);
907 visit_type_enum(v, "enum", &en, EnumOne_lookup, &err);
908 error_free_or_abort(&err);
909 visit_type_int(v, "i64", &i64, &err);
910 error_free_or_abort(&err);
911 visit_type_uint32(v, "u32", &u32, &err);
912 error_free_or_abort(&err);
913 visit_type_int8(v, "i8", &i8, &err);
914 error_free_or_abort(&err);
915 visit_type_str(v, "i8", &str, &err);
916 error_free_or_abort(&err);
917 visit_type_number(v, "dbl", &dbl, &err);
918 error_free_or_abort(&err);
919 visit_type_any(v, "any", &any, &err);
920 error_free_or_abort(&err);
921 visit_type_null(v, "null", &err);
922 error_free_or_abort(&err);
86ca0dbe
MA
923 visit_start_list(v, "sub", NULL, 0, &error_abort);
924 visit_start_struct(v, NULL, NULL, 0, &error_abort);
925 visit_type_int(v, "i64", &i64, &err);
926 error_free_or_abort(&err);
927 visit_end_struct(v, NULL);
928 visit_end_list(v, NULL);
77c47de2
MA
929 visit_end_struct(v, NULL);
930}
931
9cb8ef36
MA
932static void test_visitor_in_fail_list(TestInputVisitorData *data,
933 const void *unused)
934{
935 int64_t i64 = -1;
936 Visitor *v;
937
938 /* Unvisited list tail */
939
940 v = visitor_input_test_init(data, "[ 1, 2, 3 ]");
941
942 visit_start_list(v, NULL, NULL, 0, &error_abort);
943 visit_type_int(v, NULL, &i64, &error_abort);
944 g_assert_cmpint(i64, ==, 1);
945 visit_type_int(v, NULL, &i64, &error_abort);
946 g_assert_cmpint(i64, ==, 2);
947 visit_end_list(v, NULL);
948 /* BUG: unvisited tail not reported; actually not reportable by design */
949}
950
951static void test_visitor_in_fail_list_nested(TestInputVisitorData *data,
952 const void *unused)
953{
954 int64_t i64 = -1;
955 Visitor *v;
956
957 /* Unvisited nested list tail */
958
959 v = visitor_input_test_init(data, "[ 0, [ 1, 2, 3 ] ]");
960
961 visit_start_list(v, NULL, NULL, 0, &error_abort);
962 visit_type_int(v, NULL, &i64, &error_abort);
963 g_assert_cmpint(i64, ==, 0);
964 visit_start_list(v, NULL, NULL, 0, &error_abort);
965 visit_type_int(v, NULL, &i64, &error_abort);
966 g_assert_cmpint(i64, ==, 1);
967 visit_end_list(v, NULL);
968 /* BUG: unvisited tail not reported; actually not reportable by design */
969 visit_end_list(v, NULL);
970}
971
77c47de2
MA
972static void test_visitor_in_fail_union_native_list(TestInputVisitorData *data,
973 const void *unused)
974{
975 UserDefNativeListUnion *tmp = NULL;
976 Error *err = NULL;
977 Visitor *v;
978
979 v = visitor_input_test_init(data,
980 "{ 'type': 'integer', 'data' : [ 'string' ] }");
981
982 visit_type_UserDefNativeListUnion(v, NULL, &tmp, &err);
983 error_free_or_abort(&err);
984 g_assert(!tmp);
985}
986
987static void test_visitor_in_fail_union_flat(TestInputVisitorData *data,
988 const void *unused)
989{
990 UserDefFlatUnion *tmp = NULL;
991 Error *err = NULL;
992 Visitor *v;
993
994 v = visitor_input_test_init(data, "{ 'string': 'c', 'integer': 41, 'boolean': true }");
995
996 visit_type_UserDefFlatUnion(v, NULL, &tmp, &err);
997 error_free_or_abort(&err);
998 g_assert(!tmp);
999}
1000
1001static void test_visitor_in_fail_union_flat_no_discrim(TestInputVisitorData *data,
1002 const void *unused)
1003{
1004 UserDefFlatUnion2 *tmp = NULL;
1005 Error *err = NULL;
1006 Visitor *v;
1007
1008 /* test situation where discriminator field ('enum1' here) is missing */
1009 v = visitor_input_test_init(data, "{ 'integer': 42, 'string': 'c', 'string1': 'd', 'string2': 'e' }");
1010
1011 visit_type_UserDefFlatUnion2(v, NULL, &tmp, &err);
1012 error_free_or_abort(&err);
1013 g_assert(!tmp);
1014}
1015
1016static void test_visitor_in_fail_alternate(TestInputVisitorData *data,
1017 const void *unused)
1018{
1019 UserDefAlternate *tmp;
1020 Visitor *v;
1021 Error *err = NULL;
1022
1023 v = visitor_input_test_init(data, "3.14");
1024
1025 visit_type_UserDefAlternate(v, NULL, &tmp, &err);
1026 error_free_or_abort(&err);
1027 g_assert(!tmp);
1028}
1029
1030static void do_test_visitor_in_qmp_introspect(TestInputVisitorData *data,
1031 const char *schema_json)
1032{
1033 SchemaInfoList *schema = NULL;
1034 Visitor *v;
1035
1036 v = visitor_input_test_init_raw(data, schema_json);
1037
1038 visit_type_SchemaInfoList(v, NULL, &schema, &error_abort);
1039 g_assert(schema);
1040
1041 qapi_free_SchemaInfoList(schema);
1042}
1043
1044static void test_visitor_in_qmp_introspect(TestInputVisitorData *data,
1045 const void *unused)
1046{
1047 do_test_visitor_in_qmp_introspect(data, test_qmp_schema_json);
1048 do_test_visitor_in_qmp_introspect(data, qmp_schema_json);
1049}
1050
d88f5fd1
LC
1051int main(int argc, char **argv)
1052{
d88f5fd1
LC
1053 g_test_init(&argc, &argv, NULL);
1054
1055 input_visitor_test_add("/visitor/input/int",
b1d2e5f1 1056 NULL, test_visitor_in_int);
e92cfa0d 1057 input_visitor_test_add("/visitor/input/int_overflow",
b1d2e5f1 1058 NULL, test_visitor_in_int_overflow);
d88f5fd1 1059 input_visitor_test_add("/visitor/input/bool",
b1d2e5f1 1060 NULL, test_visitor_in_bool);
d88f5fd1 1061 input_visitor_test_add("/visitor/input/number",
b1d2e5f1 1062 NULL, test_visitor_in_number);
d88f5fd1 1063 input_visitor_test_add("/visitor/input/string",
b1d2e5f1 1064 NULL, test_visitor_in_string);
d88f5fd1 1065 input_visitor_test_add("/visitor/input/enum",
b1d2e5f1 1066 NULL, test_visitor_in_enum);
d88f5fd1 1067 input_visitor_test_add("/visitor/input/struct",
b1d2e5f1 1068 NULL, test_visitor_in_struct);
d88f5fd1 1069 input_visitor_test_add("/visitor/input/struct-nested",
b1d2e5f1 1070 NULL, test_visitor_in_struct_nested);
d88f5fd1 1071 input_visitor_test_add("/visitor/input/list",
b1d2e5f1 1072 NULL, test_visitor_in_list);
28770e05 1073 input_visitor_test_add("/visitor/input/any",
b1d2e5f1 1074 NULL, test_visitor_in_any);
3df016f1 1075 input_visitor_test_add("/visitor/input/null",
b1d2e5f1 1076 NULL, test_visitor_in_null);
2fc00432 1077 input_visitor_test_add("/visitor/input/union-flat",
b1d2e5f1 1078 NULL, test_visitor_in_union_flat);
ab045267 1079 input_visitor_test_add("/visitor/input/alternate",
b1d2e5f1 1080 NULL, test_visitor_in_alternate);
3dcf71f6 1081 input_visitor_test_add("/visitor/input/errors",
b1d2e5f1 1082 NULL, test_visitor_in_errors);
2533377c 1083 input_visitor_test_add("/visitor/input/wrong-type",
b1d2e5f1 1084 NULL, test_visitor_in_wrong_type);
9c51b441 1085 input_visitor_test_add("/visitor/input/alternate-number",
b1d2e5f1 1086 NULL, test_visitor_in_alternate_number);
199e0f17 1087 input_visitor_test_add("/visitor/input/native_list/int",
b1d2e5f1 1088 NULL, test_visitor_in_native_list_int);
199e0f17 1089 input_visitor_test_add("/visitor/input/native_list/int8",
b1d2e5f1 1090 NULL, test_visitor_in_native_list_int8);
199e0f17 1091 input_visitor_test_add("/visitor/input/native_list/int16",
b1d2e5f1 1092 NULL, test_visitor_in_native_list_int16);
199e0f17 1093 input_visitor_test_add("/visitor/input/native_list/int32",
b1d2e5f1 1094 NULL, test_visitor_in_native_list_int32);
199e0f17 1095 input_visitor_test_add("/visitor/input/native_list/int64",
b1d2e5f1 1096 NULL, test_visitor_in_native_list_int64);
199e0f17 1097 input_visitor_test_add("/visitor/input/native_list/uint8",
b1d2e5f1 1098 NULL, test_visitor_in_native_list_uint8);
199e0f17 1099 input_visitor_test_add("/visitor/input/native_list/uint16",
b1d2e5f1 1100 NULL, test_visitor_in_native_list_uint16);
199e0f17 1101 input_visitor_test_add("/visitor/input/native_list/uint32",
b1d2e5f1 1102 NULL, test_visitor_in_native_list_uint32);
199e0f17 1103 input_visitor_test_add("/visitor/input/native_list/uint64",
b1d2e5f1 1104 NULL, test_visitor_in_native_list_uint64);
199e0f17 1105 input_visitor_test_add("/visitor/input/native_list/bool",
b1d2e5f1 1106 NULL, test_visitor_in_native_list_bool);
199e0f17 1107 input_visitor_test_add("/visitor/input/native_list/str",
b1d2e5f1 1108 NULL, test_visitor_in_native_list_string);
199e0f17 1109 input_visitor_test_add("/visitor/input/native_list/number",
b1d2e5f1 1110 NULL, test_visitor_in_native_list_number);
77c47de2
MA
1111 input_visitor_test_add("/visitor/input/fail/struct",
1112 NULL, test_visitor_in_fail_struct);
1113 input_visitor_test_add("/visitor/input/fail/struct-nested",
1114 NULL, test_visitor_in_fail_struct_nested);
1115 input_visitor_test_add("/visitor/input/fail/struct-in-list",
1116 NULL, test_visitor_in_fail_struct_in_list);
1117 input_visitor_test_add("/visitor/input/fail/struct-missing",
1118 NULL, test_visitor_in_fail_struct_missing);
9cb8ef36
MA
1119 input_visitor_test_add("/visitor/input/fail/list",
1120 NULL, test_visitor_in_fail_list);
1121 input_visitor_test_add("/visitor/input/fail/list-nested",
1122 NULL, test_visitor_in_fail_list_nested);
77c47de2
MA
1123 input_visitor_test_add("/visitor/input/fail/union-flat",
1124 NULL, test_visitor_in_fail_union_flat);
1125 input_visitor_test_add("/visitor/input/fail/union-flat-no-discriminator",
1126 NULL, test_visitor_in_fail_union_flat_no_discrim);
1127 input_visitor_test_add("/visitor/input/fail/alternate",
1128 NULL, test_visitor_in_fail_alternate);
1129 input_visitor_test_add("/visitor/input/fail/union-native-list",
1130 NULL, test_visitor_in_fail_union_native_list);
1131 input_visitor_test_add("/visitor/input/qmp-introspect",
1132 NULL, test_visitor_in_qmp_introspect);
d88f5fd1
LC
1133
1134 g_test_run();
1135
1136 return 0;
1137}