From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wmut3-0002Ir-Sy for qemu-devel@nongnu.org; Tue, 20 May 2014 21:00:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wmusu-0003Oj-RY for qemu-devel@nongnu.org; Tue, 20 May 2014 21:00:05 -0400 Received: from e36.co.us.ibm.com ([32.97.110.154]:40637) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wmusu-0003MW-Is for qemu-devel@nongnu.org; Tue, 20 May 2014 20:59:56 -0400 Received: from /spool/local by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 20 May 2014 18:59:55 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id CE7AB1FF0028 for ; Tue, 20 May 2014 18:59:52 -0600 (MDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by b03cxnp08025.gho.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s4L0wiQ510551786 for ; Wed, 21 May 2014 02:59:53 +0200 Received: from d03av03.boulder.ibm.com (localhost [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s4L0K9Ee003931 for ; Tue, 20 May 2014 18:20:09 -0600 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <1400598479-27118-1-git-send-email-marcel.a@redhat.com> References: <1400598479-27118-1-git-send-email-marcel.a@redhat.com> Message-ID: <20140521001949.2719.32258@loki> Date: Tue, 20 May 2014 19:19:49 -0500 Subject: Re: [Qemu-devel] [PATCH] tests: check empty qmp output visitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcel Apfelbaum , qemu-devel@nongnu.org Cc: akong@redhat.com, armbru@redhat.com, afaerber@suse.de, lcapitulino@redhat.com Quoting Marcel Apfelbaum (2014-05-20 10:07:59) > Checks the output visitor behaviour for NULL values. > = > Signed-off-by: Marcel Apfelbaum > --- > Notes: > - I didn't add Michael's Sob because I tweaked the test a little. Tweaked it so it didn't crash 100% of the time even after your fix? :) Another approach, since the expected behavior now is for qmp_output_get_qobject() to return NULL in this case, is to just assert(arg =3D=3D NULL) and drop the qdict/QDECREF completely. > - To be added on top of "qapi: output visitor crashes qemu if it encoun= ters a NULL value", > otherwise the test will fail. > = > tests/test-qmp-output-visitor.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > = > diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visi= tor.c > index 9c15458..de1bf83 100644 > --- a/tests/test-qmp-output-visitor.c > +++ b/tests/test-qmp-output-visitor.c > @@ -507,6 +507,19 @@ static void test_visitor_out_union_anon(TestOutputVi= sitorData *data, > qapi_free_UserDefAnonUnion(tmp); > } > = > +static void test_visitor_out_empty(TestOutputVisitorData *data, > + const void *unused) > +{ > + QObject *arg; > + QDict *qdict; > + > + arg =3D qmp_output_get_qobject(data->qov); > + if (arg) { > + qdict =3D qobject_to_qdict(arg); > + QDECREF(qdict); > + } > +} > + > static void init_native_list(UserDefNativeListUnion *cvalue) > { > int i; > @@ -859,6 +872,8 @@ int main(int argc, char **argv) > &out_visitor_data, test_visitor_out_union_fl= at); > output_visitor_test_add("/visitor/output/union-anon", > &out_visitor_data, test_visitor_out_union_an= on); > + output_visitor_test_add("/visitor/output/empty", > + &out_visitor_data, test_visitor_out_empty); > output_visitor_test_add("/visitor/output/native_list/int", > &out_visitor_data, test_visitor_out_native_l= ist_int); > output_visitor_test_add("/visitor/output/native_list/int8", > -- = > 1.8.3.1