qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v8 09/17] qapi: Add positive tests to qapi-schema-test
Date: Wed, 28 Oct 2015 11:14:25 -0600	[thread overview]
Message-ID: <1446052473-19170-10-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1446052473-19170-1-git-send-email-eblake@redhat.com>

Add positive tests to qapi-schema-test for things that were
made possible by recent patches but which caused compile errors
due to collisions prior to that point.

This includes:
Use of a member 'base' in a struct with a base class
Use of a member name ending in 'Kind' or 'List'
Use of a type name starting with 'has_'
Use of a type named 'u'
Use of a union branch name of 'u'
Use of a union branch name starting with 'has_'
Use of a union branch name of 'type'

Signed-off-by: Eric Blake <eblake@redhat.com>

---
v8: new, but collects portions of subset B v10 patches 2, 3, and
16 and subset C v7 patch 6 that were deferred to later.

It might be worth dropping or simplifying this patch, depending
on how many corner cases we actually want to test.
---
 tests/qapi-schema/qapi-schema-test.json | 20 ++++++++++++++++++++
 tests/qapi-schema/qapi-schema-test.out  | 31 +++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)

diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
index 44638da..4354604 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -47,6 +47,10 @@
   'data': { 'string0': 'str',
             'dict1': 'UserDefTwoDict' } }

+# ensure that we don't have an artificial collision on 'base'
+{ 'struct': 'UserDefThree',
+  'base': 'UserDefOne', 'data': { 'base': 'str' } }
+
 # dummy struct to force generation of array types not otherwise mentioned
 { 'struct': 'ForceArrays',
   'data': { 'unused1':['UserDefOne'], 'unused2':['UserDefTwo'],
@@ -113,6 +117,22 @@
             'sizes': ['size'],
             'any': ['any'] } }

+# Even though 'u' and 'has_*' are forbidden as struct member names, they
+# should still be valid as a type or union branch name. And although
+# '*Kind' and '*List' are forbidden as type names, they should not be
+# forbidden as a member or branch name.  Flat union branches do not
+# collide with base members.
+{ 'enum': 'EnumName', 'data': [ 'value1', 'has_a', 'u', 'type' ] }
+{ 'struct': 'has_a', 'data': { 'MyKind': 'int', 'MyList': ['int'],
+                               'value1': 'EnumName' } }
+{ 'union': 'u', 'data': { 'u': 'uint8', 'myKind': 'has_a',
+                          'myList': 'has_a', 'has_a': 'has_a' } }
+{ 'union': 'UnionName', 'base': 'has_a', 'discriminator': 'value1',
+  'data': { 'value1': 'UserDefZero', 'has_a': 'UserDefZero',
+            'u': 'UserDefZero', 'type': 'UserDefZero' } }
+{ 'alternate': 'AltName', 'data': { 'type': 'int', 'u': 'bool',
+                                    'myKind': 'has_a' } }
+
 # testing commands
 { 'command': 'user_def_cmd', 'data': {} }
 { 'command': 'user_def_cmd1', 'data': {'ud1a': 'UserDefOne'} }
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index 786024e..29c46da 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -22,6 +22,8 @@ object :obj-guest-get-time-arg
     member b: int optional=True
 object :obj-guest-sync-arg
     member arg: any optional=False
+object :obj-has_a-wrapper
+    member data: has_a optional=False
 object :obj-int16List-wrapper
     member data: int16List optional=False
 object :obj-int32List-wrapper
@@ -46,6 +48,8 @@ object :obj-uint32List-wrapper
     member data: uint32List optional=False
 object :obj-uint64List-wrapper
     member data: uint64List optional=False
+object :obj-uint8-wrapper
+    member data: uint8 optional=False
 object :obj-uint8List-wrapper
     member data: uint8List optional=False
 object :obj-user_def_cmd1-arg
@@ -57,6 +61,11 @@ alternate AltIntNum
     case i: int
     case n: number
 enum AltIntNumKind ['i', 'n']
+alternate AltName
+    case type: int
+    case u: bool
+    case myKind: has_a
+enum AltNameKind ['type', 'u', 'myKind']
 alternate AltNumInt
     case n: number
     case i: int
@@ -84,6 +93,7 @@ event EVENT_D :obj-EVENT_D-arg
 object Empty1
 object Empty2
     base Empty1
+enum EnumName ['value1', 'has_a', 'u', 'type']
 enum EnumOne ['value1', 'value2', 'value3']
 object EventStructOne
     member struct1: UserDefOne optional=False
@@ -105,6 +115,13 @@ object TestStruct
     member integer: int optional=False
     member boolean: bool optional=False
     member string: str optional=False
+object UnionName
+    base has_a
+    tag value1
+    case value1: UserDefZero
+    case has_a: UserDefZero
+    case u: UserDefZero
+    case type: UserDefZero
 object UserDefA
     member boolean: bool optional=False
     member a_b: int optional=True
@@ -158,6 +175,9 @@ object UserDefOptions
     member u16: uint16List optional=True
     member i64x: int optional=True
     member u64x: uint64 optional=True
+object UserDefThree
+    base UserDefOne
+    member base: str optional=False
 object UserDefTwo
     member string0: str optional=False
     member dict1: UserDefTwoDict optional=False
@@ -201,6 +221,17 @@ command guest-get-time :obj-guest-get-time-arg -> int
    gen=True success_response=True
 command guest-sync :obj-guest-sync-arg -> any
    gen=True success_response=True
