2 * QMP Output Visitor unit-tests.
4 * Copyright (C) 2011, 2015 Red Hat Inc.
7 * Luiz Capitulino <lcapitulino@redhat.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #include "qemu/osdep.h"
16 #include "qemu-common.h"
17 #include "qapi/qmp-output-visitor.h"
18 #include "test-qapi-types.h"
19 #include "test-qapi-visit.h"
20 #include "qapi/qmp/types.h"
22 typedef struct TestOutputVisitorData
{
23 QmpOutputVisitor
*qov
;
25 } TestOutputVisitorData
;
27 static void visitor_output_setup(TestOutputVisitorData
*data
,
30 data
->qov
= qmp_output_visitor_new();
31 g_assert(data
->qov
!= NULL
);
33 data
->ov
= qmp_output_get_visitor(data
->qov
);
34 g_assert(data
->ov
!= NULL
);
37 static void visitor_output_teardown(TestOutputVisitorData
*data
,
40 qmp_output_visitor_cleanup(data
->qov
);
45 static void test_visitor_out_int(TestOutputVisitorData
*data
,
51 visit_type_int(data
->ov
, NULL
, &value
, &error_abort
);
53 obj
= qmp_output_get_qobject(data
->qov
);
54 g_assert(obj
!= NULL
);
55 g_assert(qobject_type(obj
) == QTYPE_QINT
);
56 g_assert_cmpint(qint_get_int(qobject_to_qint(obj
)), ==, value
);
61 static void test_visitor_out_bool(TestOutputVisitorData
*data
,
67 visit_type_bool(data
->ov
, NULL
, &value
, &error_abort
);
69 obj
= qmp_output_get_qobject(data
->qov
);
70 g_assert(obj
!= NULL
);
71 g_assert(qobject_type(obj
) == QTYPE_QBOOL
);
72 g_assert(qbool_get_bool(qobject_to_qbool(obj
)) == value
);
77 static void test_visitor_out_number(TestOutputVisitorData
*data
,
83 visit_type_number(data
->ov
, NULL
, &value
, &error_abort
);
85 obj
= qmp_output_get_qobject(data
->qov
);
86 g_assert(obj
!= NULL
);
87 g_assert(qobject_type(obj
) == QTYPE_QFLOAT
);
88 g_assert(qfloat_get_double(qobject_to_qfloat(obj
)) == value
);
93 static void test_visitor_out_string(TestOutputVisitorData
*data
,
96 char *string
= (char *) "Q E M U";
99 visit_type_str(data
->ov
, NULL
, &string
, &error_abort
);
101 obj
= qmp_output_get_qobject(data
->qov
);
102 g_assert(obj
!= NULL
);
103 g_assert(qobject_type(obj
) == QTYPE_QSTRING
);
104 g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj
)), ==, string
);
109 static void test_visitor_out_no_string(TestOutputVisitorData
*data
,
115 /* A null string should return "" */
116 visit_type_str(data
->ov
, NULL
, &string
, &error_abort
);
118 obj
= qmp_output_get_qobject(data
->qov
);
119 g_assert(obj
!= NULL
);
120 g_assert(qobject_type(obj
) == QTYPE_QSTRING
);
121 g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj
)), ==, "");
126 static void test_visitor_out_enum(TestOutputVisitorData
*data
,
132 for (i
= 0; i
< ENUM_ONE__MAX
; i
++) {
133 visit_type_EnumOne(data
->ov
, "unused", &i
, &error_abort
);
135 obj
= qmp_output_get_qobject(data
->qov
);
136 g_assert(obj
!= NULL
);
137 g_assert(qobject_type(obj
) == QTYPE_QSTRING
);
138 g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj
)), ==,
144 static void test_visitor_out_enum_errors(TestOutputVisitorData
*data
,
147 EnumOne i
, bad_values
[] = { ENUM_ONE__MAX
, -1 };
150 for (i
= 0; i
< ARRAY_SIZE(bad_values
) ; i
++) {
152 visit_type_EnumOne(data
->ov
, "unused", &bad_values
[i
], &err
);
159 static void test_visitor_out_struct(TestOutputVisitorData
*data
,
162 TestStruct test_struct
= { .integer
= 42,
164 .string
= (char *) "foo"};
165 TestStruct
*p
= &test_struct
;
169 visit_type_TestStruct(data
->ov
, NULL
, &p
, &error_abort
);
171 obj
= qmp_output_get_qobject(data
->qov
);
172 g_assert(obj
!= NULL
);
173 g_assert(qobject_type(obj
) == QTYPE_QDICT
);
175 qdict
= qobject_to_qdict(obj
);
176 g_assert_cmpint(qdict_size(qdict
), ==, 3);
177 g_assert_cmpint(qdict_get_int(qdict
, "integer"), ==, 42);
178 g_assert_cmpint(qdict_get_bool(qdict
, "boolean"), ==, false);
179 g_assert_cmpstr(qdict_get_str(qdict
, "string"), ==, "foo");
184 static void test_visitor_out_struct_nested(TestOutputVisitorData
*data
,
190 QDict
*qdict
, *dict1
, *dict2
, *dict3
, *userdef
;
191 const char *string
= "user def string";
192 const char *strings
[] = { "forty two", "forty three", "forty four",
195 ud2
= g_malloc0(sizeof(*ud2
));
196 ud2
->string0
= g_strdup(strings
[0]);
198 ud2
->dict1
= g_malloc0(sizeof(*ud2
->dict1
));
199 ud2
->dict1
->string1
= g_strdup(strings
[1]);
201 ud2
->dict1
->dict2
= g_malloc0(sizeof(*ud2
->dict1
->dict2
));
202 ud2
->dict1
->dict2
->userdef
= g_new0(UserDefOne
, 1);
203 ud2
->dict1
->dict2
->userdef
->string
= g_strdup(string
);
204 ud2
->dict1
->dict2
->userdef
->integer
= value
;
205 ud2
->dict1
->dict2
->string
= g_strdup(strings
[2]);
207 ud2
->dict1
->dict3
= g_malloc0(sizeof(*ud2
->dict1
->dict3
));
208 ud2
->dict1
->has_dict3
= true;
209 ud2
->dict1
->dict3
->userdef
= g_new0(UserDefOne
, 1);
210 ud2
->dict1
->dict3
->userdef
->string
= g_strdup(string
);
211 ud2
->dict1
->dict3
->userdef
->integer
= value
;
212 ud2
->dict1
->dict3
->string
= g_strdup(strings
[3]);
214 visit_type_UserDefTwo(data
->ov
, "unused", &ud2
, &error_abort
);
216 obj
= qmp_output_get_qobject(data
->qov
);
217 g_assert(obj
!= NULL
);
218 g_assert(qobject_type(obj
) == QTYPE_QDICT
);
220 qdict
= qobject_to_qdict(obj
);
221 g_assert_cmpint(qdict_size(qdict
), ==, 2);
222 g_assert_cmpstr(qdict_get_str(qdict
, "string0"), ==, strings
[0]);
224 dict1
= qdict_get_qdict(qdict
, "dict1");
225 g_assert_cmpint(qdict_size(dict1
), ==, 3);
226 g_assert_cmpstr(qdict_get_str(dict1
, "string1"), ==, strings
[1]);
228 dict2
= qdict_get_qdict(dict1
, "dict2");
229 g_assert_cmpint(qdict_size(dict2
), ==, 2);
230 g_assert_cmpstr(qdict_get_str(dict2
, "string"), ==, strings
[2]);
231 userdef
= qdict_get_qdict(dict2
, "userdef");
232 g_assert_cmpint(qdict_size(userdef
), ==, 2);
233 g_assert_cmpint(qdict_get_int(userdef
, "integer"), ==, value
);
234 g_assert_cmpstr(qdict_get_str(userdef
, "string"), ==, string
);
236 dict3
= qdict_get_qdict(dict1
, "dict3");
237 g_assert_cmpint(qdict_size(dict3
), ==, 2);
238 g_assert_cmpstr(qdict_get_str(dict3
, "string"), ==, strings
[3]);
239 userdef
= qdict_get_qdict(dict3
, "userdef");
240 g_assert_cmpint(qdict_size(userdef
), ==, 2);
241 g_assert_cmpint(qdict_get_int(userdef
, "integer"), ==, value
);
242 g_assert_cmpstr(qdict_get_str(userdef
, "string"), ==, string
);
245 qapi_free_UserDefTwo(ud2
);
248 static void test_visitor_out_struct_errors(TestOutputVisitorData
*data
,
251 EnumOne bad_values
[] = { ENUM_ONE__MAX
, -1 };
257 for (i
= 0; i
< ARRAY_SIZE(bad_values
) ; i
++) {
260 u
.enum1
= bad_values
[i
];
261 visit_type_UserDefOne(data
->ov
, "unused", &pu
, &err
);
268 static void test_visitor_out_list(TestOutputVisitorData
*data
,
271 const char *value_str
= "list value";
272 TestStructList
*p
, *head
= NULL
;
273 const int max_items
= 10;
274 bool value_bool
= true;
281 /* Build the list in reverse order... */
282 for (i
= 0; i
< max_items
; i
++) {
283 p
= g_malloc0(sizeof(*p
));
284 p
->value
= g_malloc0(sizeof(*p
->value
));
285 p
->value
->integer
= value_int
+ (max_items
- i
- 1);
286 p
->value
->boolean
= value_bool
;
287 p
->value
->string
= g_strdup(value_str
);
293 visit_type_TestStructList(data
->ov
, NULL
, &head
, &error_abort
);
295 obj
= qmp_output_get_qobject(data
->qov
);
296 g_assert(obj
!= NULL
);
297 g_assert(qobject_type(obj
) == QTYPE_QLIST
);
299 qlist
= qobject_to_qlist(obj
);
300 g_assert(!qlist_empty(qlist
));
302 /* ...and ensure that the visitor sees it in order */
304 QLIST_FOREACH_ENTRY(qlist
, entry
) {
307 g_assert(qobject_type(entry
->value
) == QTYPE_QDICT
);
308 qdict
= qobject_to_qdict(entry
->value
);
309 g_assert_cmpint(qdict_size(qdict
), ==, 3);
310 g_assert_cmpint(qdict_get_int(qdict
, "integer"), ==, value_int
+ i
);
311 g_assert_cmpint(qdict_get_bool(qdict
, "boolean"), ==, value_bool
);
312 g_assert_cmpstr(qdict_get_str(qdict
, "string"), ==, value_str
);
315 g_assert_cmpint(i
, ==, max_items
);
318 qapi_free_TestStructList(head
);
321 static void test_visitor_out_list_qapi_free(TestOutputVisitorData
*data
,
324 UserDefTwoList
*p
, *head
= NULL
;
325 const char string
[] = "foo bar";
326 int i
, max_count
= 1024;
328 for (i
= 0; i
< max_count
; i
++) {
329 p
= g_malloc0(sizeof(*p
));
330 p
->value
= g_malloc0(sizeof(*p
->value
));
332 p
->value
->string0
= g_strdup(string
);
333 p
->value
->dict1
= g_new0(UserDefTwoDict
, 1);
334 p
->value
->dict1
->string1
= g_strdup(string
);
335 p
->value
->dict1
->dict2
= g_new0(UserDefTwoDictDict
, 1);
336 p
->value
->dict1
->dict2
->userdef
= g_new0(UserDefOne
, 1);
337 p
->value
->dict1
->dict2
->userdef
->string
= g_strdup(string
);
338 p
->value
->dict1
->dict2
->userdef
->integer
= 42;
339 p
->value
->dict1
->dict2
->string
= g_strdup(string
);
340 p
->value
->dict1
->has_dict3
= false;
346 qapi_free_UserDefTwoList(head
);
349 static void test_visitor_out_any(TestOutputVisitorData
*data
,
359 qobj
= QOBJECT(qint_from_int(-42));
360 visit_type_any(data
->ov
, NULL
, &qobj
, &error_abort
);
361 obj
= qmp_output_get_qobject(data
->qov
);
362 g_assert(obj
!= NULL
);
363 g_assert(qobject_type(obj
) == QTYPE_QINT
);
364 g_assert_cmpint(qint_get_int(qobject_to_qint(obj
)), ==, -42);
366 qobject_decref(qobj
);
369 qdict_put(qdict
, "integer", qint_from_int(-42));
370 qdict_put(qdict
, "boolean", qbool_from_bool(true));
371 qdict_put(qdict
, "string", qstring_from_str("foo"));
372 qobj
= QOBJECT(qdict
);
373 visit_type_any(data
->ov
, NULL
, &qobj
, &error_abort
);
374 qobject_decref(qobj
);
375 obj
= qmp_output_get_qobject(data
->qov
);
376 g_assert(obj
!= NULL
);
377 qdict
= qobject_to_qdict(obj
);
379 qobj
= qdict_get(qdict
, "integer");
381 qint
= qobject_to_qint(qobj
);
383 g_assert_cmpint(qint_get_int(qint
), ==, -42);
384 qobj
= qdict_get(qdict
, "boolean");
386 qbool
= qobject_to_qbool(qobj
);
388 g_assert(qbool_get_bool(qbool
) == true);
389 qobj
= qdict_get(qdict
, "string");
391 qstring
= qobject_to_qstring(qobj
);
393 g_assert_cmpstr(qstring_get_str(qstring
), ==, "foo");
397 static void test_visitor_out_union_flat(TestOutputVisitorData
*data
,
403 UserDefFlatUnion
*tmp
= g_malloc0(sizeof(UserDefFlatUnion
));
404 tmp
->enum1
= ENUM_ONE_VALUE1
;
405 tmp
->string
= g_strdup("str");
406 tmp
->u
.value1
= g_malloc0(sizeof(UserDefA
));
408 tmp
->u
.value1
->boolean
= true;
410 visit_type_UserDefFlatUnion(data
->ov
, NULL
, &tmp
, &error_abort
);
411 arg
= qmp_output_get_qobject(data
->qov
);
413 g_assert(qobject_type(arg
) == QTYPE_QDICT
);
414 qdict
= qobject_to_qdict(arg
);
416 g_assert_cmpstr(qdict_get_str(qdict
, "enum1"), ==, "value1");
417 g_assert_cmpstr(qdict_get_str(qdict
, "string"), ==, "str");
418 g_assert_cmpint(qdict_get_int(qdict
, "integer"), ==, 41);
419 g_assert_cmpint(qdict_get_bool(qdict
, "boolean"), ==, true);
421 qapi_free_UserDefFlatUnion(tmp
);
425 static void test_visitor_out_alternate(TestOutputVisitorData
*data
,
429 UserDefAlternate
*tmp
;
431 tmp
= g_new0(UserDefAlternate
, 1);
432 tmp
->type
= QTYPE_QINT
;
435 visit_type_UserDefAlternate(data
->ov
, NULL
, &tmp
, &error_abort
);
436 arg
= qmp_output_get_qobject(data
->qov
);
438 g_assert(qobject_type(arg
) == QTYPE_QINT
);
439 g_assert_cmpint(qint_get_int(qobject_to_qint(arg
)), ==, 42);
441 qapi_free_UserDefAlternate(tmp
);
444 tmp
= g_new0(UserDefAlternate
, 1);
445 tmp
->type
= QTYPE_QSTRING
;
446 tmp
->u
.s
= g_strdup("hello");
448 visit_type_UserDefAlternate(data
->ov
, NULL
, &tmp
, &error_abort
);
449 arg
= qmp_output_get_qobject(data
->qov
);
451 g_assert(qobject_type(arg
) == QTYPE_QSTRING
);
452 g_assert_cmpstr(qstring_get_str(qobject_to_qstring(arg
)), ==, "hello");
454 qapi_free_UserDefAlternate(tmp
);
458 static void test_visitor_out_empty(TestOutputVisitorData
*data
,
463 arg
= qmp_output_get_qobject(data
->qov
);
464 g_assert(qobject_type(arg
) == QTYPE_QNULL
);
465 /* Check that qnull reference counting is sane */
466 g_assert(arg
->refcnt
== 2);
470 static void init_native_list(UserDefNativeListUnion
*cvalue
)
473 switch (cvalue
->type
) {
474 case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER
: {
475 intList
**list
= &cvalue
->u
.integer
;
476 for (i
= 0; i
< 32; i
++) {
477 *list
= g_new0(intList
, 1);
479 (*list
)->next
= NULL
;
480 list
= &(*list
)->next
;
484 case USER_DEF_NATIVE_LIST_UNION_KIND_S8
: {
485 int8List
**list
= &cvalue
->u
.s8
;
486 for (i
= 0; i
< 32; i
++) {
487 *list
= g_new0(int8List
, 1);
489 (*list
)->next
= NULL
;
490 list
= &(*list
)->next
;
494 case USER_DEF_NATIVE_LIST_UNION_KIND_S16
: {
495 int16List
**list
= &cvalue
->u
.s16
;
496 for (i
= 0; i
< 32; i
++) {
497 *list
= g_new0(int16List
, 1);
499 (*list
)->next
= NULL
;
500 list
= &(*list
)->next
;
504 case USER_DEF_NATIVE_LIST_UNION_KIND_S32
: {
505 int32List
**list
= &cvalue
->u
.s32
;
506 for (i
= 0; i
< 32; i
++) {
507 *list
= g_new0(int32List
, 1);
509 (*list
)->next
= NULL
;
510 list
= &(*list
)->next
;
514 case USER_DEF_NATIVE_LIST_UNION_KIND_S64
: {
515 int64List
**list
= &cvalue
->u
.s64
;
516 for (i
= 0; i
< 32; i
++) {
517 *list
= g_new0(int64List
, 1);
519 (*list
)->next
= NULL
;
520 list
= &(*list
)->next
;
524 case USER_DEF_NATIVE_LIST_UNION_KIND_U8
: {
525 uint8List
**list
= &cvalue
->u
.u8
;
526 for (i
= 0; i
< 32; i
++) {
527 *list
= g_new0(uint8List
, 1);
529 (*list
)->next
= NULL
;
530 list
= &(*list
)->next
;
534 case USER_DEF_NATIVE_LIST_UNION_KIND_U16
: {
535 uint16List
**list
= &cvalue
->u
.u16
;
536 for (i
= 0; i
< 32; i
++) {
537 *list
= g_new0(uint16List
, 1);
539 (*list
)->next
= NULL
;
540 list
= &(*list
)->next
;
544 case USER_DEF_NATIVE_LIST_UNION_KIND_U32
: {
545 uint32List
**list
= &cvalue
->u
.u32
;
546 for (i
= 0; i
< 32; i
++) {
547 *list
= g_new0(uint32List
, 1);
549 (*list
)->next
= NULL
;
550 list
= &(*list
)->next
;
554 case USER_DEF_NATIVE_LIST_UNION_KIND_U64
: {
555 uint64List
**list
= &cvalue
->u
.u64
;
556 for (i
= 0; i
< 32; i
++) {
557 *list
= g_new0(uint64List
, 1);
559 (*list
)->next
= NULL
;
560 list
= &(*list
)->next
;
564 case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN
: {
565 boolList
**list
= &cvalue
->u
.boolean
;
566 for (i
= 0; i
< 32; i
++) {
567 *list
= g_new0(boolList
, 1);
568 (*list
)->value
= (i
% 3 == 0);
569 (*list
)->next
= NULL
;
570 list
= &(*list
)->next
;
574 case USER_DEF_NATIVE_LIST_UNION_KIND_STRING
: {
575 strList
**list
= &cvalue
->u
.string
;
576 for (i
= 0; i
< 32; i
++) {
577 *list
= g_new0(strList
, 1);
578 (*list
)->value
= g_strdup_printf("%d", i
);
579 (*list
)->next
= NULL
;
580 list
= &(*list
)->next
;
584 case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER
: {
585 numberList
**list
= &cvalue
->u
.number
;
586 for (i
= 0; i
< 32; i
++) {
587 *list
= g_new0(numberList
, 1);
588 (*list
)->value
= (double)i
/ 3;
589 (*list
)->next
= NULL
;
590 list
= &(*list
)->next
;
595 g_assert_not_reached();
599 static void check_native_list(QObject
*qobj
,
600 UserDefNativeListUnionKind kind
)
607 g_assert(qobject_type(qobj
) == QTYPE_QDICT
);
608 qdict
= qobject_to_qdict(qobj
);
610 g_assert(qdict_haskey(qdict
, "data"));
611 qlist
= qlist_copy(qobject_to_qlist(qdict_get(qdict
, "data")));
614 case USER_DEF_NATIVE_LIST_UNION_KIND_S8
:
615 case USER_DEF_NATIVE_LIST_UNION_KIND_S16
:
616 case USER_DEF_NATIVE_LIST_UNION_KIND_S32
:
617 case USER_DEF_NATIVE_LIST_UNION_KIND_S64
:
618 case USER_DEF_NATIVE_LIST_UNION_KIND_U8
:
619 case USER_DEF_NATIVE_LIST_UNION_KIND_U16
:
620 case USER_DEF_NATIVE_LIST_UNION_KIND_U32
:
621 case USER_DEF_NATIVE_LIST_UNION_KIND_U64
:
622 /* all integer elements in JSON arrays get stored into QInts when
623 * we convert to QObjects, so we can check them all in the same
624 * fashion, so simply fall through here
626 case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER
:
627 for (i
= 0; i
< 32; i
++) {
630 tmp
= qlist_peek(qlist
);
632 qvalue
= qobject_to_qint(tmp
);
633 g_assert_cmpint(qint_get_int(qvalue
), ==, i
);
634 qobject_decref(qlist_pop(qlist
));
637 case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN
:
638 for (i
= 0; i
< 32; i
++) {
641 tmp
= qlist_peek(qlist
);
643 qvalue
= qobject_to_qbool(tmp
);
644 g_assert_cmpint(qbool_get_bool(qvalue
), ==, i
% 3 == 0);
645 qobject_decref(qlist_pop(qlist
));
648 case USER_DEF_NATIVE_LIST_UNION_KIND_STRING
:
649 for (i
= 0; i
< 32; i
++) {
653 tmp
= qlist_peek(qlist
);
655 qvalue
= qobject_to_qstring(tmp
);
656 sprintf(str
, "%d", i
);
657 g_assert_cmpstr(qstring_get_str(qvalue
), ==, str
);
658 qobject_decref(qlist_pop(qlist
));
661 case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER
:
662 for (i
= 0; i
< 32; i
++) {
665 GString
*double_expected
= g_string_new("");
666 GString
*double_actual
= g_string_new("");
668 tmp
= qlist_peek(qlist
);
670 qvalue
= qobject_to_qfloat(tmp
);
671 g_string_printf(double_expected
, "%.6f", (double)i
/ 3);
672 g_string_printf(double_actual
, "%.6f", qfloat_get_double(qvalue
));
673 g_assert_cmpstr(double_actual
->str
, ==, double_expected
->str
);
675 qobject_decref(qlist_pop(qlist
));
676 g_string_free(double_expected
, true);
677 g_string_free(double_actual
, true);
681 g_assert_not_reached();
686 static void test_native_list(TestOutputVisitorData
*data
,
688 UserDefNativeListUnionKind kind
)
690 UserDefNativeListUnion
*cvalue
= g_new0(UserDefNativeListUnion
, 1);
694 init_native_list(cvalue
);
696 visit_type_UserDefNativeListUnion(data
->ov
, NULL
, &cvalue
, &error_abort
);
698 obj
= qmp_output_get_qobject(data
->qov
);
699 check_native_list(obj
, cvalue
->type
);
700 qapi_free_UserDefNativeListUnion(cvalue
);
704 static void test_visitor_out_native_list_int(TestOutputVisitorData
*data
,
707 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER
);
710 static void test_visitor_out_native_list_int8(TestOutputVisitorData
*data
,
713 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_S8
);
716 static void test_visitor_out_native_list_int16(TestOutputVisitorData
*data
,
719 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_S16
);
722 static void test_visitor_out_native_list_int32(TestOutputVisitorData
*data
,
725 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_S32
);
728 static void test_visitor_out_native_list_int64(TestOutputVisitorData
*data
,
731 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_S64
);
734 static void test_visitor_out_native_list_uint8(TestOutputVisitorData
*data
,
737 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_U8
);
740 static void test_visitor_out_native_list_uint16(TestOutputVisitorData
*data
,
743 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_U16
);
746 static void test_visitor_out_native_list_uint32(TestOutputVisitorData
*data
,
749 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_U32
);
752 static void test_visitor_out_native_list_uint64(TestOutputVisitorData
*data
,
755 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_U64
);
758 static void test_visitor_out_native_list_bool(TestOutputVisitorData
*data
,
761 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN
);
764 static void test_visitor_out_native_list_str(TestOutputVisitorData
*data
,
767 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_STRING
);
770 static void test_visitor_out_native_list_number(TestOutputVisitorData
*data
,
773 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER
);
776 static void output_visitor_test_add(const char *testpath
,
777 TestOutputVisitorData
*data
,
778 void (*test_func
)(TestOutputVisitorData
*data
, const void *user_data
))
780 g_test_add(testpath
, TestOutputVisitorData
, data
, visitor_output_setup
,
781 test_func
, visitor_output_teardown
);
784 int main(int argc
, char **argv
)
786 TestOutputVisitorData out_visitor_data
;
788 g_test_init(&argc
, &argv
, NULL
);
790 output_visitor_test_add("/visitor/output/int",
791 &out_visitor_data
, test_visitor_out_int
);
792 output_visitor_test_add("/visitor/output/bool",
793 &out_visitor_data
, test_visitor_out_bool
);
794 output_visitor_test_add("/visitor/output/number",
795 &out_visitor_data
, test_visitor_out_number
);
796 output_visitor_test_add("/visitor/output/string",
797 &out_visitor_data
, test_visitor_out_string
);
798 output_visitor_test_add("/visitor/output/no-string",
799 &out_visitor_data
, test_visitor_out_no_string
);
800 output_visitor_test_add("/visitor/output/enum",
801 &out_visitor_data
, test_visitor_out_enum
);
802 output_visitor_test_add("/visitor/output/enum-errors",
803 &out_visitor_data
, test_visitor_out_enum_errors
);
804 output_visitor_test_add("/visitor/output/struct",
805 &out_visitor_data
, test_visitor_out_struct
);
806 output_visitor_test_add("/visitor/output/struct-nested",
807 &out_visitor_data
, test_visitor_out_struct_nested
);
808 output_visitor_test_add("/visitor/output/struct-errors",
809 &out_visitor_data
, test_visitor_out_struct_errors
);
810 output_visitor_test_add("/visitor/output/list",
811 &out_visitor_data
, test_visitor_out_list
);
812 output_visitor_test_add("/visitor/output/any",
813 &out_visitor_data
, test_visitor_out_any
);
814 output_visitor_test_add("/visitor/output/list-qapi-free",
815 &out_visitor_data
, test_visitor_out_list_qapi_free
);
816 output_visitor_test_add("/visitor/output/union-flat",
817 &out_visitor_data
, test_visitor_out_union_flat
);
818 output_visitor_test_add("/visitor/output/alternate",
819 &out_visitor_data
, test_visitor_out_alternate
);
820 output_visitor_test_add("/visitor/output/empty",
821 &out_visitor_data
, test_visitor_out_empty
);
822 output_visitor_test_add("/visitor/output/native_list/int",
824 test_visitor_out_native_list_int
);
825 output_visitor_test_add("/visitor/output/native_list/int8",
827 test_visitor_out_native_list_int8
);
828 output_visitor_test_add("/visitor/output/native_list/int16",
830 test_visitor_out_native_list_int16
);
831 output_visitor_test_add("/visitor/output/native_list/int32",
833 test_visitor_out_native_list_int32
);
834 output_visitor_test_add("/visitor/output/native_list/int64",
836 test_visitor_out_native_list_int64
);
837 output_visitor_test_add("/visitor/output/native_list/uint8",
839 test_visitor_out_native_list_uint8
);
840 output_visitor_test_add("/visitor/output/native_list/uint16",
842 test_visitor_out_native_list_uint16
);
843 output_visitor_test_add("/visitor/output/native_list/uint32",
845 test_visitor_out_native_list_uint32
);
846 output_visitor_test_add("/visitor/output/native_list/uint64",
848 test_visitor_out_native_list_uint64
);
849 output_visitor_test_add("/visitor/output/native_list/bool",
851 test_visitor_out_native_list_bool
);
852 output_visitor_test_add("/visitor/output/native_list/string",
854 test_visitor_out_native_list_str
);
855 output_visitor_test_add("/visitor/output/native_list/number",
857 test_visitor_out_native_list_number
);