Merge remote-tracking branch 'remotes/borntraeger/tags/s390x-20170608' into staging
[qemu/kevin.git] / tests / test-qobject-input-visitor.c
blob6b997a177d799e5f01a2614bf958744dc16aef6d
1 /*
2 * QObject Input Visitor unit-tests.
4 * Copyright (C) 2011-2016 Red Hat Inc.
6 * Authors:
7 * Luiz Capitulino <lcapitulino@redhat.com>
8 * Paolo Bonzini <pbonzini@redhat.com>
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.
14 #include "qemu/osdep.h"
16 #include "qemu-common.h"
17 #include "qapi/error.h"
18 #include "qapi/qobject-input-visitor.h"
19 #include "test-qapi-types.h"
20 #include "test-qapi-visit.h"
21 #include "qapi/qmp/types.h"
22 #include "qapi/qmp/qjson.h"
23 #include "test-qmp-introspect.h"
24 #include "qmp-introspect.h"
25 #include "qapi-visit.h"
27 typedef struct TestInputVisitorData {
28 QObject *obj;
29 Visitor *qiv;
30 } TestInputVisitorData;
32 static void visitor_input_teardown(TestInputVisitorData *data,
33 const void *unused)
35 qobject_decref(data->obj);
36 data->obj = NULL;
38 if (data->qiv) {
39 visit_free(data->qiv);
40 data->qiv = NULL;
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()). */
47 static Visitor *visitor_input_test_init_internal(TestInputVisitorData *data,
48 bool keyval,
49 const char *json_string,
50 va_list *ap)
52 visitor_input_teardown(data, NULL);
54 data->obj = qobject_from_jsonv(json_string, ap, &error_abort);
55 g_assert(data->obj);
57 if (keyval) {
58 data->qiv = qobject_input_visitor_new_keyval(data->obj);
59 } else {
60 data->qiv = qobject_input_visitor_new(data->obj);
62 g_assert(data->qiv);
63 return data->qiv;
66 static GCC_FMT_ATTR(3, 4)
67 Visitor *visitor_input_test_init_full(TestInputVisitorData *data,
68 bool keyval,
69 const char *json_string, ...)
71 Visitor *v;
72 va_list ap;
74 va_start(ap, json_string);
75 v = visitor_input_test_init_internal(data, keyval, json_string, &ap);
76 va_end(ap);
77 return v;
80 static GCC_FMT_ATTR(2, 3)
81 Visitor *visitor_input_test_init(TestInputVisitorData *data,
82 const char *json_string, ...)
84 Visitor *v;
85 va_list ap;
87 va_start(ap, json_string);
88 v = visitor_input_test_init_internal(data, false, json_string, &ap);
89 va_end(ap);
90 return v;
93 /* similar to visitor_input_test_init(), but does not expect a string
94 * literal/format json_string argument and so can be used for
95 * programatically generated strings (and we can't pass in programatically
96 * generated strings via %s format parameters since qobject_from_jsonv()
97 * will wrap those in double-quotes and treat the entire object as a
98 * string)
100 static Visitor *visitor_input_test_init_raw(TestInputVisitorData *data,
101 const char *json_string)
103 return visitor_input_test_init_internal(data, false, json_string, NULL);
106 static void test_visitor_in_int(TestInputVisitorData *data,
107 const void *unused)
109 int64_t res = 0;
110 int value = -42;
111 Visitor *v;
113 v = visitor_input_test_init(data, "%d", value);
115 visit_type_int(v, NULL, &res, &error_abort);
116 g_assert_cmpint(res, ==, value);
119 static void test_visitor_in_uint(TestInputVisitorData *data,
120 const void *unused)
122 Error *err = NULL;
123 uint64_t res = 0;
124 int value = 42;
125 Visitor *v;
127 v = visitor_input_test_init(data, "%d", value);
129 visit_type_uint64(v, NULL, &res, &error_abort);
130 g_assert_cmpuint(res, ==, (uint64_t)value);
132 /* BUG: value between INT64_MIN and -1 accepted modulo 2^64 */
134 v = visitor_input_test_init(data, "%d", -value);
136 visit_type_uint64(v, NULL, &res, &error_abort);
137 g_assert_cmpuint(res, ==, (uint64_t)-value);
139 /* BUG: value between INT64_MAX+1 and UINT64_MAX rejected */
141 v = visitor_input_test_init(data, "18446744073709551574");
143 visit_type_uint64(v, NULL, &res, &err);
144 error_free_or_abort(&err);
147 static void test_visitor_in_int_overflow(TestInputVisitorData *data,
148 const void *unused)
150 int64_t res = 0;
151 Error *err = NULL;
152 Visitor *v;
154 /* this will overflow a Qint/int64, so should be deserialized into
155 * a QFloat/double field instead, leading to an error if we pass it
156 * to visit_type_int. confirm this.
158 v = visitor_input_test_init(data, "%f", DBL_MAX);
160 visit_type_int(v, NULL, &res, &err);
161 error_free_or_abort(&err);
164 static void test_visitor_in_int_keyval(TestInputVisitorData *data,
165 const void *unused)
167 int64_t res = 0, value = -42;
168 Error *err = NULL;
169 Visitor *v;
171 v = visitor_input_test_init_full(data, true, "%" PRId64, value);
172 visit_type_int(v, NULL, &res, &err);
173 error_free_or_abort(&err);
176 static void test_visitor_in_int_str_keyval(TestInputVisitorData *data,
177 const void *unused)
179 int64_t res = 0, value = -42;
180 Visitor *v;
182 v = visitor_input_test_init_full(data, true, "\"-42\"");
184 visit_type_int(v, NULL, &res, &error_abort);
185 g_assert_cmpint(res, ==, value);
188 static void test_visitor_in_int_str_fail(TestInputVisitorData *data,
189 const void *unused)
191 int64_t res = 0;
192 Visitor *v;
193 Error *err = NULL;
195 v = visitor_input_test_init(data, "\"-42\"");
197 visit_type_int(v, NULL, &res, &err);
198 error_free_or_abort(&err);
201 static void test_visitor_in_bool(TestInputVisitorData *data,
202 const void *unused)
204 bool res = false;
205 Visitor *v;
207 v = visitor_input_test_init(data, "true");
209 visit_type_bool(v, NULL, &res, &error_abort);
210 g_assert_cmpint(res, ==, true);
213 static void test_visitor_in_bool_keyval(TestInputVisitorData *data,
214 const void *unused)
216 bool res = false;
217 Error *err = NULL;
218 Visitor *v;
220 v = visitor_input_test_init_full(data, true, "true");
222 visit_type_bool(v, NULL, &res, &err);
223 error_free_or_abort(&err);
226 static void test_visitor_in_bool_str_keyval(TestInputVisitorData *data,
227 const void *unused)
229 bool res = false;
230 Visitor *v;
232 v = visitor_input_test_init_full(data, true, "\"on\"");
234 visit_type_bool(v, NULL, &res, &error_abort);
235 g_assert_cmpint(res, ==, true);
238 static void test_visitor_in_bool_str_fail(TestInputVisitorData *data,
239 const void *unused)
241 bool res = false;
242 Visitor *v;
243 Error *err = NULL;
245 v = visitor_input_test_init(data, "\"true\"");
247 visit_type_bool(v, NULL, &res, &err);
248 error_free_or_abort(&err);
251 static void test_visitor_in_number(TestInputVisitorData *data,
252 const void *unused)
254 double res = 0, value = 3.14;
255 Visitor *v;
257 v = visitor_input_test_init(data, "%f", value);
259 visit_type_number(v, NULL, &res, &error_abort);
260 g_assert_cmpfloat(res, ==, value);
263 static void test_visitor_in_number_keyval(TestInputVisitorData *data,
264 const void *unused)
266 double res = 0, value = 3.14;
267 Error *err = NULL;
268 Visitor *v;
270 v = visitor_input_test_init_full(data, true, "%f", value);
272 visit_type_number(v, NULL, &res, &err);
273 error_free_or_abort(&err);
276 static void test_visitor_in_number_str_keyval(TestInputVisitorData *data,
277 const void *unused)
279 double res = 0, value = 3.14;
280 Visitor *v;
281 Error *err = NULL;
283 v = visitor_input_test_init_full(data, true, "\"3.14\"");
285 visit_type_number(v, NULL, &res, &error_abort);
286 g_assert_cmpfloat(res, ==, value);
288 v = visitor_input_test_init_full(data, true, "\"inf\"");
290 visit_type_number(v, NULL, &res, &err);
291 error_free_or_abort(&err);
294 static void test_visitor_in_number_str_fail(TestInputVisitorData *data,
295 const void *unused)
297 double res = 0;
298 Visitor *v;
299 Error *err = NULL;
301 v = visitor_input_test_init(data, "\"3.14\"");
303 visit_type_number(v, NULL, &res, &err);
304 error_free_or_abort(&err);
307 static void test_visitor_in_size_str_keyval(TestInputVisitorData *data,
308 const void *unused)
310 uint64_t res, value = 500 * 1024 * 1024;
311 Visitor *v;
313 v = visitor_input_test_init_full(data, true, "\"500M\"");
315 visit_type_size(v, NULL, &res, &error_abort);
316 g_assert_cmpfloat(res, ==, value);
319 static void test_visitor_in_size_str_fail(TestInputVisitorData *data,
320 const void *unused)
322 uint64_t res = 0;
323 Visitor *v;
324 Error *err = NULL;
326 v = visitor_input_test_init(data, "\"500M\"");
328 visit_type_size(v, NULL, &res, &err);
329 error_free_or_abort(&err);
332 static void test_visitor_in_string(TestInputVisitorData *data,
333 const void *unused)
335 char *res = NULL, *value = (char *) "Q E M U";
336 Visitor *v;
338 v = visitor_input_test_init(data, "%s", value);
340 visit_type_str(v, NULL, &res, &error_abort);
341 g_assert_cmpstr(res, ==, value);
343 g_free(res);
346 static void test_visitor_in_enum(TestInputVisitorData *data,
347 const void *unused)
349 Visitor *v;
350 EnumOne i;
352 for (i = 0; EnumOne_lookup[i]; i++) {
353 EnumOne res = -1;
355 v = visitor_input_test_init(data, "%s", EnumOne_lookup[i]);
357 visit_type_EnumOne(v, NULL, &res, &error_abort);
358 g_assert_cmpint(i, ==, res);
363 static void test_visitor_in_struct(TestInputVisitorData *data,
364 const void *unused)
366 TestStruct *p = NULL;
367 Visitor *v;
369 v = visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }");
371 visit_type_TestStruct(v, NULL, &p, &error_abort);
372 g_assert_cmpint(p->integer, ==, -42);
373 g_assert(p->boolean == true);
374 g_assert_cmpstr(p->string, ==, "foo");
376 g_free(p->string);
377 g_free(p);
380 static void test_visitor_in_struct_nested(TestInputVisitorData *data,
381 const void *unused)
383 UserDefTwo *udp = NULL;
384 Visitor *v;
386 v = visitor_input_test_init(data, "{ 'string0': 'string0', "
387 "'dict1': { 'string1': 'string1', "
388 "'dict2': { 'userdef': { 'integer': 42, "
389 "'string': 'string' }, 'string': 'string2'}}}");
391 visit_type_UserDefTwo(v, NULL, &udp, &error_abort);
393 g_assert_cmpstr(udp->string0, ==, "string0");
394 g_assert_cmpstr(udp->dict1->string1, ==, "string1");
395 g_assert_cmpint(udp->dict1->dict2->userdef->integer, ==, 42);
396 g_assert_cmpstr(udp->dict1->dict2->userdef->string, ==, "string");
397 g_assert_cmpstr(udp->dict1->dict2->string, ==, "string2");
398 g_assert(udp->dict1->has_dict3 == false);
400 qapi_free_UserDefTwo(udp);
403 static void test_visitor_in_list(TestInputVisitorData *data,
404 const void *unused)
406 UserDefOneList *item, *head = NULL;
407 Visitor *v;
408 int i;
410 v = visitor_input_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44 } ]");
412 visit_type_UserDefOneList(v, NULL, &head, &error_abort);
413 g_assert(head != NULL);
415 for (i = 0, item = head; item; item = item->next, i++) {
416 char string[12];
418 snprintf(string, sizeof(string), "string%d", i);
419 g_assert_cmpstr(item->value->string, ==, string);
420 g_assert_cmpint(item->value->integer, ==, 42 + i);
423 qapi_free_UserDefOneList(head);
424 head = NULL;
426 /* An empty list is valid */
427 v = visitor_input_test_init(data, "[]");
428 visit_type_UserDefOneList(v, NULL, &head, &error_abort);
429 g_assert(!head);
432 static void test_visitor_in_any(TestInputVisitorData *data,
433 const void *unused)
435 QObject *res = NULL;
436 Visitor *v;
437 QInt *qint;
438 QBool *qbool;
439 QString *qstring;
440 QDict *qdict;
441 QObject *qobj;
443 v = visitor_input_test_init(data, "-42");
444 visit_type_any(v, NULL, &res, &error_abort);
445 qint = qobject_to_qint(res);
446 g_assert(qint);
447 g_assert_cmpint(qint_get_int(qint), ==, -42);
448 qobject_decref(res);
450 v = visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }");
451 visit_type_any(v, NULL, &res, &error_abort);
452 qdict = qobject_to_qdict(res);
453 g_assert(qdict && qdict_size(qdict) == 3);
454 qobj = qdict_get(qdict, "integer");
455 g_assert(qobj);
456 qint = qobject_to_qint(qobj);
457 g_assert(qint);
458 g_assert_cmpint(qint_get_int(qint), ==, -42);
459 qobj = qdict_get(qdict, "boolean");
460 g_assert(qobj);
461 qbool = qobject_to_qbool(qobj);
462 g_assert(qbool);
463 g_assert(qbool_get_bool(qbool) == true);
464 qobj = qdict_get(qdict, "string");
465 g_assert(qobj);
466 qstring = qobject_to_qstring(qobj);
467 g_assert(qstring);
468 g_assert_cmpstr(qstring_get_str(qstring), ==, "foo");
469 qobject_decref(res);
472 static void test_visitor_in_null(TestInputVisitorData *data,
473 const void *unused)
475 Visitor *v;
476 Error *err = NULL;
477 char *tmp;
480 * FIXME: Since QAPI doesn't know the 'null' type yet, we can't
481 * test visit_type_null() by reading into a QAPI struct then
482 * checking that it was populated correctly. The best we can do
483 * for now is ensure that we consumed null from the input, proven
484 * by the fact that we can't re-read the key; and that we detect
485 * when input is not null.
488 v = visitor_input_test_init_full(data, false,
489 "{ 'a': null, 'b': '' }");
490 visit_start_struct(v, NULL, NULL, 0, &error_abort);
491 visit_type_null(v, "a", &error_abort);
492 visit_type_null(v, "b", &err);
493 error_free_or_abort(&err);
494 visit_type_str(v, "c", &tmp, &err);
495 g_assert(!tmp);
496 error_free_or_abort(&err);
497 visit_check_struct(v, &error_abort);
498 visit_end_struct(v, NULL);
501 static void test_visitor_in_union_flat(TestInputVisitorData *data,
502 const void *unused)
504 Visitor *v;
505 UserDefFlatUnion *tmp;
506 UserDefUnionBase *base;
508 v = visitor_input_test_init(data,
509 "{ 'enum1': 'value1', "
510 "'integer': 41, "
511 "'string': 'str', "
512 "'boolean': true }");
514 visit_type_UserDefFlatUnion(v, NULL, &tmp, &error_abort);
515 g_assert_cmpint(tmp->enum1, ==, ENUM_ONE_VALUE1);
516 g_assert_cmpstr(tmp->string, ==, "str");
517 g_assert_cmpint(tmp->integer, ==, 41);
518 g_assert_cmpint(tmp->u.value1.boolean, ==, true);
520 base = qapi_UserDefFlatUnion_base(tmp);
521 g_assert(&base->enum1 == &tmp->enum1);
523 qapi_free_UserDefFlatUnion(tmp);
526 static void test_visitor_in_alternate(TestInputVisitorData *data,
527 const void *unused)
529 Visitor *v;
530 Error *err = NULL;
531 UserDefAlternate *tmp;
532 WrapAlternate *wrap;
534 v = visitor_input_test_init(data, "42");
535 visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort);
536 g_assert_cmpint(tmp->type, ==, QTYPE_QINT);
537 g_assert_cmpint(tmp->u.i, ==, 42);
538 qapi_free_UserDefAlternate(tmp);
540 v = visitor_input_test_init(data, "'value1'");
541 visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort);
542 g_assert_cmpint(tmp->type, ==, QTYPE_QSTRING);
543 g_assert_cmpint(tmp->u.e, ==, ENUM_ONE_VALUE1);
544 qapi_free_UserDefAlternate(tmp);
546 v = visitor_input_test_init(data, "{'integer':1, 'string':'str', "
547 "'enum1':'value1', 'boolean':true}");
548 visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort);
549 g_assert_cmpint(tmp->type, ==, QTYPE_QDICT);
550 g_assert_cmpint(tmp->u.udfu.integer, ==, 1);
551 g_assert_cmpstr(tmp->u.udfu.string, ==, "str");
552 g_assert_cmpint(tmp->u.udfu.enum1, ==, ENUM_ONE_VALUE1);
553 g_assert_cmpint(tmp->u.udfu.u.value1.boolean, ==, true);
554 g_assert_cmpint(tmp->u.udfu.u.value1.has_a_b, ==, false);
555 qapi_free_UserDefAlternate(tmp);
557 v = visitor_input_test_init(data, "false");
558 visit_type_UserDefAlternate(v, NULL, &tmp, &err);
559 error_free_or_abort(&err);
560 qapi_free_UserDefAlternate(tmp);
562 v = visitor_input_test_init(data, "{ 'alt': 42 }");
563 visit_type_WrapAlternate(v, NULL, &wrap, &error_abort);
564 g_assert_cmpint(wrap->alt->type, ==, QTYPE_QINT);
565 g_assert_cmpint(wrap->alt->u.i, ==, 42);
566 qapi_free_WrapAlternate(wrap);
568 v = visitor_input_test_init(data, "{ 'alt': 'value1' }");
569 visit_type_WrapAlternate(v, NULL, &wrap, &error_abort);
570 g_assert_cmpint(wrap->alt->type, ==, QTYPE_QSTRING);
571 g_assert_cmpint(wrap->alt->u.e, ==, ENUM_ONE_VALUE1);
572 qapi_free_WrapAlternate(wrap);
574 v = visitor_input_test_init(data, "{ 'alt': {'integer':1, 'string':'str', "
575 "'enum1':'value1', 'boolean':true} }");
576 visit_type_WrapAlternate(v, NULL, &wrap, &error_abort);
577 g_assert_cmpint(wrap->alt->type, ==, QTYPE_QDICT);
578 g_assert_cmpint(wrap->alt->u.udfu.integer, ==, 1);
579 g_assert_cmpstr(wrap->alt->u.udfu.string, ==, "str");
580 g_assert_cmpint(wrap->alt->u.udfu.enum1, ==, ENUM_ONE_VALUE1);
581 g_assert_cmpint(wrap->alt->u.udfu.u.value1.boolean, ==, true);
582 g_assert_cmpint(wrap->alt->u.udfu.u.value1.has_a_b, ==, false);
583 qapi_free_WrapAlternate(wrap);
586 static void test_visitor_in_alternate_number(TestInputVisitorData *data,
587 const void *unused)
589 Visitor *v;
590 Error *err = NULL;
591 AltEnumBool *aeb;
592 AltEnumNum *aen;
593 AltNumEnum *ans;
594 AltEnumInt *asi;
595 AltIntNum *ain;
596 AltNumInt *ani;
598 /* Parsing an int */
600 v = visitor_input_test_init(data, "42");
601 visit_type_AltEnumBool(v, NULL, &aeb, &err);
602 error_free_or_abort(&err);
603 qapi_free_AltEnumBool(aeb);
605 v = visitor_input_test_init(data, "42");
606 visit_type_AltEnumNum(v, NULL, &aen, &error_abort);
607 g_assert_cmpint(aen->type, ==, QTYPE_QFLOAT);
608 g_assert_cmpfloat(aen->u.n, ==, 42);
609 qapi_free_AltEnumNum(aen);
611 v = visitor_input_test_init(data, "42");
612 visit_type_AltNumEnum(v, NULL, &ans, &error_abort);
613 g_assert_cmpint(ans->type, ==, QTYPE_QFLOAT);
614 g_assert_cmpfloat(ans->u.n, ==, 42);
615 qapi_free_AltNumEnum(ans);
617 v = visitor_input_test_init(data, "42");
618 visit_type_AltEnumInt(v, NULL, &asi, &error_abort);
619 g_assert_cmpint(asi->type, ==, QTYPE_QINT);
620 g_assert_cmpint(asi->u.i, ==, 42);
621 qapi_free_AltEnumInt(asi);
623 v = visitor_input_test_init(data, "42");
624 visit_type_AltIntNum(v, NULL, &ain, &error_abort);
625 g_assert_cmpint(ain->type, ==, QTYPE_QINT);
626 g_assert_cmpint(ain->u.i, ==, 42);
627 qapi_free_AltIntNum(ain);
629 v = visitor_input_test_init(data, "42");
630 visit_type_AltNumInt(v, NULL, &ani, &error_abort);
631 g_assert_cmpint(ani->type, ==, QTYPE_QINT);
632 g_assert_cmpint(ani->u.i, ==, 42);
633 qapi_free_AltNumInt(ani);
635 /* Parsing a double */
637 v = visitor_input_test_init(data, "42.5");
638 visit_type_AltEnumBool(v, NULL, &aeb, &err);
639 error_free_or_abort(&err);
640 qapi_free_AltEnumBool(aeb);
642 v = visitor_input_test_init(data, "42.5");
643 visit_type_AltEnumNum(v, NULL, &aen, &error_abort);
644 g_assert_cmpint(aen->type, ==, QTYPE_QFLOAT);
645 g_assert_cmpfloat(aen->u.n, ==, 42.5);
646 qapi_free_AltEnumNum(aen);
648 v = visitor_input_test_init(data, "42.5");
649 visit_type_AltNumEnum(v, NULL, &ans, &error_abort);
650 g_assert_cmpint(ans->type, ==, QTYPE_QFLOAT);
651 g_assert_cmpfloat(ans->u.n, ==, 42.5);
652 qapi_free_AltNumEnum(ans);
654 v = visitor_input_test_init(data, "42.5");
655 visit_type_AltEnumInt(v, NULL, &asi, &err);
656 error_free_or_abort(&err);
657 qapi_free_AltEnumInt(asi);
659 v = visitor_input_test_init(data, "42.5");
660 visit_type_AltIntNum(v, NULL, &ain, &error_abort);
661 g_assert_cmpint(ain->type, ==, QTYPE_QFLOAT);
662 g_assert_cmpfloat(ain->u.n, ==, 42.5);
663 qapi_free_AltIntNum(ain);
665 v = visitor_input_test_init(data, "42.5");
666 visit_type_AltNumInt(v, NULL, &ani, &error_abort);
667 g_assert_cmpint(ani->type, ==, QTYPE_QFLOAT);
668 g_assert_cmpfloat(ani->u.n, ==, 42.5);
669 qapi_free_AltNumInt(ani);
672 static void test_native_list_integer_helper(TestInputVisitorData *data,
673 const void *unused,
674 UserDefNativeListUnionKind kind)
676 UserDefNativeListUnion *cvalue = NULL;
677 Visitor *v;
678 GString *gstr_list = g_string_new("");
679 GString *gstr_union = g_string_new("");
680 int i;
682 for (i = 0; i < 32; i++) {
683 g_string_append_printf(gstr_list, "%d", i);
684 if (i != 31) {
685 g_string_append(gstr_list, ", ");
688 g_string_append_printf(gstr_union, "{ 'type': '%s', 'data': [ %s ] }",
689 UserDefNativeListUnionKind_lookup[kind],
690 gstr_list->str);
691 v = visitor_input_test_init_raw(data, gstr_union->str);
693 visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);
694 g_assert(cvalue != NULL);
695 g_assert_cmpint(cvalue->type, ==, kind);
697 switch (kind) {
698 case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: {
699 intList *elem = NULL;
700 for (i = 0, elem = cvalue->u.integer.data;
701 elem; elem = elem->next, i++) {
702 g_assert_cmpint(elem->value, ==, i);
704 break;
706 case USER_DEF_NATIVE_LIST_UNION_KIND_S8: {
707 int8List *elem = NULL;
708 for (i = 0, elem = cvalue->u.s8.data; elem; elem = elem->next, i++) {
709 g_assert_cmpint(elem->value, ==, i);
711 break;
713 case USER_DEF_NATIVE_LIST_UNION_KIND_S16: {
714 int16List *elem = NULL;
715 for (i = 0, elem = cvalue->u.s16.data; elem; elem = elem->next, i++) {
716 g_assert_cmpint(elem->value, ==, i);
718 break;
720 case USER_DEF_NATIVE_LIST_UNION_KIND_S32: {
721 int32List *elem = NULL;
722 for (i = 0, elem = cvalue->u.s32.data; elem; elem = elem->next, i++) {
723 g_assert_cmpint(elem->value, ==, i);
725 break;
727 case USER_DEF_NATIVE_LIST_UNION_KIND_S64: {
728 int64List *elem = NULL;
729 for (i = 0, elem = cvalue->u.s64.data; elem; elem = elem->next, i++) {
730 g_assert_cmpint(elem->value, ==, i);
732 break;
734 case USER_DEF_NATIVE_LIST_UNION_KIND_U8: {
735 uint8List *elem = NULL;
736 for (i = 0, elem = cvalue->u.u8.data; elem; elem = elem->next, i++) {
737 g_assert_cmpint(elem->value, ==, i);
739 break;
741 case USER_DEF_NATIVE_LIST_UNION_KIND_U16: {
742 uint16List *elem = NULL;
743 for (i = 0, elem = cvalue->u.u16.data; elem; elem = elem->next, i++) {
744 g_assert_cmpint(elem->value, ==, i);
746 break;
748 case USER_DEF_NATIVE_LIST_UNION_KIND_U32: {
749 uint32List *elem = NULL;
750 for (i = 0, elem = cvalue->u.u32.data; elem; elem = elem->next, i++) {
751 g_assert_cmpint(elem->value, ==, i);
753 break;
755 case USER_DEF_NATIVE_LIST_UNION_KIND_U64: {
756 uint64List *elem = NULL;
757 for (i = 0, elem = cvalue->u.u64.data; elem; elem = elem->next, i++) {
758 g_assert_cmpint(elem->value, ==, i);
760 break;
762 default:
763 g_assert_not_reached();
766 g_string_free(gstr_union, true);
767 g_string_free(gstr_list, true);
768 qapi_free_UserDefNativeListUnion(cvalue);
771 static void test_visitor_in_native_list_int(TestInputVisitorData *data,
772 const void *unused)
774 test_native_list_integer_helper(data, unused,
775 USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER);
778 static void test_visitor_in_native_list_int8(TestInputVisitorData *data,
779 const void *unused)
781 test_native_list_integer_helper(data, unused,
782 USER_DEF_NATIVE_LIST_UNION_KIND_S8);
785 static void test_visitor_in_native_list_int16(TestInputVisitorData *data,
786 const void *unused)
788 test_native_list_integer_helper(data, unused,
789 USER_DEF_NATIVE_LIST_UNION_KIND_S16);
792 static void test_visitor_in_native_list_int32(TestInputVisitorData *data,
793 const void *unused)
795 test_native_list_integer_helper(data, unused,
796 USER_DEF_NATIVE_LIST_UNION_KIND_S32);
799 static void test_visitor_in_native_list_int64(TestInputVisitorData *data,
800 const void *unused)
802 test_native_list_integer_helper(data, unused,
803 USER_DEF_NATIVE_LIST_UNION_KIND_S64);
806 static void test_visitor_in_native_list_uint8(TestInputVisitorData *data,
807 const void *unused)
809 test_native_list_integer_helper(data, unused,
810 USER_DEF_NATIVE_LIST_UNION_KIND_U8);
813 static void test_visitor_in_native_list_uint16(TestInputVisitorData *data,
814 const void *unused)
816 test_native_list_integer_helper(data, unused,
817 USER_DEF_NATIVE_LIST_UNION_KIND_U16);
820 static void test_visitor_in_native_list_uint32(TestInputVisitorData *data,
821 const void *unused)
823 test_native_list_integer_helper(data, unused,
824 USER_DEF_NATIVE_LIST_UNION_KIND_U32);
827 static void test_visitor_in_native_list_uint64(TestInputVisitorData *data,
828 const void *unused)
830 test_native_list_integer_helper(data, unused,
831 USER_DEF_NATIVE_LIST_UNION_KIND_U64);
834 static void test_visitor_in_native_list_bool(TestInputVisitorData *data,
835 const void *unused)
837 UserDefNativeListUnion *cvalue = NULL;
838 boolList *elem = NULL;
839 Visitor *v;
840 GString *gstr_list = g_string_new("");
841 GString *gstr_union = g_string_new("");
842 int i;
844 for (i = 0; i < 32; i++) {
845 g_string_append_printf(gstr_list, "%s",
846 (i % 3 == 0) ? "true" : "false");
847 if (i != 31) {
848 g_string_append(gstr_list, ", ");
851 g_string_append_printf(gstr_union, "{ 'type': 'boolean', 'data': [ %s ] }",
852 gstr_list->str);
853 v = visitor_input_test_init_raw(data, gstr_union->str);
855 visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);
856 g_assert(cvalue != NULL);
857 g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN);
859 for (i = 0, elem = cvalue->u.boolean.data; elem; elem = elem->next, i++) {
860 g_assert_cmpint(elem->value, ==, (i % 3 == 0) ? 1 : 0);
863 g_string_free(gstr_union, true);
864 g_string_free(gstr_list, true);
865 qapi_free_UserDefNativeListUnion(cvalue);
868 static void test_visitor_in_native_list_string(TestInputVisitorData *data,
869 const void *unused)
871 UserDefNativeListUnion *cvalue = NULL;
872 strList *elem = NULL;
873 Visitor *v;
874 GString *gstr_list = g_string_new("");
875 GString *gstr_union = g_string_new("");
876 int i;
878 for (i = 0; i < 32; i++) {
879 g_string_append_printf(gstr_list, "'%d'", i);
880 if (i != 31) {
881 g_string_append(gstr_list, ", ");
884 g_string_append_printf(gstr_union, "{ 'type': 'string', 'data': [ %s ] }",
885 gstr_list->str);
886 v = visitor_input_test_init_raw(data, gstr_union->str);
888 visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);
889 g_assert(cvalue != NULL);
890 g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING);
892 for (i = 0, elem = cvalue->u.string.data; elem; elem = elem->next, i++) {
893 gchar str[8];
894 sprintf(str, "%d", i);
895 g_assert_cmpstr(elem->value, ==, str);
898 g_string_free(gstr_union, true);
899 g_string_free(gstr_list, true);
900 qapi_free_UserDefNativeListUnion(cvalue);
903 #define DOUBLE_STR_MAX 16
905 static void test_visitor_in_native_list_number(TestInputVisitorData *data,
906 const void *unused)
908 UserDefNativeListUnion *cvalue = NULL;
909 numberList *elem = NULL;
910 Visitor *v;
911 GString *gstr_list = g_string_new("");
912 GString *gstr_union = g_string_new("");
913 int i;
915 for (i = 0; i < 32; i++) {
916 g_string_append_printf(gstr_list, "%f", (double)i / 3);
917 if (i != 31) {
918 g_string_append(gstr_list, ", ");
921 g_string_append_printf(gstr_union, "{ 'type': 'number', 'data': [ %s ] }",
922 gstr_list->str);
923 v = visitor_input_test_init_raw(data, gstr_union->str);
925 visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);
926 g_assert(cvalue != NULL);
927 g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER);
929 for (i = 0, elem = cvalue->u.number.data; elem; elem = elem->next, i++) {
930 GString *double_expected = g_string_new("");
931 GString *double_actual = g_string_new("");
933 g_string_printf(double_expected, "%.6f", (double)i / 3);
934 g_string_printf(double_actual, "%.6f", elem->value);
935 g_assert_cmpstr(double_expected->str, ==, double_actual->str);
937 g_string_free(double_expected, true);
938 g_string_free(double_actual, true);
941 g_string_free(gstr_union, true);
942 g_string_free(gstr_list, true);
943 qapi_free_UserDefNativeListUnion(cvalue);
946 static void input_visitor_test_add(const char *testpath,
947 const void *user_data,
948 void (*test_func)(TestInputVisitorData *data,
949 const void *user_data))
951 g_test_add(testpath, TestInputVisitorData, user_data, NULL, test_func,
952 visitor_input_teardown);
955 static void test_visitor_in_errors(TestInputVisitorData *data,
956 const void *unused)
958 TestStruct *p = NULL;
959 Error *err = NULL;
960 Visitor *v;
961 strList *q = NULL;
962 UserDefTwo *r = NULL;
963 WrapAlternate *s = NULL;
965 v = visitor_input_test_init(data, "{ 'integer': false, 'boolean': 'foo', "
966 "'string': -42 }");
968 visit_type_TestStruct(v, NULL, &p, &err);
969 error_free_or_abort(&err);
970 g_assert(!p);
972 v = visitor_input_test_init(data, "[ '1', '2', false, '3' ]");
973 visit_type_strList(v, NULL, &q, &err);
974 error_free_or_abort(&err);
975 assert(!q);
977 v = visitor_input_test_init(data, "{ 'str':'hi' }");
978 visit_type_UserDefTwo(v, NULL, &r, &err);
979 error_free_or_abort(&err);
980 assert(!r);
982 v = visitor_input_test_init(data, "{ }");
983 visit_type_WrapAlternate(v, NULL, &s, &err);
984 error_free_or_abort(&err);
985 assert(!s);
988 static void test_visitor_in_wrong_type(TestInputVisitorData *data,
989 const void *unused)
991 TestStruct *p = NULL;
992 Visitor *v;
993 strList *q = NULL;
994 int64_t i;
995 Error *err = NULL;
997 /* Make sure arrays and structs cannot be confused */
999 v = visitor_input_test_init(data, "[]");
1000 visit_type_TestStruct(v, NULL, &p, &err);
1001 error_free_or_abort(&err);
1002 g_assert(!p);
1004 v = visitor_input_test_init(data, "{}");
1005 visit_type_strList(v, NULL, &q, &err);
1006 error_free_or_abort(&err);
1007 assert(!q);
1009 /* Make sure primitives and struct cannot be confused */
1011 v = visitor_input_test_init(data, "1");
1012 visit_type_TestStruct(v, NULL, &p, &err);
1013 error_free_or_abort(&err);
1014 g_assert(!p);
1016 v = visitor_input_test_init(data, "{}");
1017 visit_type_int(v, NULL, &i, &err);
1018 error_free_or_abort(&err);
1020 /* Make sure primitives and arrays cannot be confused */
1022 v = visitor_input_test_init(data, "1");
1023 visit_type_strList(v, NULL, &q, &err);
1024 error_free_or_abort(&err);
1025 assert(!q);
1027 v = visitor_input_test_init(data, "[]");
1028 visit_type_int(v, NULL, &i, &err);
1029 error_free_or_abort(&err);
1032 static void test_visitor_in_fail_struct(TestInputVisitorData *data,
1033 const void *unused)
1035 TestStruct *p = NULL;
1036 Error *err = NULL;
1037 Visitor *v;
1039 v = visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo', 'extra': 42 }");
1041 visit_type_TestStruct(v, NULL, &p, &err);
1042 error_free_or_abort(&err);
1043 g_assert(!p);
1046 static void test_visitor_in_fail_struct_nested(TestInputVisitorData *data,
1047 const void *unused)
1049 UserDefTwo *udp = NULL;
1050 Error *err = NULL;
1051 Visitor *v;
1053 v = visitor_input_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string', 'extra': [42, 23, {'foo':'bar'}] }, 'string2': 'string2'}}}");
1055 visit_type_UserDefTwo(v, NULL, &udp, &err);
1056 error_free_or_abort(&err);
1057 g_assert(!udp);
1060 static void test_visitor_in_fail_struct_in_list(TestInputVisitorData *data,
1061 const void *unused)
1063 UserDefOneList *head = NULL;
1064 Error *err = NULL;
1065 Visitor *v;
1067 v = visitor_input_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44, 'extra': 'ggg' } ]");
1069 visit_type_UserDefOneList(v, NULL, &head, &err);
1070 error_free_or_abort(&err);
1071 g_assert(!head);
1074 static void test_visitor_in_fail_struct_missing(TestInputVisitorData *data,
1075 const void *unused)
1077 Error *err = NULL;
1078 Visitor *v;
1079 QObject *any;
1080 GenericAlternate *alt;
1081 bool present;
1082 int en;
1083 int64_t i64;
1084 uint32_t u32;
1085 int8_t i8;
1086 char *str;
1087 double dbl;
1089 v = visitor_input_test_init(data, "{ 'sub': [ {} ] }");
1090 visit_start_struct(v, NULL, NULL, 0, &error_abort);
1091 visit_start_struct(v, "struct", NULL, 0, &err);
1092 error_free_or_abort(&err);
1093 visit_start_list(v, "list", NULL, 0, &err);
1094 error_free_or_abort(&err);
1095 visit_start_alternate(v, "alternate", &alt, sizeof(*alt), false, &err);
1096 error_free_or_abort(&err);
1097 visit_optional(v, "optional", &present);
1098 g_assert(!present);
1099 visit_type_enum(v, "enum", &en, EnumOne_lookup, &err);
1100 error_free_or_abort(&err);
1101 visit_type_int(v, "i64", &i64, &err);
1102 error_free_or_abort(&err);
1103 visit_type_uint32(v, "u32", &u32, &err);
1104 error_free_or_abort(&err);
1105 visit_type_int8(v, "i8", &i8, &err);
1106 error_free_or_abort(&err);
1107 visit_type_str(v, "i8", &str, &err);
1108 error_free_or_abort(&err);
1109 visit_type_number(v, "dbl", &dbl, &err);
1110 error_free_or_abort(&err);
1111 visit_type_any(v, "any", &any, &err);
1112 error_free_or_abort(&err);
1113 visit_type_null(v, "null", &err);
1114 error_free_or_abort(&err);
1115 visit_start_list(v, "sub", NULL, 0, &error_abort);
1116 visit_start_struct(v, NULL, NULL, 0, &error_abort);
1117 visit_type_int(v, "i64", &i64, &err);
1118 error_free_or_abort(&err);
1119 visit_end_struct(v, NULL);
1120 visit_end_list(v, NULL);
1121 visit_end_struct(v, NULL);
1124 static void test_visitor_in_fail_list(TestInputVisitorData *data,
1125 const void *unused)
1127 int64_t i64 = -1;
1128 Error *err = NULL;
1129 Visitor *v;
1131 /* Unvisited list tail */
1133 v = visitor_input_test_init(data, "[ 1, 2, 3 ]");
1135 visit_start_list(v, NULL, NULL, 0, &error_abort);
1136 visit_type_int(v, NULL, &i64, &error_abort);
1137 g_assert_cmpint(i64, ==, 1);
1138 visit_type_int(v, NULL, &i64, &error_abort);
1139 g_assert_cmpint(i64, ==, 2);
1140 visit_check_list(v, &err);
1141 error_free_or_abort(&err);
1142 visit_end_list(v, NULL);
1144 /* Visit beyond end of list */
1145 v = visitor_input_test_init(data, "[]");
1147 visit_start_list(v, NULL, NULL, 0, &error_abort);
1148 visit_type_int(v, NULL, &i64, &err);
1149 error_free_or_abort(&err);
1150 visit_end_list(v, NULL);
1153 static void test_visitor_in_fail_list_nested(TestInputVisitorData *data,
1154 const void *unused)
1156 int64_t i64 = -1;
1157 Error *err = NULL;
1158 Visitor *v;
1160 /* Unvisited nested list tail */
1162 v = visitor_input_test_init(data, "[ 0, [ 1, 2, 3 ] ]");
1164 visit_start_list(v, NULL, NULL, 0, &error_abort);
1165 visit_type_int(v, NULL, &i64, &error_abort);
1166 g_assert_cmpint(i64, ==, 0);
1167 visit_start_list(v, NULL, NULL, 0, &error_abort);
1168 visit_type_int(v, NULL, &i64, &error_abort);
1169 g_assert_cmpint(i64, ==, 1);
1170 visit_check_list(v, &err);
1171 error_free_or_abort(&err);
1172 visit_end_list(v, NULL);
1173 visit_check_list(v, &error_abort);
1174 visit_end_list(v, NULL);
1177 static void test_visitor_in_fail_union_native_list(TestInputVisitorData *data,
1178 const void *unused)
1180 UserDefNativeListUnion *tmp = NULL;
1181 Error *err = NULL;
1182 Visitor *v;
1184 v = visitor_input_test_init(data,
1185 "{ 'type': 'integer', 'data' : [ 'string' ] }");
1187 visit_type_UserDefNativeListUnion(v, NULL, &tmp, &err);
1188 error_free_or_abort(&err);
1189 g_assert(!tmp);
1192 static void test_visitor_in_fail_union_flat(TestInputVisitorData *data,
1193 const void *unused)
1195 UserDefFlatUnion *tmp = NULL;
1196 Error *err = NULL;
1197 Visitor *v;
1199 v = visitor_input_test_init(data, "{ 'string': 'c', 'integer': 41, 'boolean': true }");
1201 visit_type_UserDefFlatUnion(v, NULL, &tmp, &err);
1202 error_free_or_abort(&err);
1203 g_assert(!tmp);
1206 static void test_visitor_in_fail_union_flat_no_discrim(TestInputVisitorData *data,
1207 const void *unused)
1209 UserDefFlatUnion2 *tmp = NULL;
1210 Error *err = NULL;
1211 Visitor *v;
1213 /* test situation where discriminator field ('enum1' here) is missing */
1214 v = visitor_input_test_init(data, "{ 'integer': 42, 'string': 'c', 'string1': 'd', 'string2': 'e' }");
1216 visit_type_UserDefFlatUnion2(v, NULL, &tmp, &err);
1217 error_free_or_abort(&err);
1218 g_assert(!tmp);
1221 static void test_visitor_in_fail_alternate(TestInputVisitorData *data,
1222 const void *unused)
1224 UserDefAlternate *tmp;
1225 Visitor *v;
1226 Error *err = NULL;
1228 v = visitor_input_test_init(data, "3.14");
1230 visit_type_UserDefAlternate(v, NULL, &tmp, &err);
1231 error_free_or_abort(&err);
1232 g_assert(!tmp);
1235 static void do_test_visitor_in_qmp_introspect(TestInputVisitorData *data,
1236 const char *schema_json)
1238 SchemaInfoList *schema = NULL;
1239 Visitor *v;
1241 v = visitor_input_test_init_raw(data, schema_json);
1243 visit_type_SchemaInfoList(v, NULL, &schema, &error_abort);
1244 g_assert(schema);
1246 qapi_free_SchemaInfoList(schema);
1249 static void test_visitor_in_qmp_introspect(TestInputVisitorData *data,
1250 const void *unused)
1252 do_test_visitor_in_qmp_introspect(data, test_qmp_schema_json);
1253 do_test_visitor_in_qmp_introspect(data, qmp_schema_json);
1256 int main(int argc, char **argv)
1258 g_test_init(&argc, &argv, NULL);
1260 input_visitor_test_add("/visitor/input/int",
1261 NULL, test_visitor_in_int);
1262 input_visitor_test_add("/visitor/input/uint",
1263 NULL, test_visitor_in_uint);
1264 input_visitor_test_add("/visitor/input/int_overflow",
1265 NULL, test_visitor_in_int_overflow);
1266 input_visitor_test_add("/visitor/input/int_keyval",
1267 NULL, test_visitor_in_int_keyval);
1268 input_visitor_test_add("/visitor/input/int_str_keyval",
1269 NULL, test_visitor_in_int_str_keyval);
1270 input_visitor_test_add("/visitor/input/int_str_fail",
1271 NULL, test_visitor_in_int_str_fail);
1272 input_visitor_test_add("/visitor/input/bool",
1273 NULL, test_visitor_in_bool);
1274 input_visitor_test_add("/visitor/input/bool_keyval",
1275 NULL, test_visitor_in_bool_keyval);
1276 input_visitor_test_add("/visitor/input/bool_str_keyval",
1277 NULL, test_visitor_in_bool_str_keyval);
1278 input_visitor_test_add("/visitor/input/bool_str_fail",
1279 NULL, test_visitor_in_bool_str_fail);
1280 input_visitor_test_add("/visitor/input/number",
1281 NULL, test_visitor_in_number);
1282 input_visitor_test_add("/visitor/input/number_keyval",
1283 NULL, test_visitor_in_number_keyval);
1284 input_visitor_test_add("/visitor/input/number_str_keyval",
1285 NULL, test_visitor_in_number_str_keyval);
1286 input_visitor_test_add("/visitor/input/number_str_fail",
1287 NULL, test_visitor_in_number_str_fail);
1288 input_visitor_test_add("/visitor/input/size_str_keyval",
1289 NULL, test_visitor_in_size_str_keyval);
1290 input_visitor_test_add("/visitor/input/size_str_fail",
1291 NULL, test_visitor_in_size_str_fail);
1292 input_visitor_test_add("/visitor/input/string",
1293 NULL, test_visitor_in_string);
1294 input_visitor_test_add("/visitor/input/enum",
1295 NULL, test_visitor_in_enum);
1296 input_visitor_test_add("/visitor/input/struct",
1297 NULL, test_visitor_in_struct);
1298 input_visitor_test_add("/visitor/input/struct-nested",
1299 NULL, test_visitor_in_struct_nested);
1300 input_visitor_test_add("/visitor/input/list",
1301 NULL, test_visitor_in_list);
1302 input_visitor_test_add("/visitor/input/any",
1303 NULL, test_visitor_in_any);
1304 input_visitor_test_add("/visitor/input/null",
1305 NULL, test_visitor_in_null);
1306 input_visitor_test_add("/visitor/input/union-flat",
1307 NULL, test_visitor_in_union_flat);
1308 input_visitor_test_add("/visitor/input/alternate",
1309 NULL, test_visitor_in_alternate);
1310 input_visitor_test_add("/visitor/input/errors",
1311 NULL, test_visitor_in_errors);
1312 input_visitor_test_add("/visitor/input/wrong-type",
1313 NULL, test_visitor_in_wrong_type);
1314 input_visitor_test_add("/visitor/input/alternate-number",
1315 NULL, test_visitor_in_alternate_number);
1316 input_visitor_test_add("/visitor/input/native_list/int",
1317 NULL, test_visitor_in_native_list_int);
1318 input_visitor_test_add("/visitor/input/native_list/int8",
1319 NULL, test_visitor_in_native_list_int8);
1320 input_visitor_test_add("/visitor/input/native_list/int16",
1321 NULL, test_visitor_in_native_list_int16);
1322 input_visitor_test_add("/visitor/input/native_list/int32",
1323 NULL, test_visitor_in_native_list_int32);
1324 input_visitor_test_add("/visitor/input/native_list/int64",
1325 NULL, test_visitor_in_native_list_int64);
1326 input_visitor_test_add("/visitor/input/native_list/uint8",
1327 NULL, test_visitor_in_native_list_uint8);
1328 input_visitor_test_add("/visitor/input/native_list/uint16",
1329 NULL, test_visitor_in_native_list_uint16);
1330 input_visitor_test_add("/visitor/input/native_list/uint32",
1331 NULL, test_visitor_in_native_list_uint32);
1332 input_visitor_test_add("/visitor/input/native_list/uint64",
1333 NULL, test_visitor_in_native_list_uint64);
1334 input_visitor_test_add("/visitor/input/native_list/bool",
1335 NULL, test_visitor_in_native_list_bool);
1336 input_visitor_test_add("/visitor/input/native_list/str",
1337 NULL, test_visitor_in_native_list_string);
1338 input_visitor_test_add("/visitor/input/native_list/number",
1339 NULL, test_visitor_in_native_list_number);
1340 input_visitor_test_add("/visitor/input/fail/struct",
1341 NULL, test_visitor_in_fail_struct);
1342 input_visitor_test_add("/visitor/input/fail/struct-nested",
1343 NULL, test_visitor_in_fail_struct_nested);
1344 input_visitor_test_add("/visitor/input/fail/struct-in-list",
1345 NULL, test_visitor_in_fail_struct_in_list);
1346 input_visitor_test_add("/visitor/input/fail/struct-missing",
1347 NULL, test_visitor_in_fail_struct_missing);
1348 input_visitor_test_add("/visitor/input/fail/list",
1349 NULL, test_visitor_in_fail_list);
1350 input_visitor_test_add("/visitor/input/fail/list-nested",
1351 NULL, test_visitor_in_fail_list_nested);
1352 input_visitor_test_add("/visitor/input/fail/union-flat",
1353 NULL, test_visitor_in_fail_union_flat);
1354 input_visitor_test_add("/visitor/input/fail/union-flat-no-discriminator",
1355 NULL, test_visitor_in_fail_union_flat_no_discrim);
1356 input_visitor_test_add("/visitor/input/fail/alternate",
1357 NULL, test_visitor_in_fail_alternate);
1358 input_visitor_test_add("/visitor/input/fail/union-native-list",
1359 NULL, test_visitor_in_fail_union_native_list);
1360 input_visitor_test_add("/visitor/input/qmp-introspect",
1361 NULL, test_visitor_in_qmp_introspect);
1363 g_test_run();
1365 return 0;