diff mbox

[v2,07/14] qapi: add some type check tests

Message ID 1407278346-17427-8-git-send-email-eblake@redhat.com
State New
Headers show

Commit Message

Eric Blake Aug. 5, 2014, 10:38 p.m. UTC
Demonstrate that the qapi generator silently parses confusing
types, which may cause other errors later on. Later patches
will update the expected results as the generator is made stricter.

* tests/qapi-schema/data-array-empty.*: New files.
* tests/qapi-schema/data-array-unknown.*: Likewise.
* tests/qapi-schema/data-unknown.*: Likewise.
* tests/qapi-schema/data-int.*: Likewise.
* tests/qapi-schema/returns-unknown.*: Likewise.
* tests/qapi-schema/returns-int.*: Likewise.
* tests/qapi-schema/returns-array-bad.*: Likewise.
* tests/Makefile (check-qapi-schema-y): Run them.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/Makefile                            | 4 +++-
 tests/qapi-schema/data-array-empty.err    | 0
 tests/qapi-schema/data-array-empty.exit   | 1 +
 tests/qapi-schema/data-array-empty.json   | 1 +
 tests/qapi-schema/data-array-empty.out    | 3 +++
 tests/qapi-schema/data-array-unknown.err  | 0
 tests/qapi-schema/data-array-unknown.exit | 1 +
 tests/qapi-schema/data-array-unknown.json | 1 +
 tests/qapi-schema/data-array-unknown.out  | 3 +++
 tests/qapi-schema/data-int.err            | 0
 tests/qapi-schema/data-int.exit           | 1 +
 tests/qapi-schema/data-int.json           | 1 +
 tests/qapi-schema/data-int.out            | 3 +++
 tests/qapi-schema/data-unknown.err        | 0
 tests/qapi-schema/data-unknown.exit       | 1 +
 tests/qapi-schema/data-unknown.json       | 1 +
 tests/qapi-schema/data-unknown.out        | 3 +++
 tests/qapi-schema/returns-array-bad.err   | 0
 tests/qapi-schema/returns-array-bad.exit  | 1 +
 tests/qapi-schema/returns-array-bad.json  | 1 +
 tests/qapi-schema/returns-array-bad.out   | 3 +++
 tests/qapi-schema/returns-int.err         | 0
 tests/qapi-schema/returns-int.exit        | 1 +
 tests/qapi-schema/returns-int.json        | 1 +
 tests/qapi-schema/returns-int.out         | 3 +++
 tests/qapi-schema/returns-unknown.err     | 0
 tests/qapi-schema/returns-unknown.exit    | 1 +
 tests/qapi-schema/returns-unknown.json    | 1 +
 tests/qapi-schema/returns-unknown.out     | 3 +++
 29 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 tests/qapi-schema/data-array-empty.err
 create mode 100644 tests/qapi-schema/data-array-empty.exit
 create mode 100644 tests/qapi-schema/data-array-empty.json
 create mode 100644 tests/qapi-schema/data-array-empty.out
 create mode 100644 tests/qapi-schema/data-array-unknown.err
 create mode 100644 tests/qapi-schema/data-array-unknown.exit
 create mode 100644 tests/qapi-schema/data-array-unknown.json
 create mode 100644 tests/qapi-schema/data-array-unknown.out
 create mode 100644 tests/qapi-schema/data-int.err
 create mode 100644 tests/qapi-schema/data-int.exit
 create mode 100644 tests/qapi-schema/data-int.json
 create mode 100644 tests/qapi-schema/data-int.out
 create mode 100644 tests/qapi-schema/data-unknown.err
 create mode 100644 tests/qapi-schema/data-unknown.exit
 create mode 100644 tests/qapi-schema/data-unknown.json
 create mode 100644 tests/qapi-schema/data-unknown.out
 create mode 100644 tests/qapi-schema/returns-array-bad.err
 create mode 100644 tests/qapi-schema/returns-array-bad.exit
 create mode 100644 tests/qapi-schema/returns-array-bad.json
 create mode 100644 tests/qapi-schema/returns-array-bad.out
 create mode 100644 tests/qapi-schema/returns-int.err
 create mode 100644 tests/qapi-schema/returns-int.exit
 create mode 100644 tests/qapi-schema/returns-int.json
 create mode 100644 tests/qapi-schema/returns-int.out
 create mode 100644 tests/qapi-schema/returns-unknown.err
 create mode 100644 tests/qapi-schema/returns-unknown.exit
 create mode 100644 tests/qapi-schema/returns-unknown.json
 create mode 100644 tests/qapi-schema/returns-unknown.out
