From nobody Tue Feb 10 23:59:03 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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1667222451; cv=none; d=zohomail.com; s=zohoarc; b=GsiM/+NupIDOXMPPXoegPEdPgqXHnWnJvSxfQOI0i1Do+xkAfxLlVueu/alqGWvBTKIrqPKmcerhYIvksGM786aBVnLyOnxYvZ6CafmfOBxd4CQgYWK2zeoIydRhp0TPFSxzawFtN2jhveHWHWeELlOTCJ8/74CaQ7+MgMK//LU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667222451; 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=38CIqeK6tAYrMp96yOEjbU4GfBGml0abO/Zm0V1JKyw=; b=QYZBykFf7phsCwT9smZsG2CJxSQgzQxQhycv6FfJxqD2LoBClmURzIBV3WMO/M1BcQFaLOnCfjPJdruugmQZ9POSVSHWjgqJZyaNFZVPyKUapSW4ppn5ZUWgWnTJDsN8yU+g8CN9iItfKDBJ8WbqVWl0KrufGzqHMnd36biCi9k= 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+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 SMTPS id 166722245116931.001630350983532; Mon, 31 Oct 2022 06:20:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opUiZ-0005Mj-8g; Mon, 31 Oct 2022 09:20:43 -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 1opUi1-0003JZ-Hx for qemu-devel@nongnu.org; Mon, 31 Oct 2022 09:20:09 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1opUhr-0005S7-JQ for qemu-devel@nongnu.org; Mon, 31 Oct 2022 09:20:09 -0400 Received: by mail-wr1-x435.google.com with SMTP id k8so15976332wrh.1 for ; Mon, 31 Oct 2022 06:19:58 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id p11-20020a05600c468b00b003cf75213bb9sm1771353wmo.8.2022.10.31.06.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 06:19:54 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C95731FFD3; Mon, 31 Oct 2022 13:10:13 +0000 (GMT) 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=38CIqeK6tAYrMp96yOEjbU4GfBGml0abO/Zm0V1JKyw=; b=i3yUo005Q9AZdYSkRkt2ilYEugHuZPjzLyaP5L7wRCcGJMGQAdXeOt9Ez63H84afO7 YM6EsEdDMQT+DRLUf6U1ZfLdio1lSup5bsmR07mDrJqQotJkyco+lW74ApGBsKFsG/Sh kko3fRWWK1wn6LdE4aTgupilZiJfQej7MEKbIdCQ4fyR6X4dps2TBFZhQNSo62YSJhfJ GeUdM64cY/5/UrO3/nGzbdZWZ/F58o51wJb/L/zjZMnaDCrBd1c0kmx/MCBMrChnb4E9 LiUfsCPPD97UMm3F632IYAUbLQEKwdmqf9y5J3C1N0/b+rvH5rwHCHaIuD/dFfPmr6PD +dlA== 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=38CIqeK6tAYrMp96yOEjbU4GfBGml0abO/Zm0V1JKyw=; b=GsizgXpPH0HSFi5ZkmUSNnZSrnSSpGaRCz97N/nquCrimtzJrHFkCeLArCrb9FlVAN 3SJghHJm9twLKg5R1p9u/y73Uapz6xDuvAgvjOMQC/ppwFcsicJLGCQB6wLDCfmQoJMD cXliBBrAPaH0DtpSLdyrqbDdxGrNqXUPz10M1VeVjLSrozQ1yM+04v/WZEZKAfVlxZPR 54cmR7rHpE5aOo8DEkNRZZ4SuNMXpkQP+i+ESs4aihzzmCNhTUF0ctbZhO7lr/TXNjTx wO6I7ljJygMirt7W1xerOPv/oEs6RfpcZffAGsbrue6xHq0ssL/lrITcmFXdxIrikIJs WJ4w== X-Gm-Message-State: ACrzQf0rnGq2+3EUWu8bHx40Bv7wg5E5F08e7FBXJISDPLXGfbceqSvB R6y4VK3JqOQz+ZBV1tFdfR2WJg== X-Google-Smtp-Source: AMsMyM5voTHwV/+/EG3q6DmdXP3gBshoyh2heZe9VM87Q+88kFUUIKDX/t4PPrjqErITbPs3Y3fP4g== X-Received: by 2002:a5d:588f:0:b0:231:c661:5cee with SMTP id n15-20020a5d588f000000b00231c6615ceemr8386955wrf.18.1667222397585; Mon, 31 Oct 2022 06:19:57 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Juan Quintela Subject: [PULL 30/31] tests/unit: cleanups for test-io-channel-command Date: Mon, 31 Oct 2022 13:10:09 +0000 Message-Id: <20221031131010.682984-31-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221031131010.682984-1-alex.bennee@linaro.org> References: <20221031131010.682984-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1667222453292100003 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 Reviewed-by: Daniel P. Berrang=C3=A9 Cc: Thomas Huth Cc: Marc-Andr=C3=A9 Lureau Cc: Juan Quintela Message-Id: <20221027183637.2772968-30-alex.bennee@linaro.org> diff --git a/tests/unit/test-io-channel-command.c b/tests/unit/test-io-chan= nel-command.c index 7eee939c07..43e29c8cfb 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 **) srca= rgv, 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 **) dsta= rgv, 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