From nobody Tue Apr 30 11:50:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543514524801700.8759669888301; Thu, 29 Nov 2018 10:02:04 -0800 (PST) Received: from localhost ([::1]:55641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSQdO-00021a-8I for importer@patchew.org; Thu, 29 Nov 2018 13:01:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSQcQ-0001fd-Mp for qemu-devel@nongnu.org; Thu, 29 Nov 2018 13:00:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSQcP-0006lh-NX for qemu-devel@nongnu.org; Thu, 29 Nov 2018 13:00:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57029) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gSQcP-0006l9-G2 for qemu-devel@nongnu.org; Thu, 29 Nov 2018 13:00:53 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C9D6531408E7 for ; Thu, 29 Nov 2018 18:00:52 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC90B105B1E8; Thu, 29 Nov 2018 18:00:51 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 29 Nov 2018 19:00:50 +0100 Message-Id: <20181129180050.17797-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 29 Nov 2018 18:00:52 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2] glib-compat: work around g_test_message bug with subprocess tests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Subprocesses are created by glib without leaving the file descriptors open. Therefore, g_test_message (and assertion failures, but those trigger when things are going bad anyway) will think that it is writing to the log file descriptor, but while actually stomping on the QMP file descriptor or similar. This causes spurious failures, which are as nice to debug as the reader can imagine. While I have opened a pull request on GLib, this will probably take a while to propagate to distros. I found this while working on qgraph, but the fix is generic. Signed-off-by: Paolo Bonzini Message-Id: <1543343726-53531-1-git-send-email-pbonzini@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini --- include/glib-compat.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/glib-compat.h b/include/glib-compat.h index fdf95a255d..f675c7328f 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -113,4 +113,12 @@ gint g_poll_fixed(GPollFD *fds, guint nfds, gint timeo= ut); =20 #pragma GCC diagnostic pop =20 +/* See https://gitlab.gnome.org/GNOME/glib/merge_requests/501 */ +#define g_test_message(...) \ + do { \ + if (!g_test_subprocess()) { \ + g_test_message(__VA_ARGS__); \ + } \ + } while (0) + #endif --=20 2.19.1