diff mbox

Patch

diff --git a/tests/Makefile b/tests/Makefile
index 1b0c96f..c36faca 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -192,7 +192,9 @@  $(foreach target,$(SYSEMU_TARGET_LIST), \
 check-qapi-schema-y := $(addprefix tests/qapi-schema/, \
 	comments.json empty.json enum-empty.json enum-missing-data.json \
 	enum-wrong-data.json funny-char.json indented-expr.json \
-	missing-type.json double-type.json \
+	missing-type.json double-type.json data-array-empty.json \
+	data-array-unknown.json data-unknown.json data-int.json \
+	returns-unknown.json returns-int.json returns-array-bad.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/data-array-empty.err b/tests/qapi-schema/data-array-empty.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/data-array-empty.exit b/tests/qapi-schema/data-array-empty.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/data-array-empty.exit
@@ -0,0 +1 @@ 
+0
diff --git a/tests/qapi-schema/data-array-empty.json b/tests/qapi-schema/data-array-empty.json
new file mode 100644
index 0000000..00352ac
--- /dev/null
+++ b/tests/qapi-schema/data-array-empty.json
@@ -0,0 +1 @@ 
+{ 'command': 'oops', 'data': [ ] }
diff --git a/tests/qapi-schema/data-array-empty.out b/tests/qapi-schema/data-array-empty.out
new file mode 100644
index 0000000..67802be
--- /dev/null
+++ b/tests/qapi-schema/data-array-empty.out
@@ -0,0 +1,3 @@ 
+[OrderedDict([('command', 'oops'), ('data', [])])]
+[]
+[]
diff --git a/tests/qapi-schema/data-array-unknown.err b/tests/qapi-schema/data-array-unknown.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/data-array-unknown.exit b/tests/qapi-schema/data-array-unknown.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/data-array-unknown.exit
@@ -0,0 +1 @@ 
+0
diff --git a/tests/qapi-schema/data-array-unknown.json b/tests/qapi-schema/data-array-unknown.json
new file mode 100644
index 0000000..03ef321
--- /dev/null
+++ b/tests/qapi-schema/data-array-unknown.json
@@ -0,0 +1 @@ 
+{ 'command': 'oops', 'data': [ 'NoSuchType' ] }
diff --git a/tests/qapi-schema/data-array-unknown.out b/tests/qapi-schema/data-array-unknown.out
new file mode 100644
index 0000000..c3bc05e
--- /dev/null
+++ b/tests/qapi-schema/data-array-unknown.out
@@ -0,0 +1,3 @@ 
+[OrderedDict([('command', 'oops'), ('data', ['NoSuchType'])])]
+[]
+[]
diff --git a/tests/qapi-schema/data-int.err b/tests/qapi-schema/data-int.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/data-int.exit b/tests/qapi-schema/data-int.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/data-int.exit
@@ -0,0 +1 @@ 
+0
diff --git a/tests/qapi-schema/data-int.json b/tests/qapi-schema/data-int.json
new file mode 100644
index 0000000..926c75e
--- /dev/null
+++ b/tests/qapi-schema/data-int.json
@@ -0,0 +1 @@ 
+{ 'command': 'oops', 'data': 'int' }
diff --git a/tests/qapi-schema/data-int.out b/tests/qapi-schema/data-int.out
new file mode 100644
index 0000000..e589a4f
--- /dev/null
+++ b/tests/qapi-schema/data-int.out
@@ -0,0 +1,3 @@ 
+[OrderedDict([('command', 'oops'), ('data', 'int')])]
+[]
+[]
diff --git a/tests/qapi-schema/data-unknown.err b/tests/qapi-schema/data-unknown.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/data-unknown.exit b/tests/qapi-schema/data-unknown.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/data-unknown.exit
@@ -0,0 +1 @@ 
+0
diff --git a/tests/qapi-schema/data-unknown.json b/tests/qapi-schema/data-unknown.json
new file mode 100644
index 0000000..4415584
--- /dev/null
+++ b/tests/qapi-schema/data-unknown.json
@@ -0,0 +1 @@ 
+{ 'command': 'oops', 'data': 'NoSuchType' }
diff --git a/tests/qapi-schema/data-unknown.out b/tests/qapi-schema/data-unknown.out
new file mode 100644
index 0000000..2c60726
--- /dev/null
+++ b/tests/qapi-schema/data-unknown.out
@@ -0,0 +1,3 @@ 
+[OrderedDict([('command', 'oops'), ('data', 'NoSuchType')])]
+[]
+[]
diff --git a/tests/qapi-schema/returns-array-bad.err b/tests/qapi-schema/returns-array-bad.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/returns-array-bad.exit b/tests/qapi-schema/returns-array-bad.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/returns-array-bad.exit
@@ -0,0 +1 @@ 
+0
diff --git a/tests/qapi-schema/returns-array-bad.json b/tests/qapi-schema/returns-array-bad.json
new file mode 100644
index 0000000..76bf6df
--- /dev/null
+++ b/tests/qapi-schema/returns-array-bad.json
@@ -0,0 +1 @@ 
+{ 'command': 'oops', 'data': [ 'str', 'str' ] }
diff --git a/tests/qapi-schema/returns-array-bad.out b/tests/qapi-schema/returns-array-bad.out
new file mode 100644
index 0000000..cfc474e
--- /dev/null
+++ b/tests/qapi-schema/returns-array-bad.out
@@ -0,0 +1,3 @@ 
+[OrderedDict([('command', 'oops'), ('data', ['str', 'str'])])]
+[]
+[]
diff --git a/tests/qapi-schema/returns-int.err b/tests/qapi-schema/returns-int.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/returns-int.exit b/tests/qapi-schema/returns-int.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/returns-int.exit
@@ -0,0 +1 @@ 
+0
diff --git a/tests/qapi-schema/returns-int.json b/tests/qapi-schema/returns-int.json
new file mode 100644
index 0000000..0884968
--- /dev/null
+++ b/tests/qapi-schema/returns-int.json
@@ -0,0 +1 @@ 
+{ 'command': 'okay', 'returns': 'int' }
diff --git a/tests/qapi-schema/returns-int.out b/tests/qapi-schema/returns-int.out
new file mode 100644
index 0000000..36b00a9
--- /dev/null
+++ b/tests/qapi-schema/returns-int.out
@@ -0,0 +1,3 @@ 
+[OrderedDict([('command', 'okay'), ('returns', 'int')])]
+[]
+[]
diff --git a/tests/qapi-schema/returns-unknown.err b/tests/qapi-schema/returns-unknown.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/returns-unknown.exit b/tests/qapi-schema/returns-unknown.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/returns-unknown.exit
@@ -0,0 +1 @@ 
+0
diff --git a/tests/qapi-schema/returns-unknown.json b/tests/qapi-schema/returns-unknown.json
new file mode 100644
index 0000000..508df3e
--- /dev/null
+++ b/tests/qapi-schema/returns-unknown.json
@@ -0,0 +1 @@ 
+{ 'command': 'oops', 'returns': 'NoSuchType' }
diff --git a/tests/qapi-schema/returns-unknown.out b/tests/qapi-schema/returns-unknown.out
new file mode 100644
index 0000000..a482c83
--- /dev/null
+++ b/tests/qapi-schema/returns-unknown.out
@@ -0,0 +1,3 @@ 
+[OrderedDict([('command', 'oops'), ('returns', 'NoSuchType')])]
+[]
+[]