From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WRtGa-0001LF-8z for qemu-devel@nongnu.org; Sun, 23 Mar 2014 21:01:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WRtGR-0005Ju-Pl for qemu-devel@nongnu.org; Sun, 23 Mar 2014 21:01:28 -0400 Received: from mail-ie0-x231.google.com ([2607:f8b0:4001:c03::231]:53032) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WRtGR-0005Jq-KX for qemu-devel@nongnu.org; Sun, 23 Mar 2014 21:01:19 -0400 Received: by mail-ie0-f177.google.com with SMTP id rl12so4570547iec.8 for ; Sun, 23 Mar 2014 18:01:19 -0700 (PDT) Message-ID: <532F83D4.4020700@gmail.com> Date: Mon, 24 Mar 2014 09:01:08 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1395206201-22999-1-git-send-email-wenchaoqemu@gmail.com> <1395206201-22999-5-git-send-email-wenchaoqemu@gmail.com> <532B869C.6020506@redhat.com> In-Reply-To: <532B869C.6020506@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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: Eric Blake Cc: mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com 于 2014/3/21 8:23, Eric Blake 写道: > On 03/18/2014 11:16 PM, Wenchao Xia wrote: >> These cases will verify whether the expected qdict is built. >> >> 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 >> > >> +++ 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 = (qint_get_int(qobject_to_qint(obj1)) == >> + 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 = true; >> + } else { >> + d->result = false; >> + } > Could also be written without 'if': > d->result = g_strcmp0(...) == 0; > >> + obj = qdict_get(t, "seconds"); >> + g_assert(obj&& qobject_type(obj) == QTYPE_QINT); >> + obj = qdict_get(t, "microseconds"); >> + g_assert(obj&& qobject_type(obj) == QTYPE_QINT); > Might be worth asserting that microseconds is within the range > [0,999999] (or -1 if seconds is -1) > will add those test.