qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 14/40] qapi: Remove outdated tests related to QMP/branch collisions
Date: Thu, 17 Dec 2015 09:33:19 +0100	[thread overview]
Message-ID: <1450341225-2735-15-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1450341225-2735-1-git-send-email-armbru@redhat.com>

From: Eric Blake <eblake@redhat.com>

Now that branches are in a separate C namespace, we can remove
the restrictions in the parser that claim a branch name would
collide with QMP, and delete the negative tests that are no
longer problematic.  A separate patch can then add positive
tests to qapi-schema-test to test that any corner cases will
compile correctly.

This reverts the scripts/qapi.py portion of commit 7b2a5c2,
now that the assertions that it plugged are no longer possible.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447836791-369-15-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi.py                                | 11 ++---------
 tests/Makefile                                 |  3 ---
 tests/qapi-schema/flat-union-clash-branch.err  |  0
 tests/qapi-schema/flat-union-clash-branch.exit |  1 -
 tests/qapi-schema/flat-union-clash-branch.json | 18 ------------------
 tests/qapi-schema/flat-union-clash-branch.out  | 14 --------------
 tests/qapi-schema/flat-union-clash-type.err    |  1 -
 tests/qapi-schema/flat-union-clash-type.exit   |  1 -
 tests/qapi-schema/flat-union-clash-type.json   | 14 --------------
 tests/qapi-schema/flat-union-clash-type.out    |  0
 tests/qapi-schema/union-clash-type.err         |  1 -
 tests/qapi-schema/union-clash-type.exit        |  1 -
 tests/qapi-schema/union-clash-type.json        |  9 ---------
 tests/qapi-schema/union-clash-type.out         |  0
 14 files changed, 2 insertions(+), 72 deletions(-)
 delete mode 100644 tests/qapi-schema/flat-union-clash-branch.err
 delete mode 100644 tests/qapi-schema/flat-union-clash-branch.exit
 delete mode 100644 tests/qapi-schema/flat-union-clash-branch.json
 delete mode 100644 tests/qapi-schema/flat-union-clash-branch.out
 delete mode 100644 tests/qapi-schema/flat-union-clash-type.err
 delete mode 100644 tests/qapi-schema/flat-union-clash-type.exit
 delete mode 100644 tests/qapi-schema/flat-union-clash-type.json
 delete mode 100644 tests/qapi-schema/flat-union-clash-type.out
 delete mode 100644 tests/qapi-schema/union-clash-type.err
 delete mode 100644 tests/qapi-schema/union-clash-type.exit
 delete mode 100644 tests/qapi-schema/union-clash-type.json
 delete mode 100644 tests/qapi-schema/union-clash-type.out

diff --git a/scripts/qapi.py b/scripts/qapi.py
index c6f3fce..6fc14be 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -548,8 +548,7 @@ def check_union(expr, expr_info):
     base = expr.get('base')
     discriminator = expr.get('discriminator')
     members = expr['data']
-    values = {'MAX': '(automatic)', 'KIND': '(automatic)',
-              'TYPE': '(automatic)'}
+    values = {'MAX': '(automatic)'}
 
     # Two types of unions, determined by discriminator.
 
@@ -607,19 +606,13 @@ def check_union(expr, expr_info):
                                " of branch '%s'" % key)
 
         # If the discriminator names an enum type, then all members
-        # of 'data' must also be members of the enum type, which in turn
-        # must not collide with the discriminator name.
+        # of 'data' must also be members of the enum type.
         if enum_define:
             if key not in enum_define['enum_values']:
                 raise QAPIExprError(expr_info,
                                     "Discriminator value '%s' is not found in "
                                     "enum '%s'" %
                                     (key, enum_define["enum_name"]))
-            if discriminator in enum_define['enum_values']:
-                raise QAPIExprError(expr_info,
-                                    "Discriminator name '%s' collides with "
-                                    "enum value in '%s'" %
-                                    (discriminator, enum_define["enum_name"]))
 
         # Otherwise, check for conflicts in the generated enum
         else:
diff --git a/tests/Makefile b/tests/Makefile
index a1d03b4..6518ef9 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -281,9 +281,7 @@ qapi-schema += flat-union-bad-base.json
 qapi-schema += flat-union-bad-discriminator.json
 qapi-schema += flat-union-base-any.json
 qapi-schema += flat-union-base-union.json
-qapi-schema += flat-union-clash-branch.json
 qapi-schema += flat-union-clash-member.json
