From patchwork Thu Jan 19 18:04:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 644105 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp359824pvb; Thu, 19 Jan 2023 10:06:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXsdyhulFjA0o4INzood8DIv7MS65Z1Tbm1C7OK4VT8J/s7TTJkR1C32/jkZYAm0YQHbvMqd X-Received: by 2002:a25:6b0f:0:b0:7fc:c919:a7d3 with SMTP id g15-20020a256b0f000000b007fcc919a7d3mr1748948ybc.54.1674151575140; Thu, 19 Jan 2023 10:06:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674151575; cv=none; d=google.com; s=arc-20160816; b=pWMAuvMD9s202D6B9xGFE0NWAQJ4Z3sJK5skXYBcgfL/Uw68Y9tKug5iEFxwNbNIQ9 4cEhlakgwW5ittvL+S6UhWXA3hlQv/7eUZumkf/bXqTs64zVYzAeofjs8k5+7maxMC0C EcM/RsRMA3XHQrdjagpWcgjxvGYhRqIawExPjVksPK7n7dp+cYgxtJmoUsZXbi1XQl2j F45Itl5auzYiv4Ttv+g8MSEC++BWezF3wYQHeHXdPxjuBSxNcig60LI/eRkOFFE44ZPA iK+kYZQNlvK47RwYe2XAqfPAel5aVwlSPPW54U2j957PDoXabFxZUIWCtcP/gmGynunC Y7fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3kS477a0I3Bux/zzw2KohjX48YjyxZLcbfkqW1wVgq8=; b=gDYqQqYuyivfCpYRL/LkZd77Iv2ALWpKdQ1Z3AYJba+YXmNs+C0qeVYEYqt+jOFFVm a1xd3iCaoFQrOzGSGAhejigibuGu+MTcpYFxTbo6dK+tEuo8LKuWSJHFKePjj81/t6d6 BGv4VPXKfem9ZncScP9LWlrJQA0Za/Fb4aPh82yrlGqIg4Pl1Mk97J43L/myg/DroxYd xxRNo9y5EXsUH4w4fukMlyK/Q7qvAzg0U+92oPFR2zlIylW5X1PPvLGxpjjqP0umdf28 NmglCsS7rR2qVGLnSCE+GgtjdMgqJVLmWeFgmGuvnO8AtabpYWWkyL/FbrmAloTS/paK aCDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fZizxt6C; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m6-20020a05620a24c600b006eebf6f2e6asi3674501qkn.409.2023.01.19.10.06.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Jan 2023 10:06:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fZizxt6C; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pIZHC-0003LW-KG; Thu, 19 Jan 2023 13:04:38 -0500 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 1pIZH3-0003I9-63 for qemu-devel@nongnu.org; Thu, 19 Jan 2023 13:04:29 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pIZH0-00011B-5g for qemu-devel@nongnu.org; Thu, 19 Jan 2023 13:04:28 -0500 Received: by mail-wm1-x333.google.com with SMTP id l41-20020a05600c1d2900b003daf986faaeso1875993wms.3 for ; Thu, 19 Jan 2023 10:04:23 -0800 (PST) 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=3kS477a0I3Bux/zzw2KohjX48YjyxZLcbfkqW1wVgq8=; b=fZizxt6CyzpdQICKNpdkTlblcKoio9LQiXlcr7D6r4myQoQJzivacN+7PUypKIXVNy zQxjd5+/PfVI6gH5+qqzTMgY8oJ9CV/rUiMzO/OU3TvdGXy/AWCxRUsuxgDw32dGcjqc g2EHxRBZ4i1pSA9RCluw4/Jwg3L9fjwQkpxBPKP8NZ5e9fkDm44PDFMzSiQbxRCvjLFc E5Uxy9SnvZLKaL0So/m5DFpw0Oc8VOyVYthyKkEcwMLN0IwTtudgV4wBKYuD/IofWoPa fi4d4288SOcWb5kiDJ1xfLXTwnfeCrfaS9mTGd/5HeOJly77pnElkg5UcRmOalqlfTMZ iXkA== 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=3kS477a0I3Bux/zzw2KohjX48YjyxZLcbfkqW1wVgq8=; b=4FugteZq1lcrjvJ65yV/I6FY856SMsn+BnluyjLf7/ok1FCxb571Mi1cWQjvCn+9lI jjXb8ZJ4dDMsshk6VRukWDlm53FqdGd7hKq0CefbMk1ogwvI1MFZt/IrlnD/47c10Gt8 JCrUjEh9LquYPsmOGZiUHsgu4SWyNzyHUgXK9SeLfnJHqCgPoQnfrGm0+uqjtPTNa+Me Fs9ikOSflt6EGZyzCLBX8kouvwOaNMk2ksusvw8/pqEbO/yRyh8KdT0shehLrIjipkyd 0NqTmoQnPXlJbT67kdPKl4x2drdHvLOXweXKF6fMT/Gpp/1R9enYMzbMkEeeC5Ztpb/Z yybw== X-Gm-Message-State: AFqh2kotrW+tuoTJUFslx/2qi049JV5JZyt97qg/gHU4mcdGkjNmc9ng 47F7f1kvzbG8t0XCJ0fQbGp62g== X-Received: by 2002:a05:600c:3488:b0:3d2:370b:97f4 with SMTP id a8-20020a05600c348800b003d2370b97f4mr19769221wmq.16.1674151462430; Thu, 19 Jan 2023 10:04:22 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id s4-20020a05600c384400b003d9862ec435sm5474973wmr.20.2023.01.19.10.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 10:04:20 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D5E681FFBC; Thu, 19 Jan 2023 18:04:19 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Beraldo Leal , Peter Maydell , Bandan Das , Qiuhao Li , =?utf-8?q?D?= =?utf-8?q?aniel_P=2E_Berrang=C3=A9?= , Michael Roth , Cleber Rosa , Alexander Bulekov , Darren Kenny , Stefan Hajnoczi , Markus Armbruster , John Snow , Ed Maste , Wainer dos Santos Moschetta , =?utf-8?q?Philippe_Mathi?= =?utf-8?q?eu-Daud=C3=A9?= , Paolo Bonzini , Li-Wen Hsu , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth Subject: [PATCH 04/18] tests/unit: drop hacky race avoidance in test-io-channel-command Date: Thu, 19 Jan 2023 18:04:05 +0000 Message-Id: <20230119180419.30304-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119180419.30304-1-alex.bennee@linaro.org> References: <20230119180419.30304-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We don't need to play timing games to ensure one socat wins over the other, just create the fifo they both can use before spawning the processes. However in the process we need to disable two tests for Windows platforms as we don't have an abstraction for mkfifo(). Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1403 Signed-off-by: Alex Bennée Reviewed-by: Thomas Huth --- tests/unit/test-io-channel-command.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/unit/test-io-channel-command.c b/tests/unit/test-io-channel-command.c index 19f72eab96..425e2f5594 100644 --- a/tests/unit/test-io-channel-command.c +++ b/tests/unit/test-io-channel-command.c @@ -20,6 +20,8 @@ #include "qemu/osdep.h" #include +#include +#include #include "io/channel-command.h" #include "io-channel-helpers.h" #include "qapi/error.h" @@ -29,6 +31,7 @@ static char *socat = NULL; +#ifndef _WIN32 static void test_io_channel_command_fifo(bool async) { g_autofree gchar *tmpdir = g_dir_make_tmp("qemu-test-io-channel.XXXXXX", NULL); @@ -40,12 +43,13 @@ static void test_io_channel_command_fifo(bool async) QIOChannel *src, *dst; QIOChannelTest *test; + if (mkfifo(fifo, 0600)) { + g_error("mkfifo: %s", strerror(errno)); + } + src = QIO_CHANNEL(qio_channel_command_new_spawn((const char **) srcargv, O_WRONLY, &error_abort)); - /* try to avoid a race to create the socket */ - g_usleep(1000); - dst = QIO_CHANNEL(qio_channel_command_new_spawn((const char **) dstargv, O_RDONLY, &error_abort)); @@ -60,7 +64,6 @@ static void test_io_channel_command_fifo(bool async) g_rmdir(tmpdir); } - static void test_io_channel_command_fifo_async(void) { if (!socat) { @@ -80,6 +83,7 @@ static void test_io_channel_command_fifo_sync(void) test_io_channel_command_fifo(false); } +#endif static void test_io_channel_command_echo(bool async) @@ -124,10 +128,12 @@ int main(int argc, char **argv) socat = g_find_program_in_path("socat"); +#ifndef _WIN32 g_test_add_func("/io/channel/command/fifo/sync", test_io_channel_command_fifo_sync); g_test_add_func("/io/channel/command/fifo/async", test_io_channel_command_fifo_async); +#endif g_test_add_func("/io/channel/command/echo/sync", test_io_channel_command_echo_sync); g_test_add_func("/io/channel/command/echo/async",