From patchwork Thu Aug 6 22:53:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 504946 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3CF4F1402B0 for ; Fri, 7 Aug 2015 10:06:17 +1000 (AEST) Received: from localhost ([::1]:47352 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNVAr-000811-PN for incoming@patchwork.ozlabs.org; Thu, 06 Aug 2015 20:06:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNVAZ-0007iU-2w for qemu-devel@nongnu.org; Thu, 06 Aug 2015 20:05:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNVAU-0000Cv-CJ for qemu-devel@nongnu.org; Thu, 06 Aug 2015 20:05:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44714) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNVAU-0000Cm-2A for qemu-devel@nongnu.org; Thu, 06 Aug 2015 20:05:50 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 08FBA3725B4; Fri, 7 Aug 2015 00:05:49 +0000 (UTC) Received: from [10.3.113.187] (ovpn-113-187.phx2.redhat.com [10.3.113.187]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t76MrCYU029153; Thu, 6 Aug 2015 18:53:12 -0400 To: Markus Armbruster , qemu-devel@nongnu.org References: <1438703896-12553-1-git-send-email-armbru@redhat.com> <1438703896-12553-12-git-send-email-armbru@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <55C3E553.8060208@redhat.com> 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 MIME-Version: 1.0 In-Reply-To: <1438703896-12553-12-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, berto@igalia.com, mdroth@linux.vnet.ibm.com Subject: Re: [Qemu-devel] [PATCH RFC v3 11/32] qapi-visit: Convert to QAPISchemaVisitor, fixing bugs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 > --- > 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'"): 'string1': 'd', 'string2': 'e' }"); visit_type_UserDefFlatUnion2(v, &tmp, NULL, &err); g_assert(err); 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',