[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 03/14] qapi: add some enum tests
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v2 03/14] qapi: add some enum tests |
Date: |
Tue, 5 Aug 2014 16:38:55 -0600 |
Demonstrate that the qapi generator doesn't deal well with enums
that aren't up to par. Later patches will update the expected
results as the generator is made stricter.
* tests/qapi-schema/enum-empty.*: New files.
* tests/qapi-schema/enum-missing-data.*: Likewise.
* tests/qapi-schema/enum-wrong-data.*: Likewise.
* tests/Makefile (check-qapi-schema-y): Run them.
Signed-off-by: Eric Blake <address@hidden>
---
tests/Makefile | 3 ++-
tests/qapi-schema/enum-empty.err | 0
tests/qapi-schema/enum-empty.exit | 1 +
tests/qapi-schema/enum-empty.json | 1 +
tests/qapi-schema/enum-empty.out | 3 +++
tests/qapi-schema/enum-missing-data.err | 6 ++++++
tests/qapi-schema/enum-missing-data.exit | 1 +
tests/qapi-schema/enum-missing-data.json | 1 +
tests/qapi-schema/enum-missing-data.out | 0
tests/qapi-schema/enum-wrong-data.err | 0
tests/qapi-schema/enum-wrong-data.exit | 1 +
tests/qapi-schema/enum-wrong-data.json | 1 +
tests/qapi-schema/enum-wrong-data.out | 3 +++
13 files changed, 20 insertions(+), 1 deletion(-)
create mode 100644 tests/qapi-schema/enum-empty.err
create mode 100644 tests/qapi-schema/enum-empty.exit
create mode 100644 tests/qapi-schema/enum-empty.json
create mode 100644 tests/qapi-schema/enum-empty.out
create mode 100644 tests/qapi-schema/enum-missing-data.err
create mode 100644 tests/qapi-schema/enum-missing-data.exit
create mode 100644 tests/qapi-schema/enum-missing-data.json
create mode 100644 tests/qapi-schema/enum-missing-data.out
create mode 100644 tests/qapi-schema/enum-wrong-data.err
create mode 100644 tests/qapi-schema/enum-wrong-data.exit
create mode 100644 tests/qapi-schema/enum-wrong-data.json
create mode 100644 tests/qapi-schema/enum-wrong-data.out
diff --git a/tests/Makefile b/tests/Makefile
index aa17e44..fbf6909 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -190,7 +190,8 @@ $(foreach target,$(SYSEMU_TARGET_LIST), \
$(eval check-qtest-$(target)-y += tests/qom-test$(EXESUF)))
check-qapi-schema-y := $(addprefix tests/qapi-schema/, \
- comments.json empty.json funny-char.json indented-expr.json \
+ comments.json empty.json enum-empty.json enum-missing-data.json \
+ enum-wrong-data.json funny-char.json indented-expr.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/enum-empty.err b/tests/qapi-schema/enum-empty.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/enum-empty.exit
b/tests/qapi-schema/enum-empty.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/enum-empty.exit
@@ -0,0 +1 @@
+0
diff --git a/tests/qapi-schema/enum-empty.json
b/tests/qapi-schema/enum-empty.json
new file mode 100644
index 0000000..f550aa0
--- /dev/null
+++ b/tests/qapi-schema/enum-empty.json
@@ -0,0 +1 @@
+{ 'enum': 'MyEnum', 'data': [ ] }
diff --git a/tests/qapi-schema/enum-empty.out b/tests/qapi-schema/enum-empty.out
new file mode 100644
index 0000000..3b75c16
--- /dev/null
+++ b/tests/qapi-schema/enum-empty.out
@@ -0,0 +1,3 @@
+[OrderedDict([('enum', 'MyEnum'), ('data', [])])]
+[{'enum_name': 'MyEnum', 'enum_values': []}]
+[]
diff --git a/tests/qapi-schema/enum-missing-data.err
b/tests/qapi-schema/enum-missing-data.err
new file mode 100644
index 0000000..1fec213
--- /dev/null
+++ b/tests/qapi-schema/enum-missing-data.err
@@ -0,0 +1,6 @@
+Traceback (most recent call last):
+ File "tests/qapi-schema/test-qapi.py", line 19, in <module>
+ exprs = parse_schema(sys.argv[1])
+ File "scripts/qapi.py", line 339, in parse_schema
+ add_enum(expr['enum'], expr['data'])
+KeyError: 'data'
diff --git a/tests/qapi-schema/enum-missing-data.exit
b/tests/qapi-schema/enum-missing-data.exit
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/tests/qapi-schema/enum-missing-data.exit
@@ -0,0 +1 @@
+1
diff --git a/tests/qapi-schema/enum-missing-data.json
b/tests/qapi-schema/enum-missing-data.json
new file mode 100644
index 0000000..6e2acd8
--- /dev/null
+++ b/tests/qapi-schema/enum-missing-data.json
@@ -0,0 +1 @@
+{ 'enum': 'MyEnum' }
diff --git a/tests/qapi-schema/enum-missing-data.out
b/tests/qapi-schema/enum-missing-data.out
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/enum-wrong-data.err
b/tests/qapi-schema/enum-wrong-data.err
new file mode 100644
index 0000000..e69de29
diff --git a/tests/qapi-schema/enum-wrong-data.exit
b/tests/qapi-schema/enum-wrong-data.exit
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/tests/qapi-schema/enum-wrong-data.exit
@@ -0,0 +1 @@
+0
diff --git a/tests/qapi-schema/enum-wrong-data.json
b/tests/qapi-schema/enum-wrong-data.json
new file mode 100644
index 0000000..4b7e90c
--- /dev/null
+++ b/tests/qapi-schema/enum-wrong-data.json
@@ -0,0 +1 @@
+{ 'enum': 'MyEnum', 'data': { 'value': 'str' } }
diff --git a/tests/qapi-schema/enum-wrong-data.out
b/tests/qapi-schema/enum-wrong-data.out
new file mode 100644
index 0000000..28d2211
--- /dev/null
+++ b/tests/qapi-schema/enum-wrong-data.out
@@ -0,0 +1,3 @@
+[OrderedDict([('enum', 'MyEnum'), ('data', OrderedDict([('value', 'str')]))])]
+[{'enum_name': 'MyEnum', 'enum_values': OrderedDict([('value', 'str')])}]
+[]
--
1.9.3
- [Qemu-devel] [PATCH v2 00/14] drop qapi nested structs, Eric Blake, 2014/08/05
- [Qemu-devel] [PATCH v2 03/14] qapi: add some enum tests,
Eric Blake <=
- [Qemu-devel] [PATCH v2 01/14] qapi: consistent whitespace in tests/Makefile, Eric Blake, 2014/08/05
- [Qemu-devel] [PATCH v2 04/14] qapi: better error message for bad enum, Eric Blake, 2014/08/05
- [Qemu-devel] [PATCH v2 08/14] qapi: add expr_name() helper, Eric Blake, 2014/08/05
- [Qemu-devel] [PATCH v2 06/14] qapi: require valid expressions, Eric Blake, 2014/08/05
- [Qemu-devel] [PATCH v2 02/14] qapi: ignore files created during make check, Eric Blake, 2014/08/05
- [Qemu-devel] [PATCH v2 09/14] qapi: add check_type helper function, Eric Blake, 2014/08/05
- [Qemu-devel] [PATCH v2 10/14] qapi: merge UserDefTwo and UserDefNested in tests, Eric Blake, 2014/08/05
- [Qemu-devel] [PATCH v2 07/14] qapi: add some type check tests, Eric Blake, 2014/08/05