Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp611529lqp; Fri, 5 Apr 2024 03:54:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXKfFShDgzNdoRYUmkDT1EuBYj3B6KOHo4aN4mOnospkaobnUjlbNFAOy28cNxiw5jSoB8AjkjLSCTNoomH8uF2EVT2jD1zLwSY5F+eTQ== X-Google-Smtp-Source: AGHT+IEHVrbzzaW2TA91fmTjVcXRXndx4PCnlq3fntrNx7n3FHMutWUtf4xptFsTenHw7nW/dMsm X-Received: by 2002:a81:84d2:0:b0:615:15c7:9d6b with SMTP id u201-20020a8184d2000000b0061515c79d6bmr956663ywf.4.1712314484062; Fri, 05 Apr 2024 03:54:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712314484; cv=pass; d=google.com; s=arc-20160816; b=0Mf1oCVZenqr7bBaydL/Gyi5930UUIZ2PAXaNhNy8/86wLaDTl8CLhkQBtNniwikmN NzQZCdh0ZSQ/myCVNsl5xVI1Te4ssq12gZL/Nr92gCyZEbQW42S53D7BRrpGMBOD+qRf mWIgj2vvanHDa2/TpGOqTWwVvsO7yQR0Tmr/TgKYJGBuaXrLJPJB0hi7TLQkMMa1vLeM t/TNgt1b50xbUvSDEgo6qII40gmQ38fxZ4mfP/NRR+v9Fho+DLTWLDr6cF/806m0+hk5 n+6PLHCP5ztN6Vh9kcL5q8/v9C9Vu2r/Lv0olJvVCby3d8VaVYByHXcNusm68juEtvtw J8sQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=i9y+PaLF6ue5N8dA+4J3NJEScdWjtzaAWv5/QspvAk4=; fh=gM1fTaWoK9TL7webZ8yB3tcO8X47vwS7DNlJ3C0B/Lk=; b=fZ55VpeHPnX4bhXFLJrcF4or8xr4RGexLgxhJxTEZMOS0HiqkAXxflmlamSK1/1AeU vS6SyMLvfT1r6ESbMMYpMIYyFm+RWJqnGai+jcyyGKepRzUHRf0YtJAuKPQkEJCb2TZy xO6AllGsDLjg0I/uqAm7P68Pvz32r5ZrwNizNjBs8aV7JAxJ1Atz3CAyKL72QsIfLYZN ixfJZ9bkHkZATdSWdWYYDaTARwcuwWsR+WXsyU4ey+vBSkD/fswk6VHQ51+ZK6i3Y64I uWNb0Xni2FDN9/wYtHuEXB9TVwY5v8mMxBALoym0WY7PaDuUcfXDWleNpCofwsJ6XRF3 KLWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=I7FOEtKT; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-132861-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132861-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o9-20020a05622a138900b00434665d8bb6si236830qtk.328.2024.04.05.03.54.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 03:54:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132861-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=I7FOEtKT; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-132861-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132861-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A284A1C216B4 for ; Fri, 5 Apr 2024 10:54:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B606B16D32A; Fri, 5 Apr 2024 10:52:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I7FOEtKT" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBF7F16D316; Fri, 5 Apr 2024 10:52:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712314366; cv=none; b=qkAZmSZXg4iXL0i1eQXvehgJtVRPMSWR3O1mKVkzFxdBOIG0myHHbejD9NZ5d6sRhpMkHNluHT8BfhBfulhZk7waU8K2l/H81kpaBli9PYxv8YRGv5N6Ms6dND/MLJU4ZSAkQ8aBtX1XPRcv12Vnz1RyF1RssKD5SAD0FjxnmrE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712314366; c=relaxed/simple; bh=cklO41Gnr8RqkCP7eGl0T3qddR+iFR4uJimzzItAXao=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IAmJeWPt7LLCpsMsZa6P1cOE3VkaT2SVG8unbNGc9raDUClBhkcbvi03FPZ5/bsyhGidQeOeFdBj7H5ZwL3euqkMpYuEE5y+O7I1ZAyCqFk0PFJePD1QRserFYiyB7X9QRFE8kXNboFIs13ePxAb4tEzJ/tLFiEqFtCjQp4JZE8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I7FOEtKT; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E5E0C433C7; Fri, 5 Apr 2024 10:52:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712314366; bh=cklO41Gnr8RqkCP7eGl0T3qddR+iFR4uJimzzItAXao=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=I7FOEtKTzEMEu0pZsYWX8dQUPdYd6r3dU+ikAr38R7hVYQ31vQsrE67saphXw7sSV w/t8nuvRWGzFoK8ItXAKtRFf4rJFSvh1iJBFLVCIFB0odvMJbrVZc65VW/SSw8xaDO YSzO55zK17FgMQfyMifniW+7GB34RJZ7QMvZ/nbVRP3tCVNWfIU04LrYODUp/O4ouU T5YwiAn3hE6LjlLDIwVYpg/hdAEYUG65lTDsvrIY1CIhuz3CeeQ8xyYoXxkzjZJE4Y KaXW7n4pkdjw0NkDOKDK4eQ0ELjDiiZffQw46czYOMrykXuf4Fiz1fOLUXRSRFFpCa y8ZSKk1U3HycA== From: "Matthieu Baerts (NGI0)" Date: Fri, 05 Apr 2024 12:52:11 +0200 Subject: [PATCH net-next 07/11] selftests: mptcp: join: update endpoint ops Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-7-eabc9b960966@kernel.org> References: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@kernel.org> In-Reply-To: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3646; i=matttbe@kernel.org; h=from:subject:message-id; bh=9sKu4QP3l55pYCRc5lz8qgHWCijkZyX6+gKVicInu50=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmD9fl653O5H/NmNoUNMAGsdtrT1O/VZ9YGLCbr 2ZPtO9oDceJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZg/X5QAKCRD2t4JPQmmg c0RTD/sEwyqvlwCzgdhDy6TfcPNucqi0gJ4vapixjhAnjBWQ5ObWcQB6gTvqIbq6xgdy9xy5aM2 wBwNwgio3eT+rl58dNu2MWWIm3s9BMyGC632Y0eav7poqct3sdPUoinPLLBidoyXadCUrtCaiBB Nt1CjYRYSPdouMOOHsbNHCQvyDhxvpR1Gz7vQuvtptAX/T5+a6tXQ1peG/t15+y2SziDUx7kB5o WbWSpeAH0aqPi6K2HkYhAwNoZEvfYXsIJ5Fa5fox16rHYzodCSfvyfJAawT19c3yZBxcJsDW3EK a6FI1HFb+i5SjRSUOz5ePfz6pjxSytYUFLiZnWRaUX3zp+WaOX4IyAG0+yIk6o3PwP0/RZewSgH ezF42pNQdxGiq3HJf5XDpBWd7zHpb8/RLXJdwnhC65RGiIHhtFFxmco2DUX31yQe9fHKSfI9ttx YHw+3e3o2fy1MW3CjmV+M2YGwyLLrSNO+cAfhamQVoPevkrfIpB1SxNZcyx6ailWxG/rZkQ494+ BqZGKUeOuP7HdjBKfRrCyUBDykj4FvO4duo1DOdkTwVm4u1MjD31/n3FaE+FfjiKUPh2TCETdw3 1ouVN0C8z27GAnBrFzWRE9PCOdiNFZ+yiXAWYcZmnst63/D7wl1P1XAKuoH6ypj9Ustc8Wm0Nyi ehDvjVUtCvqcL1A== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang This patch uses 'case' statements to simplify pm_nl_add_endpoint() and pm_nl_check_endpoint(). And simplify pm_nl_check_endpoint() with check_output() helper. Also update pm_nl_del_endpoint() to avoid the 'double quote' shellcheck warning. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 72 ++++++++----------------- 1 file changed, 23 insertions(+), 49 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index d48da81daa06..8862b6a5caa0 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -620,39 +620,27 @@ pm_nl_add_endpoint() { local ns=$1 local addr=$2 - local flags _flags - local port _port - local dev _dev - local id _id + local flags dev id port local nr=2 local p for p in "${@}" do - if [ $p = "flags" ]; then - eval _flags=\$"$nr" - [ -n "$_flags" ]; flags="flags $_flags" - fi - if [ $p = "dev" ]; then - eval _dev=\$"$nr" - [ -n "$_dev" ]; dev="dev $_dev" - fi - if [ $p = "id" ]; then - eval _id=\$"$nr" - [ -n "$_id" ]; id="id $_id" - fi - if [ $p = "port" ]; then - eval _port=\$"$nr" - [ -n "$_port" ]; port="port $_port" - fi + case "${p}" in + "flags" | "dev" | "id" | "port") + eval "${p}"=\$"${nr}" + ;; + esac nr=$((nr + 1)) done if mptcp_lib_is_ip_mptcp; then - ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port + ip -n "${ns}" mptcp endpoint add "${addr}" ${flags//","/" "} \ + ${dev:+dev "${dev}"} ${id:+id "${id}"} ${port:+port "${port}"} else - ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port + ip netns exec "${ns}" ./pm_nl_ctl add "${addr}" ${flags:+flags "${flags}"} \ + ${dev:+dev "${dev}"} ${id:+id "${id}"} ${port:+port "${port}"} fi } @@ -664,7 +652,7 @@ pm_nl_del_endpoint() if mptcp_lib_is_ip_mptcp; then [ $id -ne 0 ] && addr='' - ip -n $ns mptcp endpoint delete id $id $addr + ip -n $ns mptcp endpoint delete id $id ${addr:+"${addr}"} else ip netns exec $ns ./pm_nl_ctl del $id $addr fi @@ -707,49 +695,35 @@ pm_nl_change_endpoint() pm_nl_check_endpoint() { - local line expected_line local msg="$1" local ns=$2 local addr=$3 - local _flags="" - local _port - local dev - local _id + local flags dev id port print_check "${msg}" shift 3 while [ -n "$1" ]; do - if [ $1 = "flags" ]; then - _flags=$2 + case "${1}" in + "flags" | "dev" | "id" | "port") + eval "${1}"="${2}" shift - elif [ $1 = "dev" ]; then - [ -n "$2" ]; dev="$2" - shift - elif [ $1 = "id" ]; then - _id=$2 - shift - elif [ $1 = "port" ]; then - _port=$2 - shift - fi + ;; + *) + ;; + esac shift done - if [ -z "${_id}" ]; then + if [ -z "${id}" ]; then test_fail "bad test - missing endpoint id" return fi - line=$(mptcp_lib_pm_nl_get_endpoint "${ns}" "${_id}") - expected_line=$(mptcp_lib_pm_nl_format_endpoints \ - "${_id},${addr},${_flags//","/" "},${dev},${_port}") - if [ "$line" = "$expected_line" ]; then - print_ok - else - fail_test "expected '$expected_line' found '$line'" - fi + check_output "mptcp_lib_pm_nl_get_endpoint ${ns} ${id}" \ + "$(mptcp_lib_pm_nl_format_endpoints \ + "${id},${addr},${flags//","/" "},${dev},${port}")" } pm_nl_set_endpoint() -- 2.43.0