From nobody Mon Apr 29 04:05:14 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1490963865853709.396671322386; Fri, 31 Mar 2017 05:37:45 -0700 (PDT) Received: from localhost ([::1]:40867 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctvoF-00017L-FH for importer@patchew.org; Fri, 31 Mar 2017 08:37:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctvnS-0000ky-8A for qemu-devel@nongnu.org; Fri, 31 Mar 2017 08:36:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctvnR-0002aQ-C6 for qemu-devel@nongnu.org; Fri, 31 Mar 2017 08:36:54 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:48999) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ctvnR-0002Wh-5h for qemu-devel@nongnu.org; Fri, 31 Mar 2017 08:36:53 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1ctvnG-00047C-Kn; Fri, 31 Mar 2017 13:36:43 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 31 Mar 2017 13:36:41 +0100 Message-Id: <1490963801-27870-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH] tests/libqtest.c: Delete possible stale unix sockets 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: , Cc: Markus Armbruster , patches@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Occasionally if a test crashes or is interrupted by the user at the wrong moment it could leave behind a stale UNIX socket in /tmp/. This will then cause a subsequent test run to fail spuriously with tests/libqtest.c:70:init_socket: assertion failed (ret !=3D -1): (-1 !=3D = -1) if it happens to reuse the same PID. Defend against this by deleting any stray stale socket before trying to open the new ones for this test. Signed-off-by: Peter Maydell Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- This seems like an easy way to shut up this infrequent but irritating error case... tests/libqtest.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/libqtest.c b/tests/libqtest.c index a5c3d2b..99b1195 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -167,6 +167,14 @@ QTestState *qtest_init_without_qmp_handshake(const cha= r *extra_args) socket_path =3D g_strdup_printf("/tmp/qtest-%d.sock", getpid()); qmp_socket_path =3D g_strdup_printf("/tmp/qtest-%d.qmp", getpid()); =20 + /* It's possible that if an earlier test run crashed it might + * have left a stale unix socket lying around. Delete any + * stale old socket to avoid spurious test failures with + * tests/libqtest.c:70:init_socket: assertion failed (ret !=3D -1): (-= 1 !=3D -1) + */ + unlink(socket_path); + unlink(qmp_socket_path); + sock =3D init_socket(socket_path); qmpsock =3D init_socket(qmp_socket_path); =20 --=20 2.7.4