aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2021-03-23 10:40:23 +0100
committerMarkus Armbruster <armbru@redhat.com>2021-03-23 22:31:43 +0100
commit5aceeac04de50e3a9d5c2a965379324659a94be0 (patch)
treedc467a25f992c721e8dd87fc2a1533809fbcf468 /tests
parente75d4225b76842ec899f25e8ff39b070119f033f (diff)
downloadqemu-5aceeac04de50e3a9d5c2a965379324659a94be0.zip
qemu-5aceeac04de50e3a9d5c2a965379324659a94be0.tar.gz
qemu-5aceeac04de50e3a9d5c2a965379324659a94be0.tar.bz2
qapi: Enforce struct member naming rules
Struct members, including command arguments, event data, and union inline base members, should use '-', not '_'. Enforce this. Fix the fixable offenders (all in tests/), and add the remainder to pragma member-name-exceptions. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-27-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/qapi-schema/qapi-schema-test.json8
-rw-r--r--tests/qapi-schema/qapi-schema-test.out4
-rw-r--r--tests/qapi-schema/struct-member-name-clash.err2
-rw-r--r--tests/qapi-schema/struct-member-name-clash.json1
4 files changed, 10 insertions, 5 deletions
diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
index e635db4..387678a 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -6,6 +6,10 @@
# Whitelists to permit QAPI rule violations
{ 'pragma': {
+ # Types whose member names may use '_'
+ 'member-name-exceptions': [
+ 'UserDefA'
+ ],
# Commands allowed to return a non-dictionary:
'command-returns-exceptions': [
'guest-get-time',
@@ -231,7 +235,7 @@
'if': 'defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)' }
{ 'command': 'test-if-union-cmd',
- 'data': { 'union_cmd_arg': 'TestIfUnion' },
+ 'data': { 'union-cmd-arg': 'TestIfUnion' },
'if': 'defined(TEST_IF_UNION)' }
{ 'alternate': 'TestIfAlternate', 'data':
@@ -240,7 +244,7 @@
'if': 'defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT)' }
{ 'command': 'test-if-alternate-cmd',
- 'data': { 'alt_cmd_arg': 'TestIfAlternate' },
+ 'data': { 'alt-cmd-arg': 'TestIfAlternate' },
'if': 'defined(TEST_IF_ALT)' }
{ 'command': 'test-if-cmd',
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index 3f1ea34..51efe5d 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -320,7 +320,7 @@ object TestIfUnion
if ['defined(TEST_IF_UNION_BAR)']
if ['defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)']
object q_obj_test-if-union-cmd-arg
- member union_cmd_arg: TestIfUnion optional=False
+ member union-cmd-arg: TestIfUnion optional=False
if ['defined(TEST_IF_UNION)']
command test-if-union-cmd q_obj_test-if-union-cmd-arg -> None
gen=True success_response=True boxed=False oob=False preconfig=False
@@ -332,7 +332,7 @@ alternate TestIfAlternate
if ['defined(TEST_IF_ALT_BAR)']
if ['defined(TEST_IF_ALT) && defined(TEST_IF_STRUCT)']
object q_obj_test-if-alternate-cmd-arg
- member alt_cmd_arg: TestIfAlternate optional=False
+ member alt-cmd-arg: TestIfAlternate optional=False
if ['defined(TEST_IF_ALT)']
command test-if-alternate-cmd q_obj_test-if-alternate-cmd-arg -> None
gen=True success_response=True boxed=False oob=False preconfig=False
diff --git a/tests/qapi-schema/struct-member-name-clash.err b/tests/qapi-schema/struct-member-name-clash.err
index 6ac042d..7e53a60 100644
--- a/tests/qapi-schema/struct-member-name-clash.err
+++ b/tests/qapi-schema/struct-member-name-clash.err
@@ -1,2 +1,2 @@
struct-member-name-clash.json: In struct 'Oops':
-struct-member-name-clash.json:4: member 'a_b' collides with member 'a-b'
+struct-member-name-clash.json:5: member 'a_b' collides with member 'a-b'
diff --git a/tests/qapi-schema/struct-member-name-clash.json b/tests/qapi-schema/struct-member-name-clash.json
index 3fb69cc..571acf0 100644
--- a/tests/qapi-schema/struct-member-name-clash.json
+++ b/tests/qapi-schema/struct-member-name-clash.json
@@ -1,4 +1,5 @@
# C member name collision
# Reject members that clash when mapped to C names (we would have two 'a_b'
# members).
+{ 'pragma': { 'member-name-exceptions': [ 'Oops' ] } }
{ 'struct': 'Oops', 'data': { 'a-b': 'str', 'a_b': 'str' } }