[Top][All Lists]

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

Re: [Qemu-devel] [PATCH v8 05/26] tests/qapi-schema: Convert test harnes

From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v8 05/26] tests/qapi-schema: Convert test harness to QAPISchemaVisitor
Date: Wed, 16 Sep 2015 09:27:50 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0

On 09/16/2015 05:06 AM, Markus Armbruster wrote:
> The old code prints the result of parsing (list of expression
> dictionaries), and partial results of semantic analysis (list of enum
> dictionaries, list of struct dictionaries).
> The new code prints a trace of a schema visit, i.e. what the back-ends
> are going to use.  Built-in and array types are omitted, because
> they're boring.
> Signed-off-by: Markus Armbruster <address@hidden>
> ---

> +class QAPISchemaTestVisitor(QAPISchemaVisitor):
> +    def visit_enum_type(self, name, info, values, prefix):
> +        print 'enum %s %s prefix=%s' % (name, values, prefix)
> +
> +    def visit_object_type(self, name, info, base, members, variants):
> +        print 'object %s' % name
> +        if base:
> +            print '    base %s' % base.name

For consistency with other visitors, I might have done:

if prefix:
    print '    prefix %s' % prefix

instead of printing prefix=None for most enums.  In particular,

> +enum EnumOne ['value1', 'value2', 'value3'] prefix=None
> +object EventStructOne
> + member struct1: UserDefOne optional=False
> + member string: str optional=False
> + member enum2: EnumOne optional=True
> +object NestedEnumsOne
> + member enum1: EnumOne optional=False
> + member enum2: EnumOne optional=True
> + member enum3: EnumOne optional=False
> + member enum4: EnumOne optional=True
> +enum QEnumTwo ['value1', 'value2'] prefix=QENUM_TWO

the fact that prefix=None and prefix=QENUM_TWO doesn't offer any visual
clues on whether the string was user-supplied, means that the following
would result in ambiguous output:
 { 'enum':'Foo', 'prefix':'None', 'data':[] }

But it's not necessarily a strong enough reason for a respin.

Reviewed-by: Eric Blake <address@hidden>

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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