-qapi-schema += flat-union-clash-type.json
 qapi-schema += flat-union-empty.json
 qapi-schema += flat-union-inline.json
 qapi-schema += flat-union-int-branch.json
@@ -345,7 +343,6 @@ qapi-schema += union-bad-branch.json
 qapi-schema += union-base-no-discriminator.json
 qapi-schema += union-clash-branches.json
 qapi-schema += union-clash-data.json
-qapi-schema += union-clash-type.json
 qapi-schema += union-empty.json
 qapi-schema += union-invalid-base.json
 qapi-schema += union-max.json
diff --git a/tests/qapi-schema/flat-union-clash-branch.err b/tests/qapi-schema/flat-union-clash-branch.err
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/qapi-schema/flat-union-clash-branch.exit b/tests/qapi-schema/flat-union-clash-branch.exit
deleted file mode 100644
index 573541a..0000000
--- a/tests/qapi-schema/flat-union-clash-branch.exit
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/tests/qapi-schema/flat-union-clash-branch.json b/tests/qapi-schema/flat-union-clash-branch.json
deleted file mode 100644
index e593336..0000000
--- a/tests/qapi-schema/flat-union-clash-branch.json
+++ /dev/null
@@ -1,18 +0,0 @@
-# Flat union branch name collision
-# FIXME: this parses, but then fails to compile due to a duplicate 'c_d'
-# (one from the base member, the other from the branch name).  We should
-# either reject the collision at parse time, or munge the generated branch
-# name to allow this to compile.
-{ 'enum': 'TestEnum',
-  'data': [ 'base', 'c-d' ] }
-{ 'struct': 'Base',
-  'data': { 'enum1': 'TestEnum', '*c_d': 'str' } }
-{ 'struct': 'Branch1',
-  'data': { 'string': 'str' } }
-{ 'struct': 'Branch2',
-  'data': { 'value': 'int' } }
-{ 'union': 'TestUnion',
-  'base': 'Base',
-  'discriminator': 'enum1',
-  'data': { 'base': 'Branch1',
-            'c-d': 'Branch2' } }
diff --git a/tests/qapi-schema/flat-union-clash-branch.out b/tests/qapi-schema/flat-union-clash-branch.out
deleted file mode 100644
index 8e0da73..0000000
--- a/tests/qapi-schema/flat-union-clash-branch.out
+++ /dev/null
@@ -1,14 +0,0 @@
-object :empty
-object Base
-    member enum1: TestEnum optional=False
-    member c_d: str optional=True
-object Branch1
-    member string: str optional=False
-object Branch2
-    member value: int optional=False
-enum TestEnum ['base', 'c-d']
-object TestUnion
-    base Base
-    tag enum1
-    case base: Branch1
-    case c-d: Branch2
diff --git a/tests/qapi-schema/flat-union-clash-type.err b/tests/qapi-schema/flat-union-clash-type.err
deleted file mode 100644
index b44dd40..0000000
--- a/tests/qapi-schema/flat-union-clash-type.err
+++ /dev/null
@@ -1 +0,0 @@
-tests/qapi-schema/flat-union-clash-type.json:11: Discriminator name 'type' collides with enum value in 'TestEnum'
diff --git a/tests/qapi-schema/flat-union-clash-type.exit b/tests/qapi-schema/flat-union-clash-type.exit
deleted file mode 100644
index d00491f..0000000
--- a/tests/qapi-schema/flat-union-clash-type.exit
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/tests/qapi-schema/flat-union-clash-type.json b/tests/qapi-schema/flat-union-clash-type.json
deleted file mode 100644
index 8f710f0..0000000
--- a/tests/qapi-schema/flat-union-clash-type.json
+++ /dev/null
@@ -1,14 +0,0 @@
-# Flat union branch 'type'
-# Reject this, because we would have a clash in generated C, between the
-# outer tag 'type' and the branch name 'type' within the union.
-# TODO: We could munge the generated C branch name to let it compile.
-{ 'enum': 'TestEnum',
-  'data': [ 'type' ] }
-{ 'struct': 'Base',
-  'data': { 'type': 'TestEnum' } }
-{ 'struct': 'Branch1',
-  'data': { 'string': 'str' } }
-{ 'union': 'TestUnion',
-  'base': 'Base',
-  'discriminator': 'type',
-  'data': { 'type': 'Branch1' } }
diff --git a/tests/qapi-schema/flat-union-clash-type.out b/tests/qapi-schema/flat-union-clash-type.out
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/qapi-schema/union-clash-type.err b/tests/qapi-schema/union-clash-type.err
deleted file mode 100644
index a5dead1..0000000
--- a/tests/qapi-schema/union-clash-type.err
+++ /dev/null
@@ -1 +0,0 @@
-tests/qapi-schema/union-clash-type.json:8: Union 'TestUnion' member 'kind' clashes with '(automatic)'
diff --git a/tests/qapi-schema/union-clash-type.exit b/tests/qapi-schema/union-clash-type.exit
deleted file mode 100644
index d00491f..0000000
--- a/tests/qapi-schema/union-clash-type.exit
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/tests/qapi-schema/union-clash-type.json b/tests/qapi-schema/union-clash-type.json
deleted file mode 100644
index cfc256b..0000000
--- a/tests/qapi-schema/union-clash-type.json
+++ /dev/null
@@ -1,9 +0,0 @@
-# Union branch 'type'
-# Reject this, because we would have a clash in generated C, between the
-# simple union's implicit tag member 'kind' and the branch name 'kind'
-# within the union.
-# TODO: Even when the generated C is switched to use 'type' rather than
-# 'kind', to match the QMP spelling, the collision should still be detected.
-# Or, we could munge the branch name to allow compilation.
-{ 'union': 'TestUnion',
-  'data': { 'kind': 'int', 'type': 'str' } }
diff --git a/tests/qapi-schema/union-clash-type.out b/tests/qapi-schema/union-clash-type.out
deleted file mode 100644
index e69de29..0000000
-- 
2.4.3

  parent reply	other threads:[~2015-12-17  8:33 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-17  8:33 [Qemu-devel] [PULL 00/40] QAPI patches for 2015-12-17 Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 01/40] qapi: Track simple union tag in object.local_members Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 02/40] qapi-types: Consolidate gen_struct() and gen_union() Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 03/40] qapi-types: Simplify gen_struct_field[s] Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 04/40] qapi: Drop obsolete tag value collision assertions Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 05/40] qapi: Simplify QAPISchemaObjectTypeMember.check() Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 06/40] qapi: Clean up after previous commit Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 07/40] qapi: Fix up commit 7618b91's clash sanity checking change Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 08/40] qapi: Eliminate QAPISchemaObjectType.check() variable members Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 09/40] qapi: Factor out QAPISchemaObjectTypeMember.check_clash() Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 10/40] qapi: Simplify QAPISchemaObjectTypeVariants.check() Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 11/40] qapi: Check for QAPI collisions involving variant members Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 12/40] qapi: Factor out QAPISchemaObjectType.check_clash() Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 13/40] qapi: Hoist tag collision check to Variants.check() Markus Armbruster
