From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtLua-0003jM-J7 for qemu-devel@nongnu.org; Wed, 18 Dec 2013 13:32:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VtLuT-0004sJ-3l for qemu-devel@nongnu.org; Wed, 18 Dec 2013 13:32:00 -0500 Received: from cantor2.suse.de ([195.135.220.15]:44468 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtLuS-0004sF-Tc for qemu-devel@nongnu.org; Wed, 18 Dec 2013 13:31:53 -0500 Message-ID: <52B1EA14.7050700@suse.de> Date: Wed, 18 Dec 2013 19:31:48 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1387384489-25671-1-git-send-email-stefanha@redhat.com> In-Reply-To: <1387384489-25671-1-git-send-email-stefanha@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] qdev-monitor-test: simplify using g_assert_cmpstr() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , qemu-devel@nongnu.org Cc: Markus Armbruster Am 18.12.2013 17:34, schrieb Stefan Hajnoczi: > Use g_assert_cmpstr() instead of combining g_assert() and strcmp(3). I vaguely remember that some such handy function was introduced only after the minimum GLib version we require. Did you check on that? But IIRC we already have higher requirements for qtest that for the non-check code so it might not really matter... Andreas > This simplifies the code since we no longer have to play games to > distinguish NULL from "" using "(null)". >=20 > gcc extension haters will also be happy that ?: was dropped. >=20 > Suggested-by: Markus Armbruster > Signed-off-by: Stefan Hajnoczi > --- > tests/qdev-monitor-test.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) >=20 > diff --git a/tests/qdev-monitor-test.c b/tests/qdev-monitor-test.c > index ba7f9cc..eefaab8 100644 > --- a/tests/qdev-monitor-test.c > +++ b/tests/qdev-monitor-test.c > @@ -32,8 +32,9 @@ static void test_device_add(void) > "}}"); > g_assert(response); > error =3D qdict_get_qdict(response, "error"); > - g_assert(!strcmp(qdict_get_try_str(error, "desc") ?: "", > - "Device needs media, but drive is empty")); > + g_assert_cmpstr(qdict_get_try_str(error, "desc"), > + =3D=3D, > + "Device needs media, but drive is empty"); > QDECREF(response); > =20 > /* Delete the drive */ > @@ -42,7 +43,7 @@ static void test_device_add(void) > " \"command-line\": \"drive_del drive0\"" > "}}"); > g_assert(response); > - g_assert(!strcmp(qdict_get_try_str(response, "return") ?: "(null)"= , "")); > + g_assert_cmpstr(qdict_get_try_str(response, "return"), =3D=3D, "")= ; > QDECREF(response); > =20 > /* Try to re-add the drive. This fails with duplicate IDs if a le= aked > @@ -53,8 +54,7 @@ static void test_device_add(void) > " \"command-line\": \"drive_add pci-addr=3Dauto i= f=3Dnone,id=3Ddrive0\"" > "}}"); > g_assert(response); > - g_assert(!strcmp(qdict_get_try_str(response, "return") ?: "", > - "OK\r\n")); > + g_assert_cmpstr(qdict_get_try_str(response, "return"), =3D=3D, "OK= \r\n"); > QDECREF(response); > =20 > qtest_end(); >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg