From nobody Wed Feb 11 02:08:30 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666896850; cv=none; d=zohomail.com; s=zohoarc; b=Na0aYVze0SUIW0HqzAS+kkclE6DmFO6KTAqN4/08obuhiS/pWu+sFsm7TYFgzAPTgwqQT+6ZFBIVVUNwc+q6m1pfS9/KApbNPyev/jhQeloskQTRODvo7yrlSrvz335Takto3Ht/R2HKSC6eZRIucp8A02NIigMSq3p+kyOXjfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666896850; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sHYyMytvaRwCrcUxnHHFfEwhoSYAHml8PTkMZH1b3Uw=; b=mFRK5yEZLeeJVuwdG/7+MZU5hc2MY/Ed/DO1A8Gf9ZtQQ5E/6TEIhuP+XcPz64zM73uAHmeeuH+lGWzDPnfy3954lWQgPRW8Nkl9ScxV2BCmhTa5rlxCDSLNE1JvlmG3T5fvMLGDKxRkfOhQVmwaESF6/lX6+PCZN4C9gsJHEE0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTP id 1666896850660897.2440318078446; Thu, 27 Oct 2022 11:54:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oo7tF-0005ki-Cj; Thu, 27 Oct 2022 14:46:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oo7sC-0005SR-8m for qemu-devel@nongnu.org; Thu, 27 Oct 2022 14:45:03 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oo7s6-0004jT-U0 for qemu-devel@nongnu.org; Thu, 27 Oct 2022 14:44:59 -0400 Received: by mail-wr1-x42d.google.com with SMTP id bs21so3717074wrb.4 for ; Thu, 27 Oct 2022 11:44:54 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id e8-20020adffd08000000b0022e653f5abbsm1770173wrr.69.2022.10.27.11.44.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 11:44:51 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 10C031FFBC; Thu, 27 Oct 2022 19:36:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sHYyMytvaRwCrcUxnHHFfEwhoSYAHml8PTkMZH1b3Uw=; b=i7CMzyk2Q/F/37Y8xk/nuncJNSx1vG9hbjqjaNU7I6xAjqq8xZAyG2rzAF7QhOYz31 fQk5uEXt6kZMwFWxZzFoatSA1PMhpBhN4q95vOLpoK96TtkLalZ9C41xJcEa8FbKz1IA gtrxP9h5VSFTAgOvm8B5sEd4HpKHE+qzqn2xNyAj41f1xNhmDvCvDwzOI8W9FmvXwVUU rkbDGrT8zvmGG+Awx9tSLw/TJcy516G7DqQOZrww0PkoGRPxr+nFwuufE1cQxbt478wn 1WMUyn6hpAHAP/cUC+LJSSAkWs/bkddk0to6SNhYjSAmoA0arjGr/FGQtj8F5taeFRm4 NQKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sHYyMytvaRwCrcUxnHHFfEwhoSYAHml8PTkMZH1b3Uw=; b=KxQEoZPVusoKhHsSCuOBbIBaa+znjSaqZiby3CTHYYYBodKXkxqFX2l0CDLgv7vwkH IMhJte2ivIqpB1/P3kqsIwQOYdsLchvUEXB0p+ADRCUGp3qMQ0sLRqLp73MUxARTFG0k ivtKTSJq9JjePmRDS8jVTzmj5h2fu4hfELwyImy8sYCtYEXjK56R7emMTxj2bhfDe6r3 BpzdHIGf6G7zMqDRgv1PtrHbnljeWVDZeorG6p6jzOtp9Y13QlB0ID9/uUkf3xyJCvZh SE2rmdT520sHUci8QPVSaTpMh3TQo0NxHijwuGuMejwAKPfKgQ9HscbA2vcLX1WsaVdH x5Sw== X-Gm-Message-State: ACrzQf20edvv4w5tk1Wiookdz/i5mx0ArfFpCtNG9NkBZvdlJtS1hVAF ua6zGtn714Gwd4mT4hxfhjIE3Q== X-Google-Smtp-Source: AMsMyM5g6ltUHGXGv/KzENSfsis9g8fRv/Ewo70qyVogM9Fzq+FSoMxEfJqhZ/MFj6FxSbnkaEdW4g== X-Received: by 2002:a05:6000:144f:b0:231:2053:ef7c with SMTP id v15-20020a056000144f00b002312053ef7cmr32995992wrx.179.1666896293358; Thu, 27 Oct 2022 11:44:53 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: fam@euphon.net, berrange@redhat.com, f4bug@amsat.org, aurelien@aurel32.net, pbonzini@redhat.com, stefanha@redhat.com, crosa@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Juan Quintela Subject: [PATCH v4 29/30] tests/unit: cleanups for test-io-channel-command Date: Thu, 27 Oct 2022 19:36:35 +0100 Message-Id: <20221027183637.2772968-30-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027183637.2772968-1-alex.bennee@linaro.org> References: <20221027183637.2772968-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666896852089100003 This test is hanging under heavy load when the two socats race while trying to create the socket. I've tried various approaches to avoid the race but it seems "creat=3D0" won't stop socat trying to create a pipe if it executes first. In the end I just use a small sleep which seems to be reliable enough on the load situations I've tried. While I was there I also properly created a tmpdir for the socket to live in which is cleaned up at the end of the test. Signed-off-by: Alex Benn=C3=A9e Cc: Thomas Huth Cc: Daniel P. Berrang=C3=A9 Cc: Marc-Andr=C3=A9 Lureau Cc: Juan Quintela --- tests/unit/test-io-channel-command.c | 45 +++++++++++++++++----------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/tests/unit/test-io-channel-command.c b/tests/unit/test-io-chan= nel-command.c index 7eee939c07..54bb0f139a 100644 --- a/tests/unit/test-io-channel-command.c +++ b/tests/unit/test-io-channel-command.c @@ -19,6 +19,7 @@ */ =20 #include "qemu/osdep.h" +#include #include "io/channel-command.h" #include "io-channel-helpers.h" #include "qapi/error.h" @@ -26,32 +27,32 @@ =20 #define TEST_FIFO "test-io-channel-command.fifo" =20 -#define SOCAT_SRC "PIPE:" TEST_FIFO ",wronly" -#define SOCAT_DST "PIPE:" TEST_FIFO ",rdonly" - static char *socat =3D NULL; =20 static void test_io_channel_command_fifo(bool async) { + g_autofree gchar *tmpdir =3D g_dir_make_tmp("qemu-test-io-channel.XXXX= XX", NULL); + g_autofree gchar *fifo =3D g_strdup_printf("%s/%s", tmpdir, TEST_FIFO); + g_autoptr(GString) srcargs =3D g_string_new(socat); + g_autoptr(GString) dstargs =3D g_string_new(socat); + g_auto(GStrv) srcargv; + g_auto(GStrv) dstargv; QIOChannel *src, *dst; QIOChannelTest *test; - const char *srcargv[] =3D { - socat, "-", SOCAT_SRC, NULL, - }; - const char *dstargv[] =3D { - socat, SOCAT_DST, "-", NULL, - }; =20 - if (!socat) { - g_test_skip("socat is not found in PATH"); - return; - } + g_string_append_printf(srcargs, " - PIPE:%s,wronly", fifo); + g_string_append_printf(dstargs, " PIPE:%s,rdonly -", fifo); + + srcargv =3D g_strsplit(srcargs->str, " ", -1); + dstargv =3D g_strsplit(dstargs->str, " ", -1); =20 - unlink(TEST_FIFO); - src =3D QIO_CHANNEL(qio_channel_command_new_spawn(srcargv, + src =3D QIO_CHANNEL(qio_channel_command_new_spawn((const char**) srcar= gv, O_WRONLY, &error_abort)); - dst =3D QIO_CHANNEL(qio_channel_command_new_spawn(dstargv, + /* try to avoid a race to create the socket */ + g_usleep(1000); + + dst =3D QIO_CHANNEL(qio_channel_command_new_spawn((const char**) dstar= gv, O_RDONLY, &error_abort)); =20 @@ -62,17 +63,27 @@ static void test_io_channel_command_fifo(bool async) object_unref(OBJECT(src)); object_unref(OBJECT(dst)); =20 - unlink(TEST_FIFO); + g_rmdir(tmpdir); } =20 =20 static void test_io_channel_command_fifo_async(void) { + if (!socat) { + g_test_skip("socat is not found in PATH"); + return; + } + test_io_channel_command_fifo(true); } =20 static void test_io_channel_command_fifo_sync(void) { + if (!socat) { + g_test_skip("socat is not found in PATH"); + return; + } + test_io_channel_command_fifo(false); } =20 --=20 2.34.1