+object has_a
+    member MyKind: int optional=False
+    member MyList: intList optional=False
+    member value1: EnumName optional=False
+object u
+    member type: uKind optional=False
+    case u: :obj-uint8-wrapper
+    case myKind: :obj-has_a-wrapper
+    case myList: :obj-has_a-wrapper
+    case has_a: :obj-has_a-wrapper
+enum uKind ['u', 'myKind', 'myList', 'has_a']
 command user_def_cmd None -> None
    gen=True success_response=True
 command user_def_cmd1 :obj-user_def_cmd1-arg -> None
-- 
2.4.3

  parent reply	other threads:[~2015-10-28 17:14 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-28 17:14 [Qemu-devel] [PATCH v8 00/17] alternate layout (post-introspection cleanups, subset C) Eric Blake
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 01/17] qapi: Use generated TestStruct machinery in tests Eric Blake
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 02/17] qapi: Strengthen test of TestStructList Eric Blake
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 03/17] qapi: Provide nicer array names in introspection Eric Blake
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 04/17] qapi-introspect: Guarantee particular sorting Eric Blake
2015-10-30 11:20   ` Markus Armbruster
2015-10-30 15:41     ` Eric Blake
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 05/17] qapi: Track simple union tag in object.local_members Eric Blake
2015-10-30 12:54   ` Markus Armbruster
2015-10-30 16:32     ` Eric Blake
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 06/17] qapi-types: Consolidate gen_struct() and gen_union() Eric Blake
2015-10-30 13:01   ` Markus Armbruster
2015-10-30 16:36     ` Eric Blake
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 07/17] qapi: Rework collision assertions Eric Blake
2015-11-02 15:37   ` Markus Armbruster
2015-11-02 17:20     ` Eric Blake
2015-11-02 21:24     ` Eric Blake
2015-11-03  7:56       ` Markus Armbruster
2015-11-03 13:30         ` Eric Blake
2015-11-02 22:41     ` [Qemu-devel] [PATCH v8.5 0/4] rework of 7/17 Eric Blake
2015-11-02 22:41     ` [Qemu-devel] [PATCH v8.5 1/4] qapi: Drop all_members parameter from check() Eric Blake
2015-11-03 11:06       ` Markus Armbruster
2015-11-03 13:26         ` Eric Blake
2015-11-03 14:02           ` Markus Armbruster
2015-11-03 14:12             ` Eric Blake
2015-11-03 16:19               ` Markus Armbruster
2015-11-03 17:34                 ` Eric Blake
2015-11-03 14:04         ` [Qemu-devel] [PATCH 1/7] qapi: Drop obsolete tag value collision assertions Markus Armbruster
2015-11-03 14:04           ` [Qemu-devel] [PATCH 2/7] qapi: Simplify QAPISchemaObjectTypeMember.check() Markus Armbruster
2015-11-03 14:04           ` [Qemu-devel] [PATCH 3/7] qapi: Clean up after previous commit Markus Armbruster
2015-11-03 14:04           ` [Qemu-devel] [PATCH 4/7] qapi: Fix up commit 7618b91's clash sanity checking change Markus Armbruster
2015-11-03 14:04           ` [Qemu-devel] [PATCH 5/7] qapi: Eliminate QAPISchemaObjectType.check() variable members Markus Armbruster
2015-11-03 14:04           ` [Qemu-devel] [PATCH 6/7] qapi: Factor out QAPISchemaObjectTypeMember.check_clash() Markus Armbruster
2015-11-03 14:04           ` [Qemu-devel] [PATCH 7/7] qapi: QAPISchemaObjectTypeVariants.check() Markus Armbruster
2015-11-02 22:41     ` [Qemu-devel] [PATCH v8.5 2/4] qapi: Check for QMP collisions of flat union branches Eric Blake
2015-11-02 22:41     ` [Qemu-devel] [PATCH v8.5 3/4] qapi: Fix check for variant tag values collision Eric Blake
2015-11-02 22:41     ` [Qemu-devel] [PATCH v8.5 4/4] qapi: Consolidate collision detection code Eric Blake
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 08/17] qapi: Remove outdated tests related to QMP/branch collisions Eric Blake
2015-11-03 16:32   ` Markus Armbruster
2015-10-28 17:14 ` Eric Blake [this message]
2015-11-03 16:43   ` [Qemu-devel] [PATCH v8 09/17] qapi: Add positive tests to qapi-schema-test Markus Armbruster
2015-11-03 16:56     ` Eric Blake
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 10/17] qapi: Simplify visiting of alternate types Eric Blake
2015-11-03 18:30   ` Markus Armbruster
2015-11-03 18:59     ` Eric Blake
2015-11-04  7:30       ` Markus Armbruster
2015-11-04 16:03       ` Markus Armbruster
2015-11-04 20:52         ` Eric Blake
2015-11-05  7:17           ` Markus Armbruster
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 11/17] qapi: Fix alternates that accept 'number' but not 'int' Eric Blake
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 12/17] qapi: Remove dead visitor code Eric Blake
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 13/17] qapi: Plug leaks in test-qmp-* Eric Blake
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 14/17] qapi: Simplify error testing " Eric Blake
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 15/17] qapi: Test failure in middle of array parse Eric Blake
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 16/17] qapi: More tests of input arrays Eric Blake
2015-10-28 17:14 ` [Qemu-devel] [PATCH v8 17/17] qapi: Simplify visits of optional fields Eric Blake

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=1446052473-19170-10-git-send-email-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=mdroth@linux.vnet.ibm.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).