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
---
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 000..e69de29
diff --git a/tests/qapi-schema/enum-empty.exit
b/tests/qapi-schema/enum-empty.exit
new file mode 100644
index 000..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 000..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 000..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 000..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
+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 000..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 000..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 000..e69de29
diff --git a/tests/qapi-schema/enum-wrong-data.err
b/tests/qapi-schema/enum-wrong-data.err
new file mode 100644
index 000..e69de29
diff --git a/tests/qapi-schema/enum-wrong-data.exit
b/tests/qapi-schema/enum-wrong-data.exit
new file mode 100644
index 000..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 000..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/