2 * QMP Output Visitor unit-tests.
4 * Copyright (C) 2011 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.
15 #include "qemu-common.h"
16 #include "qapi/qmp-output-visitor.h"
17 #include "test-qapi-types.h"
18 #include "test-qapi-visit.h"
19 #include "qapi/qmp/types.h"
21 typedef struct TestOutputVisitorData
{
22 QmpOutputVisitor
*qov
;
24 } TestOutputVisitorData
;
26 static void visitor_output_setup(TestOutputVisitorData
*data
,
29 data
->qov
= qmp_output_visitor_new();
30 g_assert(data
->qov
!= NULL
);
32 data
->ov
= qmp_output_get_visitor(data
->qov
);
33 g_assert(data
->ov
!= NULL
);
36 static void visitor_output_teardown(TestOutputVisitorData
*data
,
39 qmp_output_visitor_cleanup(data
->qov
);
44 static void test_visitor_out_int(TestOutputVisitorData
*data
,
51 visit_type_int(data
->ov
, &value
, NULL
, &errp
);
54 obj
= qmp_output_get_qobject(data
->qov
);
55 g_assert(obj
!= NULL
);
56 g_assert(qobject_type(obj
) == QTYPE_QINT
);
57 g_assert_cmpint(qint_get_int(qobject_to_qint(obj
)), ==, value
);
62 static void test_visitor_out_bool(TestOutputVisitorData
*data
,
69 visit_type_bool(data
->ov
, &value
, NULL
, &errp
);
72 obj
= qmp_output_get_qobject(data
->qov
);
73 g_assert(obj
!= NULL
);
74 g_assert(qobject_type(obj
) == QTYPE_QBOOL
);
75 g_assert(qbool_get_int(qobject_to_qbool(obj
)) == value
);
80 static void test_visitor_out_number(TestOutputVisitorData
*data
,
87 visit_type_number(data
->ov
, &value
, NULL
, &errp
);
90 obj
= qmp_output_get_qobject(data
->qov
);
91 g_assert(obj
!= NULL
);
92 g_assert(qobject_type(obj
) == QTYPE_QFLOAT
);
93 g_assert(qfloat_get_double(qobject_to_qfloat(obj
)) == value
);
98 static void test_visitor_out_string(TestOutputVisitorData
*data
,
101 char *string
= (char *) "Q E M U";
105 visit_type_str(data
->ov
, &string
, NULL
, &errp
);
108 obj
= qmp_output_get_qobject(data
->qov
);
109 g_assert(obj
!= NULL
);
110 g_assert(qobject_type(obj
) == QTYPE_QSTRING
);
111 g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj
)), ==, string
);
116 static void test_visitor_out_no_string(TestOutputVisitorData
*data
,
123 /* A null string should return "" */
124 visit_type_str(data
->ov
, &string
, NULL
, &errp
);
127 obj
= qmp_output_get_qobject(data
->qov
);
128 g_assert(obj
!= NULL
);
129 g_assert(qobject_type(obj
) == QTYPE_QSTRING
);
130 g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj
)), ==, "");
135 static void test_visitor_out_enum(TestOutputVisitorData
*data
,
142 for (i
= 0; i
< ENUM_ONE_MAX
; i
++) {
143 visit_type_EnumOne(data
->ov
, &i
, "unused", &errp
);
146 obj
= qmp_output_get_qobject(data
->qov
);
147 g_assert(obj
!= NULL
);
148 g_assert(qobject_type(obj
) == QTYPE_QSTRING
);
149 g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj
)), ==,
155 static void test_visitor_out_enum_errors(TestOutputVisitorData
*data
,
158 EnumOne i
, bad_values
[] = { ENUM_ONE_MAX
, -1 };
161 for (i
= 0; i
< ARRAY_SIZE(bad_values
) ; i
++) {
163 visit_type_EnumOne(data
->ov
, &bad_values
[i
], "unused", &errp
);
169 typedef struct TestStruct
176 static void visit_type_TestStruct(Visitor
*v
, TestStruct
**obj
,
177 const char *name
, Error
**errp
)
179 visit_start_struct(v
, (void **)obj
, "TestStruct", name
, sizeof(TestStruct
),
182 visit_type_int(v
, &(*obj
)->integer
, "integer", errp
);
183 visit_type_bool(v
, &(*obj
)->boolean
, "boolean", errp
);
184 visit_type_str(v
, &(*obj
)->string
, "string", errp
);
186 visit_end_struct(v
, errp
);
189 static void test_visitor_out_struct(TestOutputVisitorData
*data
,
192 TestStruct test_struct
= { .integer
= 42,
194 .string
= (char *) "foo"};
195 TestStruct
*p
= &test_struct
;
200 visit_type_TestStruct(data
->ov
, &p
, NULL
, &errp
);
203 obj
= qmp_output_get_qobject(data
->qov
);
204 g_assert(obj
!= NULL
);
205 g_assert(qobject_type(obj
) == QTYPE_QDICT
);
207 qdict
= qobject_to_qdict(obj
);
208 g_assert_cmpint(qdict_size(qdict
), ==, 3);
209 g_assert_cmpint(qdict_get_int(qdict
, "integer"), ==, 42);
210 g_assert_cmpint(qdict_get_bool(qdict
, "boolean"), ==, 0);
211 g_assert_cmpstr(qdict_get_str(qdict
, "string"), ==, "foo");
216 static void test_visitor_out_struct_nested(TestOutputVisitorData
*data
,
223 QDict
*qdict
, *dict1
, *dict2
, *dict3
, *userdef
;
224 const char *string
= "user def string";
225 const char *strings
[] = { "forty two", "forty three", "forty four",
228 ud2
= g_malloc0(sizeof(*ud2
));
229 ud2
->string0
= g_strdup(strings
[0]);
231 ud2
->dict1
.string1
= g_strdup(strings
[1]);
232 ud2
->dict1
.dict2
.userdef1
= g_malloc0(sizeof(UserDefOne
));
233 ud2
->dict1
.dict2
.userdef1
->string
= g_strdup(string
);
234 ud2
->dict1
.dict2
.userdef1
->base
= g_new0(UserDefZero
, 1);
235 ud2
->dict1
.dict2
.userdef1
->base
->integer
= value
;
236 ud2
->dict1
.dict2
.string2
= g_strdup(strings
[2]);
238 ud2
->dict1
.has_dict3
= true;
239 ud2
->dict1
.dict3
.userdef2
= g_malloc0(sizeof(UserDefOne
));
240 ud2
->dict1
.dict3
.userdef2
->string
= g_strdup(string
);
241 ud2
->dict1
.dict3
.userdef2
->base
= g_new0(UserDefZero
, 1);
242 ud2
->dict1
.dict3
.userdef2
->base
->integer
= value
;
243 ud2
->dict1
.dict3
.string3
= g_strdup(strings
[3]);
245 visit_type_UserDefNested(data
->ov
, &ud2
, "unused", &errp
);
248 obj
= qmp_output_get_qobject(data
->qov
);
249 g_assert(obj
!= NULL
);
250 g_assert(qobject_type(obj
) == QTYPE_QDICT
);
252 qdict
= qobject_to_qdict(obj
);
253 g_assert_cmpint(qdict_size(qdict
), ==, 2);
254 g_assert_cmpstr(qdict_get_str(qdict
, "string0"), ==, strings
[0]);
256 dict1
= qdict_get_qdict(qdict
, "dict1");
257 g_assert_cmpint(qdict_size(dict1
), ==, 3);
258 g_assert_cmpstr(qdict_get_str(dict1
, "string1"), ==, strings
[1]);
260 dict2
= qdict_get_qdict(dict1
, "dict2");
261 g_assert_cmpint(qdict_size(dict2
), ==, 2);
262 g_assert_cmpstr(qdict_get_str(dict2
, "string2"), ==, strings
[2]);
263 userdef
= qdict_get_qdict(dict2
, "userdef1");
264 g_assert_cmpint(qdict_size(userdef
), ==, 2);
265 g_assert_cmpint(qdict_get_int(userdef
, "integer"), ==, value
);
266 g_assert_cmpstr(qdict_get_str(userdef
, "string"), ==, string
);
268 dict3
= qdict_get_qdict(dict1
, "dict3");
269 g_assert_cmpint(qdict_size(dict3
), ==, 2);
270 g_assert_cmpstr(qdict_get_str(dict3
, "string3"), ==, strings
[3]);
271 userdef
= qdict_get_qdict(dict3
, "userdef2");
272 g_assert_cmpint(qdict_size(userdef
), ==, 2);
273 g_assert_cmpint(qdict_get_int(userdef
, "integer"), ==, value
);
274 g_assert_cmpstr(qdict_get_str(userdef
, "string"), ==, string
);
277 qapi_free_UserDefNested(ud2
);
280 static void test_visitor_out_struct_errors(TestOutputVisitorData
*data
,
283 EnumOne bad_values
[] = { ENUM_ONE_MAX
, -1 };
285 UserDefOne u
= { .base
= &b
}, *pu
= &u
;
289 for (i
= 0; i
< ARRAY_SIZE(bad_values
) ; i
++) {
292 u
.enum1
= bad_values
[i
];
293 visit_type_UserDefOne(data
->ov
, &pu
, "unused", &errp
);
299 typedef struct TestStructList
305 struct TestStructList
*next
;
308 static void visit_type_TestStructList(Visitor
*v
, TestStructList
**obj
,
309 const char *name
, Error
**errp
)
311 GenericList
*i
, **head
= (GenericList
**)obj
;
313 visit_start_list(v
, name
, errp
);
315 for (*head
= i
= visit_next_list(v
, head
, errp
); i
; i
= visit_next_list(v
, &i
, errp
)) {
316 TestStructList
*native_i
= (TestStructList
*)i
;
317 visit_type_TestStruct(v
, &native_i
->value
, NULL
, errp
);
320 visit_end_list(v
, errp
);
323 static void test_visitor_out_list(TestOutputVisitorData
*data
,
326 char *value_str
= (char *) "list value";
327 TestStructList
*p
, *head
= NULL
;
328 const int max_items
= 10;
329 bool value_bool
= true;
337 for (i
= 0; i
< max_items
; i
++) {
338 p
= g_malloc0(sizeof(*p
));
339 p
->value
= g_malloc0(sizeof(*p
->value
));
340 p
->value
->integer
= value_int
;
341 p
->value
->boolean
= value_bool
;
342 p
->value
->string
= value_str
;
348 visit_type_TestStructList(data
->ov
, &head
, NULL
, &errp
);
351 obj
= qmp_output_get_qobject(data
->qov
);
352 g_assert(obj
!= NULL
);
353 g_assert(qobject_type(obj
) == QTYPE_QLIST
);
355 qlist
= qobject_to_qlist(obj
);
356 g_assert(!qlist_empty(qlist
));
359 QLIST_FOREACH_ENTRY(qlist
, entry
) {
362 g_assert(qobject_type(entry
->value
) == QTYPE_QDICT
);
363 qdict
= qobject_to_qdict(entry
->value
);
364 g_assert_cmpint(qdict_size(qdict
), ==, 3);
365 g_assert_cmpint(qdict_get_int(qdict
, "integer"), ==, value_int
);
366 g_assert_cmpint(qdict_get_bool(qdict
, "boolean"), ==, value_bool
);
367 g_assert_cmpstr(qdict_get_str(qdict
, "string"), ==, value_str
);
370 g_assert_cmpint(i
, ==, max_items
);
375 TestStructList
*tmp
= p
->next
;
382 static void test_visitor_out_list_qapi_free(TestOutputVisitorData
*data
,
385 UserDefNestedList
*p
, *head
= NULL
;
386 const char string
[] = "foo bar";
387 int i
, max_count
= 1024;
389 for (i
= 0; i
< max_count
; i
++) {
390 p
= g_malloc0(sizeof(*p
));
391 p
->value
= g_malloc0(sizeof(*p
->value
));
393 p
->value
->string0
= g_strdup(string
);
394 p
->value
->dict1
.string1
= g_strdup(string
);
395 p
->value
->dict1
.dict2
.userdef1
= g_malloc0(sizeof(UserDefOne
));
396 p
->value
->dict1
.dict2
.userdef1
->string
= g_strdup(string
);
397 p
->value
->dict1
.dict2
.userdef1
->base
= g_new0(UserDefZero
, 1);
398 p
->value
->dict1
.dict2
.userdef1
->base
->integer
= 42;
399 p
->value
->dict1
.dict2
.string2
= g_strdup(string
);
400 p
->value
->dict1
.has_dict3
= false;
406 qapi_free_UserDefNestedList(head
);
409 static void test_visitor_out_union(TestOutputVisitorData
*data
,
412 QObject
*arg
, *qvalue
;
413 QDict
*qdict
, *value
;
417 UserDefUnion
*tmp
= g_malloc0(sizeof(UserDefUnion
));
418 tmp
->kind
= USER_DEF_UNION_KIND_A
;
420 tmp
->a
= g_malloc0(sizeof(UserDefA
));
421 tmp
->a
->boolean
= true;
423 visit_type_UserDefUnion(data
->ov
, &tmp
, NULL
, &err
);
424 g_assert(err
== NULL
);
425 arg
= qmp_output_get_qobject(data
->qov
);
427 g_assert(qobject_type(arg
) == QTYPE_QDICT
);
428 qdict
= qobject_to_qdict(arg
);
430 g_assert_cmpstr(qdict_get_str(qdict
, "type"), ==, "a");
431 g_assert_cmpint(qdict_get_int(qdict
, "integer"), ==, 41);
433 qvalue
= qdict_get(qdict
, "data");
434 g_assert(data
!= NULL
);
435 g_assert(qobject_type(qvalue
) == QTYPE_QDICT
);
436 value
= qobject_to_qdict(qvalue
);
437 g_assert_cmpint(qdict_get_bool(value
, "boolean"), ==, true);
439 qapi_free_UserDefUnion(tmp
);
443 static void test_visitor_out_union_flat(TestOutputVisitorData
*data
,
451 UserDefFlatUnion
*tmp
= g_malloc0(sizeof(UserDefFlatUnion
));
452 tmp
->kind
= ENUM_ONE_VALUE1
;
453 tmp
->string
= g_strdup("str");
454 tmp
->value1
= g_malloc0(sizeof(UserDefA
));
455 /* TODO when generator bug is fixed: tmp->integer = 41; */
456 tmp
->value1
->boolean
= true;
458 visit_type_UserDefFlatUnion(data
->ov
, &tmp
, NULL
, &err
);
459 g_assert(err
== NULL
);
460 arg
= qmp_output_get_qobject(data
->qov
);
462 g_assert(qobject_type(arg
) == QTYPE_QDICT
);
463 qdict
= qobject_to_qdict(arg
);
465 g_assert_cmpstr(qdict_get_str(qdict
, "enum1"), ==, "value1");
466 g_assert_cmpstr(qdict_get_str(qdict
, "string"), ==, "str");
467 /* TODO g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, 41); */
468 g_assert_cmpint(qdict_get_bool(qdict
, "boolean"), ==, true);
470 qapi_free_UserDefFlatUnion(tmp
);
474 static void test_visitor_out_union_anon(TestOutputVisitorData
*data
,
480 UserDefAnonUnion
*tmp
= g_malloc0(sizeof(UserDefAnonUnion
));
481 tmp
->kind
= USER_DEF_ANON_UNION_KIND_I
;
484 visit_type_UserDefAnonUnion(data
->ov
, &tmp
, NULL
, &err
);
485 g_assert(err
== NULL
);
486 arg
= qmp_output_get_qobject(data
->qov
);
488 g_assert(qobject_type(arg
) == QTYPE_QINT
);
489 g_assert_cmpint(qint_get_int(qobject_to_qint(arg
)), ==, 42);
491 qapi_free_UserDefAnonUnion(tmp
);
494 static void init_native_list(UserDefNativeListUnion
*cvalue
)
497 switch (cvalue
->kind
) {
498 case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER
: {
499 intList
**list
= &cvalue
->integer
;
500 for (i
= 0; i
< 32; i
++) {
501 *list
= g_new0(intList
, 1);
503 (*list
)->next
= NULL
;
504 list
= &(*list
)->next
;
508 case USER_DEF_NATIVE_LIST_UNION_KIND_S8
: {
509 int8List
**list
= &cvalue
->s8
;
510 for (i
= 0; i
< 32; i
++) {
511 *list
= g_new0(int8List
, 1);
513 (*list
)->next
= NULL
;
514 list
= &(*list
)->next
;
518 case USER_DEF_NATIVE_LIST_UNION_KIND_S16
: {
519 int16List
**list
= &cvalue
->s16
;
520 for (i
= 0; i
< 32; i
++) {
521 *list
= g_new0(int16List
, 1);
523 (*list
)->next
= NULL
;
524 list
= &(*list
)->next
;
528 case USER_DEF_NATIVE_LIST_UNION_KIND_S32
: {
529 int32List
**list
= &cvalue
->s32
;
530 for (i
= 0; i
< 32; i
++) {
531 *list
= g_new0(int32List
, 1);
533 (*list
)->next
= NULL
;
534 list
= &(*list
)->next
;
538 case USER_DEF_NATIVE_LIST_UNION_KIND_S64
: {
539 int64List
**list
= &cvalue
->s64
;
540 for (i
= 0; i
< 32; i
++) {
541 *list
= g_new0(int64List
, 1);
543 (*list
)->next
= NULL
;
544 list
= &(*list
)->next
;
548 case USER_DEF_NATIVE_LIST_UNION_KIND_U8
: {
549 uint8List
**list
= &cvalue
->u8
;
550 for (i
= 0; i
< 32; i
++) {
551 *list
= g_new0(uint8List
, 1);
553 (*list
)->next
= NULL
;
554 list
= &(*list
)->next
;
558 case USER_DEF_NATIVE_LIST_UNION_KIND_U16
: {
559 uint16List
**list
= &cvalue
->u16
;
560 for (i
= 0; i
< 32; i
++) {
561 *list
= g_new0(uint16List
, 1);
563 (*list
)->next
= NULL
;
564 list
= &(*list
)->next
;
568 case USER_DEF_NATIVE_LIST_UNION_KIND_U32
: {
569 uint32List
**list
= &cvalue
->u32
;
570 for (i
= 0; i
< 32; i
++) {
571 *list
= g_new0(uint32List
, 1);
573 (*list
)->next
= NULL
;
574 list
= &(*list
)->next
;
578 case USER_DEF_NATIVE_LIST_UNION_KIND_U64
: {
579 uint64List
**list
= &cvalue
->u64
;
580 for (i
= 0; i
< 32; i
++) {
581 *list
= g_new0(uint64List
, 1);
583 (*list
)->next
= NULL
;
584 list
= &(*list
)->next
;
588 case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN
: {
589 boolList
**list
= &cvalue
->boolean
;
590 for (i
= 0; i
< 32; i
++) {
591 *list
= g_new0(boolList
, 1);
592 (*list
)->value
= (i
% 3 == 0);
593 (*list
)->next
= NULL
;
594 list
= &(*list
)->next
;
598 case USER_DEF_NATIVE_LIST_UNION_KIND_STRING
: {
599 strList
**list
= &cvalue
->string
;
600 for (i
= 0; i
< 32; i
++) {
601 *list
= g_new0(strList
, 1);
602 (*list
)->value
= g_strdup_printf("%d", i
);
603 (*list
)->next
= NULL
;
604 list
= &(*list
)->next
;
608 case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER
: {
609 numberList
**list
= &cvalue
->number
;
610 for (i
= 0; i
< 32; i
++) {
611 *list
= g_new0(numberList
, 1);
612 (*list
)->value
= (double)i
/ 3;
613 (*list
)->next
= NULL
;
614 list
= &(*list
)->next
;
619 g_assert_not_reached();
623 static void check_native_list(QObject
*qobj
,
624 UserDefNativeListUnionKind kind
)
631 g_assert(qobject_type(qobj
) == QTYPE_QDICT
);
632 qdict
= qobject_to_qdict(qobj
);
634 g_assert(qdict_haskey(qdict
, "data"));
635 qlist
= qlist_copy(qobject_to_qlist(qdict_get(qdict
, "data")));
638 case USER_DEF_NATIVE_LIST_UNION_KIND_S8
:
639 case USER_DEF_NATIVE_LIST_UNION_KIND_S16
:
640 case USER_DEF_NATIVE_LIST_UNION_KIND_S32
:
641 case USER_DEF_NATIVE_LIST_UNION_KIND_S64
:
642 case USER_DEF_NATIVE_LIST_UNION_KIND_U8
:
643 case USER_DEF_NATIVE_LIST_UNION_KIND_U16
:
644 case USER_DEF_NATIVE_LIST_UNION_KIND_U32
:
645 case USER_DEF_NATIVE_LIST_UNION_KIND_U64
:
646 /* all integer elements in JSON arrays get stored into QInts when
647 * we convert to QObjects, so we can check them all in the same
648 * fashion, so simply fall through here
650 case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER
:
651 for (i
= 0; i
< 32; i
++) {
654 tmp
= qlist_peek(qlist
);
656 qvalue
= qobject_to_qint(tmp
);
657 g_assert_cmpint(qint_get_int(qvalue
), ==, i
);
658 qobject_decref(qlist_pop(qlist
));
661 case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN
:
662 for (i
= 0; i
< 32; i
++) {
665 tmp
= qlist_peek(qlist
);
667 qvalue
= qobject_to_qbool(tmp
);
668 g_assert_cmpint(qbool_get_int(qvalue
), ==, (i
% 3 == 0) ? 1 : 0);
669 qobject_decref(qlist_pop(qlist
));
672 case USER_DEF_NATIVE_LIST_UNION_KIND_STRING
:
673 for (i
= 0; i
< 32; i
++) {
677 tmp
= qlist_peek(qlist
);
679 qvalue
= qobject_to_qstring(tmp
);
680 sprintf(str
, "%d", i
);
681 g_assert_cmpstr(qstring_get_str(qvalue
), ==, str
);
682 qobject_decref(qlist_pop(qlist
));
685 case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER
:
686 for (i
= 0; i
< 32; i
++) {
689 GString
*double_expected
= g_string_new("");
690 GString
*double_actual
= g_string_new("");
692 tmp
= qlist_peek(qlist
);
694 qvalue
= qobject_to_qfloat(tmp
);
695 g_string_printf(double_expected
, "%.6f", (double)i
/ 3);
696 g_string_printf(double_actual
, "%.6f", qfloat_get_double(qvalue
));
697 g_assert_cmpstr(double_actual
->str
, ==, double_expected
->str
);
699 qobject_decref(qlist_pop(qlist
));
700 g_string_free(double_expected
, true);
701 g_string_free(double_actual
, true);
705 g_assert_not_reached();
710 static void test_native_list(TestOutputVisitorData
*data
,
712 UserDefNativeListUnionKind kind
)
714 UserDefNativeListUnion
*cvalue
= g_new0(UserDefNativeListUnion
, 1);
719 init_native_list(cvalue
);
721 visit_type_UserDefNativeListUnion(data
->ov
, &cvalue
, NULL
, &err
);
722 g_assert(err
== NULL
);
724 obj
= qmp_output_get_qobject(data
->qov
);
725 check_native_list(obj
, cvalue
->kind
);
726 qapi_free_UserDefNativeListUnion(cvalue
);
730 static void test_visitor_out_native_list_int(TestOutputVisitorData
*data
,
733 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER
);
736 static void test_visitor_out_native_list_int8(TestOutputVisitorData
*data
,
739 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_S8
);
742 static void test_visitor_out_native_list_int16(TestOutputVisitorData
*data
,
745 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_S16
);
748 static void test_visitor_out_native_list_int32(TestOutputVisitorData
*data
,
751 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_S32
);
754 static void test_visitor_out_native_list_int64(TestOutputVisitorData
*data
,
757 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_S64
);
760 static void test_visitor_out_native_list_uint8(TestOutputVisitorData
*data
,
763 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_U8
);
766 static void test_visitor_out_native_list_uint16(TestOutputVisitorData
*data
,
769 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_U16
);
772 static void test_visitor_out_native_list_uint32(TestOutputVisitorData
*data
,
775 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_U32
);
778 static void test_visitor_out_native_list_uint64(TestOutputVisitorData
*data
,
781 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_U64
);
784 static void test_visitor_out_native_list_bool(TestOutputVisitorData
*data
,
787 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN
);
790 static void test_visitor_out_native_list_str(TestOutputVisitorData
*data
,
793 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_STRING
);
796 static void test_visitor_out_native_list_number(TestOutputVisitorData
*data
,
799 test_native_list(data
, unused
, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER
);
802 static void output_visitor_test_add(const char *testpath
,
803 TestOutputVisitorData
*data
,
804 void (*test_func
)(TestOutputVisitorData
*data
, const void *user_data
))
806 g_test_add(testpath
, TestOutputVisitorData
, data
, visitor_output_setup
,
807 test_func
, visitor_output_teardown
);
810 int main(int argc
, char **argv
)
812 TestOutputVisitorData out_visitor_data
;
814 g_test_init(&argc
, &argv
, NULL
);
816 output_visitor_test_add("/visitor/output/int",
817 &out_visitor_data
, test_visitor_out_int
);
818 output_visitor_test_add("/visitor/output/bool",
819 &out_visitor_data
, test_visitor_out_bool
);
820 output_visitor_test_add("/visitor/output/number",
821 &out_visitor_data
, test_visitor_out_number
);
822 output_visitor_test_add("/visitor/output/string",
823 &out_visitor_data
, test_visitor_out_string
);
824 output_visitor_test_add("/visitor/output/no-string",
825 &out_visitor_data
, test_visitor_out_no_string
);
826 output_visitor_test_add("/visitor/output/enum",
827 &out_visitor_data
, test_visitor_out_enum
);
828 output_visitor_test_add("/visitor/output/enum-errors",
829 &out_visitor_data
, test_visitor_out_enum_errors
);
830 output_visitor_test_add("/visitor/output/struct",
831 &out_visitor_data
, test_visitor_out_struct
);
832 output_visitor_test_add("/visitor/output/struct-nested",
833 &out_visitor_data
, test_visitor_out_struct_nested
);
834 output_visitor_test_add("/visitor/output/struct-errors",
835 &out_visitor_data
, test_visitor_out_struct_errors
);
836 output_visitor_test_add("/visitor/output/list",
837 &out_visitor_data
, test_visitor_out_list
);
838 output_visitor_test_add("/visitor/output/list-qapi-free",
839 &out_visitor_data
, test_visitor_out_list_qapi_free
);
840 output_visitor_test_add("/visitor/output/union",
841 &out_visitor_data
, test_visitor_out_union
);
842 output_visitor_test_add("/visitor/output/union-flat",
843 &out_visitor_data
, test_visitor_out_union_flat
);
844 output_visitor_test_add("/visitor/output/union-anon",
845 &out_visitor_data
, test_visitor_out_union_anon
);
846 output_visitor_test_add("/visitor/output/native_list/int",
847 &out_visitor_data
, test_visitor_out_native_list_int
);
848 output_visitor_test_add("/visitor/output/native_list/int8",
849 &out_visitor_data
, test_visitor_out_native_list_int8
);
850 output_visitor_test_add("/visitor/output/native_list/int16",
851 &out_visitor_data
, test_visitor_out_native_list_int16
);
852 output_visitor_test_add("/visitor/output/native_list/int32",
853 &out_visitor_data
, test_visitor_out_native_list_int32
);
854 output_visitor_test_add("/visitor/output/native_list/int64",
855 &out_visitor_data
, test_visitor_out_native_list_int64
);
856 output_visitor_test_add("/visitor/output/native_list/uint8",
857 &out_visitor_data
, test_visitor_out_native_list_uint8
);
858 output_visitor_test_add("/visitor/output/native_list/uint16",
859 &out_visitor_data
, test_visitor_out_native_list_uint16
);
860 output_visitor_test_add("/visitor/output/native_list/uint32",
861 &out_visitor_data
, test_visitor_out_native_list_uint32
);
862 output_visitor_test_add("/visitor/output/native_list/uint64",
863 &out_visitor_data
, test_visitor_out_native_list_uint64
);
864 output_visitor_test_add("/visitor/output/native_list/bool",
865 &out_visitor_data
, test_visitor_out_native_list_bool
);
866 output_visitor_test_add("/visitor/output/native_list/string",
867 &out_visitor_data
, test_visitor_out_native_list_str
);
868 output_visitor_test_add("/visitor/output/native_list/number",
869 &out_visitor_data
, test_visitor_out_native_list_number
);