[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 09/19] qapi: Add tests of redefined expressions
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v4 09/19] qapi: Add tests of redefined expressions |
Date: |
Fri, 19 Sep 2014 16:24:54 -0600 |
Demonstrate that the qapi generator doesn't deal very well with
redefined expressions. At the parse level, they are silently
accepted; I'm not sure what would happen if we tried to go
further and use it in generated code, but the end result can't
be good. A later patch will tighten things up and adjust the
testsuite to match.
Signed-off-by: Eric Blake <address@hidden>
---
tests/Makefile | 3 ++-
tests/qapi-schema/redefined-builtin.err | 0
tests/qapi-schema/redefined-builtin.exit | 1 +
tests/qapi-schema/redefined-builtin.json | 2 ++
tests/qapi-schema/redefined-builtin.out | 3 +++
tests/qapi-schema/redefined-command.err | 0
tests/qapi-schema/redefined-command.exit | 1 +
tests/qapi-schema/redefined-command.json | 3 +++
tests/qapi-schema/redefined-command.out | 4 ++++
tests/qapi-schema/redefined-event.err | 0
tests/qapi-schema/redefined-event.exit | 1 +
tests/qapi-schema/redefined-event.json | 3 +++
tests/qapi-schema/redefined-event.out | 4 ++++
tests/qapi-schema/redefined-type.err | 0
tests/qapi-schema/redefined-type.exit | 1 +
tests/qapi-schema/redefined-type.json | 3 +++
tests/qapi-schema/redefined-type.out | 4 ++++
17 files changed, 32 insertions(+), 1 deletion(-)
create mode 100644 tests/qapi-schema/redefined-builtin.err
create mode 100644 tests/qapi-schema/redefined-builtin.exit
create mode 100644 tests/qapi-schema/redefined-builtin.json
create mode 100644 tests/qapi-schema/redefined-builtin.out
create mode 100644 tests/qapi-schema/redefined-command.err
create mode 100644 tests/qapi-schema/redefined-command.exit
create mode 100644 tests/qapi-schema/redefined-command.json
create mode 100644 tests/qapi-schema/redefined-command.out
create mode 100644 tests/qapi-schema/redefined-event.err
create mode 100644 tests/qapi-schema/redefined-event.exit
create mode 100644 tests/qapi-schema/redefined-event.json
create mode 100644 tests/qapi-schema/redefined-event.out
create mode 100644 tests/qapi-schema/redefined-type.err
create mode 100644 tests/qapi-schema/redefined-type.exit
create mode 100644 tests/qapi-schema/redefined-type.json
create mode 100644 tests/qapi-schema/redefined-type.out
diff --git a/tests/Makefile b/tests/Makefile
index 753f7bd..201e006 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -200,7 +200,8 @@ check-qapi-schema-y := $(addprefix tests/qapi-schema/, \
enum-clash-member.json enum-max-member.json \
funny-char.json indented-expr.json missing-type.json \
double-type.json bad-type-int.json bad-type-dict.json \
- double-data.json unknown-expr-key.json \
+ double-data.json unknown-expr-key.json redefined-type.json \
+ redefined-command.json redefined-builtin.json redefined-event.json \
missing-colon.json missing-comma-list.json \
missing-comma-object.json non-objects.json \
qapi-schema-test.json quoted-structural-chars.json \
diff --git a/tests/qapi-schema/redefined-builtin.err
b/tests/qapi-schema/redefined-builtin.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/redefined-builtin.exit
b/tests/qapi-schema/redefined-builtin.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/redefined-builtin.exit
@@ -0,0 +1 @@
+0
diff --git a/tests/qapi-schema/redefined-builtin.json
b/tests/qapi-schema/redefined-builtin.json
new file mode 100644
index 0000000..a10050d
--- /dev/null
+++ b/tests/qapi-schema/redefined-builtin.json
@@ -0,0 +1,2 @@
+# FIXME: we should reject types that duplicate builtin names
+{ 'type': 'size', 'data': { 'myint': 'size' } }
diff --git a/tests/qapi-schema/redefined-builtin.out
b/tests/qapi-schema/redefined-builtin.out
new file mode 100644
index 0000000..b0a9aea
--- /dev/null
+++ b/tests/qapi-schema/redefined-builtin.out
@@ -0,0 +1,3 @@
+[OrderedDict([('type', 'size'), ('data', OrderedDict([('myint', 'size')]))])]
+[]
+[OrderedDict([('type', 'size'), ('data', OrderedDict([('myint', 'size')]))])]
diff --git a/tests/qapi-schema/redefined-command.err
b/tests/qapi-schema/redefined-command.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/redefined-command.exit
b/tests/qapi-schema/redefined-command.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/redefined-command.exit
@@ -0,0 +1 @@
+0
diff --git a/tests/qapi-schema/redefined-command.json
b/tests/qapi-schema/redefined-command.json
new file mode 100644
index 0000000..d8c9975
--- /dev/null
+++ b/tests/qapi-schema/redefined-command.json
@@ -0,0 +1,3 @@
+# FIXME: we should reject commands defined more than once
+{ 'command': 'foo', 'data': { 'one': 'str' } }
+{ 'command': 'foo', 'data': { '*two': 'str' } }
diff --git a/tests/qapi-schema/redefined-command.out
b/tests/qapi-schema/redefined-command.out
new file mode 100644
index 0000000..44ddba6
--- /dev/null
+++ b/tests/qapi-schema/redefined-command.out
@@ -0,0 +1,4 @@
+[OrderedDict([('command', 'foo'), ('data', OrderedDict([('one', 'str')]))]),
+ OrderedDict([('command', 'foo'), ('data', OrderedDict([('*two', 'str')]))])]
+[]
+[]
diff --git a/tests/qapi-schema/redefined-event.err
b/tests/qapi-schema/redefined-event.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/redefined-event.exit
b/tests/qapi-schema/redefined-event.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/redefined-event.exit
@@ -0,0 +1 @@
+0
diff --git a/tests/qapi-schema/redefined-event.json
b/tests/qapi-schema/redefined-event.json
new file mode 100644
index 0000000..152cce7
--- /dev/null
+++ b/tests/qapi-schema/redefined-event.json
@@ -0,0 +1,3 @@
+# FIXME: we should reject duplicate events
+{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } }
+{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } }
diff --git a/tests/qapi-schema/redefined-event.out
b/tests/qapi-schema/redefined-event.out
new file mode 100644
index 0000000..261b183
--- /dev/null
+++ b/tests/qapi-schema/redefined-event.out
@@ -0,0 +1,4 @@
+[OrderedDict([('event', 'EVENT_A'), ('data', OrderedDict([('myint',
'int')]))]),
+ OrderedDict([('event', 'EVENT_A'), ('data', OrderedDict([('myint',
'int')]))])]
+[]
+[]
diff --git a/tests/qapi-schema/redefined-type.err
b/tests/qapi-schema/redefined-type.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/redefined-type.exit
b/tests/qapi-schema/redefined-type.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/redefined-type.exit
@@ -0,0 +1 @@
+0
diff --git a/tests/qapi-schema/redefined-type.json
b/tests/qapi-schema/redefined-type.json
new file mode 100644
index 0000000..7972194
--- /dev/null
+++ b/tests/qapi-schema/redefined-type.json
@@ -0,0 +1,3 @@
+# FIXME: we should reject types defined more than once
+{ 'type': 'foo', 'data': { 'one': 'str' } }
+{ 'enum': 'foo', 'data': [ 'two' ] }
diff --git a/tests/qapi-schema/redefined-type.out
b/tests/qapi-schema/redefined-type.out
new file mode 100644
index 0000000..b509e57
--- /dev/null
+++ b/tests/qapi-schema/redefined-type.out
@@ -0,0 +1,4 @@
+[OrderedDict([('type', 'foo'), ('data', OrderedDict([('one', 'str')]))]),
+ OrderedDict([('enum', 'foo'), ('data', ['two'])])]
+[{'enum_name': 'foo', 'enum_values': ['two']}]
+[OrderedDict([('type', 'foo'), ('data', OrderedDict([('one', 'str')]))])]
--
1.9.3
- Re: [Qemu-devel] [PATCH v4 04/19] qapi: Document type-safety considerations, (continued)
- [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Eric Blake, 2014/09/19
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Markus Armbruster, 2014/09/23
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Eric Blake, 2014/09/23
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Markus Armbruster, 2014/09/24
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Kevin Wolf, 2014/09/24
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Markus Armbruster, 2014/09/24
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Markus Armbruster, 2014/09/26
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Kevin Wolf, 2014/09/26
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Markus Armbruster, 2014/09/26
[Qemu-devel] [PATCH v4 09/19] qapi: Add tests of redefined expressions,
Eric Blake <=
[Qemu-devel] [PATCH v4 11/19] qapi: Add tests of type bypass, Eric Blake, 2014/09/19
[Qemu-devel] [PATCH v4 13/19] qapi: More rigourous checking of types, Eric Blake, 2014/09/19
[Qemu-devel] [PATCH v4 07/19] qapi: Add some expr tests, Eric Blake, 2014/09/19