From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 11CCDC433FE for ; Thu, 10 Mar 2022 11:19:08 +0000 (UTC) Received: from localhost ([::1]:38832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSGp1-0000f1-7R for qemu-devel@archiver.kernel.org; Thu, 10 Mar 2022 06:19:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGhg-0001YJ-Po for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:11:34 -0500 Received: from [2a00:1450:4864:20::32c] (port=33462 helo=mail-wm1-x32c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGhe-0005Ce-Ia for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:11:31 -0500 Received: by mail-wm1-x32c.google.com with SMTP id n33-20020a05600c3ba100b003832caf7f3aso4222977wms.0 for ; Thu, 10 Mar 2022 03:11:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GIV82CZNgnanzRJPRn5lCyHiATcM90EI6CwYUt6MnP0=; b=mM7G8Cx038zDVMSONoZx9rEBmn4jM5/eDilfHYWA8ehlUF251UU9pDcBFVNLKzmqnU P/q3QOIm19U/6g3OGSqbHOpdmLRdZ8iJBo8ZmrbtJq4Gkz8IZSEnFYj+ylw+lxkBjrKV 5/1C24ifY0nhnWxpKMuCZidTX26tALH6hhS1CeO+Ol+Q2H96pwSrmwZ54qMVOqutG+Pv tjjjVqSaki5yypZb2pn7ZFLgI1gvMEqNssPMUhBz3YpnhAtS1zV0taqQS6c0Ld1HyCdr pghkxrNijxfQ45p65G3VlJQImgpTNn08EIKRrxn722LRjEbbkPEkyM8TDEDOng2Pk8sN KBvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GIV82CZNgnanzRJPRn5lCyHiATcM90EI6CwYUt6MnP0=; b=ehDUAoNG5dwpk0OxyKr5lLsmTamr+2vEsVgNF6FQbB1zs4UGvw/PNPzS7ui92ETWtV NCjqJcQjk8iu/FnJQTmYDXm54jfRPPIyPcL1uUM1rljodwYqli5TCFXWk9X5BZ+jCXt8 XxcZViXRSsz1UpqDeeWjhfshixIVMlnQODa+mQMIN98bu7g6HLbKPLUZPsaXgrvdmxQ0 OKwQHfq/SbXdjV6As7wSGetw86zM+6x+OJt32uEQqNJU5DWL5Mw+ns+Yp76Zk2pSfVOL YThrG5uOn8wEolJsAfemGkyPJmfUjqO6+ougPDAjImuZSfuOex4i/QZqFpsr60lq27RX PzoA== X-Gm-Message-State: AOAM532QRRZVDvDK7LMZDcYNetVW/abP8BduDpse1lrohNQKc1GGCDST 0TIED9TbhR5rv01GNIK7jMiBXiA2jYPAx1zNViOhd3rqKBCNMg== X-Google-Smtp-Source: ABdhPJwjXxMf2oDwSPXtbepb4nmmzrIGT4aidNXi6Y6/+O3YOwbNspyQYQBrU9mICPkgCn9zIh5Q8H9M4sf+4i7N1A0= X-Received: by 2002:a7b:c7c3:0:b0:389:cbf1:fadf with SMTP id z3-20020a7bc7c3000000b00389cbf1fadfmr8426206wmk.147.1646910680869; Thu, 10 Mar 2022 03:11:20 -0800 (PST) MIME-Version: 1.0 References: <20220302174932.2692378-1-berrange@redhat.com> <20220302174932.2692378-5-berrange@redhat.com> <57b8b146-a197-2f46-bf56-6ab80122e9bd@redhat.com> In-Reply-To: From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Date: Thu, 10 Mar 2022 15:11:08 +0400 Message-ID: Subject: Re: [PATCH 04/18] tests: print newline after QMP response in qtest logs To: =?UTF-8?Q?Daniel_P=2E_Berrang=C3=A9?= Content-Type: multipart/alternative; boundary="0000000000001c322a05d9db46e2" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32c (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=marcandre.lureau@gmail.com; helo=mail-wm1-x32c.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Juan Quintela , "Dr. David Alan Gilbert" , Peter Xu , QEMU , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --0000000000001c322a05d9db46e2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi On Thu, Mar 10, 2022 at 2:56 PM Daniel P. Berrang=C3=A9 wrote: > On Mon, Mar 07, 2022 at 11:09:37AM +0100, Thomas Huth wrote: > > On 07/03/2022 11.06, Daniel P. Berrang=C3=A9 wrote: > > > On Mon, Mar 07, 2022 at 02:51:23PM +0800, Peter Xu wrote: > > > > On Wed, Mar 02, 2022 at 05:49:18PM +0000, Daniel P. Berrang=C3=A9 w= rote: > > > > > The QMP commands have a trailing newline, but the response does > not. > > > > > This makes the qtest logs hard to follow as the next QMP command > > > > > appears in the same line as the previous QMP response. > > > > > > > > > > Signed-off-by: Daniel P. Berrang=C3=A9 > > > > > --- > > > > > tests/qtest/libqtest.c | 3 +++ > > > > > 1 file changed, 3 insertions(+) > > > > > > > > > > diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c > > > > > index a85f8a6d05..79c3edcf4b 100644 > > > > > --- a/tests/qtest/libqtest.c > > > > > +++ b/tests/qtest/libqtest.c > > > > > @@ -629,6 +629,9 @@ QDict *qmp_fd_receive(int fd) > > > > > } > > > > > json_message_parser_feed(&qmp.parser, &c, 1); > > > > > } > > > > > + if (log) { > > > > > + g_assert(write(2, "\n", 1) =3D=3D 1); > > > > > + } > > > > > > > > Drop the g_assert() to remove side effect of G_DISABLE_ASSERT? > > > > > > You need to check the return value of write() otherwise you'll get a > > > compile failure due to a warn_unused_result attribute annotation. > > > > > > I don't think G_DISABLE_ASSERT is a problem as we're not defining > > > that in our code. > > > > You could use g_assert_true() - that's not affected by G_DISABLE_ASSERT= . > > I don't think we need to do that, per existing common practice: > > $ git grep '\bg_assert(' | wc -l > 2912 > > $ git grep '\bg_assert(' tests | wc -l > 2296 > > On the topic of assert() usage, it would be nice to state clearly when to assert() or g_assert(). g_assert() behaviour is claimed to be more consistent than assert() across platforms. Also -DNDEBUG is less obvious than -DG_DISABLE_CHECKS or -DG_DISABLE_ASSERT= . I would remove assert.h and prevent from using it back, but I might be missing some reasons to still use it. --=20 Marc-Andr=C3=A9 Lureau --0000000000001c322a05d9db46e2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

On Thu, Mar 10, 2022 at 2:56 PM Dan= iel P. Berrang=C3=A9 <berrange@re= dhat.com> wrote:
On Mon, Mar 07, 2022 at 11:09:37AM +0100, Thomas Huth wrote:
> On 07/03/2022 11.06, Daniel P. Berrang=C3=A9 wrote:
> > On Mon, Mar 07, 2022 at 02:51:23PM +0800, Peter Xu wrote:
> > > On Wed, Mar 02, 2022 at 05:49:18PM +0000, Daniel P. Berrang= =C3=A9 wrote:
> > > > The QMP commands have a trailing newline, but the respo= nse does not.
> > > > This makes the qtest logs hard to follow as the next QM= P command
> > > > appears in the same line as the previous QMP response.<= br> > > > >
> > > > Signed-off-by: Daniel P. Berrang=C3=A9 <berrange@redhat.com> > > > > ---
> > > >=C2=A0 =C2=A0tests/qtest/libqtest.c | 3 +++
> > > >=C2=A0 =C2=A01 file changed, 3 insertions(+)
> > > >
> > > > diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqt= est.c
> > > > index a85f8a6d05..79c3edcf4b 100644
> > > > --- a/tests/qtest/libqtest.c
> > > > +++ b/tests/qtest/libqtest.c
> > > > @@ -629,6 +629,9 @@ QDict *qmp_fd_receive(int fd)
> > > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> > > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0json_message_pa= rser_feed(&qmp.parser, &c, 1);
> > > >=C2=A0 =C2=A0 =C2=A0 =C2=A0}
> > > > +=C2=A0 =C2=A0 if (log) {
> > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 g_assert(write(2, "\n= ", 1) =3D=3D 1);
> > > > +=C2=A0 =C2=A0 }
> > >
> > > Drop the g_assert() to remove side effect of G_DISABLE_ASSER= T?
> >
> > You need to check the return value of write() otherwise you'l= l get a
> > compile failure due to a warn_unused_result attribute annotation.=
> >
> > I don't think G_DISABLE_ASSERT is a problem as we're not = defining
> > that in our code.
>
> You could use g_assert_true() - that's not affected by G_DISABLE_A= SSERT.

I don't think we need to do that, per existing common practice:

$ git grep '\bg_assert('=C2=A0 | wc -l
2912

$ git grep '\bg_assert(' tests | wc -l
2296


On the topic of assert() usage, it w= ould be nice to state clearly when to assert() or g_assert().
g_assert() behaviour is claimed to be more consistent than asse= rt() across platforms.

Also -DNDEBUG is less obvio= us than -DG_DISABLE_CHECKS or -DG_DISABLE_ASSERT.

= I would remove assert.h and prevent from using it back, but I might be miss= ing some reasons to still use it.

--
Marc-Andr=C3=A9 Lureau
--0000000000001c322a05d9db46e2--