[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/28] tests/qapi-schema: Tweak to demonstrate buggy member name
From: |
Markus Armbruster |
Subject: |
[PATCH 06/28] tests/qapi-schema: Tweak to demonstrate buggy member name check |
Date: |
Tue, 23 Mar 2021 10:40:03 +0100 |
Member name 'u' and names starting with 'has-' or 'has_' are reserved
for the generator. check_type() enforces this, covered by tests
reserved-member-u and reserved-member-has.
These tests neglect to cover optional members, where the name starts
with '*'. Tweak reserved-member-u to fix that.
This demonstrates the reserved member name check is broken for
optional members. The next commit will fix it.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
tests/qapi-schema/reserved-member-u.err | 2 --
tests/qapi-schema/reserved-member-u.json | 3 ++-
tests/qapi-schema/reserved-member-u.out | 14 ++++++++++++++
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/tests/qapi-schema/reserved-member-u.err
b/tests/qapi-schema/reserved-member-u.err
index 231d552494..e69de29bb2 100644
--- a/tests/qapi-schema/reserved-member-u.err
+++ b/tests/qapi-schema/reserved-member-u.err
@@ -1,2 +0,0 @@
-reserved-member-u.json: In struct 'Oops':
-reserved-member-u.json:7: 'data' member 'u' uses reserved name
diff --git a/tests/qapi-schema/reserved-member-u.json
b/tests/qapi-schema/reserved-member-u.json
index 1eaf0f301c..15005abb09 100644
--- a/tests/qapi-schema/reserved-member-u.json
+++ b/tests/qapi-schema/reserved-member-u.json
@@ -4,4 +4,5 @@
# This is true even for non-unions, because it is possible to convert a
# struct to flat union while remaining backwards compatible in QMP.
# TODO - we could munge the member name to 'q_u' to avoid the collision
-{ 'struct': 'Oops', 'data': { 'u': 'str' } }
+# BUG: not rejected
+{ 'struct': 'Oops', 'data': { '*u': 'str' } }
diff --git a/tests/qapi-schema/reserved-member-u.out
b/tests/qapi-schema/reserved-member-u.out
index e69de29bb2..6a3705518b 100644
--- a/tests/qapi-schema/reserved-member-u.out
+++ b/tests/qapi-schema/reserved-member-u.out
@@ -0,0 +1,14 @@
+module ./builtin
+object q_empty
+enum QType
+ prefix QTYPE
+ member none
+ member qnull
+ member qnum
+ member qstring
+ member qdict
+ member qlist
+ member qbool
+module reserved-member-u.json
+object Oops
+ member u: str optional=True
--
2.26.3
- Re: [PATCH 03/28] tests/qapi-schema: Rework comments on longhand member definitions, (continued)
[PATCH 05/28] tests/qapi-schema: Drop TODO comment on simple unions, Markus Armbruster, 2021/03/23
[PATCH 04/28] tests/qapi-schema: Belatedly update comment on alternate clash, Markus Armbruster, 2021/03/23
[PATCH 24/28] qapi: Enforce command naming rules, Markus Armbruster, 2021/03/23