2015-12-17  8:33 ` Markus Armbruster [this message]
2015-12-17  8:33 ` [Qemu-devel] [PULL 15/40] qapi: Track owner of each object member Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 16/40] qapi: Detect collisions in C member names Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 17/40] qapi: Fix c_name() munging Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 18/40] qapi: Remove dead visitor code Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 19/40] blkdebug: Merge hand-rolled and qapi BlkdebugEvent enum Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 20/40] blkdebug: Avoid '.' in enum values Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 21/40] qapi: Tighten the regex on valid names Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 22/40] qapi: Don't let implicit enum MAX member collide Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 23/40] qapi: Remove obsolete tests for MAX collision Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 24/40] cpu: Convert CpuInfo into flat union Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 25/40] qapi: Add alias for ErrorClass Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 26/40] qapi: Change munging of CamelCase enum values Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 27/40] qobject: Simplify QObject Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 28/40] qobject: Rename qtype_code to QType Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 29/40] qapi: Convert QType into QAPI built-in enum type Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 30/40] qapi: Simplify visiting of alternate types Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 31/40] qapi-types: Drop unnedeed ._fwdefn Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 32/40] qapi: Inline _make_implicit_tag() Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 33/40] qapi: Fix alternates that accept 'number' but not 'int' Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 34/40] qapi: Simplify visits of optional fields Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 35/40] qapi: Shorter " Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 36/40] qapi: Prepare new QAPISchemaMember base class Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 37/40] qapi: Track enum values by QAPISchemaMember, not string Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 38/40] qapi: Enforce (or whitelist) case conventions on qapi members Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 39/40] qapi: Move duplicate collision checks to schema check() Markus Armbruster
2015-12-17  8:33 ` [Qemu-devel] [PULL 40/40] qapi: Detect base class loops Markus Armbruster
2015-12-17 12:39 ` [Qemu-devel] [PULL 00/40] QAPI patches for 2015-12-17 Peter Maydell

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=1450341225-2735-15-git-send-email-armbru@redhat.com \
    --to=armbru@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).