From patchwork Tue Jan 24 18:00:56 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: 646032 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp339366pvb; Tue, 24 Jan 2023 10:04:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXsYPUCfNFx3b82h3tB8BNEJWBt4zKeeCkCRi9nl9DtlnP4tV0l3mTeQQIQVnGEEELHUCIWL X-Received: by 2002:a05:622a:40c4:b0:3b6:94a3:b0e7 with SMTP id ch4-20020a05622a40c400b003b694a3b0e7mr32078081qtb.34.1674583475802; Tue, 24 Jan 2023 10:04:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674583475; cv=none; d=google.com; s=arc-20160816; b=w6KWOufOCAUtwXnXpJGI3zLsJ6BLcGOxjpVNZRnSFzFe0Gcyl9ZY36IIZwhUi9Lczl NM79wg48tXmNIghgUywF2e25ciMoAeTGKL0tiPHOqIRuZFf4X49dXsmSnFs0umbj+oQ8 mRKQ4YVi0G2LN+7SDs4iOslkhJq7hlZFKcaeisfrjrz0nsgYy/2uzuhHArEv1Rtka1v/ Pq1fjp7N+zXiMJLj357TVgcGcVNtNUneMC/itQDGVXFO6v/Ae/c82Dozt3lktZDyhRRn dW0cP88AZpLhpZugXyMxDP5/28QXoHPPF1hwSLAhmd2v2aL1yFn1hszuYrjB2ir1fBH7 mo/A== 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=TiUYUMEdHeKvAYgG93JWPs0c1Z36rOO+tDqIFqok7gF9iVvuZOCR6ZEnpuKe7ow/Iv ggGHoHPU5CZEvoAlYWgmqfEpMD74hCz3EU2g2Sfh1rsL/ys6QBqXy5SOktPvezD51d/m rUFrONGGMzMVQXAWHoLnBR0nsy/FgoQMXpBtl24hyj5ChUB1iO0M68mOYpVXtdVCaKQm DQaQY6x1a1ReKU65/vVXNHSjfKyzZop8ABQ/GdT2udgyQszPyffvPMpXbgZaLdH0yLmx Tev9yZ4Q86U+Eswmo5E6Pmhe6Bh43igihV9aIFkbVZn2uJyKiketsq+icVWAaLUarZN5 rwnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FfNqOfyl; 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 fc17-20020a05622a489100b003b3ba458741si2050251qtb.22.2023.01.24.10.04.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Jan 2023 10:04:35 -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=FfNqOfyl; 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 1pKNcD-0001Xf-A8; Tue, 24 Jan 2023 13:01:49 -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 1pKNc6-0001VA-MC for qemu-devel@nongnu.org; Tue, 24 Jan 2023 13:01:44 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKNbz-000650-OJ for qemu-devel@nongnu.org; Tue, 24 Jan 2023 13:01:42 -0500 Received: by mail-wm1-x32a.google.com with SMTP id o17-20020a05600c511100b003db021ef437so11569732wms.4 for ; Tue, 24 Jan 2023 10:01:33 -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=FfNqOfylbecedL6P2quvOgNTEbF3H47cS2dJouZ9we1yqAYQ60+78qaoJ3sKx1dbrY UVRAe8rPl69KyY2r0dBMgqdpK10SvYxgQX+hPnecwtM8v1mIyKOXQOZpqN1kmVagmPrC gAoODBv30WQogmKvTTd7eC+xA+GJWiz4uWa67Es+vrAn20YOfpdtLM0YUYPk+6gb/Lke HbyixTXVKXHIobUmpjMEQDdEoyZlHIDZmGCB980NYABGcdFeIHCzsvb9HYDHcqJ2yedP /OddJqhx3VCZf5lHfGZU+079B9OS1xJfWxlYMQ7oxCiqBg6I4CiY+6vGyMbZ7Nsn6l1y elcQ== 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=7LyK+NwZH/zpFmdZbZvt2MT3UQr8KJqlazPmG8QE4kmt1FSrmw5TGN9dI9xwjzxahL g1FMiUYQqHwD9OofQvHJG08ULpjTRUf4o2RdymTFEVhSJbZqVbN5bx+nn7SD0Nr6a0xy mzIWRo9D75IATKoxsyb7yreft80LZsiS2ZdlQlxl1NYyWdPjUz8CKMXVuzENl8QMQlhl SqmFEI54q4I7EWNhhkHE3kDP59ran5rL4wd1jrte00CDZNBgIh5CxwDlC0lXbBxDHptX Rs29+LyRhxn7qpebQQhEnTpFpH+PrVWQHWSP5hzhTu0i7q4HQHDt7EDXGT6PzGBZi/z4 enVQ== X-Gm-Message-State: AFqh2krOyD7hC38unBS7PTygv+978AeOUzWoBixJDU8kl7kv3wqDAm6f 9seYNkvibHnkgb35/oMf3ukhJA== X-Received: by 2002:a05:600c:2152:b0:3d9:ecae:853f with SMTP id v18-20020a05600c215200b003d9ecae853fmr29055591wml.3.1674583291908; Tue, 24 Jan 2023 10:01:31 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id s35-20020a05600c31a300b003db0dbbea53sm2490011wmp.30.2023.01.24.10.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 10:01:29 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 067FB1FFBC; Tue, 24 Jan 2023 18:01:28 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Ed Maste , Thomas Huth , Alexandre Iooss , Markus Armbruster , Jagannathan Raman , John G Johnson , Mahmoud Mandour , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , Bandan Das , Elena Ufimtseva , Michael Roth , Eduardo Habkost , Beraldo Leal , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Qiuhao Li , Stefan Hajnoczi , Alexander Bulekov , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , John Snow , Paolo Bonzini , Darren Kenny , qemu-arm@nongnu.org, Yanan Wang , Cleber Rosa , Wainer dos Santos Moschetta , Marcel Apfelbaum , Li-Wen Hsu , Peter Maydell Subject: [PATCH v2 04/35] tests/unit: drop hacky race avoidance in test-io-channel-command Date: Tue, 24 Jan 2023 18:00:56 +0000 Message-Id: <20230124180127.1881110-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124180127.1881110-1-alex.bennee@linaro.org> References: <20230124180127.1881110-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.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",