From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB0C6C6FA81 for ; Fri, 2 Sep 2022 07:16:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235136AbiIBHQI (ORCPT ); Fri, 2 Sep 2022 03:16:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233931AbiIBHQH (ORCPT ); Fri, 2 Sep 2022 03:16:07 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0903A52E66 for ; Fri, 2 Sep 2022 00:16:06 -0700 (PDT) Received: from localhost.localdomain (unknown [182.2.70.226]) by gnuweeb.org (Postfix) with ESMTPSA id 06D0380C52; Fri, 2 Sep 2022 07:16:01 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1662102965; bh=8CxoNLdpfZGlVSeMG07m4BkqhkERVBRYGewViV876js=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HKHIB9nGvMeZb6apL5hbyK7KrXb9vKmkKmbgF2hmXXR+uiTWMzv0SBhlbvYvRi2Eg qg/AhXKCkKNwxVohbuOGw5Dll5M/kuID/mok8qZLTs88EH52cHcwwXnCbj0UTiu+O2 qjo1+yFcHZVr2JqAs6ImkEZIVcExyhzUnn52rxNdUVC9hj9RxWdLYC8EBk9JWKEyXL 9+SMlw9E8N29l+riCEc4t+IAAhrpkes0RNIAweXQD980IVPUJfv8IPmgAEothGpTjv VFyHtRCqrDzqGD2Ksz+rE9jyQ3Bc5vQxSnfyjePM1CUZhNO1fwaVXyFa9I13/5sACl ss4AuIvA6oqOQ== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Dylan Yudaken , Facebook Kernel Team , Pavel Begunkov , io-uring Mailing List , GNU/Weeb Mailing List , Kanna Scarlet , Muhammad Rizki , Alviro Iskandar Setiawan Subject: [PATCH liburing v2 09/12] t/shutdown: Don't use a static port number Date: Fri, 2 Sep 2022 14:15:02 +0700 Message-Id: <20220902071153.3168814-10-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902071153.3168814-1-ammar.faizi@intel.com> References: <20220902071153.3168814-1-ammar.faizi@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi Don't use a static port number. It might already be in use, resulting in a test failure. Use an ephemeral port to make this test reliable. Cc: Dylan Yudaken Cc: Facebook Kernel Team Cc: Pavel Begunkov Reviewed-by: Alviro Iskandar Setiawan Tested-by: Alviro Iskandar Setiawan Signed-off-by: Ammar Faizi --- test/shutdown.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/shutdown.c b/test/shutdown.c index 14c7407..064ee36 100644 --- a/test/shutdown.c +++ b/test/shutdown.c @@ -15,44 +15,43 @@ #include #include #include #include #include #include "liburing.h" +#include "helpers.h" static void sig_pipe(int sig) { } int main(int argc, char *argv[]) { int p_fd[2], ret; int32_t recv_s0; int32_t val = 1; - struct sockaddr_in addr; + struct sockaddr_in addr = { }; if (argc > 1) return 0; srand(getpid()); recv_s0 = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP); ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val)); assert(ret != -1); ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)); assert(ret != -1); addr.sin_family = AF_INET; - addr.sin_port = htons((rand() % 61440) + 4096); addr.sin_addr.s_addr = inet_addr("127.0.0.1"); - ret = bind(recv_s0, (struct sockaddr*)&addr, sizeof(addr)); - assert(ret != -1); + assert(!t_bind_ephemeral_port(recv_s0, &addr)); ret = listen(recv_s0, 128); assert(ret != -1); p_fd[1] = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP); val = 1; ret = setsockopt(p_fd[1], IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); -- Ammar Faizi