diff options
| author | Eric Blake <eblake@redhat.com> | 2015-05-04 09:05:04 -0600 |
|---|---|---|
| committer | Markus Armbruster <armbru@redhat.com> | 2015-05-05 18:39:00 +0200 |
| commit | cf3935907b5df16f667d54ad6761c7e937dcf425 (patch) | |
| tree | ac11b4cc953cc0d7a605eb589e13128f15cf5803 /tests/qapi-schema/enum-missing-data.err | |
| parent | ad11dbb93752ffd4bd1d5f31da7e2d9c40a68e8a (diff) | |
| download | focaccia-qemu-cf3935907b5df16f667d54ad6761c7e937dcf425.tar.gz focaccia-qemu-cf3935907b5df16f667d54ad6761c7e937dcf425.zip | |
qapi: Better error messages for bad enums
The previous commit demonstrated that the generator had several flaws with less-than-perfect enums: - an enum that listed the same string twice (or two variant strings that map to the same C enumerator) ended up generating an invalid C enum - because the generator adds a _MAX terminator to each enum, the use of an enum member 'max' can also cause this clash - if an enum omits 'data', the generator left a python stack trace rather than a graceful message - an enum that used a non-array 'data' was silently accepted by the parser - an enum that used non-string members in the 'data' member was silently accepted by the parser Add check_enum to cover these situations, and update testcases to match. While valid .json files won't trigger any of these cases, we might as well be nicer to developers that make a typo while trying to add new QAPI code. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'tests/qapi-schema/enum-missing-data.err')
| -rw-r--r-- | tests/qapi-schema/enum-missing-data.err | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/tests/qapi-schema/enum-missing-data.err b/tests/qapi-schema/enum-missing-data.err index 814ab2613d..b8ccae071b 100644 --- a/tests/qapi-schema/enum-missing-data.err +++ b/tests/qapi-schema/enum-missing-data.err @@ -1,6 +1 @@ -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 334, in parse_schema - add_enum(expr['enum'], expr['data']) -KeyError: 'data' +tests/qapi-schema/enum-missing-data.json:2: Enum 'MyEnum' requires an array for 'data' |