[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 13/28] qapi: Add some expr tests
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v5 13/28] qapi: Add some expr tests |
Date: |
Thu, 26 Mar 2015 16:55:53 +0100 |
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
> expressions that aren't up to par. Later patches will improve
> the expected results as the generator is made stricter. Only
> one of the added tests actually behaves sanely at rejecting
> obvious problems.
>
> Note that in some cases, we reject bad QAPI merely because our
> pseudo-JSON parser does not yet know how to parse numbers. This
> series does not address that, but when a later series adds support
> for numeric defaults of integer fields, the testsuite will ensure
> that we don't lose the error (and hopefully that the error
> message quality is improved).
>
> Signed-off-by: Eric Blake <address@hidden>
[...]
> new file mode 100644
> index 0000000..e69de29
> diff --git a/tests/qapi-schema/event-case.exit
> b/tests/qapi-schema/event-case.exit
> new file mode 100644
> index 0000000..573541a
> --- /dev/null
> +++ b/tests/qapi-schema/event-case.exit
> @@ -0,0 +1 @@
> +0
> diff --git a/tests/qapi-schema/event-case.json
> b/tests/qapi-schema/event-case.json
> new file mode 100644
> index 0000000..52dfc3a
> --- /dev/null
> +++ b/tests/qapi-schema/event-case.json
> @@ -0,0 +1,2 @@
> +# FIXME: we should reject an event name that is not all caps
> +{ 'event': 'oops' }
qapi-code-gen.txt documents the naming conventions:
Types, commands, and events share a common namespace. Therefore,
generally speaking, type definitions should always use CamelCase for
user-defined type names, while built-in types are lowercase. Type
definitions should not end in 'Kind', as this namespace is used for
creating implicit C enums for visiting union types. Command names,
and field names within a type, should be all lower case with words
separated by a hyphen. However, some existing older commands and
complex types use underscore; when extending such expressions,
consistency is preferred over blindly avoiding underscore. Event
names should be ALL_CAPS with words separated by underscore. The
special string '**' appears for some commands that manually perform
their own type checking rather than relying on the type-safe code
produced by the qapi code generators.
We should either enforce the conventions consistently, or not at all.
Enforcing them makes certain kinds of name clashes in generated C
impossible. If we don't enforce them, we should catch the clashes.
Since I haven't read to the end of your series, I have to ask: do you
intend to enforce them?
> diff --git a/tests/qapi-schema/event-case.out
> b/tests/qapi-schema/event-case.out
> new file mode 100644
> index 0000000..3764bc7
> --- /dev/null
> +++ b/tests/qapi-schema/event-case.out
> @@ -0,0 +1,3 @@
> +[OrderedDict([('event', 'oops')])]
> +[]
> +[]
[...]
- [Qemu-devel] [PATCH v5 04/28] qapi: Add some enum tests, (continued)
- [Qemu-devel] [PATCH v5 04/28] qapi: Add some enum tests, Eric Blake, 2015/03/24
- [Qemu-devel] [PATCH v5 07/28] qapi: Simplify tests of simple unions, Eric Blake, 2015/03/24
- [Qemu-devel] [PATCH v5 09/28] qapi: Prepare for catching more semantic parse errors, Eric Blake, 2015/03/24
- [Qemu-devel] [PATCH v5 12/28] qapi: Introduce 'alternate' to replace anonymous union, Eric Blake, 2015/03/24
- [Qemu-devel] [PATCH v5 13/28] qapi: Add some expr tests, Eric Blake, 2015/03/24
- Re: [Qemu-devel] [PATCH v5 13/28] qapi: Add some expr tests,
Markus Armbruster <=
[Qemu-devel] [PATCH v5 18/28] qapi: Unify type bypass and add tests, Eric Blake, 2015/03/24
[Qemu-devel] [PATCH v5 11/28] qapi: Rename anonymous union type in test, Eric Blake, 2015/03/24