[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC v2 14/47] qapi-tests: New tests for union, alter
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH RFC v2 14/47] qapi-tests: New tests for union, alternate command arguments |
Date: |
Wed, 1 Jul 2015 22:22:02 +0200 |
A command's 'data' must be a struct type, given either as a
dictionary, or as struct type name.
Existing test case data-int.json covers simple type 'int'. Add test
cases for type names referring to union and alternate types.
The latter is caught (good), but the former is not (bug).
Signed-off-by: Markus Armbruster <address@hidden>
---
tests/Makefile | 3 ++-
tests/qapi-schema/args-alternate.err | 1 +
tests/qapi-schema/args-alternate.exit | 1 +
tests/qapi-schema/args-alternate.json | 4 ++++
tests/qapi-schema/args-alternate.out | 0
tests/qapi-schema/args-union.err | 0
tests/qapi-schema/args-union.exit | 1 +
tests/qapi-schema/args-union.json | 4 ++++
tests/qapi-schema/args-union.out | 4 ++++
9 files changed, 17 insertions(+), 1 deletion(-)
create mode 100644 tests/qapi-schema/args-alternate.err
create mode 100644 tests/qapi-schema/args-alternate.exit
create mode 100644 tests/qapi-schema/args-alternate.json
create mode 100644 tests/qapi-schema/args-alternate.out
create mode 100644 tests/qapi-schema/args-union.err
create mode 100644 tests/qapi-schema/args-union.exit
create mode 100644 tests/qapi-schema/args-union.json
create mode 100644 tests/qapi-schema/args-union.out
diff --git a/tests/Makefile b/tests/Makefile
index eff5e11..5a38748 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -225,7 +225,8 @@ check-qapi-schema-y := $(addprefix tests/qapi-schema/, \
type-bypass.json type-bypass-no-gen.json type-bypass-bad-gen.json \
data-array-empty.json data-array-unknown.json data-int.json \
data-unknown.json data-member-unknown.json data-member-array.json \
- data-member-array-bad.json returns-array-bad.json returns-int.json \
+ data-member-array-bad.json args-union.json args-alternate.json \
+ returns-array-bad.json returns-int.json \
returns-unknown.json returns-alternate.json returns-whitelist.json \
missing-colon.json missing-comma-list.json missing-comma-object.json \
nested-struct-data.json nested-struct-returns.json non-objects.json \
diff --git a/tests/qapi-schema/args-alternate.err
b/tests/qapi-schema/args-alternate.err
new file mode 100644
index 0000000..fc90a9e
--- /dev/null
+++ b/tests/qapi-schema/args-alternate.err
@@ -0,0 +1 @@
+tests/qapi-schema/args-alternate.json:4: 'data' for command 'oops' cannot use
alternate type 'Alt'
diff --git a/tests/qapi-schema/args-alternate.exit
b/tests/qapi-schema/args-alternate.exit
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/tests/qapi-schema/args-alternate.exit
@@ -0,0 +1 @@
+1
diff --git a/tests/qapi-schema/args-alternate.json
b/tests/qapi-schema/args-alternate.json
new file mode 100644
index 0000000..d2f9199
--- /dev/null
+++ b/tests/qapi-schema/args-alternate.json
@@ -0,0 +1,4 @@
+# we do not allow alternate arguments
+# TODO should we support this?
+{ 'alternate': 'Alt', 'data': { 'case1': 'int', 'case2': 'str' } }
+{ 'command': 'oops', 'data': 'Alt' }
diff --git a/tests/qapi-schema/args-alternate.out
b/tests/qapi-schema/args-alternate.out
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/args-union.err b/tests/qapi-schema/args-union.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/args-union.exit
b/tests/qapi-schema/args-union.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/args-union.exit
@@ -0,0 +1 @@
+0
diff --git a/tests/qapi-schema/args-union.json
b/tests/qapi-schema/args-union.json
new file mode 100644
index 0000000..db97ef6
--- /dev/null
+++ b/tests/qapi-schema/args-union.json
@@ -0,0 +1,4 @@
+# FIXME we should reject union arguments
+# TODO should we support this?
+{ 'union': 'Uni', 'data': { 'case1': 'int', 'case2': 'str' } }
+{ 'command': 'oops', 'data': 'Uni' }
diff --git a/tests/qapi-schema/args-union.out b/tests/qapi-schema/args-union.out
new file mode 100644
index 0000000..907080c
--- /dev/null
+++ b/tests/qapi-schema/args-union.out
@@ -0,0 +1,4 @@
+[OrderedDict([('union', 'Uni'), ('data', OrderedDict([('case1', 'int'),
('case2', 'str')]))]),
+ OrderedDict([('command', 'oops'), ('data', 'Uni')])]
+[{'enum_name': 'UniKind', 'enum_values': None}]
+[]
--
1.9.3
- [Qemu-devel] [PATCH RFC v2 10/47] qapi-visit: Fix two name arguments passed to visitors, (continued)
- [Qemu-devel] [PATCH RFC v2 10/47] qapi-visit: Fix two name arguments passed to visitors, Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 11/47] tests/qapi-schema: Document alternate's enum lacks visit function, Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 13/47] tests/qapi-schema: Restore test case for flat union base bug, Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 16/47] qapi-commands: Fix gen_err_check(e) for e and e != 'local_err', Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 17/47] qapi-commands: Inline gen_marshal_output_call(), Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 14/47] qapi-tests: New tests for union, alternate command arguments,
Markus Armbruster <=
[Qemu-devel] [PATCH RFC v2 25/47] qapi: Make generators work on sorted schema expressions, Markus Armbruster, 2015/07/01
[Qemu-devel] [PATCH RFC v2 15/47] qapi: Fix to reject union command arguments, Markus Armbruster, 2015/07/01