qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, mdroth@linux.vnet.ibm.com,
	lcapitulino@redhat.com, aliguori@amazon.com, pbonzini@redhat.com
Subject: [Qemu-devel] [PATCH v3 06/13] tests/qapi-schema: Cover union types with base
Date: Sat,  1 Mar 2014 08:40:32 +0100	[thread overview]
Message-ID: <1393659639-12959-7-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1393659639-12959-1-git-send-email-armbru@redhat.com>

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 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

  parent reply	other threads:[~2014-03-01  7:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-01  7:40 [Qemu-devel] [PATCH v3 00/13] qapi: Test coverage & clean up generated code Markus Armbruster
2014-03-01  7:40 ` [Qemu-devel] [PATCH v3 01/13] tests/qapi-schema: Actually check successful QMP command response Markus Armbruster
2014-03-01  7:40 ` [Qemu-devel] [PATCH v3 02/13] tests/qapi-schema: Cover optional command arguments Markus Armbruster
2014-03-01  7:40 ` [Qemu-devel] [PATCH v3 03/13] tests/qapi-schema: Cover simple argument types Markus Armbruster
2014-03-01  7:40 ` [Qemu-devel] [PATCH v3 04/13] tests/qapi-schema: Cover anonymous union types Markus Armbruster
2014-03-01  7:40 ` [Qemu-devel] [PATCH v3 05/13] tests/qapi-schema: Cover complex types with base Markus Armbruster
2014-03-01  7:40 ` Markus Armbruster [this message]
2014-03-01  7:40 ` [Qemu-devel] [PATCH v3 07/13] tests/qapi-schema: Cover flat union types Markus Armbruster
2014-03-01  7:40 ` [Qemu-devel] [PATCH v3 08/13] qapi: Fix licensing of scripts Markus Armbruster
2014-03-01  7:40 ` [Qemu-devel] [PATCH v3 09/13] qapi: Drop nonsensical header guard in generated qapi-visit.c Markus Armbruster
2014-03-01  7:40 ` [Qemu-devel] [PATCH v3 10/13] qapi: Drop unused code in qapi-commands.py Markus Armbruster
2014-03-01  7:40 ` [Qemu-devel] [PATCH v3 11/13] qapi: Clean up null checking in generated visitors Markus Armbruster
2014-03-01 13:38   ` Eric Blake
2014-03-01  7:40 ` [Qemu-devel] [PATCH v3 12/13] qapi: Clean up superfluous null check in qapi_dealloc_type_str() Markus Armbruster
2014-03-01  7:40 ` [Qemu-devel] [PATCH v3 13/13] qapi: Add missing null check to opts_start_struct() Markus Armbruster
2014-03-03 16:21 ` [Qemu-devel] [PATCH v3 00/13] qapi: Test coverage & clean up generated code Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393659639-12959-7-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).