From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQnFn-0005Hv-Ea for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:24:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQnFi-0002Tr-Hq for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:24:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46888) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQnFi-0002Ti-A3 for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:24:02 -0400 Message-ID: <532B869C.6020506@redhat.com> Date: Thu, 20 Mar 2014 18:23:56 -0600 From: Eric Blake MIME-Version: 1.0 References: <1395206201-22999-1-git-send-email-wenchaoqemu@gmail.com> <1395206201-22999-5-git-send-email-wenchaoqemu@gmail.com> In-Reply-To: <1395206201-22999-5-git-send-email-wenchaoqemu@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="eGDFmq4liBMF61hJWHM64iHkVrgwHGQvf" Subject: Re: [Qemu-devel] [RFC PATCH V3 4/5] test: add test cases for qapi event List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia , qemu-devel@nongnu.org Cc: mdroth@linux.vnet.ibm.com, armbru@redhat.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --eGDFmq4liBMF61hJWHM64iHkVrgwHGQvf Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 03/18/2014 11:16 PM, Wenchao Xia wrote: > These cases will verify whether the expected qdict is built. >=20 > Signed-off-by: Wenchao Xia > --- > tests/Makefile | 14 ++- > tests/qapi-schema/qapi-schema-test.json | 12 ++ > tests/qapi-schema/qapi-schema-test.out | 10 +- > tests/test-qmp-event.c | 258 +++++++++++++++++++++++= ++++++++ > 4 files changed, 289 insertions(+), 5 deletions(-) > create mode 100644 tests/test-qmp-event.c >=20 > +++ b/tests/test-qmp-event.c > @@ -0,0 +1,258 @@ > +/* > + * qapi event unit-tests. > + * > + * Authors: > + * Wenchao Xia > + * > + * This work is licensed under the terms of the GNU LGPL, version 2.1 = or later. > + * See the COPYING.LIB file in the top-level directory. > + * Missing "Copyright" > + case QTYPE_QINT: > + d->result =3D (qint_get_int(qobject_to_qint(obj1)) =3D=3D > + qint_get_int(qobject_to_qint(obj2))); > + return; > + case QTYPE_QSTRING: > + if (!g_strcmp0(qstring_get_str(qobject_to_qstring(obj1)), > + qstring_get_str(qobject_to_qstring(obj2)))) { > + d->result =3D true; > + } else { > + d->result =3D false; > + } Could also be written without 'if': d->result =3D g_strcmp0(...) =3D=3D 0; > + obj =3D qdict_get(t, "seconds"); > + g_assert(obj && qobject_type(obj) =3D=3D QTYPE_QINT); > + obj =3D qdict_get(t, "microseconds"); > + g_assert(obj && qobject_type(obj) =3D=3D QTYPE_QINT); Might be worth asserting that microseconds is within the range [0,999999] (or -1 if seconds is -1) --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --eGDFmq4liBMF61hJWHM64iHkVrgwHGQvf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTK4acAAoJEKeha0olJ0NqunMH/227jbXXL/w4O44+D5e2VUbU 2jtZoHUAf4h+cNq36MpQFvzIcTMMyc9rIeYnWuO4NTkm/zFb7S7u2d/YZ30hJaQF HElwR3P6DP4xmRLChHa3SXTpMO5/Z5FAGmjXN4Wa1Ir/UaqS4tK6rIJ0u4JGPzIF zT+9NCvBFBiHHkzbAHP2sQ6P/vMWAEeiB9MTUQZSvhAgYCVf8ov8f0lqZeLvuxJ8 gBYpHg1+QAtDCXYoKmem7c89E7F57rW+L9F9zGgpkgKJljG4X/mZ7j+gw43HB4tJ 4TnKlyV0EtCiomTRkjmrLWvt1d2X2QxR1JYmBFVHfcv+zqAcNZVtJ6F0PDREQfQ= =S1bv -----END PGP SIGNATURE----- --eGDFmq4liBMF61hJWHM64iHkVrgwHGQvf--