From patchwork Mon Oct 5 22:45:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 526566 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 AA9F514090A for ; Tue, 6 Oct 2015 09:45:54 +1100 (AEDT) Received: from localhost ([::1]:48052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjEW0-000107-Ox for incoming@patchwork.ozlabs.org; Mon, 05 Oct 2015 18:45:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjEVW-0000ed-T2 for qemu-devel@nongnu.org; Mon, 05 Oct 2015 18:45:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjEVT-0006c0-JM for qemu-devel@nongnu.org; Mon, 05 Oct 2015 18:45:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45910) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjEVT-0006ac-CL for qemu-devel@nongnu.org; Mon, 05 Oct 2015 18:45:19 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id DED33C0A1471; Mon, 5 Oct 2015 22:45:18 +0000 (UTC) Received: from [10.3.113.202] (ovpn-113-202.phx2.redhat.com [10.3.113.202]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t95MjIR6013622; Mon, 5 Oct 2015 18:45:18 -0400 To: qemu-devel@nongnu.org References: <1443565276-4535-1-git-send-email-eblake@redhat.com> <1443565276-4535-9-git-send-email-eblake@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: <5612FD74.5000403@redhat.com> Date: Mon, 5 Oct 2015 16:45:08 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1443565276-4535-9-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: marcandre.lureau@redhat.com, Michael Roth , ehabkost@redhat.com, armbru@redhat.com Subject: Re: [Qemu-devel] [PATCH v7 08/18] qapi: Test use of 'number' within alternates 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 09/29/2015 04:21 PM, Eric Blake wrote: > Add some testsuite exposure for use of a 'number' as part of > an alternate. The current state of the tree has a few bugs > exposed by this: our input parser depends on the ordering of > how the qapi schema declared the alternate, and the parser > does not accept integers for a 'number' in an alternate even > though it does for numbers outside of an alternate. > > Mixing 'int' and 'number' in the same alternate is unusual, > since both are supplied by json-numbers, but there does not > seem to be a technical reason to forbid it given that our > json lexer distinguishes between json-numbers that can be > represented as an int vs. those that cannot. > > Improve the existing test_visitor_in_alternate() to match the > style of the new test_visitor_in_alternate_number(), and to > ensure full coverage of all possible qtype parsing. > > Signed-off-by: Eric Blake > > --- > +static void test_visitor_in_alternate_number(TestInputVisitorData *data, > + const void *unused) > +{ > + Visitor *v; > + Error *err = NULL; > + AltStrBool *asb; > + AltStrNum *asn; > + AltNumStr *ans; > + AltStrInt *asi; > + AltIntNum *ain; > + AltNumInt *ani; > + > + /* Parsing an int */ > + > + v = visitor_input_test_init(data, "42"); > + visit_type_AltStrBool(v, &asb, NULL, &err); > + g_assert(err); > + qapi_free_AltStrBool(asb); > + visitor_input_teardown(data, NULL); This fails to reset err = NULL... > + > + /* FIXME: Order of alternate should not affect semantics; asn should > + * parse the same as ans */ > + v = visitor_input_test_init(data, "42"); > + visit_type_AltStrNum(v, &asn, NULL, &err); > + /* FIXME g_assert_cmpint(asn->kind, == ALT_STR_NUM_KIND_N); */ > + /* FIXME g_assert_cmpfloat(asn->n, ==, 42); */ > + g_assert(err); > + error_free(err); > + err = NULL; ...which means that this test is not reliable. Do you need a v8, or can you squash this in? v = visitor_input_test_init(data, "42"); diff --git a/tests/test-qmp-input-visitor.c b/tests/test-qmp-input-visitor.c index 1b5a369..6104ac6 100644 --- a/tests/test-qmp-input-visitor.c +++ b/tests/test-qmp-input-visitor.c @@ -395,6 +395,8 @@ static void test_visitor_in_alternate_number(TestInputVisitorData *data, v = visitor_input_test_init(data, "42"); visit_type_AltStrBool(v, &asb, NULL, &err); g_assert(err); + error_free(err); + err = NULL; qapi_free_AltStrBool(asb);