[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC v3 11/32] qapi-visit: Convert to QAPISchemaV
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH RFC v3 11/32] qapi-visit: Convert to QAPISchemaVisitor, fixing bugs |
Date: |
Thu, 6 Aug 2015 16:53:07 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 |
On 08/04/2015 09:57 AM, Markus Armbruster wrote:
> Fixes flat unions to visit the base's base members (the previous
> commit merely added them to the struct). Same test case.
>
> Patch's effect on visit_type_UserDefFlatUnion():
>
> static void visit_type_UserDefFlatUnion_fields(Visitor *m,
> UserDefFlatUnion **obj, Error **errp)
> {
> Error *err = NULL;
>
> + visit_type_int(m, &(*obj)->integer, "integer", &err);
> + if (err) {
> + goto out;
> + }
> visit_type_str(m, &(*obj)->string, "string", &err);
> if (err) {
> goto out;
>
> Test cases updated for the bug fix.
Not quite right.
>
> Fixes alternates to generate a visitor for their implicit enumeration
> type. None of them are currently used, obviously. Example:
> block-core.json's BlockdevRef now generates
> visit_type_BlockdevRefKind().
>
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
> scripts/qapi-visit.py | 260
> +++++++++++++-------------------
> tests/qapi-schema/qapi-schema-test.json | 3 -
> tests/test-qmp-input-strict.c | 2 +-
> tests/test-qmp-input-visitor.c | 4 +-
> 4 files changed, 106 insertions(+), 163 deletions(-)
> +++ b/tests/test-qmp-input-strict.c
> @@ -167,9 +167,9 @@ static void test_validate_union_flat(TestInputVisitorData
> *data,
>
> v = validate_test_init(data,
> "{ 'enum1': 'value1', "
> + "'integer': 41, "
> "'string': 'str', "
> "'boolean': true }");
> - /* TODO when generator bug is fixed, add 'integer': 41 */
>
> visit_type_UserDefFlatUnion(v, &tmp, NULL, &err);
> g_assert(!err);
Incomplete fix; you need to squash this in to test that cleanup of a
partial struct is still correct (otherwise, the test sets err for the
wrong reason of "missing 'integer'" rather than the intended reason of
"missing 'enum1'"):
diff --git i/tests/test-qmp-input-strict.c w/tests/test-qmp-input-strict.c
index bfd9d04..4c18096 100644
--- i/tests/test-qmp-input-strict.c
+++ w/tests/test-qmp-input-strict.c
@@ -299,7 +299,7 @@ static void
test_validate_fail_union_flat_no_discrim(TestInputVisitorData *data,
Visitor *v;
/* test situation where discriminator field ('enum1' here) is
missing */
- v = validate_test_init(data, "{ 'string': 'c', 'string1': 'd',
'string2': 'e' }");
+ v = validate_test_init(data, "{ 'integer': 42, 'string': 'c',
'string1': 'd', 'string2': 'e' }");
visit_type_UserDefFlatUnion2(v, &tmp, NULL, &err);
g_assert(err);
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH RFC v3 18/32] qapi: Replace dirty is_c_ptr() by method c_null(), (continued)
- [Qemu-devel] [PATCH RFC v3 13/32] qapi: De-duplicate enum code generation, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH RFC v3 23/32] qapi: De-duplicate parameter list generation, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH RFC v3 21/32] qapi-commands: Rearrange code, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH RFC v3 07/32] qapi: Generate comments to simplify splitting for review, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH RFC v3 11/32] qapi-visit: Convert to QAPISchemaVisitor, fixing bugs, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH RFC v3 25/32] qapi: Improve built-in type documentation, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH RFC v3 15/32] qapi-event: Convert to QAPISchemaVisitor, fixing data with base, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH RFC v3 05/32] tests/qapi-schema: Convert test harness to QAPISchemaVisitor, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH RFC v3 28/32] qapi-schema: Fix up misleading specification of netdev_add, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH RFC v3 10/32] qapi-types: Convert to QAPISchemaVisitor, fixing flat unions, Markus Armbruster, 2015/08/04