aboutsummaryrefslogtreecommitdiff
path: root/tests/qapi-schema
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2023-03-16 08:13:20 +0100
committerMarkus Armbruster <armbru@redhat.com>2023-04-24 15:21:39 +0200
commit8fba2f737a372be07739aefeea16c09614a152f0 (patch)
tree0151b68e16418052d32bb606d73ab272472efc0a /tests/qapi-schema
parente2050ef633f77781e6b7b3aa04dd736e0ad825e1 (diff)
downloadqemu-8fba2f737a372be07739aefeea16c09614a152f0.zip
qemu-8fba2f737a372be07739aefeea16c09614a152f0.tar.gz
qemu-8fba2f737a372be07739aefeea16c09614a152f0.tar.bz2
tests/qapi-schema: Improve union discriminator coverage
A union's 'discriminator' must name one of the common members. QAPISchemaVariants.check() looks it up by its c_name(), then checks the name matches exactly (because c_name() is not injective). Tests union-base-empty and union-invalid-discriminator both cover the case where lookup fails. Repurpose the latter to cover the case where it succeeds and the name check fails. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-10-armbru@redhat.com Reviewed-by: Eric Blake <eblake@redhat.com> [Commit message typo fixed]
Diffstat (limited to 'tests/qapi-schema')
-rw-r--r--tests/qapi-schema/union-invalid-discriminator.err2
-rw-r--r--tests/qapi-schema/union-invalid-discriminator.json4
2 files changed, 3 insertions, 3 deletions
diff --git a/tests/qapi-schema/union-invalid-discriminator.err b/tests/qapi-schema/union-invalid-discriminator.err
index 38efb24..6bd774c 100644
--- a/tests/qapi-schema/union-invalid-discriminator.err
+++ b/tests/qapi-schema/union-invalid-discriminator.err
@@ -1,2 +1,2 @@
union-invalid-discriminator.json: In union 'TestUnion':
-union-invalid-discriminator.json:10: discriminator 'enum_wrong' is not a member of 'base'
+union-invalid-discriminator.json:10: discriminator 'type_tag' is not a member of 'base'
diff --git a/tests/qapi-schema/union-invalid-discriminator.json b/tests/qapi-schema/union-invalid-discriminator.json
index c4fce97..f315f36 100644
--- a/tests/qapi-schema/union-invalid-discriminator.json
+++ b/tests/qapi-schema/union-invalid-discriminator.json
@@ -8,7 +8,7 @@
'data': { 'integer': 'int' } }
{ 'union': 'TestUnion',
- 'base': { 'enum1': 'TestEnum' },
- 'discriminator': 'enum_wrong',
+ 'base': { 'type-tag': 'TestEnum' },
+ 'discriminator': 'type_tag',
'data': { 'value1': 'TestTypeA',
'value2': 'TestTypeB' } }