[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 25/32] tests/qapi-schema: Cover union types with base
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PULL 25/32] tests/qapi-schema: Cover union types with base |
Date: |
Mon, 3 Mar 2014 12:12:16 -0500 |
From: Markus Armbruster <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
tests/qapi-schema/qapi-schema-test.json | 1 +
tests/qapi-schema/qapi-schema-test.out | 2 +-
tests/test-qmp-input-strict.c | 4 ++--
tests/test-qmp-input-visitor.c | 3 ++-
tests/test-qmp-output-visitor.c | 2 ++
5 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/tests/qapi-schema/qapi-schema-test.json
b/tests/qapi-schema/qapi-schema-test.json
index c7e6be8..f5c5d37 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -34,6 +34,7 @@
'data': { 'integer': 'int' } }
{ 'union': 'UserDefUnion',
+ 'base': 'UserDefZero',
'data': { 'a' : 'UserDefA', 'b' : 'UserDefB' } }
{ 'union': 'UserDefAnonUnion',
diff --git a/tests/qapi-schema/qapi-schema-test.out
b/tests/qapi-schema/qapi-schema-test.out
index 89e213a..3f51afd 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -6,7 +6,7 @@
OrderedDict([('type', 'UserDefNested'), ('data', OrderedDict([('string0',
'str'), ('dict1', OrderedDict([('string1', 'str'), ('dict2',
OrderedDict([('userdef1', 'UserDefOne'), ('string2', 'str')])), ('*dict3',
OrderedDict([('userdef2', 'UserDefOne'), ('string3', 'str')]))]))]))]),
OrderedDict([('type', 'UserDefA'), ('data', OrderedDict([('boolean',
'bool')]))]),
OrderedDict([('type', 'UserDefB'), ('data', OrderedDict([('integer',
'int')]))]),
- OrderedDict([('union', 'UserDefUnion'), ('data', OrderedDict([('a',
'UserDefA'), ('b', 'UserDefB')]))]),
+ OrderedDict([('union', 'UserDefUnion'), ('base', 'UserDefZero'), ('data',
OrderedDict([('a', 'UserDefA'), ('b', 'UserDefB')]))]),
OrderedDict([('union', 'UserDefAnonUnion'), ('discriminator', OrderedDict()),
('data', OrderedDict([('uda', 'UserDefA'), ('s', 'str'), ('i', 'int')]))]),
OrderedDict([('union', 'UserDefNativeListUnion'), ('data',
OrderedDict([('integer', ['int']), ('s8', ['int8']), ('s16', ['int16']),
('s32', ['int32']), ('s64', ['int64']), ('u8', ['uint8']), ('u16', ['uint16']),
('u32', ['uint32']), ('u64', ['uint64']), ('number', ['number']), ('boolean',
['bool']), ('string', ['str'])]))]),
OrderedDict([('command', 'user_def_cmd'), ('data', OrderedDict())]),
diff --git a/tests/test-qmp-input-strict.c b/tests/test-qmp-input-strict.c
index 67adc2a..9b99b48 100644
--- a/tests/test-qmp-input-strict.c
+++ b/tests/test-qmp-input-strict.c
@@ -132,7 +132,7 @@ static void test_validate_union(TestInputVisitorData *data,
Visitor *v;
Error *errp = NULL;
- v = validate_test_init(data, "{ 'type': 'b', 'data' : { 'integer': 42 }
}");
+ v = validate_test_init(data, "{ 'type': 'b', 'integer': 41, 'data' : {
'integer': 42 } }");
visit_type_UserDefUnion(v, &tmp, NULL, &errp);
g_assert(!errp);
@@ -205,7 +205,7 @@ static void test_validate_fail_union(TestInputVisitorData
*data,
Error *errp = NULL;
Visitor *v;
- v = validate_test_init(data, "{ 'type': 'b', 'data' : { 'integer': 42 },
'extra': 'yyy' }");
+ v = validate_test_init(data, "{ 'type': 'b', 'data' : { 'integer': 42 }
}");
visit_type_UserDefUnion(v, &tmp, NULL, &errp);
g_assert(errp);
diff --git a/tests/test-qmp-input-visitor.c b/tests/test-qmp-input-visitor.c
index 9c7bf38..a0607cf 100644
--- a/tests/test-qmp-input-visitor.c
+++ b/tests/test-qmp-input-visitor.c
@@ -293,11 +293,12 @@ static void test_visitor_in_union(TestInputVisitorData
*data,
Error *err = NULL;
UserDefUnion *tmp;
- v = visitor_input_test_init(data, "{ 'type': 'b', 'data' : { 'integer': 42
} }");
+ v = visitor_input_test_init(data, "{ 'type': 'b', 'integer': 41, 'data' :
{ 'integer': 42 } }");
visit_type_UserDefUnion(v, &tmp, NULL, &err);
g_assert(err == NULL);
g_assert_cmpint(tmp->kind, ==, USER_DEF_UNION_KIND_B);
+ g_assert_cmpint(tmp->integer, ==, 41);
g_assert_cmpint(tmp->b->integer, ==, 42);
qapi_free_UserDefUnion(tmp);
}
diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c
index 6b29849..c932871 100644
--- a/tests/test-qmp-output-visitor.c
+++ b/tests/test-qmp-output-visitor.c
@@ -416,6 +416,7 @@ static void test_visitor_out_union(TestOutputVisitorData
*data,
UserDefUnion *tmp = g_malloc0(sizeof(UserDefUnion));
tmp->kind = USER_DEF_UNION_KIND_A;
+ tmp->integer = 41;
tmp->a = g_malloc0(sizeof(UserDefA));
tmp->a->boolean = true;
@@ -427,6 +428,7 @@ static void test_visitor_out_union(TestOutputVisitorData
*data,
qdict = qobject_to_qdict(arg);
g_assert_cmpstr(qdict_get_str(qdict, "type"), ==, "a");
+ g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, 41);
qvalue = qdict_get(qdict, "data");
g_assert(data != NULL);
--
1.8.1.4
- [Qemu-devel] [PULL 16/32] dump: add 'query-dump-guest-memory-capability' command, (continued)
- [Qemu-devel] [PULL 16/32] dump: add 'query-dump-guest-memory-capability' command, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 17/32] qmp: Check for returned data from __json_read in get_events, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 19/32] monitor: Remove left-over code in do_info_profile., Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 18/32] qerror: Improve QERR_DEVICE_NOT_ACTIVE message, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 22/32] tests/qapi-schema: Cover simple argument types, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 20/32] tests/qapi-schema: Actually check successful QMP command response, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 21/32] tests/qapi-schema: Cover optional command arguments, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 24/32] tests/qapi-schema: Cover complex types with base, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 23/32] tests/qapi-schema: Cover anonymous union types, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 26/32] tests/qapi-schema: Cover flat union types, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 25/32] tests/qapi-schema: Cover union types with base,
Luiz Capitulino <=
- [Qemu-devel] [PULL 31/32] qapi: Clean up superfluous null check in qapi_dealloc_type_str(), Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 29/32] qapi: Drop unused code in qapi-commands.py, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 27/32] qapi: Fix licensing of scripts, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 32/32] qapi: Add missing null check to opts_start_struct(), Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 28/32] qapi: Drop nonsensical header guard in generated qapi-visit.c, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 30/32] qapi: Clean up null checking in generated visitors, Luiz Capitulino, 2014/03/03
- Re: [Qemu-devel] [PULL 00/32] QMP queue, Peter Maydell, 2014/03/04