qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 03/14] qapi: add some enum tests


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v3 03/14] qapi: add some enum tests
Date: Thu, 14 Aug 2014 11:23:27 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Eric Blake <address@hidden> 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 <address@hidden>
[...]
> 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]