Eric Blake <ebl...@redhat.com> writes: > 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 <ebl...@redhat.com> [...] > 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')])}] > +[]
For tests demonstrating incorrect behavior, a comment describing the expected behavior is always welcome.