From patchwork Fri Mar 8 22:10:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 779343 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 C4486604B5; Fri, 8 Mar 2024 22:10:25 +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=1709935825; cv=none; b=gzN1dq7JkAswGeY9mZGICHY3p8zuEK4RC3xod2pcNoUscwdgbfkrgOMIUsbSUad/fArosg0l+lL2yy5CzCSFsLeTYj0hti9m4R1+gMFtW+r0wbgwkHrdgG9BNwe8XhSRMZ2mmwLLQr9KdQrps3LZmBcqIEFLEdBQgZ2ZO1FA8IE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935825; c=relaxed/simple; bh=i1l1HeZAQJKXmN37TV6fUvmIfHotoheRGwDNA5lNhgc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DcQMzn8jjtcU904phJ3O5Tq/p2KLf9/fWoPGeFSuy4f4sjjxi1JK/NwKygepP2E4R3pmxxSvSoprHqFOdJhkeVKpJhKNMnI819jDFGm9QN+ujYS5yUOIRmFfjPhmvrHOjgaYg5HaeC/u4stgugHs+MvqontvIwqjOyQed4JtRlI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NLCh61mM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NLCh61mM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 306B4C43390; Fri, 8 Mar 2024 22:10:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935825; bh=i1l1HeZAQJKXmN37TV6fUvmIfHotoheRGwDNA5lNhgc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NLCh61mMTdUSKZ7QjtgAhknuxjLcmd+KvjaezpU2SinkMisFO9Zy8uP5FyEFR/TaJ ecGEAWgEtdy6qYPr4/Snn4gxuLDYCo2fWfirgXd82151VWX1p95eiXe5Ay4nDQ+pKZ xCt+WyffVYh3nlwXIWUyZl8pKF3PcVu7r6BmcZ7nZKyi0mGF/UTilvgJHeBMAVSpU/ 5fff1hGsWPmWTbSFCXVb1tfBKz71qFBLCurQf9qW6k+m7oBLYiMK/KSAPvEIjXw7BC ZnwfexR/6a8lIS+1gMhfR/c+buzA7clXJvj1NWptZ54uAeAjy+C8WuGXrnHw1Y0yz1 YMxc1/muQHruw== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:08 +0100 Subject: [PATCH net-next 01/15] selftests: mptcp: print all error messages to stdout Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-1-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , 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)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3871; i=matttbe@kernel.org; h=from:subject:message-id; bh=4ZsgBrZv+LBpKaiW/nO4hYLCEY/5jrgsAIGaAf+PH0A=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zJjpjp4iYCmsZT4/EH+TG5UZfnW19z3sjOd evHhRBTbnKJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMyQAKCRD2t4JPQmmg cw8yD/9b78omiFAYv7ns/4yDYj9wbjZM5EeBFNXbB1Cvh39gHqfIyMIQnMpLqWbQTyN79MlRiZP 41HcsSAL1fnvhJObS2eKRPZgDx+8rnB0BQRICEVZQ9Ulo8PiqJyHU7ASxdsqpoMYvyy1g3zGRbe 50aUpTrm5GygdNPQTsS43pXaC1jKORf5mHxdZ0gcvZNSKfhLm6XLZ+KnCKQZrD6RtP1Fc8/4WpR 3BcmFtImCJIdWxr/0FTN1a5Dz5eROAI3FCwOOmpgrW1aaVOsY4sIkLSnGe6iC6jX8aA1DyG3GN0 GA3MOvHEQN5uzEa8Pwovj0XZQd9EUIe37YPGphjVnKztQk0GpXPfH5+lJOqrvX8/r/AlVwhfqTS b5EM4VEjq1m8iFSIf9+zNCMVZCjOKzq74x4wNjX3G2EzQZNKM9m956bpGeEYb7gGEnHRVnN7eLm 2+0YwEwll3YE/t0MkcKB3YAAG5g4/IdAzwy/Voqfwq2IndPbfLuTpqozDzdi5z52RAH7nM6mgn9 RjWjtf9k2tscufZlq6RDSegOKdcex6ZUbItEIYNdzunn9MHcQI0paTyWTRr6XfxLfYnBQ0uts4k VN/e6J9cWV5yX2Reab6OQxfZ9sseNr4nOyhKxJkxVW9gD7mEiwgsRxCiNqrx1R/S534uPVhcZsn Ym+WH0Olkvt7Wtg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang Some error messages are printed to stderr while the others are printed to 'stdout'. As part of the unification, this patch drop "1>&2" to let all errors messages are printed to 'stdout'. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 10 +++++----- tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index 0ca2960c9099..679e366c8f6b 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -294,7 +294,7 @@ do_ping() ip netns exec ${connector_ns} ping ${ping_args} $connect_addr >/dev/null || rc=1 if [ $rc -ne 0 ] ; then - echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2 + echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" ret=1 return 1 @@ -470,13 +470,13 @@ do_transfer() if [ ${stat_synrx_now_l} -lt ${expect_synrx} ]; then printf "[ FAIL ] lower MPC SYN rx (%d) than expected (%d)\n" \ - "${stat_synrx_now_l}" "${expect_synrx}" 1>&2 + "${stat_synrx_now_l}" "${expect_synrx}" retc=1 fi if [ ${stat_ackrx_now_l} -lt ${expect_ackrx} ] && [ ${stat_ooo_now} -eq 0 ]; then if [ ${stat_ooo_now} -eq 0 ]; then printf "[ FAIL ] lower MPC ACK rx (%d) than expected (%d)\n" \ - "${stat_ackrx_now_l}" "${expect_ackrx}" 1>&2 + "${stat_ackrx_now_l}" "${expect_ackrx}" rets=1 else printf "[ Note ] fallback due to TCP OoO" @@ -721,7 +721,7 @@ EOF ip -net "$listener_ns" route del local $local_addr/0 dev lo table 100 if [ $lret -ne 0 ]; then - echo "FAIL: $msg, mptcp connection error" 1>&2 + echo "FAIL: $msg, mptcp connection error" ret=$lret return 1 fi @@ -810,7 +810,7 @@ log_if_error() local msg="$1" if [ ${ret} -ne 0 ]; then - echo "FAIL: ${msg}" 1>&2 + echo "FAIL: ${msg}" final_ret=${ret} ret=0 diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh index 6ed4aa32222f..7c70b52e63c6 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -103,7 +103,8 @@ check_mark() local v for v in $values; do if [ $v -ne 0 ]; then - echo "FAIL: got $tables $values in ns $ns , not 0 - not all expected packets marked" 1>&2 + echo "FAIL: got $tables $values in ns $ns," \ + "not 0 - not all expected packets marked" ret=1 return 1 fi @@ -162,7 +163,7 @@ do_transfer() local rets=$? if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then - echo " client exit code $retc, server $rets" 1>&2 + echo " client exit code $retc, server $rets" echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port" @@ -221,7 +222,7 @@ do_mptcp_sockopt_tests() lret=$? if [ $lret -ne 0 ]; then - echo "FAIL: SOL_MPTCP getsockopt" 1>&2 + echo "FAIL: SOL_MPTCP getsockopt" mptcp_lib_result_fail "sockopt v4" ret=$lret return @@ -232,7 +233,7 @@ do_mptcp_sockopt_tests() lret=$? if [ $lret -ne 0 ]; then - echo "FAIL: SOL_MPTCP getsockopt (ipv6)" 1>&2 + echo "FAIL: SOL_MPTCP getsockopt (ipv6)" mptcp_lib_result_fail "sockopt v6" ret=$lret return @@ -263,7 +264,7 @@ do_tcpinq_test() local lret=$? if [ $lret -ne 0 ];then ret=$lret - echo "FAIL: mptcp_inq $*" 1>&2 + echo "FAIL: mptcp_inq $*" mptcp_lib_result_fail "TCP_INQ: $*" return $lret fi From patchwork Fri Mar 8 22:10:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 778980 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 B2F5F605BD; Fri, 8 Mar 2024 22:10:29 +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=1709935829; cv=none; b=OF5A3dntUxuoE8oxoxffJTjlIImXNWP7PSCZSTIsdXlPKffYi48uhyaWgRrEbV3zhuTS5bH4agz/MKAi5Og5v5QLLNp1WUAvKPqjAmXRWNnS8sqQydtxepwaXZIXtiBUW3MPCSxhXKqcNLUaDrlTKtf9GL1D0Bj9dDjmWHC4/kU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935829; c=relaxed/simple; bh=4nVIS17p6hfpmz31cy1Qa7DP7XG9Y9xY1ocKKw5lq2w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eB4UWiF0TOnP3HRQnkhMfH/zpBMaP8Jz1G9sPXaI509i8Tgb5rDvhDUWklM/Zio1IXfd+bltjySE6mev1wHorDjuPWcL6IDpC/2Ttd8gFUnO4D1WlNWAM/12nyhcZ85vhu2VMjJXmAsvLbG+KNGt30vZLn5uOHKE/e4OXiOKjG4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=arHj7jRf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="arHj7jRf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3964C433F1; Fri, 8 Mar 2024 22:10:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935829; bh=4nVIS17p6hfpmz31cy1Qa7DP7XG9Y9xY1ocKKw5lq2w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=arHj7jRfh0wt3L9GPo/NcZfTpEDVO0rDWgHW0Hq3xC/R8QlStosEhzSPo20eM4qCK LR1kZNEN5fQXlaFa5dBf+l+nQJIrUAV7Es1n47Uj15OPG6RL0Y2y36903rgu2tFh4m 2dncchbPM78GVaWEI4HuUBaQ6WnxsAS49iAhxQdmFvb1CHtsutAWVmWttfdBVMpCVK 4UyDqWSC+lmoyWwQc3/UNoZpBUuSmwXfGbusYPAsjRQc2UliH33dm1rkx9jbG3PXRn QqugqBsSWbpXcOxTL7Cev8WShjKYe1ptr/OOD5Nlyoop1S1k9VdZlNzeNxj7p2IuFJ V2+gQ06I4dGAQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:09 +0100 Subject: [PATCH net-next 02/15] selftests: mptcp: connect: add dedicated port counter Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-2-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , 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)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1385; i=matttbe@kernel.org; h=from:subject:message-id; bh=uZotqfOJH05r/mkzZnPzrup9bfcx9v2c7hqAmWQhC7o=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zJiuJltdcfRCNiztqCUe/Di09/CiDya2IMd PZCFRiYb/SJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMyQAKCRD2t4JPQmmg c3YUEAC2gns6Li7mDBS6aBV6mvpF2w8E7QmIvpWFTuQR6Cg4F88IpXwGKE+WeObG7NVg1rfdUCf Yh0PewFQKsGBQWXO/caFVrNi1SNRm1D0910PfgX3GGGILTTS8cbRisqFIOzny35cFyRY/7WD7GY fchWjA6SCKs07cs6K3buCh3eSGyC4avlVNZh39DeW/GZcm+EkQtSdnvQIziLsvo2vtS4IeLQ2St xTL0Yg8+BWHxbaVr2qiPLfgNDBQxJJK46cUqlrdJH+fbQibTND7L3CxzsjwJpmAgUqHHXYup6XP J6uu5UNRcwQZwrukTNkS/WSQiIW++qR7RKPMiYbXMTuxgXXm72Fd9P+LLYR2M55W7sVxbLNPPGS +sibcKVdjcev3grIkj0srjemto5clMqpUGGxNCan6Fe9q1ZEBbv3bwzLHkysxpdw6ozfFi3HB1+ q2VMytrN/9G6IlAAB5AASiUuAkyBuzi0r/oaHvbAroI/z37GiARbDEWRqMRbqI96QRIb/S50VRn cYg0XSdtV6dDApKqdUVrNAf+LPGsmQU4hK2ikpTieyeimlFO2ocTNd1eoW7y2XoJaodQ7XYITav FIcWX7ZIXw0I+x7qEckDTr6sPbn/NKGEGqoiSL3CgCd7mESc7V7S8zspNVo+/S2WV6xU4Xs9wyS Cclld2D716fW4Ig== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang This patch adds a new dedicated counter 'port' instead of TEST_COUNT to increase port numbers in mptcp_connect.sh. This can avoid outputting discontinuous test counters. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index 679e366c8f6b..ab3f52434753 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -33,6 +33,7 @@ do_tcp=0 checksum=false filesize=0 connect_per_transfer=1 +port=$((10000 - 1)) if [ $tc_loss -eq 100 ];then tc_loss=1% @@ -313,8 +314,7 @@ do_transfer() local local_addr="$6" local extra_args="$7" - local port - port=$((10000+TEST_COUNT)) + port=$((port + 1)) TEST_COUNT=$((TEST_COUNT+1)) if [ "$rcvbuf" -gt 0 ]; then @@ -710,7 +710,7 @@ EOF echo "INFO: test $msg" - TEST_COUNT=10000 + port=$((20000 - 1)) local extra_args="-o TRANSPARENT" do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP \ ${connect_addr} ${local_addr} "${extra_args}" From patchwork Fri Mar 8 22:10:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 779342 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 E79E760B98; Fri, 8 Mar 2024 22:10:32 +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=1709935833; cv=none; b=lJqmqkDzM1t789TALm0MIiRloHQm5S0nJhdTcMX42Tmrf81Nqzv3x59CRFzQ8nKmSNKAZ3t33B4WlyHlNNC6edvoHl6ZUU2uhe7JsdaTVssNuqT/Md1p3ZDVime4Wm4vfBLE+NB+M9HtxRHLgSnSHt2nDSWmRM6uHb7oXnQeziA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935833; c=relaxed/simple; bh=AuyUJEy8/GFimI6CwhS0MaqX8nAZA6UQMnkCDSU/jzI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Bmyn3VUuXmvhRWUvS2sP3iMxcxTjVheiYvsCWd5NyeIyHe8dtqWcMiyOPipM+otxOzt5WfIy7jIH8b/P1mkcE3C/NC+8XqXm5mpx/ddh9gaMB3nN/12kyTJuHz1wpLKsDuljoxHvxoxqO8kLPc+AkjCnaAfSFV6rMFugM2Hsdbk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dE16c/gk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dE16c/gk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAD58C43390; Fri, 8 Mar 2024 22:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935832; bh=AuyUJEy8/GFimI6CwhS0MaqX8nAZA6UQMnkCDSU/jzI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dE16c/gk17P/s1W7YESFsK5M6ClDFa10MAK1asHYMtg/78gmCGyk5KSv1a9GkLNju aBtDtjReX9m6Y+RYBI32n1EqYQBQe1vpgV5vDOMB7ar2+Rxt5gD2+f/6khcijoOZ26 nFuwqtgPE0m0SxY5C76NNLpNZNU6/tNg0qvJjr05pw3RcaT5g/77ucfXq1BO4Lp3Mp yP9AxgJu0nJ9GwfEWhxuOOi+/k8CvuWI820RgmtYvjDxQWbnvrjt4J2IcDHOrI4wtO UMm7dK2lnP3yfeUy8/qP3Y8v2K5sVfoqAwWVVlAfXYkdBaQ7gWLmo5wSa2Tspl8fmN YMOHtkXrvNtzg== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:10 +0100 Subject: [PATCH net-next 03/15] selftests: mptcp: connect: fix misaligned output Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-3-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , 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)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3136; i=matttbe@kernel.org; h=from:subject:message-id; bh=prJQDSXkGk0bgVFnt5VqgYB54OTpymEkzl8crkakD0M=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zJr7eRlLmjzQutMXiAAbc/UHNbZ4qHX1QDN 109RZbK0suJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMyQAKCRD2t4JPQmmg cwcwEADuOeD0hasvEJzIzH758PoeKJ1DSXRsIOD1l46v2wVK0bZlRqobGALGM/yLLzJ68QHuzN8 HOkF9GFmrtmBJRevF/6GaJU/GaYFCkQT+OgpNjAhmevn1fHg7AWv7FFVah8h+quHUidSqG5rZX0 qdy7drZLNKa2/lqSA112NkbVEBYDBWqkIvg95wgXFrlxVa5WvO9sPGMFsYYGrKf993/QE123nUK SGFuN/lSQS8Pj/eI00h8Yaqlhjo2393IRMUi7R51UsehOxarojXLOAZKrwjb7rx1hCgNMEqKVnU nTrKS9LYpZJn4ddLqHyVMvt26C7ji4L30eOR3WkPCwuQlFzO2Pnsy0SE6vZKkl75nuJBxXL0xyN 8lkt95kUJpzFJzCKfCX0k/0EfcLtA1oM/gi+qtgPnuEWTHrjDISmwtraHjMC/zM64mI3O7l8EJe i1rXE0I6EePQJUvxN9tK4/vTS1qXH0bCnWxqBQDk4iTKH6afvNunPUmwIdDG6Yv0zxMAsj7pqfZ vR8QY4IQLDZmAxjtdyDfK3cCK+9d0HEaQ5wj8jhIdi60Ro0e0NAOUR5HL0fGTR7RByBpHDUSOh0 /xo2X4njtmCLcCcOYy9y7dB5cwabVRsAaGXaA2El0BfMVx+FUqj4qG0iXwmu2Xx0RrhFoAqbSTf zoUQATTRWsYe4hQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang The first [ OK ] in the output of mptcp_connect.sh misaligns with the others: New MPTCP socket can be blocked via sysctl [ OK ] INFO: validating network environment with pings INFO: Using loss of 0.85% delay 16 ms reorder 95% 70% with delay 4ms on ns1 MPTCP -> ns1 (10.0.1.1:10000 ) MPTCP (duration 184ms) [ OK ] ns1 MPTCP -> ns1 (10.0.1.1:10001 ) TCP (duration 50ms) [ OK ] ns1 TCP -> ns1 (10.0.1.1:10002 ) MPTCP (duration 55ms) [ OK ] This patch aligns them by using 69 chars to display the first two lines, and 50 chars for the other. Since 19 chars are used to display duration time. Also print out a [ OK ] at the end of the 2nd line for consistency. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index ab3f52434753..ce9342b241cd 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -248,11 +248,17 @@ else set_ethtool_flags "$ns4" ns4eth3 "$ethtool_args" fi +print_larger_title() { + # here we don't have the time, a bit longer for the alignment + printf "%-69s" "${@}" +} + check_mptcp_disabled() { local disabled_ns mptcp_lib_ns_init disabled_ns + print_larger_title "New MPTCP socket can be blocked via sysctl" # net.mptcp.enabled should be enabled by default if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ print $3 }')" -ne 1 ]; then echo -e "net.mptcp.enabled sysctl is not 1 by default\t\t[ FAIL ]" @@ -274,7 +280,7 @@ check_mptcp_disabled() return 1 fi - echo -e "New MPTCP socket can be blocked via sysctl\t\t[ OK ]" + echo "[ OK ]" mptcp_lib_result_pass "New MPTCP socket can be blocked via sysctl" return 0 } @@ -342,7 +348,7 @@ do_transfer() addr_port=$(printf "%s:%d" ${connect_addr} ${port}) local result_msg result_msg="$(printf "%.3s %-5s -> %.3s (%-20s) %-5s" ${connector_ns} ${cl_proto} ${listener_ns} ${addr_port} ${srv_proto})" - printf "%s\t" "${result_msg}" + printf "%-50s" "${result_msg}" if $capture; then local capuser @@ -835,7 +841,7 @@ check_mptcp_disabled stop_if_error "The kernel configuration is not valid for MPTCP" -echo "INFO: validating network environment with pings" +print_larger_title "Validating network environment with pings" for sender in "$ns1" "$ns2" "$ns3" "$ns4";do do_ping "$ns1" $sender 10.0.1.1 do_ping "$ns1" $sender dead:beef:1::1 @@ -857,6 +863,7 @@ done mptcp_lib_result_code "${ret}" "ping tests" stop_if_error "Could not even run ping tests" +echo "[ OK ]" [ -n "$tc_loss" ] && tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $tc_loss delay ${tc_delay}ms echo -n "INFO: Using loss of $tc_loss " From patchwork Fri Mar 8 22:10:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 778979 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 64EAF60DD0; Fri, 8 Mar 2024 22:10:36 +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=1709935836; cv=none; b=HfdE74q4fwfi2MqrqfnOU9Dv68WqFjYD60ANG3P8uXRn0CZGMhgMrVhhpFz4mLAUhSrMmcLo5nSfq1u7flzkwJFDELoDA/WZhclY2kEGseU+uVx/j62OP8WmIpGxjy8wc+WLikNPWDME1ksMj7PZkBHm9TxQL3190beWfmyE1H0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935836; c=relaxed/simple; bh=VXfS3QkWb4QTBKWtbjBrmOHymSFfzccAQy0CBA3kINA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M42I3RBkSeIXR0I1dQTX4c5MM/a8tOvjHH3CEMZ0emO/L6LpOjQQJFG/CGHt51eucqTbbg6H2hneIpP7RJaq3tWwRYq2I7TvksUF17UWgSgXfkL1oG7iRWGLgVpyzcZbvUAI1pLUt6ZCrkrJBtukyCNuAuxTOq8cPA62ArALKMc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YXmCT4vi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YXmCT4vi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45A08C433C7; Fri, 8 Mar 2024 22:10:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935836; bh=VXfS3QkWb4QTBKWtbjBrmOHymSFfzccAQy0CBA3kINA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=YXmCT4vizmPLwoq0ClyzaFgwRMlabUXwkemg2eYmY0mirb+h3rYd45WnW3YxKYNkh mYQ2CcxyOBufIuUtKTLV7E8luYeBWtsETikqUlEC31WsKnphwlQR7sVWOeQgAl0f8t mMWRZ5IiGpY0FKOULtii2Nn18JnGIUoUPW7Z4CDP5yJpeovco35VsJ/W7xg4Z+0NES Q8niGxs+Q2C+B8mo3LjPr+Ak79aV7HzKwrTlCGMvtY3r+OVUOK7R9R78jYz6IedQgm B1kRh1YJYW6y5qn67eQkjgx2w0UTHSjKHr65nygr3u1JBb4asqLkO6lBcBJEQdc9+x un8R6sfYMir5A== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:11 +0100 Subject: [PATCH net-next 04/15] selftests: mptcp: sockopt: print every test result Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-4-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , 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)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5499; i=matttbe@kernel.org; h=from:subject:message-id; bh=ue8QxXqH8/zNeDcEyTf1Ear/bDXhGP/IbYKP00DKFC8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zJ9rczW87UrP/yHM1zd6cRW2a0393PHMzk3 vChA6BrR5iJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMyQAKCRD2t4JPQmmg c3ZGEACuRatMijxhY5shAnb9VysLLokTsf0MfQ15Fwdr+goTBPbOBCoEHFNncIXKdRxI3KU+9r4 zNUPCFBKZd6kSGQCabpuni/vg1Oey4owYEvuVjj+8CGGg1rb/uynIQ7vzyfVcPdl89M592ZGIHv +VNaYPzGCtRN9fTOwXRZsOqImFdj4VcTr8HVYs+osUtxZZb3b8tO3jeAlkLd4Vd1drQLlLsg5mx 4G2wjViq0Dcb3xevYo4vCK9+chsEpOur/K4xaUiZQhO77PlOq/IRw7ZsAO/HlQRGZISfroXS/rP wMTAT15Abof4H5MKTRxlZMKellUqYu11R3MVDtTxy1S+/HINFL24V3uZu8P4uGZvCKb+eFLui60 zxBBLUQjyj7sZcyjH5MjuyIiw2fUR+uKn/Z46K6yLehgJ7SlOGAm9cXSChL//3pvrUlNU4OTx9t 9T1RltHgpdFJIo3DwqVwX4vrClKUfEQzwk8EmFpF9bVRdE+gE67ZNDtIc0EZb7WH0QWIxkcfa1U r8YnvtSxYrGWhnaFWJCPpjym2WeGNLB6Mbt5UpFJWmCempTt1ndXjUysH2StGZbQT9t5yqNZl3+ /v0V0bsx0KhUHgJaJjqcmXxWVnHff2IZGeYWzCqToqGUYj1zkVOj9no0GX9TdvYTK0YIeYx3wnG suZiOxQ6FHdw4oQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang Only total test results are printed out in mptcp_sockopt.sh: PASS: all packets had packet mark set PASS: SOL_MPTCP getsockopt has expected information PASS: TCP_INQ cmsg/ioctl -t tcp PASS: TCP_INQ cmsg/ioctl -6 -t tcp PASS: TCP_INQ cmsg/ioctl -r tcp PASS: TCP_INQ cmsg/ioctl -6 -r tcp PASS: TCP_INQ cmsg/ioctl -r tcp -t tcp They mismatch with the test results: ok 1 - mptcp_sockopt: mark ipv4 ok 2 - mptcp_sockopt: transfer ipv4 ok 3 - mptcp_sockopt: mark ipv6 ok 4 - mptcp_sockopt: transfer ipv6 ok 5 - mptcp_sockopt: sockopt v4 ok 6 - mptcp_sockopt: sockopt v6 ok 7 - mptcp_sockopt: TCP_INQ: -t tcp ok 8 - mptcp_sockopt: TCP_INQ: -6 -t tcp ok 9 - mptcp_sockopt: TCP_INQ: -r tcp ok 10 - mptcp_sockopt: TCP_INQ: -6 -r tcp ok 11 - mptcp_sockopt: TCP_INQ: -r tcp -t tcp 'mptcp_sockopt.sh' now display more detailed results + why (what you had in a former patch from v6, merged here). It no longer displays 'PASS:', because it is duplicated info now that the detailed are displayed: Transfer v4 [ OK ] Mark v4 [ OK ] Transfer v6 [ OK ] Mark v6 [ OK ] SOL_MPTCP sockopt v4 [ OK ] SOL_MPTCP sockopt v6 [ OK ] TCP_INQ cmsg/ioctl -t tcp [ OK ] TCP_INQ cmsg/ioctl -6 -t tcp [ OK ] TCP_INQ cmsg/ioctl -r tcp [ OK ] TCP_INQ cmsg/ioctl -6 -r tcp [ OK ] TCP_INQ cmsg/ioctl -r tcp -t tcp [ OK ] Also fix the TAP output: ok 1 - mptcp_sockopt: transfer ipv4 ok 2 - mptcp_sockopt: mark ipv4 ok 3 - mptcp_sockopt: transfer ipv6 ok 4 - mptcp_sockopt: mark ipv6 ok 5 - mptcp_sockopt: sockopt v4 ok 6 - mptcp_sockopt: sockopt v6 ok 7 - mptcp_sockopt: TCP_INQ: -t tcp ok 8 - mptcp_sockopt: TCP_INQ: -6 -t tcp ok 9 - mptcp_sockopt: TCP_INQ: -r tcp ok 10 - mptcp_sockopt: TCP_INQ: -6 -r tcp ok 11 - mptcp_sockopt: TCP_INQ: -r tcp -t tcp Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 42 +++++++++++++--------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh index 7c70b52e63c6..17b36c1312f4 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -113,6 +113,11 @@ check_mark() return 0 } +print_title() +{ + printf "%-50s" "${@}" +} + do_transfer() { local listener_ns="$1" @@ -162,8 +167,9 @@ do_transfer() wait $spid local rets=$? + print_title "Transfer ${ip:2}" if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then - echo " client exit code $retc, server $rets" + echo "[FAIL] client exit code $retc, server $rets" echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port" @@ -175,7 +181,14 @@ do_transfer() ret=1 return 1 fi + if ! mptcp_lib_check_transfer $cin $sout "file received by server"; then + rets=1 + else + echo "[ OK ]" + fi + mptcp_lib_result_code "${rets}" "transfer ${ip}" + print_title "Mark ${ip:2}" if [ $local_addr = "::" ];then check_mark $listener_ns 6 || retc=1 check_mark $connector_ns 6 || retc=1 @@ -184,15 +197,13 @@ do_transfer() check_mark $connector_ns 4 || retc=1 fi - mptcp_lib_check_transfer $cin $sout "file received by server" - rets=$? - mptcp_lib_result_code "${retc}" "mark ${ip}" - mptcp_lib_result_code "${rets}" "transfer ${ip}" if [ $retc -eq 0 ] && [ $rets -eq 0 ];then + echo "[ OK ]" return 0 fi + echo "[FAIL]" return 1 } @@ -221,23 +232,27 @@ do_mptcp_sockopt_tests() ip netns exec "$ns_sbox" ./mptcp_sockopt lret=$? + print_title "SOL_MPTCP sockopt v4" if [ $lret -ne 0 ]; then - echo "FAIL: SOL_MPTCP getsockopt" + echo "[FAIL]" mptcp_lib_result_fail "sockopt v4" ret=$lret return fi + echo "[ OK ]" mptcp_lib_result_pass "sockopt v4" ip netns exec "$ns_sbox" ./mptcp_sockopt -6 lret=$? + print_title "SOL_MPTCP sockopt v6" if [ $lret -ne 0 ]; then - echo "FAIL: SOL_MPTCP getsockopt (ipv6)" + echo "[FAIL]" mptcp_lib_result_fail "sockopt v6" ret=$lret return fi + echo "[ OK ]" mptcp_lib_result_pass "sockopt v6" } @@ -260,16 +275,17 @@ run_tests() do_tcpinq_test() { + print_title "TCP_INQ cmsg/ioctl $*" ip netns exec "$ns_sbox" ./mptcp_inq "$@" local lret=$? if [ $lret -ne 0 ];then ret=$lret - echo "FAIL: mptcp_inq $*" + echo "[FAIL]" mptcp_lib_result_fail "TCP_INQ: $*" return $lret fi - echo "PASS: TCP_INQ cmsg/ioctl $*" + echo "[ OK ]" mptcp_lib_result_pass "TCP_INQ: $*" return $lret } @@ -315,15 +331,7 @@ trap cleanup EXIT run_tests $ns1 $ns2 10.0.1.1 run_tests $ns1 $ns2 dead:beef:1::1 -if [ $ret -eq 0 ];then - echo "PASS: all packets had packet mark set" -fi - do_mptcp_sockopt_tests -if [ $ret -eq 0 ];then - echo "PASS: SOL_MPTCP getsockopt has expected information" -fi - do_tcpinq_tests mptcp_lib_result_print_all_tap From patchwork Fri Mar 8 22:10:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 779341 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 60FE260DFF; Fri, 8 Mar 2024 22:10:39 +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=1709935840; cv=none; b=rsCOexgAsH8HXIYkH9xNrLPCB9VeZlKLTpm8McdOpTQSpDLPDx45Ll+tZppZc6YBFDPQAYqnRTgw0K7dTkRXMvlKPkApTRpN9UALQnZIocQtcdIEJyzWFr07Z9W4udZiPRbR2niWOfPZ44m5T6oPeuHrUng9gyVgE6Gl6MfVyFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935840; c=relaxed/simple; bh=WCm5fVeBx2RidgxLFnn5lWB43KtM3GQHbIliD1YqVU8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iZVpTcQ0VWsgPzi8PMMwMvXfBNl7dkD5ouuyrsRFNV+Jbb7+nCEbJyYgtSf4YdC1e/eViZwP1OTVwZWZdeisNtwoDoMzNlayWXmtrpR3SKXg7P+k+Xz1jeN7W7k0h5oX2e8YONnPtr7pdXvAVRJd2e4DQbQiWpZPae8tO9KnnB0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XBHI8nwF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XBHI8nwF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE099C43142; Fri, 8 Mar 2024 22:10:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935839; bh=WCm5fVeBx2RidgxLFnn5lWB43KtM3GQHbIliD1YqVU8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XBHI8nwFQndMIUM6NjYZ0MHgfo37727nk+NWK9l2SQlSveTi1VtIjLd/m87SITQgY W5b7kGpmQXklMGEkalapevHdzKd5m/I2w+f9gPEjUvfYOIwxRfOdLSL1ltik9wkfdt TEV9uNKDjqPpPNTCU3jOQ785ohPO+w9pk82QLY0f9xZWTzEm4TlSHl9gTqeyU1Gzx2 dxfk5sYYTUXG0xUkR2R7g+KLw/7TnWv1AbqQrN/FBSrGPll/fyXxmqlfKFx+hT8Ssa Zn4OZqkk4gFwZI3JwGIyVDBob6a3WOJ7yLbGF76mNuNAfxsLQEq6o21dPp7IffEQT1 hfrukVONWhz7A== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:12 +0100 Subject: [PATCH net-next 05/15] selftests: mptcp: export TEST_COUNTER variable Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-5-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , 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)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5783; i=matttbe@kernel.org; h=from:subject:message-id; bh=yurptwHKr74ItMKbFqhWWBfncz+etA7RPQk0wFWUt/I=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zJ+Q4f/pWAZHoygOW8iInggyXcavOWjDfCb jdNfpmYXrWJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMyQAKCRD2t4JPQmmg cy+oD/9cmJ5MwO5GH8hc6s1Q4nnmwRo/Bz8E4z/Kp+24qWsnFvKMBv8fWcPQ8vmw38R6W8JO3Sf mbkw5nhafYlok9dUoZfqTUwmaHp30bo2Di0f8FwvzsF6ihKWYHYkmW3lNvBEG5X65s5qH9/44tC Z3K+YSDyryv+ntoy1X9Y575agkjl4RDMZM4kjeHiTNUL/EG0YFOzVe+UjvzeyFjaABd7eEo+HKy cr6N+CtQ7S1xhGPJwQMdFQJZaMTCkOBY392YBEMi2GDTfWQw3SwLTDBovnZLsKo1kvHmdpcujv/ l59WGAjmURcq4i2wQpZepAg1YFMy0h7Oq7goSEevdpvPORXNl4lbDMRBr+bACRrnQEm1Bunt7C2 8tg7PldRNf2Hzq2rk+LKA8gDXSkGC4tfBPoYWSdYgLJe8oJ4oMDIG5KJ3mpFfsttJRoEL3s8NM4 /ibI7yfYESGf448D7HQEC7Attsfo+36yLodipUtvIi/PtJyLF9XSssou3mQMvhusrs5hHDw1yo3 GsvGboE1WJszao0zDi9uUv/WfL5FoZEm6EkDIMc08xLUD0omTfsNl2CPOnJcGdSpuL0g977DrSU TsYycSMY10j2+VeqbcMX2fwT+6iS6V/17lkSOSo+obrm8+JLz0rgVEivjHszIpDo/cW7SA3d/eo Gx1TU41R/zhRKmQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang Variable TEST_COUNT are used in mptcp_connect.sh and mptcp_join.sh as test counters, which are initialized to 0, while variable test_cnt are used in diag.sh and simult_flows.sh, which are initialized to 1. To maintain consistency, this patch renames them all as MPTCP_LIB_TEST_COUNTER, initializes it to 1, and exports it into mptcp_lib.sh. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/diag.sh | 5 ++--- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 3 +-- tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 +++++++-------- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 2 ++ tools/testing/selftests/net/mptcp/simult_flows.sh | 5 ++--- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh index afe862895946..b63510ce2327 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -9,7 +9,6 @@ . "$(dirname "${0}")/mptcp_lib.sh" ns="" -test_cnt=1 timeout_poll=30 timeout_test=$((timeout_poll * 2 + 1)) ret=0 @@ -69,7 +68,7 @@ __chk_nr() echo "[ ok ]" mptcp_lib_result_pass "${msg}" fi - test_cnt=$((test_cnt+1)) + MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1)) } __chk_msk_nr() @@ -127,7 +126,7 @@ wait_msk_nr() echo "[ ok ]" mptcp_lib_result_pass "${msg}" fi - test_cnt=$((test_cnt+1)) + MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1)) } chk_msk_fallback_nr() diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index ce9342b241cd..915faee77e25 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -131,7 +131,6 @@ ns2="" ns3="" ns4="" -TEST_COUNT=0 TEST_GROUP="" # This function is used in the cleanup trap @@ -321,7 +320,7 @@ do_transfer() local extra_args="$7" port=$((port + 1)) - TEST_COUNT=$((TEST_COUNT+1)) + MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1)) if [ "$rcvbuf" -gt 0 ]; then extra_args="$extra_args -R $rcvbuf" diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 1df2d24979a0..4ef0d5ae9dae 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -48,7 +48,6 @@ declare -A all_tests declare -a only_tests_ids declare -a only_tests_names declare -A failed_tests -TEST_COUNT=0 TEST_NAME="" nr_blank=6 @@ -172,7 +171,7 @@ cleanup() print_title() { - printf "%03u %s\n" "${TEST_COUNT}" "${TEST_NAME}" + printf "%03u %s\n" "${MPTCP_LIB_TEST_COUNTER}" "${TEST_NAME}" } print_check() @@ -233,7 +232,7 @@ skip_test() local i for i in "${only_tests_ids[@]}"; do - if [ "${TEST_COUNT}" -eq "${i}" ]; then + if [ "${MPTCP_LIB_TEST_COUNTER}" -eq "${i}" ]; then return 1 fi done @@ -268,7 +267,7 @@ reset() TEST_NAME="${1}" - TEST_COUNT=$((TEST_COUNT+1)) + MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1)) if skip_test; then last_test_ignored=1 @@ -462,7 +461,7 @@ fail_test() # just in case a test is marked twice as failed if [ ${last_test_failed} -eq 0 ]; then - failed_tests[${TEST_COUNT}]="${TEST_NAME}" + failed_tests[${MPTCP_LIB_TEST_COUNTER}]="${TEST_NAME}" dump_stats last_test_failed=1 fi @@ -973,7 +972,7 @@ do_transfer() local srv_proto="$4" local connect_addr="$5" - local port=$((10000 + TEST_COUNT - 1)) + local port=$((10000 + MPTCP_LIB_TEST_COUNTER - 1)) local cappid local FAILING_LINKS=${FAILING_LINKS:-""} local fastclose=${fastclose:-""} @@ -991,9 +990,9 @@ do_transfer() capuser="-Z $SUDO_USER" fi - capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}") + capfile=$(printf "mp_join-%02u-%s.pcap" "$MPTCP_LIB_TEST_COUNTER" "${listener_ns}") - echo "Capturing traffic for test $TEST_COUNT into $capfile" + echo "Capturing traffic for test $MPTCP_LIB_TEST_COUNTER into $capfile" ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 & cappid=$! diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index 5d071b6eb780..63abf4431993 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -10,6 +10,8 @@ readonly KSFT_TEST="${MPTCP_LIB_KSFT_TEST:-$(basename "${0}" .sh)}" MPTCP_LIB_SUBTESTS=() MPTCP_LIB_SUBTESTS_DUPLICATED=0 +# shellcheck disable=SC2034 # unused at this moment +MPTCP_LIB_TEST_COUNTER=0 # only if supported (or forced) and not disabled, see no-color.org if { [ -t 1 ] || [ "${SELFTESTS_MPTCP_LIB_COLOR_FORCE:-}" = "1" ]; } && diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh index 365fb3d6ef55..3ad663e38c42 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -14,7 +14,6 @@ ns3="" capture=false timeout_poll=30 timeout_test=$((timeout_poll * 2 + 1)) -test_cnt=1 ret=0 bail=0 slack=50 @@ -126,8 +125,8 @@ do_transfer() local sin=$2 local max_time=$3 local port - port=$((10000+test_cnt)) - test_cnt=$((test_cnt+1)) + port=$((10000+MPTCP_LIB_TEST_COUNTER)) + MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1)) :> "$cout" :> "$sout" From patchwork Fri Mar 8 22:10:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 778978 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 AD07860EEA; Fri, 8 Mar 2024 22:10:43 +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=1709935843; cv=none; b=WZekmwdYMDeOxouZFVGEEoAMb07Gec2BYiifRzsC0x4KDXoX/WuLtCnlscrwiT8aWy4bGDyOTUVgKoSHeCoEINjrccgQNslKoAEgT5NDOU7gHhGZiwLKXeg4pgBVLqFhNucAzMq196mK3R8ng5dJp28SzVOCbHTLXgzM/4ZDa7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935843; c=relaxed/simple; bh=5iHWN71u8FnrK4su6Pxr/Ce0MriuDLNYlOjgzzlB7lY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TvkFS63HS3tnI4Dc1eJBrDBuwP3GaPHKFsaaejzurxCHxvmuy7xe2nJt4529MydQmpLzvmynGjXdSjXbqzLEZt7aSPZfJVHOhnXG8Lt88Uu+jHZuV+D15HTLq1Rct3gh+SKuZMXxgEVIXD+vZjXISm5JQeEuRb5ovShmvx5HtbE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A8tnEfSB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A8tnEfSB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68607C43330; Fri, 8 Mar 2024 22:10:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935843; bh=5iHWN71u8FnrK4su6Pxr/Ce0MriuDLNYlOjgzzlB7lY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=A8tnEfSBg8Kwq1Y/Bs+IixZI7dw75NMN2yuJMbs1erozPbmNPLm5uY9nDXuAw4k27 yEZXINuJrOA+py4fi7c/jH8tFiuR3D91OVB/d3Gvgk/XTBJmtmCqrCjD27MdfvWn4F z7AKInBBFmHliTCo1AFwIHSnje580W7djsUTHTS/8+qokOdUV8rDfjwfwRLP2New63 HptGNPcRo05X10BMwr6QkRF0X0xJN8NSzUhK1r2Pxsqvxh7mxWsYaxv1YoMcHmc+qE 9jI2HlFxyQEBx4zMdRmnLtBvVBzoY8YNGDtdGuEV9Ynm3c8tWsDCFhThsjWqzr4fk+ 59/JJogKpf64w== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:13 +0100 Subject: [PATCH net-next 06/15] selftests: mptcp: add print_title in mptcp_lib Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-6-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , 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)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3139; i=matttbe@kernel.org; h=from:subject:message-id; bh=c/Oh+VCrsNdpQsgZKz9EFklI8GqtmsKHi5z+kv2litY=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zJD7ExCtlDuWREcVMp9xcn1281k9X5EM/ZN RQenMrK32aJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMyQAKCRD2t4JPQmmg c2YPD/93Ko4cF68+Bg5GbARE8tDdFC9mUXn89IYoFs2ySwe4Id1kAycSKI+pGQMtyizyfFGoA1/ +FoSD+46RnrFapRBWFduTd6J5TGqmefRfBOaVNSnnjmVGyggBGV7HpTY1m5dOCXYkiDC8oOJFq5 m6YvZZg1L33n+TfduX+XiI+yCD+B4/AhMMYEUQXT186BLIHWMNkAyl8f68GCQVBJ53DrgoC4tPB W1gDwJg/k5D35KIDuisENjmPEKWmVN7eypvaN5UHBG84w52VqkZr26vOPF6jvXgD9X3YkgG/UdB 7K3g+YDJ7uKEvqcNLRPsBnRV14S73O10gm3J9/wy1Jeigj+vqXXfUPdulilMh9WdePXzDA6Oohw hfV29Q4ohPAJDmnUpSdVXQewt6cU7hjIrYY6YmYDyma4kt7gMGpzlgrxWo6oQLyi+fDEG7PC2T1 rko+K7Z52WXvQjTXryV/Dr0s2ngrgAt1mO8Syx6uecql23x0Cc5r5hdxsfmYQcEzaa8WR6pszJ1 AiA83X9ebf+axkzNkGw5fDUYgodfvSpKbin3wMj/cFejMyKeKJKxXf37C+1I78VCZ35Rob2oIGd KoypXulzQZPv5ZCdrz5z8s9nv1BJGbXisEMQOYd7NQgcnW2FMSkUZwDuIKOpT7sSzp44wNb63WM BOpu51YrUEERyOg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang This patch adds a new variable MPTCP_LIB_TEST_FORMAT as the test title printing format. Also add a helper mptcp_lib_print_title() to use this format to print the test title with test counters. They are used in mptcp_join.sh first. Each MPTCP selftest is having subtests, and it helps to give them a number to quickly identify them. This can be managed by mptcp_lib.sh, reusing what has been done here. The following commit will use these new helpers in the other tests. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 13 ++++--------- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 10 +++++++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 4ef0d5ae9dae..2f34e2b9a1c4 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -48,6 +48,7 @@ declare -A all_tests declare -a only_tests_ids declare -a only_tests_names declare -A failed_tests +MPTCP_LIB_TEST_FORMAT="%03u %s\n" TEST_NAME="" nr_blank=6 @@ -169,11 +170,6 @@ cleanup() cleanup_partial } -print_title() -{ - printf "%03u %s\n" "${MPTCP_LIB_TEST_COUNTER}" "${TEST_NAME}" -} - print_check() { printf "%-${nr_blank}s%-36s" " " "${*}" @@ -232,7 +228,7 @@ skip_test() local i for i in "${only_tests_ids[@]}"; do - if [ "${MPTCP_LIB_TEST_COUNTER}" -eq "${i}" ]; then + if [ "$((MPTCP_LIB_TEST_COUNTER+1))" -eq "${i}" ]; then return 1 fi done @@ -267,14 +263,13 @@ reset() TEST_NAME="${1}" - MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1)) - if skip_test; then + MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1)) last_test_ignored=1 return 1 fi - print_title + mptcp_lib_print_title "${TEST_NAME}" if [ "${init}" != "1" ]; then init diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index 63abf4431993..eb740a2f7898 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -10,8 +10,8 @@ readonly KSFT_TEST="${MPTCP_LIB_KSFT_TEST:-$(basename "${0}" .sh)}" MPTCP_LIB_SUBTESTS=() MPTCP_LIB_SUBTESTS_DUPLICATED=0 -# shellcheck disable=SC2034 # unused at this moment MPTCP_LIB_TEST_COUNTER=0 +MPTCP_LIB_TEST_FORMAT="%02u %-50s" # only if supported (or forced) and not disabled, see no-color.org if { [ -t 1 ] || [ "${SELFTESTS_MPTCP_LIB_COLOR_FORCE:-}" = "1" ]; } && @@ -412,3 +412,11 @@ mptcp_lib_events() { ip netns exec "${ns}" ./pm_nl_ctl events >> "${evts}" 2>&1 & pid=$! } + +mptcp_lib_print_title() { + : "${MPTCP_LIB_TEST_COUNTER:?}" + : "${MPTCP_LIB_TEST_FORMAT:?}" + + # shellcheck disable=SC2059 # the format is in a variable + printf "${MPTCP_LIB_TEST_FORMAT}" "$((++MPTCP_LIB_TEST_COUNTER))" "${*}" +} From patchwork Fri Mar 8 22:10:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 779340 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 79BAD604AE; Fri, 8 Mar 2024 22:10:47 +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=1709935847; cv=none; b=nKmiRuckE7EQL8CK8JXlyrdEjanwnRz4OzBsj5LKASnAwbIm2ce/8CJqHcxMT7Xp5ZJUbAtHXRVuLNcARu5lkLo8/okomZxinwtKlVVYk6lIwCVsdOxjKpArwZv+JqMoQQ8JjFdpaMLR8QDY9kDJ4Fz5swLlyg0Pg+azlmeWfE8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935847; c=relaxed/simple; bh=k3pO3hnLCW/alnlqIUwAbF2UvgKeQHQuP8aHNnAk8HM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hPToTKiyZokKWVL2NLC9xYqiezIPr0Zm/SxQLyMc6BFsMUgb2eFV244a6u6TFyzWgEnoq9vVaJ09wit+7vZ3cRBvGYa4blg+DZWz0QuWudhvAPz4wNPNe4UMnnN1Qz2QPtJ2MXvlQ2wq18ZeUs+0xCjTNbW05Pquz178u8BaYso= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rit7KkAy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rit7KkAy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4D95C433C7; Fri, 8 Mar 2024 22:10:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935847; bh=k3pO3hnLCW/alnlqIUwAbF2UvgKeQHQuP8aHNnAk8HM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rit7KkAy9BK0mjHDy3Ao4UFqmYdKbae3cu0tBaAjCNo9uyF3/m8tvNGj2BuLFWTBF +KUaa2Z3RvISXynO8MOFv/D0znIYzH+R+gH9v9j7gMA6c8tczf5/nOVKEsYxQ8w8TR 0w2kSynFZVN8+UUBeOtPbrSwCRjWrWq8d8VheGsXayDxoWiQk4n64lgxuofEqH7cfI 8Vxm2qLVJ9o+i/J/QqVMQlJMU/UVbvZvxU3+9ZBN5owUg17xkp/71uvGz3E3dnr7xE PNm05XPBzPJH+iTYyDuAWhYwli8t5dGAPg7D0dkYKXfr3GTyMdRjsrk4JpMxUl0AGy IIz2F/ml6VGdA== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:14 +0100 Subject: [PATCH net-next 07/15] selftests: mptcp: print test results with counters Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-7-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , 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)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8730; i=matttbe@kernel.org; h=from:subject:message-id; bh=DjHe3xAzBiAiqIyC1BiWr2qIGtMGUJkKvi+FFhkNfuE=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zJjcM0NGUIHMzJGAVkeGA3DIxFJyj7gawsv 3XX62rlWzyJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMyQAKCRD2t4JPQmmg c9tMD/0ZoZIZoVlJLVbfldNJalShseMQTSvsfEysN5Ot6e+4TX8nVJN0mlJTyRyAMr2KjsRnO9x OBFi+FNV+Dgfr4+NjyMTy2PMo0Zy9uHnZsEYvElGQcrn4oc2+f98B2PY3jSQYeihADgae+9z4aq CUbzwZTt7/2/qlS7XI4116Pc/CXz/WkkAidZbvqhvvPTIhMC/g7/S+nQSyiko2gyS76BWghkRL8 Pf7S8Lkv212452IF4nCYmm9WXOhKR3ESj2EqDC5l5Kt0ay+GcoMwrZn/NJthVDxA6Rew5R0c2Jv Pmn30DeWiPfAfLn7w6tGpNIF2ftE9CepT9A+5VG+PvW+9pfYYD/LCX6g8zw1h4X6lmuAcrG3Jek gOu4tb28MlC6/T1jegfIbwKZAiv0zG3n2hII9xre2v0fqduiQ3YranQzg8iIja9xnrHCSyC5Nf1 g2I2/M0NMes62LL1jcdbqIdNcFXg/dmZ+/LKs36twfjGFLU/VjDSPtP6+d4ZZp0knrolXcaekNF cIwD3LUrwOTRP2bzzj6V8EnAfpfOVOlCIUhcBTcPAu+amQvcvusKZyR9fhYpA5EcBdLLvLeN8tS arnugFwNjSkx2ArXjbRkW3q3Go6c8GlOu4gVtLAQSC3iS79skVK+4VYtcnpALM+3jhWadHUFVLN aZp0j8XHn0Hxlyg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang This patch adds a new helper mptcp_lib_print_title(), a wrapper of mptcp_lib_inc_test_counter() and mptcp_lib_pr_title_counter(), to print out test counter in each test result and increase the counter. Use this helper to print out test counters for every tests in diag.sh, mptcp_connect.sh, mptcp_sockopt.sh, pm_netlink.sh, simult_flows.sh, and userspace_pm.sh. diag.sh: 01 no msk on netns creation [ ok ] 02 listen match for dport 10000 [ ok ] 03 listen match for sport 10000 [ ok ] 04 listen match for saddr and sport [ ok ] 05 all listen sockets [ ok ] mptcp_connect.sh: 01 New MPTCP socket can be blocked via sysctl [ OK ] 02 Validating network environment with pings [ OK ] INFO: Using loss of 0.85% delay 31 ms reorder .. with delay 7ms on ns3eth4 03 ns1 MPTCP -> ns1 (10.0.1.1:10000 ) MPTCP (duration 69ms) [ OK ] 04 ns1 MPTCP -> ns1 (10.0.1.1:10001 ) TCP (duration 20ms) [ OK ] 05 ns1 TCP -> ns1 (10.0.1.1:10002 ) MPTCP (duration 16ms) [ OK ] mptcp_sockopt.sh: 01 Transfer v4 [ OK ] 02 Mark v4 [ OK ] 03 Transfer v6 [ OK ] 04 Mark v6 [ OK ] 05 SOL_MPTCP sockopt v4 [ OK ] pm_netlink.sh: 01 defaults addr list [ OK ] 02 simple add/get addr [ OK ] 03 dump addrs [ OK ] 04 simple del addr [ OK ] 05 dump addrs after del [ OK ] simult_flows.sh: 01 balanced bwidth 7391 max 8456 [ OK ] 02 balanced bwidth - reverse direction 7403 max 8456 [ OK ] 03 balanced bwidth with unbalanced delay 7429 max 8456 [ OK ] 04 balanced bwidth with unbalanced delay - reverse ... 7485 max 8456 [ OK ] 05 unbalanced bwidth 7549 max 8456 [ OK ] userspace_pm.sh: 01 Created network namespaces ns1, ns2 [ OK ] INFO: Make connections 02 Established IPv4 MPTCP Connection ns2 => ns1 [ OK ] 03 Established IPv6 MPTCP Connection ns2 => ns1 [ OK ] INFO: Announce tests 04 ADD_ADDR 10.0.2.2 (ns2) => ns1, invalid token [ OK ] 05 ADD_ADDR id:67 10.0.2.2 (ns2) => ns1, reuse port [ OK ] Having test counters helps to quickly identify issues when looking at a long list of output logs and results. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/diag.sh | 6 ++---- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 6 +++--- tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 2 +- tools/testing/selftests/net/mptcp/pm_netlink.sh | 5 +++-- tools/testing/selftests/net/mptcp/simult_flows.sh | 7 ++++--- tools/testing/selftests/net/mptcp/userspace_pm.sh | 4 +++- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh index b63510ce2327..4ffdd415e670 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -54,7 +54,7 @@ __chk_nr() nr=$(eval $command) - printf "%-50s" "$msg" + mptcp_lib_print_title "$msg" if [ "$nr" != "$expected" ]; then if [ "$nr" = "$skip" ] && ! mptcp_lib_expect_all_features; then echo "[ skip ] Feature probably not supported" @@ -68,7 +68,6 @@ __chk_nr() echo "[ ok ]" mptcp_lib_result_pass "${msg}" fi - MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1)) } __chk_msk_nr() @@ -113,7 +112,7 @@ wait_msk_nr() sleep 1 done - printf "%-50s" "$msg" + mptcp_lib_print_title "$msg" if [ $i -ge $timeout ]; then echo "[ fail ] timeout while expecting $expected max $max last $nr" mptcp_lib_result_fail "${msg} # timeout" @@ -126,7 +125,6 @@ wait_msk_nr() echo "[ ok ]" mptcp_lib_result_pass "${msg}" fi - MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1)) } chk_msk_fallback_nr() diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index 915faee77e25..bbda37d6514f 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -249,7 +249,8 @@ fi print_larger_title() { # here we don't have the time, a bit longer for the alignment - printf "%-69s" "${@}" + MPTCP_LIB_TEST_FORMAT="%02u %-69s" \ + mptcp_lib_print_title "${@}" } check_mptcp_disabled() @@ -320,7 +321,6 @@ do_transfer() local extra_args="$7" port=$((port + 1)) - MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1)) if [ "$rcvbuf" -gt 0 ]; then extra_args="$extra_args -R $rcvbuf" @@ -347,7 +347,7 @@ do_transfer() addr_port=$(printf "%s:%d" ${connect_addr} ${port}) local result_msg result_msg="$(printf "%.3s %-5s -> %.3s (%-20s) %-5s" ${connector_ns} ${cl_proto} ${listener_ns} ${addr_port} ${srv_proto})" - printf "%-50s" "${result_msg}" + mptcp_lib_print_title "${result_msg}" if $capture; then local capuser diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh index 17b36c1312f4..19d0ac31b6a9 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -115,7 +115,7 @@ check_mark() print_title() { - printf "%-50s" "${@}" + mptcp_lib_print_title "${@}" } do_transfer() diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index 427fc5c70b3c..5b9bc25dfef4 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -53,7 +53,7 @@ check() local msg="$3" local rc=0 - printf "%-50s" "$msg" + mptcp_lib_print_title "$msg" mptcp_lib_check_output "${err}" "${cmd}" "${expected}" || rc=${?} if [ ${rc} -eq 2 ]; then mptcp_lib_result_fail "${msg} # error ${rc}" @@ -189,7 +189,8 @@ subflow,backup,fullmesh 10.0.1.1" " (backup,fullmesh)" else for st in fullmesh nofullmesh backup,fullmesh; do st=" (${st})" - printf "%-50s%s\n" "${st}" "[SKIP]" + mptcp_lib_print_title "${st}" + echo "[SKIP]" mptcp_lib_result_skip "${st}" done fi diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh index 3ad663e38c42..b7549d9364d6 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -14,6 +14,8 @@ ns3="" capture=false timeout_poll=30 timeout_test=$((timeout_poll * 2 + 1)) +# a bit more space: because we have more to display +MPTCP_LIB_TEST_FORMAT="%02u %-60s" ret=0 bail=0 slack=50 @@ -126,7 +128,6 @@ do_transfer() local max_time=$3 local port port=$((10000+MPTCP_LIB_TEST_COUNTER)) - MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1)) :> "$cout" :> "$sout" @@ -238,7 +239,7 @@ run_test() # completion (see mptcp_connect): 200ms on each side, add some slack time=$((time + 400 + slack)) - printf "%-60s" "$msg" + mptcp_lib_print_title "$msg" do_transfer $small $large $time lret=$? mptcp_lib_result_code "${lret}" "${msg}" @@ -248,7 +249,7 @@ run_test() fi msg+=" - reverse direction" - printf "%-60s" "${msg}" + mptcp_lib_print_title "${msg}" do_transfer $large $small $time lret=$? mptcp_lib_result_code "${lret}" "${msg}" diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index b0cce8f065d8..ca238592baee 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -54,6 +54,8 @@ ns1="" ns2="" ret=0 test_name="" +# a bit more space: because we have more to display +MPTCP_LIB_TEST_FORMAT="%02u %-68s" _printf() { stdbuf -o0 -e0 printf "${@}" @@ -69,7 +71,7 @@ print_test() { test_name="${1}" - _printf "%-68s" "${test_name}" + mptcp_lib_print_title "${test_name}" } print_results() From patchwork Fri Mar 8 22:10:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 778977 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 BEC98626CB; Fri, 8 Mar 2024 22:10:50 +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=1709935850; cv=none; b=WKx5dmvnw1Lo2TWTyZxR9aknZwjPIIghfC+9FQ/nL6S42CpTHES/RGc4MPKjTS0QyJcTL1zLoBgQKqdBQaJmQ63o4xDn4kBU9XmOpaXqWd4FryNyDM2zRQ4dp1xOSWY1p9qPvpsfqL+vmmiikyE91QIuHHfmcD+bZFQV5Zz88Cw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935850; c=relaxed/simple; bh=q3m/d7yCdtsrxUydsniJZyBpMcyHpEysCb+mRWQJC8Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LsfToHMp9sqcQxpk5PyUcU6zuBG87D5sEreJzmBkSaeZMM8VyqbwyHXlC6NfuhO4wyNkexyGG6XkzRuKcXmXDRr5t8SxeoxagY3l4T3CNtyVDetTy1B5E8JsrA4b0+gkIW8LTvYU2AOqScB1K/QUQyMViVhAlykcaKeZ57pmHt0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A93w+COl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A93w+COl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 917A8C43394; Fri, 8 Mar 2024 22:10:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935850; bh=q3m/d7yCdtsrxUydsniJZyBpMcyHpEysCb+mRWQJC8Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=A93w+COlV9Um2obv67LxtdSuKBVSjQlUDgOCf/PpxNp2T2egrD5XtB3pwscF+dqLd 2xtS/t0taJosVRNItSbN6Ye8v4DOK5gstF9MDfTt6AGNQGC19CYmvLmkxjURrXZU+B G4VYx3I8Tr3cS93Psv+J8E/8Ygb3jotb7+Qosgmy9uIhkPcmZvUJvHNzIeLKSropVq stM5ZqYx5R10a0D5YZKTpKWnVSJ6XoDSo7Kt9GU2HBGMywTefVCO6UgKrs1FWpRqOV ZpkEP99YIztJBEQSpx+DtHRH7ckSN3xQxT2PljqpM9sTQXlGd72ng1bVhlxiPGgOkg 5EBBp7R+gM2MA== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:15 +0100 Subject: [PATCH net-next 08/15] selftests: mptcp: use += operator to append strings Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-8-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , 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)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8534; i=matttbe@kernel.org; h=from:subject:message-id; bh=1BDUdqInfX3BPSCLx67+D/8WGffyV6zeq++VeSyyKik=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zJDFCBKmrkYRDFq5auLmcO5dLo665i3Zsdm V0reLO26KeJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMyQAKCRD2t4JPQmmg cyfZD/wPHc+pgzHmhEDxOAQhumjxGAH/xgPY8K3hoTc+Gu4pEPfVzg0j7BPWrKQ77+pi/ZKBsb0 0hkCSLP3X2XUkPYB3L9QGvqqOQrzHZQAaI9kK3nbVz85H7MTNUs2Bsh0xKvNgqkx+aH0xovxpBU YLHv0tu4pE7zblv5mTM97q8iz0glladGv+KWfAe8wTtYBApk22bKzprws3TtB45eghuTBsMFoC+ I3A+hidF8UG/6Nk0kjmT0i5keeCllAyBaOC5pTevLrK9v0Q1/YwbfZlAO6YkXHltt4qM/P3lhcK DHUOyHh9oUOB7dtAEv9tigwbuvMMIATXr0jrXwdqxBzjqUEvU9HAjBPxMIE8qxLiillISshvb0R q7r5Soyh3Cw5l1rJa9NBsj01x3o0XnIgyF5rFnZAVH2zBab5LlrVKq5+Sor8re2EvOYrZc4xnoH p5sezWzemsI1uUEZXlQBMfRAbJqEuzKl/MAv9i3i/xWdel8JZm7qw7VMzLn/jVnpG3li6QTJGVt xHn58erXRaSVCyWCBMqCX4Ko1LzDm5KgeoTqrPyMnnSjbR9ruckMAUX+BllG6FSiPFox4HpcwEJ +76TMEzPoE/daOtM2cT5suZp1p73LueqnpCFM7+J5jSODxy40geP2T1nHHhpvcSD3yAa1U2d484 tBuLhRki9kG4V2w== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang This patch uses addition assignment operator (+=) to append strings instead of duplicating the variable name in mptcp_connect.sh and mptcp_join.sh. This can make the statements shorter. Note: in mptcp_connect.sh, add a local variable extra in do_transfer to save the various extra warning logs, using += to append it. And add a new variable tc_info to save various tc info, also using += to append it. This can make the code more readable and prepare for the next commit. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 53 ++++++++++++---------- tools/testing/selftests/net/mptcp/mptcp_join.sh | 30 ++++++------ 2 files changed, 43 insertions(+), 40 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index bbda37d6514f..78098546ddd3 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -323,15 +323,15 @@ do_transfer() port=$((port + 1)) if [ "$rcvbuf" -gt 0 ]; then - extra_args="$extra_args -R $rcvbuf" + extra_args+=" -R $rcvbuf" fi if [ "$sndbuf" -gt 0 ]; then - extra_args="$extra_args -S $sndbuf" + extra_args+=" -S $sndbuf" fi if [ -n "$testmode" ]; then - extra_args="$extra_args -m $testmode" + extra_args+=" -m $testmode" fi if [ -n "$extra_args" ] && $options_log; then @@ -451,6 +451,7 @@ do_transfer() mptcp_lib_check_transfer $cin $sout "file received by server" rets=$? + local extra="" local stat_synrx_now_l local stat_ackrx_now_l local stat_cookietx_now @@ -484,7 +485,7 @@ do_transfer() "${stat_ackrx_now_l}" "${expect_ackrx}" rets=1 else - printf "[ Note ] fallback due to TCP OoO" + extra+=" [ Note ] fallback due to TCP OoO" fi fi @@ -507,39 +508,41 @@ do_transfer() fi fi - if [ $retc -eq 0 ] && [ $rets -eq 0 ]; then - printf "[ OK ]" - mptcp_lib_result_pass "${TEST_GROUP}: ${result_msg}" - else - mptcp_lib_result_fail "${TEST_GROUP}: ${result_msg}" - fi - if [ $cookies -eq 2 ];then if [ $stat_cookietx_last -ge $stat_cookietx_now ] ;then - printf " WARN: CookieSent: did not advance" + extra+=" WARN: CookieSent: did not advance" fi if [ $stat_cookierx_last -ge $stat_cookierx_now ] ;then - printf " WARN: CookieRecv: did not advance" + extra+=" WARN: CookieRecv: did not advance" fi else if [ $stat_cookietx_last -ne $stat_cookietx_now ] ;then - printf " WARN: CookieSent: changed" + extra+=" WARN: CookieSent: changed" fi if [ $stat_cookierx_last -ne $stat_cookierx_now ] ;then - printf " WARN: CookieRecv: changed" + extra+=" WARN: CookieRecv: changed" fi fi if [ ${stat_synrx_now_l} -gt ${expect_synrx} ]; then - printf " WARN: SYNRX: expect %d, got %d (probably retransmissions)" \ - "${expect_synrx}" "${stat_synrx_now_l}" + extra+=" WARN: SYNRX: expect ${expect_synrx}," + extra+=" got ${stat_synrx_now_l} (probably retransmissions)" fi if [ ${stat_ackrx_now_l} -gt ${expect_ackrx} ]; then - printf " WARN: ACKRX: expect %d, got %d (probably retransmissions)" \ - "${expect_ackrx}" "${stat_ackrx_now_l}" + extra+=" WARN: ACKRX: expect ${expect_ackrx}," + extra+=" got ${stat_ackrx_now_l} (probably retransmissions)" + fi + + if [ $retc -eq 0 ] && [ $rets -eq 0 ]; then + printf "[ OK ]%s\n" "${extra:1}" + mptcp_lib_result_pass "${TEST_GROUP}: ${result_msg}" + else + if [ -n "${extra}" ]; then + printf "%s\n" "${extra:1}" + fi + mptcp_lib_result_fail "${TEST_GROUP}: ${result_msg}" fi - echo cat "$capout" [ $retc -eq 0 ] && [ $rets -eq 0 ] } @@ -865,8 +868,8 @@ stop_if_error "Could not even run ping tests" echo "[ OK ]" [ -n "$tc_loss" ] && tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $tc_loss delay ${tc_delay}ms -echo -n "INFO: Using loss of $tc_loss " -test "$tc_delay" -gt 0 && echo -n "delay $tc_delay ms " +tc_info="loss of $tc_loss " +test "$tc_delay" -gt 0 && tc_info+="delay $tc_delay ms " reorder_delay=$((tc_delay / 4)) @@ -877,17 +880,17 @@ if [ -z "${tc_reorder}" ]; then if [ $reorder_delay -gt 0 ] && [ $reorder1 -lt 100 ] && [ $reorder2 -gt 0 ]; then tc_reorder="reorder ${reorder1}% ${reorder2}%" - echo -n "$tc_reorder with delay ${reorder_delay}ms " + tc_info+="$tc_reorder with delay ${reorder_delay}ms " fi elif [ "$tc_reorder" = "0" ];then tc_reorder="" elif [ "$reorder_delay" -gt 0 ];then # reordering requires some delay tc_reorder="reorder $tc_reorder" - echo -n "$tc_reorder with delay ${reorder_delay}ms " + tc_info+="$tc_reorder with delay ${reorder_delay}ms " fi -echo "on ns3eth4" +echo "INFO: Using ${tc_info}on ns3eth4" tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${reorder_delay}ms $tc_reorder diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 2f34e2b9a1c4..d2969eec36d5 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -754,18 +754,18 @@ pm_nl_check_endpoint() line="${line% }" # the dump order is: address id flags port dev [ -n "$addr" ] && expected_line="$addr" - expected_line="$expected_line $id" - [ -n "$_flags" ] && expected_line="$expected_line ${_flags//","/" "}" - [ -n "$dev" ] && expected_line="$expected_line $dev" - [ -n "$port" ] && expected_line="$expected_line $port" + expected_line+=" $id" + [ -n "$_flags" ] && expected_line+=" ${_flags//","/" "}" + [ -n "$dev" ] && expected_line+=" $dev" + [ -n "$port" ] && expected_line+=" $port" else line=$(ip netns exec $ns ./pm_nl_ctl get $_id) # the dump order is: id flags dev address port expected_line="$id" - [ -n "$flags" ] && expected_line="$expected_line $flags" - [ -n "$dev" ] && expected_line="$expected_line $dev" - [ -n "$addr" ] && expected_line="$expected_line $addr" - [ -n "$_port" ] && expected_line="$expected_line $_port" + [ -n "$flags" ] && expected_line+=" $flags" + [ -n "$dev" ] && expected_line+=" $dev" + [ -n "$addr" ] && expected_line+=" $addr" + [ -n "$_port" ] && expected_line+=" $_port" fi if [ "$line" = "$expected_line" ]; then print_ok @@ -1216,7 +1216,7 @@ chk_csum_nr() print_check "sum" count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtDataCsumErr") if [ "$count" != "$csum_ns1" ]; then - extra_msg="$extra_msg ns1=$count" + extra_msg+=" ns1=$count" fi if [ -z "$count" ]; then print_skip @@ -1229,7 +1229,7 @@ chk_csum_nr() print_check "csum" count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtDataCsumErr") if [ "$count" != "$csum_ns2" ]; then - extra_msg="$extra_msg ns2=$count" + extra_msg+=" ns2=$count" fi if [ -z "$count" ]; then print_skip @@ -1273,7 +1273,7 @@ chk_fail_nr() print_check "ftx" count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPFailTx") if [ "$count" != "$fail_tx" ]; then - extra_msg="$extra_msg,tx=$count" + extra_msg+=",tx=$count" fi if [ -z "$count" ]; then print_skip @@ -1287,7 +1287,7 @@ chk_fail_nr() print_check "failrx" count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtMPFailRx") if [ "$count" != "$fail_rx" ]; then - extra_msg="$extra_msg,rx=$count" + extra_msg+=",rx=$count" fi if [ -z "$count" ]; then print_skip @@ -1322,7 +1322,7 @@ chk_fclose_nr() if [ -z "$count" ]; then print_skip elif [ "$count" != "$fclose_tx" ]; then - extra_msg="$extra_msg,tx=$count" + extra_msg+=",tx=$count" fail_test "got $count MP_FASTCLOSE[s] TX expected $fclose_tx" else print_ok @@ -1333,7 +1333,7 @@ chk_fclose_nr() if [ -z "$count" ]; then print_skip elif [ "$count" != "$fclose_rx" ]; then - extra_msg="$extra_msg,rx=$count" + extra_msg+=",rx=$count" fail_test "got $count MP_FASTCLOSE[s] RX expected $fclose_rx" else print_ok @@ -1702,7 +1702,7 @@ chk_rm_nr() count=$((count + cnt)) if [ "$count" != "$rm_subflow_nr" ]; then suffix="$count in [$rm_subflow_nr:$((rm_subflow_nr*2))]" - extra_msg="$extra_msg simult" + extra_msg+=" simult" fi if [ $count -ge "$rm_subflow_nr" ] && \ [ "$count" -le "$((rm_subflow_nr *2 ))" ]; then From patchwork Fri Mar 8 22:10:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 779339 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 C7F7B60DC4; Fri, 8 Mar 2024 22:10:54 +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=1709935854; cv=none; b=UUpSz5Gmx3/yeg7lqK8rq2uP983YhcKbKt2LUzQb79vfdmDthH8xbCyaDQeFc6wJRf4kxv9B9g9fzal7Ru1BM+Co+7AVZ9IY9DSYg3ohDCfPhs1n+Q1dI47EkFMTryHC9+Ff0m/4b5jdFJ6eF+qDAoRJsVxEhuoPqVpLHZiTYx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935854; c=relaxed/simple; bh=uyqvsoaRrnLR6yhPHBS94xllCcIN5fBJ4ncKT8ArQdw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qJ8Me+YSRBQCG+tkRG98h2MgzJKXfWJdUO2xy5BgxSdLGikAFHQRUMCDIpiZHObUeeh1aIS/2IdPtxLRkM5jwsotiGHVeQuJM75o9MGH61pw/arhHxfU530OsXapooPCcUk5sxJAC8pqjjWda8eAp7YtzVwg3LZ2LilK7MP2KBs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IKbzoYNJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IKbzoYNJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BDCAC43142; Fri, 8 Mar 2024 22:10:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935854; bh=uyqvsoaRrnLR6yhPHBS94xllCcIN5fBJ4ncKT8ArQdw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IKbzoYNJc5XGLL6ZJnlHBaZCNX26FYWtMUiqn+vkOlvfrMJ5lDl14cVCj59IiQu8D e9+EKe1OSws3R2BlSQ0miykOt46+gFjBBa5LIpIPxhof/KuKvU3bcrqcH91T7EOn2+ dBxVHAWf/U0lXUJ1O23XJIow0liOssApDp/rD1xUJGfu3hlEy3Dy7kFgf1pfU4WL2z UfEGq7R+N0Q1SnwQKHS+NgaiTBVys5kJA9uusIUjk601w/RVRCv11AT37jeVUHCfir w5GuzEsf47znVZYBikECBdX569pBblRpDYk1EKyziWfaR9OOY5K4obiSIbQu456JNy IPU57b2ZP9tBg== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:16 +0100 Subject: [PATCH net-next 09/15] selftests: mptcp: print test results with colors Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-9-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , 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)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=20899; i=matttbe@kernel.org; h=from:subject:message-id; bh=D4D/pDXl/09Pod0sqxssqWVy5sWk0z7RWDFoFe9BSj8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zJZAadlXyOKcDFxYGnv7PTH95AyZWBcYU4V o/23xfKwO+JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMyQAKCRD2t4JPQmmg c8HsD/4kWc0Wx15H+hhCWtnIl9nyzNLCmyxd29v4/A42D4vjs3pD3yuNbTvLwYjklbyy5fMm0m+ to0kt1TsCzTMzonNQV2XxnSflRodtnMnaitNrYGQdsJcuLId8fxjXuUbCNlUO0cCr7LS3sx+NZ+ egIn+dY0ksk0gjHpyOyU1iEI8s14QH5ndi1A+dd7mKvvZMD1l9mcMPCtp+crYq7S/J68sDzAsm1 hibIkpOCChK+8iF2Yek3//lMTxFFZvfjUiSF9lbPlECn7NVq9NymevZODlcu9A/+wj4r4qJlVxS fhaw8ISrhuF0R7L/sNyud3hA/GhJNymSClm4hOmEeOdkxu0UDl8YN/mJS0tWw4S0IdSdZqxwU+g EGPHmNpv3/4vCFgTHSqacbZyaX+onRdriGLlmWpHX1WIOrTWj9HgD/N3eRaMCy4gfABgJS4i2Ik 3hST2UjvUjzvSXsF2Agu2IJu4OYY4+UiCCj45AveBeGVn5BjpUrTThlB2KTMPYEGWOdIbQVbAwb fcM+dwn6iYVkLxjicl4nLtv+Y+vvns7g1Qn5bgc09mUpMDtSPLxavC1c/1oHJu3MxUpmpw1Fp3q rwNZKU/y44hMJ4odmlrSet/SzLTOorM4H8ADAygnxltkunhvPQhCDbGiQPWlPYEhNk/0ry9ftHy Hi7sROg59m4rMiw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang To unify the output formats of all test scripts, this patch adds four more helpers: mptcp_lib_pr_ok() mptcp_lib_pr_skip() mptcp_lib_pr_fail() mptcp_lib_pr_info() to print out [ OK ], [SKIP], [FAIL] and 'INFO: ' with colors. Use them in all scripts to print the "ok/skip/fail/info' using the same 'format'. Having colors helps to quickly identify issues when looking at a long list of output logs and results. Note that now all print the same keywords, which was not the case before, but it is good to uniform that. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/diag.sh | 12 ++--- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 62 +++++++++++----------- tools/testing/selftests/net/mptcp/mptcp_join.sh | 6 +-- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 36 +++++++++---- tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 28 +++++----- tools/testing/selftests/net/mptcp/pm_netlink.sh | 2 +- tools/testing/selftests/net/mptcp/simult_flows.sh | 4 +- tools/testing/selftests/net/mptcp/userspace_pm.sh | 27 +++------- 8 files changed, 90 insertions(+), 87 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh index 4ffdd415e670..bc97ab33a00e 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -57,15 +57,15 @@ __chk_nr() mptcp_lib_print_title "$msg" if [ "$nr" != "$expected" ]; then if [ "$nr" = "$skip" ] && ! mptcp_lib_expect_all_features; then - echo "[ skip ] Feature probably not supported" + mptcp_lib_pr_skip "Feature probably not supported" mptcp_lib_result_skip "${msg}" else - echo "[ fail ] expected $expected found $nr" + mptcp_lib_pr_fail "expected $expected found $nr" mptcp_lib_result_fail "${msg}" ret=${KSFT_FAIL} fi else - echo "[ ok ]" + mptcp_lib_pr_ok mptcp_lib_result_pass "${msg}" fi } @@ -114,15 +114,15 @@ wait_msk_nr() mptcp_lib_print_title "$msg" if [ $i -ge $timeout ]; then - echo "[ fail ] timeout while expecting $expected max $max last $nr" + mptcp_lib_pr_fail "timeout while expecting $expected max $max last $nr" mptcp_lib_result_fail "${msg} # timeout" ret=${KSFT_FAIL} elif [ $nr != $expected ]; then - echo "[ fail ] expected $expected found $nr" + mptcp_lib_pr_fail "expected $expected found $nr" mptcp_lib_result_fail "${msg} # unexpected result" ret=${KSFT_FAIL} else - echo "[ ok ]" + mptcp_lib_pr_ok mptcp_lib_result_pass "${msg}" fi } diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index 78098546ddd3..cb1837f2761a 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -218,7 +218,7 @@ set_ethtool_flags() { local flags="$3" if ip netns exec $ns ethtool -K $dev $flags 2>/dev/null; then - echo "INFO: set $ns dev $dev: ethtool -K $flags" + mptcp_lib_pr_info "set $ns dev $dev: ethtool -K $flags" fi } @@ -261,7 +261,7 @@ check_mptcp_disabled() print_larger_title "New MPTCP socket can be blocked via sysctl" # net.mptcp.enabled should be enabled by default if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ print $3 }')" -ne 1 ]; then - echo -e "net.mptcp.enabled sysctl is not 1 by default\t\t[ FAIL ]" + mptcp_lib_pr_fail "net.mptcp.enabled sysctl is not 1 by default" mptcp_lib_result_fail "net.mptcp.enabled sysctl is not 1 by default" ret=1 return 1 @@ -274,13 +274,13 @@ check_mptcp_disabled() mptcp_lib_ns_exit "${disabled_ns}" if [ ${err} -eq 0 ]; then - echo -e "New MPTCP socket cannot be blocked via sysctl\t\t[ FAIL ]" + mptcp_lib_pr_fail "New MPTCP socket cannot be blocked via sysctl" mptcp_lib_result_fail "New MPTCP socket cannot be blocked via sysctl" ret=1 return 1 fi - echo "[ OK ]" + mptcp_lib_pr_ok mptcp_lib_result_pass "New MPTCP socket can be blocked via sysctl" return 0 } @@ -301,7 +301,7 @@ do_ping() ip netns exec ${connector_ns} ping ${ping_args} $connect_addr >/dev/null || rc=1 if [ $rc -ne 0 ] ; then - echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" + mptcp_lib_pr_fail "$listener_ns -> $connect_addr connectivity" ret=1 return 1 @@ -335,7 +335,7 @@ do_transfer() fi if [ -n "$extra_args" ] && $options_log; then - echo "INFO: extra options: $extra_args" + mptcp_lib_pr_info "extra options: $extra_args" fi options_log=false @@ -432,7 +432,7 @@ do_transfer() result_msg+=" # time=${duration}ms" printf "(duration %05sms) " "${duration}" if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then - echo "[ FAIL ] client exit code $retc, server $rets" 1>&2 + mptcp_lib_pr_fail "client exit code $retc, server $rets" echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port" cat /tmp/${listener_ns}.out @@ -475,14 +475,14 @@ do_transfer() fi if [ ${stat_synrx_now_l} -lt ${expect_synrx} ]; then - printf "[ FAIL ] lower MPC SYN rx (%d) than expected (%d)\n" \ - "${stat_synrx_now_l}" "${expect_synrx}" + mptcp_lib_pr_fail "lower MPC SYN rx (${stat_synrx_now_l})" \ + "than expected (${expect_synrx})" retc=1 fi if [ ${stat_ackrx_now_l} -lt ${expect_ackrx} ] && [ ${stat_ooo_now} -eq 0 ]; then if [ ${stat_ooo_now} -eq 0 ]; then - printf "[ FAIL ] lower MPC ACK rx (%d) than expected (%d)\n" \ - "${stat_ackrx_now_l}" "${expect_ackrx}" + mptcp_lib_pr_fail "lower MPC ACK rx (${stat_ackrx_now_l})" \ + "than expected (${expect_ackrx})" rets=1 else extra+=" [ Note ] fallback due to TCP OoO" @@ -497,13 +497,13 @@ do_transfer() local csum_err_s_nr=$((csum_err_s - stat_csum_err_s)) if [ $csum_err_s_nr -gt 0 ]; then - printf "[ FAIL ]\nserver got %d data checksum error[s]" ${csum_err_s_nr} + mptcp_lib_pr_fail "server got ${csum_err_s_nr} data checksum error[s]" rets=1 fi local csum_err_c_nr=$((csum_err_c - stat_csum_err_c)) if [ $csum_err_c_nr -gt 0 ]; then - printf "[ FAIL ]\nclient got %d data checksum error[s]" ${csum_err_c_nr} + mptcp_lib_pr_fail "client got ${csum_err_c_nr} data checksum error[s]" retc=1 fi fi @@ -534,11 +534,11 @@ do_transfer() fi if [ $retc -eq 0 ] && [ $rets -eq 0 ]; then - printf "[ OK ]%s\n" "${extra:1}" + mptcp_lib_pr_ok "${extra:1}" mptcp_lib_result_pass "${TEST_GROUP}: ${result_msg}" else if [ -n "${extra}" ]; then - printf "%s\n" "${extra:1}" + mptcp_lib_print_warn "${extra:1}" fi mptcp_lib_result_fail "${TEST_GROUP}: ${result_msg}" fi @@ -668,7 +668,7 @@ run_test_transparent() # following function has been exported (T). Not great but better than # checking for a specific kernel version. if ! mptcp_lib_kallsyms_has "T __ip_sock_set_tos$"; then - echo "INFO: ${msg} not supported by the kernel: SKIP" + mptcp_lib_pr_skip "${msg} not supported by the kernel" mptcp_lib_result_skip "${TEST_GROUP}" return fi @@ -685,7 +685,7 @@ table inet mangle { } EOF then - echo "SKIP: $msg, could not load nft ruleset" + mptcp_lib_pr_skip "$msg, could not load nft ruleset" mptcp_lib_fail_if_expected_feature "nft rules" mptcp_lib_result_skip "${TEST_GROUP}" return @@ -701,7 +701,7 @@ EOF if ! ip -net "$listener_ns" $r6flag rule add fwmark 1 lookup 100; then ip netns exec "$listener_ns" nft flush ruleset - echo "SKIP: $msg, ip $r6flag rule failed" + mptcp_lib_pr_skip "$msg, ip $r6flag rule failed" mptcp_lib_fail_if_expected_feature "ip rule" mptcp_lib_result_skip "${TEST_GROUP}" return @@ -710,13 +710,13 @@ EOF if ! ip -net "$listener_ns" route add local $local_addr/0 dev lo table 100; then ip netns exec "$listener_ns" nft flush ruleset ip -net "$listener_ns" $r6flag rule del fwmark 1 lookup 100 - echo "SKIP: $msg, ip route add local $local_addr failed" + mptcp_lib_pr_skip "$msg, ip route add local $local_addr failed" mptcp_lib_fail_if_expected_feature "ip route" mptcp_lib_result_skip "${TEST_GROUP}" return fi - echo "INFO: test $msg" + mptcp_lib_pr_info "test $msg" port=$((20000 - 1)) local extra_args="-o TRANSPARENT" @@ -729,12 +729,12 @@ EOF ip -net "$listener_ns" route del local $local_addr/0 dev lo table 100 if [ $lret -ne 0 ]; then - echo "FAIL: $msg, mptcp connection error" + mptcp_lib_pr_fail "$msg, mptcp connection error" ret=$lret return 1 fi - echo "PASS: $msg" + mptcp_lib_pr_info "$msg pass" return 0 } @@ -743,7 +743,7 @@ run_tests_peekmode() local peekmode="$1" TEST_GROUP="peek mode: ${peekmode}" - echo "INFO: with peek mode: ${peekmode}" + mptcp_lib_pr_info "with peek mode: ${peekmode}" run_tests_lo "$ns1" "$ns1" 10.0.1.1 1 "-P ${peekmode}" run_tests_lo "$ns1" "$ns1" dead:beef:1::1 1 "-P ${peekmode}" } @@ -753,12 +753,12 @@ run_tests_mptfo() TEST_GROUP="MPTFO" if ! mptcp_lib_kallsyms_has "mptcp_fastopen_"; then - echo "INFO: TFO not supported by the kernel: SKIP" + mptcp_lib_pr_skip "TFO not supported by the kernel" mptcp_lib_result_skip "${TEST_GROUP}" return fi - echo "INFO: with MPTFO start" + mptcp_lib_pr_info "with MPTFO start" ip netns exec "$ns1" sysctl -q net.ipv4.tcp_fastopen=2 ip netns exec "$ns2" sysctl -q net.ipv4.tcp_fastopen=1 @@ -770,7 +770,7 @@ run_tests_mptfo() ip netns exec "$ns1" sysctl -q net.ipv4.tcp_fastopen=0 ip netns exec "$ns2" sysctl -q net.ipv4.tcp_fastopen=0 - echo "INFO: with MPTFO end" + mptcp_lib_pr_info "with MPTFO end" } run_tests_disconnect() @@ -781,7 +781,7 @@ run_tests_disconnect() TEST_GROUP="full disconnect" if ! mptcp_lib_kallsyms_has "mptcp_pm_data_reset$"; then - echo "INFO: Full disconnect not supported: SKIP" + mptcp_lib_pr_skip "Full disconnect not supported" mptcp_lib_result_skip "${TEST_GROUP}" return fi @@ -794,7 +794,7 @@ run_tests_disconnect() cin_disconnect="$old_cin" connect_per_transfer=3 - echo "INFO: disconnect" + mptcp_lib_pr_info "disconnect" run_tests_lo "$ns1" "$ns1" 10.0.1.1 1 "-I 3 -i $old_cin" run_tests_lo "$ns1" "$ns1" dead:beef:1::1 1 "-I 3 -i $old_cin" @@ -818,7 +818,7 @@ log_if_error() local msg="$1" if [ ${ret} -ne 0 ]; then - echo "FAIL: ${msg}" + mptcp_lib_pr_fail "${msg}" final_ret=${ret} ret=0 @@ -865,7 +865,7 @@ done mptcp_lib_result_code "${ret}" "ping tests" stop_if_error "Could not even run ping tests" -echo "[ OK ]" +mptcp_lib_pr_ok [ -n "$tc_loss" ] && tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $tc_loss delay ${tc_delay}ms tc_info="loss of $tc_loss " @@ -890,7 +890,7 @@ elif [ "$reorder_delay" -gt 0 ];then tc_info+="$tc_reorder with delay ${reorder_delay}ms " fi -echo "INFO: Using ${tc_info}on ns3eth4" +mptcp_lib_pr_info "Using ${tc_info}on ns3eth4" tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${reorder_delay}ms $tc_reorder diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index d2969eec36d5..9f67b9ba97d8 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -185,17 +185,17 @@ print_info() print_ok() { - mptcp_lib_print_ok "[ ok ]${1:+ ${*}}" + mptcp_lib_pr_ok "${@}" } print_fail() { - mptcp_lib_print_err "[fail]${1:+ ${*}}" + mptcp_lib_pr_fail "${@}" } print_skip() { - mptcp_lib_print_warn "[skip]${1:+ ${*}}" + mptcp_lib_pr_skip "${@}" } # [ $1: fail msg ] diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index eb740a2f7898..ea39392c68e7 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -50,6 +50,23 @@ mptcp_lib_print_err() { mptcp_lib_print_color "${MPTCP_LIB_COLOR_RED}${*}" } +# shellcheck disable=SC2120 # parameters are optional +mptcp_lib_pr_ok() { + mptcp_lib_print_ok "[ OK ]${1:+ ${*}}" +} + +mptcp_lib_pr_skip() { + mptcp_lib_print_warn "[SKIP]${1:+ ${*}}" +} + +mptcp_lib_pr_fail() { + mptcp_lib_print_err "[FAIL]${1:+ ${*}}" +} + +mptcp_lib_pr_info() { + mptcp_lib_print_info "INFO: ${*}" +} + # SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var can be set when validating all # features using the last version of the kernel and the selftests to make sure # a test is not being skipped by mistake. @@ -80,14 +97,14 @@ mptcp_lib_has_file() { mptcp_lib_check_mptcp() { if ! mptcp_lib_has_file "/proc/sys/net/mptcp/enabled"; then - echo "SKIP: MPTCP support is not available" + mptcp_lib_pr_skip "MPTCP support is not available" exit ${KSFT_SKIP} fi } mptcp_lib_check_kallsyms() { if ! mptcp_lib_has_file "/proc/kallsyms"; then - echo "SKIP: CONFIG_KALLSYMS is missing" + mptcp_lib_pr_skip "CONFIG_KALLSYMS is missing" exit ${KSFT_SKIP} fi } @@ -294,7 +311,7 @@ mptcp_lib_check_transfer() { local what="${3}" if ! cmp "$in" "$out" > /dev/null 2>&1; then - echo "[ FAIL ] $what does not match (in, out):" + mptcp_lib_pr_fail "$what does not match (in, out):" mptcp_lib_print_file_err "$in" mptcp_lib_print_file_err "$out" @@ -334,13 +351,13 @@ mptcp_lib_check_output() { fi if [ ${cmd_ret} -ne 0 ]; then - mptcp_lib_print_err "[FAIL] command execution '${cmd}' stderr" + mptcp_lib_pr_fail "command execution '${cmd}' stderr" cat "${err}" return 2 elif [ "${out}" = "${expected}" ]; then return 0 else - mptcp_lib_print_err "[FAIL] expected '${expected}' got '${out}'" + mptcp_lib_pr_fail "expected '${expected}' got '${out}'" return 1 fi } @@ -352,29 +369,30 @@ mptcp_lib_check_tools() { case "${tool}" in "ip") if ! ip -Version &> /dev/null; then - mptcp_lib_print_warn "SKIP: Could not run test without ip tool" + mptcp_lib_pr_skip "Could not run test without ip tool" exit ${KSFT_SKIP} fi ;; "ss") if ! ss -h | grep -q MPTCP; then - mptcp_lib_print_warn "SKIP: ss tool does not support MPTCP" + mptcp_lib_pr_skip "ss tool does not support MPTCP" exit ${KSFT_SKIP} fi ;; "iptables"* | "ip6tables"*) if ! "${tool}" -V &> /dev/null; then - mptcp_lib_print_warn "SKIP: Could not run all tests without ${tool}" + mptcp_lib_pr_skip "Could not run all tests without ${tool}" exit ${KSFT_SKIP} fi ;; *) - mptcp_lib_print_err "Internal error: unsupported tool: ${tool}" + mptcp_lib_pr_fail "Internal error: unsupported tool: ${tool}" exit ${KSFT_FAIL} ;; esac done } + mptcp_lib_ns_init() { local sec rndh diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh index 19d0ac31b6a9..96aa8f71bbb0 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -103,8 +103,8 @@ check_mark() local v for v in $values; do if [ $v -ne 0 ]; then - echo "FAIL: got $tables $values in ns $ns," \ - "not 0 - not all expected packets marked" + mptcp_lib_pr_fail "got $tables $values in ns $ns," \ + "not 0 - not all expected packets marked" ret=1 return 1 fi @@ -169,7 +169,7 @@ do_transfer() print_title "Transfer ${ip:2}" if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then - echo "[FAIL] client exit code $retc, server $rets" + mptcp_lib_pr_fail "client exit code $retc, server $rets" echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port" @@ -184,7 +184,7 @@ do_transfer() if ! mptcp_lib_check_transfer $cin $sout "file received by server"; then rets=1 else - echo "[ OK ]" + mptcp_lib_pr_ok fi mptcp_lib_result_code "${rets}" "transfer ${ip}" @@ -200,10 +200,10 @@ do_transfer() mptcp_lib_result_code "${retc}" "mark ${ip}" if [ $retc -eq 0 ] && [ $rets -eq 0 ];then - echo "[ OK ]" + mptcp_lib_pr_ok return 0 fi - echo "[FAIL]" + mptcp_lib_pr_fail return 1 } @@ -224,7 +224,7 @@ do_mptcp_sockopt_tests() local lret=0 if ! mptcp_lib_kallsyms_has "mptcp_diag_fill_info$"; then - echo "INFO: MPTCP sockopt not supported: SKIP" + mptcp_lib_pr_skip "MPTCP sockopt not supported" mptcp_lib_result_skip "sockopt" return fi @@ -234,12 +234,12 @@ do_mptcp_sockopt_tests() print_title "SOL_MPTCP sockopt v4" if [ $lret -ne 0 ]; then - echo "[FAIL]" + mptcp_lib_pr_fail mptcp_lib_result_fail "sockopt v4" ret=$lret return fi - echo "[ OK ]" + mptcp_lib_pr_ok mptcp_lib_result_pass "sockopt v4" ip netns exec "$ns_sbox" ./mptcp_sockopt -6 @@ -247,12 +247,12 @@ do_mptcp_sockopt_tests() print_title "SOL_MPTCP sockopt v6" if [ $lret -ne 0 ]; then - echo "[FAIL]" + mptcp_lib_pr_fail mptcp_lib_result_fail "sockopt v6" ret=$lret return fi - echo "[ OK ]" + mptcp_lib_pr_ok mptcp_lib_result_pass "sockopt v6" } @@ -280,12 +280,12 @@ do_tcpinq_test() local lret=$? if [ $lret -ne 0 ];then ret=$lret - echo "[FAIL]" + mptcp_lib_pr_fail mptcp_lib_result_fail "TCP_INQ: $*" return $lret fi - echo "[ OK ]" + mptcp_lib_pr_ok mptcp_lib_result_pass "TCP_INQ: $*" return $lret } @@ -295,7 +295,7 @@ do_tcpinq_tests() local lret=0 if ! mptcp_lib_kallsyms_has "mptcp_ioctl$"; then - echo "INFO: TCP_INQ not supported: SKIP" + mptcp_lib_pr_skip "TCP_INQ not supported" mptcp_lib_result_skip "TCP_INQ" return fi diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index 5b9bc25dfef4..69ffff8b076b 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -190,7 +190,7 @@ else for st in fullmesh nofullmesh backup,fullmesh; do st=" (${st})" mptcp_lib_print_title "${st}" - echo "[SKIP]" + mptcp_lib_pr_skip mptcp_lib_result_skip "${st}" done fi diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh index b7549d9364d6..e62052c3206d 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -187,12 +187,12 @@ do_transfer() printf "%-16s" " max $max_time " if [ $retc -eq 0 ] && [ $rets -eq 0 ] && \ [ $cmpc -eq 0 ] && [ $cmps -eq 0 ]; then - echo "[ OK ]" + mptcp_lib_pr_ok cat "$capout" return 0 fi - echo " [ fail ]" + mptcp_lib_pr_fail echo "client exit code $retc, server $rets" 1>&2 echo -e "\nnetns ${ns3} socket stat for $port:" 1>&2 ip netns exec ${ns3} ss -nita 1>&2 -o "sport = :$port" diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index ca238592baee..4e29aa9c2529 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -57,13 +57,9 @@ test_name="" # a bit more space: because we have more to display MPTCP_LIB_TEST_FORMAT="%02u %-68s" -_printf() { - stdbuf -o0 -e0 printf "${@}" -} - print_title() { - _printf "INFO: %s\n" "${1}" + mptcp_lib_pr_info "${1}" } # $1: test name @@ -74,33 +70,23 @@ print_test() mptcp_lib_print_title "${test_name}" } -print_results() -{ - _printf "[%s]\n" "${1}" -} - test_pass() { - print_results " OK " + mptcp_lib_pr_ok mptcp_lib_result_pass "${test_name}" } test_skip() { - print_results "SKIP" + mptcp_lib_pr_skip mptcp_lib_result_skip "${test_name}" } # $1: msg test_fail() { - print_results "FAIL" + mptcp_lib_pr_fail "${@}" ret=1 - - if [ -n "${1}" ]; then - _printf "\t%s\n" "${1}" - fi - mptcp_lib_result_fail "${test_name}" } @@ -122,7 +108,7 @@ cleanup() rm -rf $file $client_evts $server_evts - _printf "Done\n" + mptcp_lib_pr_info "Done" } trap cleanup EXIT @@ -256,8 +242,7 @@ check_expected_one() test_fail fi - _printf "\tExpected value for '%s': '%s', got '%s'.\n" \ - "${var}" "${!exp}" "${!var}" + mptcp_lib_print_err "\tExpected value for '${var}': '${!exp}', got '${!var}'." return 1 } From patchwork Fri Mar 8 22:10:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 778976 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 36246629E2; Fri, 8 Mar 2024 22:10:57 +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=1709935858; cv=none; b=KBrRMyzY3LpYQTF1XTOUnlZk0lHS+P+0/JMaZ7FveNRpCQikhwa9Lik0LXZuOk3GUeNh8iXkmizPPFoYblV2a3w7NBctUEfrwYoU4QBgW66/AiytmL1+YKnNQPsNfGNKcgzIn49gBGk3Yb8tKfvwgKAvYcVIButBhZcu94/v10g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935858; c=relaxed/simple; bh=qhWKz2Hx+SC+H9/gRU/WVHYJNNy2Y+xaeP8ticJ8Clo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f+r+bQUEPdX+TFilYe+vRIcRo41rI0WBFW6uz3fWq0gLYQHcZE3SL8k/VWtXCAbXI49BMyfiNZbQbfXOW7R+pOLjt9qpNDhvxfZ6d2eBVV553DXJXlC3Ns587qNYwkhwQ88epTpQFLI23lDqLuK2k3Bm3Mooqvr2VU8k8hvfkQ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S9cutr8c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="S9cutr8c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3991C43394; Fri, 8 Mar 2024 22:10:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935857; bh=qhWKz2Hx+SC+H9/gRU/WVHYJNNy2Y+xaeP8ticJ8Clo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=S9cutr8cVnAGZ+0+U60qZ15JFOgcPicvwRumj8vW+1Q8bJV9XVNj3twU2xmG8TfVn wIlBJjZvQywS3uTAmQ6ON4R8q7ftsjurNQV04O1g/7h2XtNOikZXo4PptIbDUgIeWY 4uQ2xVqbFfbnm7i/GvvE5d5X6nN+WFaWZ1anT9okaNLqMKGg+GGCaYFk5x97gLijha SGvl9JCx6xicYiArKscN1W8V3xDl4sdUanGueLXSgxtAgGAyptIGsfa0ZnqSJ2OqWg 2lOZ6Zfst30P9bRm3Rmi0SmrqHIaT152Xpztnbhc4LvCvVDPCG5BBiPwz/7zEz5ZZy hSTaM7TCeI5sA== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:17 +0100 Subject: [PATCH net-next 10/15] selftests: mptcp: call test_fail without argument Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-10-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , 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)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2735; i=matttbe@kernel.org; h=from:subject:message-id; bh=hyKC6Mx+pB1z+Ddbi6L//7nB2D7vJLp369U14/WWHzc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zJmqFOtfe7CB9QgpGxydbJnWN0jqXZ809Xv U41c9p8UEaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMyQAKCRD2t4JPQmmg czwvD/9De9QKe5Zxvv4hxisXhRIUJYxEldA89+8zDFVZuAhCSU7qgRFX73kvU2CMS49dX7G3NPT SvXiQ85vBsQqPqT/DCOMrvJN1+7p3tbvz5hZR5qtqAPlUX4ffkYqvXYhxvuAPcAwZVDiLHxGQy0 VQKXmfWRZHeIdBqPQHgB6TJH8HBxI0AqTObL55O85aTqJclrHUJ28K7yClN8HAss9UHdaO5Ncev z4966/oifLuBwLSDhR1N9Nri1L1JUp5EX3LP45Ka/NlBt56YlJeY0Le0qGBPd5W4v5srXgKYaOV ToQO6+QBPjZ+P+W5UPhu5P+OwZXYWzpA5NtF+W9PPkZAc28ok3L3WIxCQXPAsdkZvZqhPWmzPqJ Y0wEoGEfXXFYnQJahC0ePEu7AdLW8Tjsv6DtmEwBAc0iSMX3APQidlwNCn6UX2OA/Td35JoMTrO qnmpevZL1ulgaqL3zdbwylxJs/UVQ7eHzPeETp0cU4Gs/77awTV1oyLCIfCxkGO1N5q7o8GeZty ZCTTXvWrTBNpSODDrYi89bhnmSNe8xFaOOtIR/d3itt6t9VbCOt3lWxEvMkcBTD2IojrTzu9yZm E562xQx2DrApH70qyeviA07SEG4l1EImJ/vV/+ljzvIoKBr5fEgreXiPQQhe5gDSfRPV9wkko9P rlxj+7Aa+GtryzQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang This patch modifies test_fail() to call mptcp_lib_pr_fail() only if there are arguments (if [ ${#} -gt 0 ]) in userspace_pm.sh, add arguments "unexpected type: ${type}" when calling test_fail() from test_remove(). Then mptcp_lib_pr_fail() can be used in check_expected_one() instead of test_fail(). The same in mptcp_join.sh, calling fail_test() without argument, and adapt this helper not to call print_fail() in this case. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 7 +++++-- tools/testing/selftests/net/mptcp/userspace_pm.sh | 12 ++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 9f67b9ba97d8..041175ec1304 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -452,7 +452,9 @@ fail_test() { ret=1 - print_fail "${@}" + if [ ${#} -gt 0 ]; then + print_fail "${@}" + fi # just in case a test is marked twice as failed if [ ${last_test_failed} -eq 0 ]; then @@ -2834,7 +2836,8 @@ verify_listener_events() print_ok return 0 fi - fail_test "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$sport" + print_fail "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$sport" + fail_test } add_addr_ports_tests() diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index 4e29aa9c2529..bc2f0184b1eb 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -85,7 +85,10 @@ test_skip() # $1: msg test_fail() { - mptcp_lib_pr_fail "${@}" + if [ ${#} -gt 0 ] + then + mptcp_lib_pr_fail "${@}" + fi ret=1 mptcp_lib_result_fail "${test_name}" } @@ -239,7 +242,7 @@ check_expected_one() if [ "${prev_ret}" = "0" ] then - test_fail + mptcp_lib_pr_fail fi mptcp_lib_print_err "\tExpected value for '${var}': '${!exp}', got '${!var}'." @@ -263,6 +266,7 @@ check_expected() return 0 fi + test_fail return 1 } @@ -412,7 +416,7 @@ test_remove() then test_pass else - test_fail + test_fail "unexpected type: ${type}" fi # RM_ADDR using an invalid addr id should result in no action @@ -425,7 +429,7 @@ test_remove() then test_pass else - test_fail + test_fail "unexpected type: ${type}" fi # RM_ADDR from the client to server machine From patchwork Fri Mar 8 22:10:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 779338 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 7F064633E9; Fri, 8 Mar 2024 22:11:01 +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=1709935861; cv=none; b=Tace2MQr4/gjijmJQtPNU1/eAb2/gE5eT3Os728xvwrGwfL2GUkwhrf7+W28R30h8bRIK5IzGaM3fsRYFpmnwatDPQEpel3mdrhuo4VMvQ4CeDg7nNRnlyeRlgnqt7Ax08mzROMF6fQ3yF1dO0LJpasS2On4VX6xGmSKIJQp//Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935861; c=relaxed/simple; bh=ST+FsQCbwuMBVVqFTYxSEcbjGdoTfeXer5gDUehfP2w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nH6mS9fFN6yxKkSQXufqiSB2bxRh/kHa6b2dId/tH/aQEur/A+y5niqnk3qHWxbCXL+AIbdhBwPFTvWCZ6i4xXTvt56FEGNtzofHTlegRHZBYBRwQSIv5dFdqf8neUsaVPBbp5cjPdKgv0BySDwMqHwFTOfhjO1f3qEtlcboVGw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cHBK8uD5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cHBK8uD5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54791C433C7; Fri, 8 Mar 2024 22:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935861; bh=ST+FsQCbwuMBVVqFTYxSEcbjGdoTfeXer5gDUehfP2w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cHBK8uD5RQVSmQiXqxgriZwQ+W4QztrbfPeS0Lsz/G42EsU6GZO4ojRLfzzomuF5S vZN2EzL0QSzr5jNqfHUfqUL5pBJ4NUjQurCJcTec4fIjKtKPBMLfdEwj4/3/90ofhS /Ixc5UCaYxT8ia3ieG+tezzhT1FldqkqPtEiIEzI+rfRZPAazgDB2K/jZTA4kO7Se4 iyDOwnayt20YoQWg5mZw2mvdH1esiV7Up0msTTq5ZTN56NKSMkSd5m5Gg0GV5yVRXe E04glOiIzjsSVI+7BeSba04K0Qe+Bezp0En2ZtQ++07CAoRktohJLT2ixl7FWxawUu FDmKdQDXI8MZg== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:18 +0100 Subject: [PATCH net-next 11/15] selftests: mptcp: extract mptcp_lib_check_expected Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-11-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , 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)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2950; i=matttbe@kernel.org; h=from:subject:message-id; bh=HA9w5Ex3KPLfxV6h/+RxCQzHWGG3h+xZEiImAvFkmnk=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zJzChePs7yPb47ACIKF+toQ/i0dKUzsUcQi WbI28q2IamJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMyQAKCRD2t4JPQmmg c+FID/9LJigb2kitVlzLdDfNjOyz0zc3g5gLVt68PKE4Lhux4/PhPorepxHQII1OnKIg4KvDSLj 0arLS6vh/0T5EgB80jk25NTVUBFweWH62QaslhoBppNqNeWFO9KrVRemyAIwTxJaohJ4ChINxdb ChPA1I+8e6eD1+FB8FxN5OUtNgAFF3VZDqsT0gTpt58+xfSMlfzp5YOf1vqrduBEVkjmsLM91hY u7Um3GLGcCJ2XO1PE9nteaVasfSxyzwFdeyegoTDD3MNud2+6+dREPe1w9ycLRAM+OioA2vbBOh FzyE8C1Ib+dV5+ZMYXdqDrR1muWFZGkXTa1Eu4IkEIIjfsns2ZhFk3JZ0MlaqBhBjqX+2UZlVXi cLh2SIybFRe+1R4CE1H2EJpLTZerauqNdFvYCKsg0k9MubxNrhuXT1mHvmq/b8qpLIba6ogarUk C3k2AL8uIGjWNvP2PfGaalmWE5cbMpBT4cO+2GzMnciDj9V5ubfJh3xLKfu5QM06RJPaC5A4QJ5 Q2ydE+fa3ei/oarEWyzt3heSeG+7if9dEQc8MleS/H16WnMqg8QTPcMHWO5jwqK/acdq3e8gPLs SkOM9kzSpbVqT6PJZFkTHNRna9VnwTurd4nVwyUCeVQPQnK2h72ce2egmxiarRDhDArWSwqQrcP 5XGh+ndGM3PYKTA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang Extract the main part of check_expected() in userspace_pm.sh to a new function mptcp_lib_check_expected() in mptcp_lib.sh. It will be used in both mptcp_john.sh and userspace_pm.sh. check_expected_one() is moved into mptcp_lib.sh too as mptcp_lib_check_expected_one(). Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 30 +++++++++++++++++++++ tools/testing/selftests/net/mptcp/userspace_pm.sh | 33 ++--------------------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index ea39392c68e7..44491f18ed17 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -438,3 +438,33 @@ mptcp_lib_print_title() { # shellcheck disable=SC2059 # the format is in a variable printf "${MPTCP_LIB_TEST_FORMAT}" "$((++MPTCP_LIB_TEST_COUNTER))" "${*}" } + +# $1: var name ; $2: prev ret +mptcp_lib_check_expected_one() { + local var="${1}" + local exp="e_${var}" + local prev_ret="${2}" + + if [ "${!var}" = "${!exp}" ]; then + return 0 + fi + + if [ "${prev_ret}" = "0" ]; then + mptcp_lib_pr_fail + fi + + mptcp_lib_print_err "Expected value for '${var}': '${!exp}', got '${!var}'." + return 1 +} + +# $@: all var names to check +mptcp_lib_check_expected() { + local rc=0 + local var + + for var in "${@}"; do + mptcp_lib_check_expected_one "${var}" "${rc}" || rc=1 + done + + return "${rc}" +} diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index bc2f0184b1eb..6d0862a1b68d 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -5,7 +5,7 @@ # code but we accept it. #shellcheck disable=SC2086 -# Some variables are used below but indirectly, see check_expected_one() +# Some variables are used below but indirectly, see verify_*_event() #shellcheck disable=SC2034 . "$(dirname "${0}")/mptcp_lib.sh" @@ -228,39 +228,10 @@ make_connection() fi } -# $1: var name ; $2: prev ret -check_expected_one() -{ - local var="${1}" - local exp="e_${var}" - local prev_ret="${2}" - - if [ "${!var}" = "${!exp}" ] - then - return 0 - fi - - if [ "${prev_ret}" = "0" ] - then - mptcp_lib_pr_fail - fi - - mptcp_lib_print_err "\tExpected value for '${var}': '${!exp}', got '${!var}'." - return 1 -} - # $@: all var names to check check_expected() { - local rc=0 - local var - - for var in "${@}" - do - check_expected_one "${var}" "${rc}" || rc=1 - done - - if [ ${rc} -eq 0 ] + if mptcp_lib_check_expected "${@}" then test_pass return 0 From patchwork Fri Mar 8 22:10:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 778975 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 3308E64AB6; Fri, 8 Mar 2024 22:11:05 +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=1709935865; cv=none; b=gIGyjk3eA2uqAHcqEsXiL4DigvgBRtUZsv96bNKHygJ03BLc0RSyBtE9TgoKLDASEUtArg0XQKqYYFGAB7antS5oy9wVKL2+BzrndINInTDhZdDH7M2SVHmZx3d5LdDOEZj4Wp/0vvawnbmjjuCLSLCxgdo1BZllCW4oC20Tv5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935865; c=relaxed/simple; bh=ZIYQB+KzyVVuQY99Ima/pHk8e/qhoSdaRzLvkUvByoE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Jyif2j3G70harHXs3e9D+N+u0Ny8JTNCFrVsFHbiR2k3+8+TR5iSxwCQxfa6WAiir7a1sG2lA01xmk9GwsslAmNePtLBOzaJO7ygtCnp7Is1BTn12W7t5jUS8GCR0sNUxUkcisQWqMpstcpjIQrc4mJ2keu1BnzAWV9S+TpAiwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lZb5nU/9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lZb5nU/9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3364C433A6; Fri, 8 Mar 2024 22:11:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935865; bh=ZIYQB+KzyVVuQY99Ima/pHk8e/qhoSdaRzLvkUvByoE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lZb5nU/9OrGHjO6k54vqrE46viLbAWBqhuSh9Bf8O5Twjjsnw9dNcUvjB7/Y19sZq UPa+Skse/uHx6SXuCljbxT1VqaRSXQU4Gc3U0AjpjCko4aFaurT3md/tDlD1dDAH6r 9GNU2/jUoMv+yGYrlVtM8mOZn2p98JJBw+t9OSfqrp+/3HyPM01UpMmlJy4PvRH2FO DOGnu2fBgFdFs+iD0C+X8WiUUiTE4ARnKIKqP0HFl4FREOZzfJuFnSMh9CZOcdfGsm ztB6cVCF1nZlzyCegkwpNMX+rOyTH3BusoOfeBh3ExHTaScvXP7l1iuzh+BPBvpXMA lygEwEFS5GI7g== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:19 +0100 Subject: [PATCH net-next 12/15] selftests: mptcp: print_test out of verify_listener_events Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-12-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , 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)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1806; i=matttbe@kernel.org; h=from:subject:message-id; bh=p0AphtGjcDw+iiDKBH/TekIuR6JxnoGE+w4YmACLQaY=; b=owEBawKU/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zJNNdI9bL+Lp4gaXO54fqB3FpDQM2Em4sAH /fwxSeu1nmJAjEEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMyQAKCRD2t4JPQmmg c4NJD+0a4wVzQzMtGhDUW/8Wuf1sf8M+bsbE9NO7RfuKtZigCLLPKwAWCJVJQtsp7HRTbwM7ASa ZLpDXDcOZDTUGbLntA+mN2DgnsVT0tZcDnVUNawjT9tQ5H04ZUBxxaIzDTBrAWres+iJHbk4J3d V5lZsfF7R3Uhz87xZCp7VDoxYwoYyb/RqPxtQrC4Q7TxA0o73+wD+Ri0Hl5FJYApyPDVNbWj1gB yLYVhnWcyWgvjmLW+VzKVEQFfcBLIFILFyn8g9/LYm1AoXq9KUVcVeb0vjNO8SiruBsXRrVqec5 rupMLOYAFpNl3THAlaVen2f7B1FSx/Fft544J/XtxENCciSjrwVBLJzcKleftnc6VSzCcKBbDIS 9EDPIv9g+lyXK3DMJlSUFb5ULsh1zCpWIV+JM3pmX1vIfhLcbcOdr2V3xi8gRXDYIFu0+Amnohc snpHq4vko1Y2urO5jj/tXiXz7RtL/HxR0Ozj3P8q9Yk9atIAWKhrG6EWMLJrLScg3YHg/WbT9U1 qyZCU0/ppkpXkFocbMKoVwJqPg5b+5Mtus0iBip++DJfszM+CumwhcAQf1oCqRL+MBayT4c3Dan GgVC2oaGF8H3xf7KxBc4y30c57TAQ6mkD4erHrl0USDSKYD8wbjLE5OUZdNcGVQj6D0zwP/9RGy 8HYf77bJVkfg= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang verify_listener_events() helper will be exported into mptcp_lib.sh as a public function, but print_test() is invoked in it, which is a private function in userspace_pm.sh only. So this patch moves print_test() out of verify_listener_events(). Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/userspace_pm.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index 6d0862a1b68d..e9aea44edee5 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -845,12 +845,6 @@ verify_listener_events() local saddr local sport - if [ $e_type = $LISTENER_CREATED ]; then - print_test "CREATE_LISTENER $e_saddr:$e_sport" - elif [ $e_type = $LISTENER_CLOSED ]; then - print_test "CLOSE_LISTENER $e_saddr:$e_sport" - fi - type=$(mptcp_lib_evts_get_info type $evt $e_type) family=$(mptcp_lib_evts_get_info family $evt $e_type) sport=$(mptcp_lib_evts_get_info sport $evt $e_type) @@ -882,6 +876,7 @@ test_listener() local listener_pid=$! sleep 0.5 + print_test "CREATE_LISTENER 10.0.2.2:$client4_port" verify_listener_events $client_evts $LISTENER_CREATED $AF_INET 10.0.2.2 $client4_port # ADD_ADDR from client to server machine reusing the subflow port @@ -898,6 +893,7 @@ test_listener() mptcp_lib_kill_wait $listener_pid sleep 0.5 + print_test "CLOSE_LISTENER 10.0.2.2:$client4_port" verify_listener_events $client_evts $LISTENER_CLOSED $AF_INET 10.0.2.2 $client4_port } From patchwork Fri Mar 8 22:10:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 779337 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 E1CE7651A4; Fri, 8 Mar 2024 22:11:08 +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=1709935869; cv=none; b=c1c5Yqbm5uhtF34Ux4TvEN4fK8WdBOLf2TewE16lhn9B+JObgIfHqvyJReoQbnrmiLtlvdG6O0mldO6tUE0zRIdyATYWiQUiOuHimBnt321HKzCZcJo2oDXX0dsxitIHDAESdji1BwCW1Ya0soAAfkyH/MuR954lyCh1VA0a2h8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935869; c=relaxed/simple; bh=gI7gAxG7/7enPUG2m1/wk/2tQuTd6pa5cKzSuAGaaZE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gD5rEng5s0ttTNumtbKerKZl1lvK7eIuikRxLiTPqCqrrlmclu92Q1i3rNq1mpFGgCSmeDAk9FZgnlgFNUdIcVOrgfHsitNU7KKHwlPniAuWD7HHR1tamkP3o67sRFov2q3ix7IvsTRbDYObVwbNXWS/n/Sk6wqeowaJ9q2fID4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hpCtWGOE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hpCtWGOE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96D7AC43394; Fri, 8 Mar 2024 22:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935868; bh=gI7gAxG7/7enPUG2m1/wk/2tQuTd6pa5cKzSuAGaaZE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hpCtWGOEX+iXWfErxAPPeQO3r8fzsK71uNugJ99jFLMCiy9IT72HCfTpPxq8JdHkC K+O81QHv8Vkz9BihnpFTKU9/33gB9EFNqWdsil1kYXWJvlapHuhD8qe/sY3KEj3xRA wdgauIBQ2cKpb+aERvIcUavVUzWECmaClCxgL2PEwPSad2ZrE0Qo7qMAjvDWz0AI7o nM5EdBRaw+Rln+MS8vyGLPJnaTwmIxBfjVZi8emEs7VSvyvCpVWHrnBJgE80R3/iCa kNnFeQsQbYOYOR3HOAWRo7fooXks+Gq6yWKK2pKhp5kmZOWLpVT9Be+NMU58wpjlWK tAK3c7yXK44GA== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:20 +0100 Subject: [PATCH net-next 13/15] selftests: mptcp: add mptcp_lib_verify_listener_events Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-13-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , 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)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4275; i=matttbe@kernel.org; h=from:subject:message-id; bh=pARL3ytgyARb+QzDKu12q0Cw4Y2pvqigZlKc4xpTC+8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zJ7kzUaDOHz8NVkhyIbvdx3NmFlSXMhO7GF uZKiTuBxNmJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMyQAKCRD2t4JPQmmg cwSPEACZoaAg5fwmfNaFNwjUo6mzoRqE7sI6Hr2fml9t52zDSp3VsP9I3TduJwROs05U8j/DDZn El4a80D+yyaMEsv9/PZpvCH9H8Bn7bhcopWvMSVfmmHnQY5oOFSy3x8d+4eC5mhW1S0IPTKpYM1 ciApsfwz7VKORpm/ubOdmVKhBQg7Bm+LFqsLhootFwZYneRO+Goe6jVu48gYlVSnucrkvsA8Rvg m/LFprUpnfdrhkNU/tj3JaXxfxC+E4wx5XVHe66u0+eYcVezX3g7OAwOHkTYC1AYSXBcckMePla XSsdewrfD1rp6ijv7xcoBxqQl+YAoDSqa9AKpaHZDpOIAY0eC2XVH2rNHFmYrhbXj3p1GxLidKt ZVaR40QrZRO+qOvsP3BuoBKgXZR4LNdAU7Gc6XJaiG1WrADG4gBW1upm6ZKtTnBJkfObIN9fdhe NOemXnJvRKulu1wOzmcWbXO4tn2t1/NFEdiTFwx9yOQt/VL3QobVwI4x5rrDkUldr7xsCZpEhJO R8B2Un5QA/hh6wuXHzLWjCnYRRSoHYWLg8Pql+YhbJs53rBRHB5d0TpTfNk6ixe7vFGPbC9Ac2g lWvW1p1+1DJlJycMzpsprLFaznc+gKuS+mcWeXYyig0DB7JgCOVrYzqdxd6eJ4nDed2Y7sQdsJr xW3d9tXzoqDNr/Q== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang To avoid duplicated code in different MPTCP selftests, we can add and use helpers defined in mptcp_lib.sh. The helper verify_listener_events() is defined both in mptcp_join.sh and userspace_pm.sh, export it into mptcp_lib.sh and rename it with mptcp_lib_ prefix. Use this new helper in both scripts. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 21 +----------------- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 26 +++++++++++++++++++++++ tools/testing/selftests/net/mptcp/userspace_pm.sh | 21 +++--------------- 3 files changed, 30 insertions(+), 38 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 041175ec1304..9b538a7071e7 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -2794,15 +2794,9 @@ AF_INET6=10 verify_listener_events() { - local evt=$1 local e_type=$2 - local e_family=$3 local e_saddr=$4 local e_sport=$5 - local type - local family - local saddr - local sport local name if [ $e_type = $LISTENER_CREATED ]; then @@ -2820,23 +2814,10 @@ verify_listener_events() return fi - type=$(mptcp_lib_evts_get_info type "$evt" "$e_type") - family=$(mptcp_lib_evts_get_info family "$evt" "$e_type") - sport=$(mptcp_lib_evts_get_info sport "$evt" "$e_type") - if [ $family ] && [ $family = $AF_INET6 ]; then - saddr=$(mptcp_lib_evts_get_info saddr6 "$evt" "$e_type") - else - saddr=$(mptcp_lib_evts_get_info saddr4 "$evt" "$e_type") - fi - - if [ $type ] && [ $type = $e_type ] && - [ $family ] && [ $family = $e_family ] && - [ $saddr ] && [ $saddr = $e_saddr ] && - [ $sport ] && [ $sport = $e_sport ]; then + if mptcp_lib_verify_listener_events "${@}"; then print_ok return 0 fi - print_fail "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$sport" fail_test } diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index 44491f18ed17..a977a722fb3d 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -468,3 +468,29 @@ mptcp_lib_check_expected() { return "${rc}" } + +# shellcheck disable=SC2034 # Some variables are used below but indirectly +mptcp_lib_verify_listener_events() { + local evt=${1} + local e_type=${2} + local e_family=${3} + local e_saddr=${4} + local e_sport=${5} + local type + local family + local saddr + local sport + local rc=0 + + type=$(mptcp_lib_evts_get_info type "${evt}" "${e_type}") + family=$(mptcp_lib_evts_get_info family "${evt}" "${e_type}") + if [ "${family}" ] && [ "${family}" = "${AF_INET6}" ]; then + saddr=$(mptcp_lib_evts_get_info saddr6 "${evt}" "${e_type}") + else + saddr=$(mptcp_lib_evts_get_info saddr4 "${evt}" "${e_type}") + fi + sport=$(mptcp_lib_evts_get_info sport "${evt}" "${e_type}") + + mptcp_lib_check_expected "type" "family" "saddr" "sport" || rc="${?}" + return "${rc}" +} diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index e9aea44edee5..1e0b39e5525c 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -835,26 +835,11 @@ test_prio() verify_listener_events() { - local evt=$1 - local e_type=$2 - local e_family=$3 - local e_saddr=$4 - local e_sport=$5 - local type - local family - local saddr - local sport - - type=$(mptcp_lib_evts_get_info type $evt $e_type) - family=$(mptcp_lib_evts_get_info family $evt $e_type) - sport=$(mptcp_lib_evts_get_info sport $evt $e_type) - if [ $family ] && [ $family = $AF_INET6 ]; then - saddr=$(mptcp_lib_evts_get_info saddr6 $evt $e_type) + if mptcp_lib_verify_listener_events "${@}"; then + test_pass else - saddr=$(mptcp_lib_evts_get_info saddr4 $evt $e_type) + test_fail fi - - check_expected "type" "family" "saddr" "sport" } test_listener() From patchwork Fri Mar 8 22:10:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 778974 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 725CA657C4; Fri, 8 Mar 2024 22:11:12 +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=1709935872; cv=none; b=idSxZAJiqW2GWiAG4llmlIW7wjvDj5+A354uaPNLqwB3sw/F2o76l74yfTXiUxZdFIIZR+jipsD1qLQrujgNlME6DAG0KQ7oQnAxTfgLEyqJz7Jl51wmTsysNatdQw04GDwi98VKkyDgNdwKo7yRvRHYj4ftmepuEFyMjwZQzFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935872; c=relaxed/simple; bh=qoHUiLkNsIx47I1kuK2C8KpRsVMntythSQv1v4fIqIU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KfhUyhLknv/vMs+t7U6yB9kKSL0LzcjuO2dqZhD+5d4MElE9SSMQo+RjsXCR3rm8D8EIzNkPFJKSfbHUlshqZoWzoXajnAZKjpTodtF3CpSVvNpuK/9miSY8ag2aK2WZsSYCFHkDSyCRjBPEYkVnYd3jsCcLuXttcE8lrxa2VjM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fy8YAOpF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Fy8YAOpF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E146EC433F1; Fri, 8 Mar 2024 22:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935871; bh=qoHUiLkNsIx47I1kuK2C8KpRsVMntythSQv1v4fIqIU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Fy8YAOpFppiARung7CuASEVVtNjJClxY5s/BnIrI1ifgWd5lhi3rzVwj52gb2CJ8t 6YPIiDHZuyCByOi0JRwpvufqL1ax6Rltxb3INHXHZ2czsUzN1StWPs9q3xQvc9ZABm +HDWj0sMNrCFD460FW50jZFMCp4kw9Jm+corE08ajFLOMR8e3x4KzswFys2njqC5Yf 54HqB8czQ6coA8HTGPHeuEEpY1oagrbXlaGP+L1HkOdxBE81d1kBXbo29Y6AIfcYRT g6l9q45klhaYjjEJQyuuCGKAswQ2xIne0r6BZdA/KAxNrFM2/dnFKn4kUmj1RNFJ6v ZNijpQmkRpoZw== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:21 +0100 Subject: [PATCH net-next 14/15] selftests: mptcp: declare event macros in mptcp_lib Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-14-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , 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)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5514; i=matttbe@kernel.org; h=from:subject:message-id; bh=CZSpCvGHHfieUfdGxngJ4O/ETYY90UBVLWZIKItSxzs=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zJysgjwFRUD01v/+WgUciv4h+Zf/wWu+SPN 0iroQDShyaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMyQAKCRD2t4JPQmmg c6B2EAC8WLF3jebucBxcPTPikPb5Fvl5GMoT+pLWB5lez7p/qnk1RNKpmkVZbof3ljSB5TNjlZ8 WW3YbUJzKT45u2lEGevrNXJtX5H4fpwMSKL+HaiDFDW+ZxaEfN7GwH5J8+nh2h8FBZFstkh64if I7AD2Eb8WDKkKEOX7erXdxXxCH/ngIYzXugX4BUyQJ8xA7YriSNCwfj3JuXC0l+N2J64IaWMd3f jWJJlfk/s5vuQkh5lTmBg6dt9pg9//Stld2Lu4ChaQgG9SA1dJxn+ziICeeJTbkBd1IlGezJUSQ Hx0yZT4r20s5bD9n8TIAl9tuUduvp7Lp7qfZZD0qkpmkSOVeMv3+H6NrLMsGbmO1eFZ6VVT7/Dr lR6fWjbpqghUyp6b2aAgLljjHwtg7UW6QhEP4u9pHoGRy4MIy1JGg6esZ944RvA+lM0Q/46FAmB UOrNasc11PO1mw9WTgAyzb6GKXpm490lFwg1EEt1kJwust4+zam7wkxemighDRor7rA4b1G8Unl GuGY1tYYXewTj39mLqXCX4RNzR83ghOPrNkZj6PoSsiVE8S+l+vQvhvml1J5OX2SeTm71kupdOL hSeMt8f8AQ0a5vCfJka5sIzit8TNVzJBfnF14BEMmxnriHkVnooGwa7Z4TwQtm/GBUP9fZGXM60 UNLuVuxYNH00WCg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang MPTCP event macros (SUB_ESTABLISHED, LISTENER_CREATED, LISTENER_CLOSED), and the protocol family macros (AF_INET, AF_INET6) are defined in both mptcp_join.sh and userspace_pm.sh. In order not to duplicate code, this patch declares them all in mptcp_lib.sh with MPTCP_LIB_ prefixs. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 23 +++++++++-------------- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 11 +++++++++++ tools/testing/selftests/net/mptcp/userspace_pm.sh | 16 ++++++++-------- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 9b538a7071e7..728575fd86ea 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -2785,13 +2785,6 @@ backup_tests() fi } -SUB_ESTABLISHED=10 # MPTCP_EVENT_SUB_ESTABLISHED -LISTENER_CREATED=15 #MPTCP_EVENT_LISTENER_CREATED -LISTENER_CLOSED=16 #MPTCP_EVENT_LISTENER_CLOSED - -AF_INET=2 -AF_INET6=10 - verify_listener_events() { local e_type=$2 @@ -2799,9 +2792,9 @@ verify_listener_events() local e_sport=$5 local name - if [ $e_type = $LISTENER_CREATED ]; then + if [ $e_type = $MPTCP_LIB_EVENT_LISTENER_CREATED ]; then name="LISTENER_CREATED" - elif [ $e_type = $LISTENER_CLOSED ]; then + elif [ $e_type = $MPTCP_LIB_EVENT_LISTENER_CLOSED ]; then name="LISTENER_CLOSED " else name="$e_type" @@ -2856,8 +2849,10 @@ add_addr_ports_tests() chk_add_nr 1 1 1 chk_rm_nr 1 1 invert - verify_listener_events $evts_ns1 $LISTENER_CREATED $AF_INET 10.0.2.1 10100 - verify_listener_events $evts_ns1 $LISTENER_CLOSED $AF_INET 10.0.2.1 10100 + verify_listener_events $evts_ns1 $MPTCP_LIB_EVENT_LISTENER_CREATED \ + $MPTCP_LIB_AF_INET 10.0.2.1 10100 + verify_listener_events $evts_ns1 $MPTCP_LIB_EVENT_LISTENER_CLOSED \ + $MPTCP_LIB_AF_INET 10.0.2.1 10100 kill_events_pids fi @@ -3463,11 +3458,11 @@ userspace_tests() userspace_pm_chk_get_addr "${ns1}" "10" "id 10 flags signal 10.0.2.1" userspace_pm_chk_get_addr "${ns1}" "20" "id 20 flags signal 10.0.3.1" userspace_pm_rm_addr $ns1 10 - userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $SUB_ESTABLISHED + userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $MPTCP_LIB_EVENT_SUB_ESTABLISHED userspace_pm_chk_dump_addr "${ns1}" \ "id 20 flags signal 10.0.3.1" "after rm_addr 10" userspace_pm_rm_addr $ns1 20 - userspace_pm_rm_sf $ns1 10.0.3.1 $SUB_ESTABLISHED + userspace_pm_rm_sf $ns1 10.0.3.1 $MPTCP_LIB_EVENT_SUB_ESTABLISHED userspace_pm_chk_dump_addr "${ns1}" "" "after rm_addr 20" chk_rm_nr 2 2 invert chk_mptcp_info subflows 0 subflows 0 @@ -3494,7 +3489,7 @@ userspace_tests() "subflow" userspace_pm_chk_get_addr "${ns2}" "20" "id 20 flags subflow 10.0.3.2" userspace_pm_rm_addr $ns2 20 - userspace_pm_rm_sf $ns2 10.0.3.2 $SUB_ESTABLISHED + userspace_pm_rm_sf $ns2 10.0.3.2 $MPTCP_LIB_EVENT_SUB_ESTABLISHED userspace_pm_chk_dump_addr "${ns2}" \ "" \ "after rm_addr 20" diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index a977a722fb3d..d529b4b37af8 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -8,6 +8,17 @@ readonly KSFT_SKIP=4 # shellcheck disable=SC2155 # declare and assign separately readonly KSFT_TEST="${MPTCP_LIB_KSFT_TEST:-$(basename "${0}" .sh)}" +# These variables are used in some selftests, read-only +declare -rx MPTCP_LIB_EVENT_ANNOUNCED=6 # MPTCP_EVENT_ANNOUNCED +declare -rx MPTCP_LIB_EVENT_REMOVED=7 # MPTCP_EVENT_REMOVED +declare -rx MPTCP_LIB_EVENT_SUB_ESTABLISHED=10 # MPTCP_EVENT_SUB_ESTABLISHED +declare -rx MPTCP_LIB_EVENT_SUB_CLOSED=11 # MPTCP_EVENT_SUB_CLOSED +declare -rx MPTCP_LIB_EVENT_LISTENER_CREATED=15 # MPTCP_EVENT_LISTENER_CREATED +declare -rx MPTCP_LIB_EVENT_LISTENER_CLOSED=16 # MPTCP_EVENT_LISTENER_CLOSED + +declare -rx MPTCP_LIB_AF_INET=2 +declare -rx MPTCP_LIB_AF_INET6=10 + MPTCP_LIB_SUBTESTS=() MPTCP_LIB_SUBTESTS_DUPLICATED=0 MPTCP_LIB_TEST_COUNTER=0 diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index 1e0b39e5525c..72dca742280f 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -19,15 +19,15 @@ if ! mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then fi mptcp_lib_check_tools ip -ANNOUNCED=6 # MPTCP_EVENT_ANNOUNCED -REMOVED=7 # MPTCP_EVENT_REMOVED -SUB_ESTABLISHED=10 # MPTCP_EVENT_SUB_ESTABLISHED -SUB_CLOSED=11 # MPTCP_EVENT_SUB_CLOSED -LISTENER_CREATED=15 #MPTCP_EVENT_LISTENER_CREATED -LISTENER_CLOSED=16 #MPTCP_EVENT_LISTENER_CLOSED +ANNOUNCED=${MPTCP_LIB_EVENT_ANNOUNCED} +REMOVED=${MPTCP_LIB_EVENT_REMOVED} +SUB_ESTABLISHED=${MPTCP_LIB_EVENT_SUB_ESTABLISHED} +SUB_CLOSED=${MPTCP_LIB_EVENT_SUB_CLOSED} +LISTENER_CREATED=${MPTCP_LIB_EVENT_LISTENER_CREATED} +LISTENER_CLOSED=${MPTCP_LIB_EVENT_LISTENER_CLOSED} -AF_INET=2 -AF_INET6=10 +AF_INET=${MPTCP_LIB_AF_INET} +AF_INET6=${MPTCP_LIB_AF_INET6} file="" server_evts="" From patchwork Fri Mar 8 22:10:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 779336 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 339A465BA9; Fri, 8 Mar 2024 22:11:15 +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=1709935876; cv=none; b=T0n5+rq1gtE7QaPWxzQRPoUf5uXRHyBBSJBRuF1Dk/pcnBB0If+8tasB786B8VW9hwMbsYY88JYGATogsBlzedp1hebiArIJ0mR/I+ziukaT4PTgm0Oo9QXSmmKgC7l2FHlLiAZR9qts9XawCDGbHVjctk+YSuUppG3gHkqD61M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709935876; c=relaxed/simple; bh=NDO5GUxYDlFqdD8WdhJZtIxFwcsqQH8196TFTWPwy14=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=J3uHKUuWx24kdUBM1wEGAOMUpU9LCRlLfNwuiRfJTBSnFH5oLBUPo8FzOwiaFXlff+qqRtt7NjLZ0dzG5+BVRfin4QX+tEJvD4g+NeRshtDLPh56Z98S6tOuT2pDhLjTcaHO4ma4uoRB26eT73mNmzKpbTX/f7gleECr+2kgu7k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m+v54EXi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="m+v54EXi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71849C43394; Fri, 8 Mar 2024 22:11:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709935875; bh=NDO5GUxYDlFqdD8WdhJZtIxFwcsqQH8196TFTWPwy14=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=m+v54EXif8ZlMTJ7Equ3gKVaVQH8X2Zs5jqRsWksfQI2xWOOByZG7DnH++Q3kKSBa yYldrq1GFieW3gf23iS3yvSlJm8i+TUjsByAstvz6+9CHTdcxj6KMyMD5es5oL+PgW YGPaiMWn29FVpZ4ehvJGFKWHMx7G2oTigcN3TZ6yRIS/uNZBiALCe8hdU1FZR+tM7s zkqbfjQASclPbX9ML6sgj0guUAlKCqNC90AsNpJqUwQbSUtKVXrShfcNtoSxSvUL2f cEFAvs0vwJgYRJMb6jAd4saEcEbY6KhWxcH34HwD2ZJee2ZDpsLA7UuBHb9f/2+nzq jQNxebGULZVHg== From: "Matthieu Baerts (NGI0)" Date: Fri, 08 Mar 2024 23:10:22 +0100 Subject: [PATCH net-next 15/15] selftests: mptcp: use KSFT_SKIP/KSFT_PASS/KSFT_FAIL Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-15-4f42c347b653@kernel.org> References: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> In-Reply-To: <20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , 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)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7667; i=matttbe@kernel.org; h=from:subject:message-id; bh=MFPhv4UY1RWRBU0fNNptB2KkxW4wGTFhXA3Gm+mmJuQ=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl64zKklzPyBogkU+fFBi02DdhEwZKmZJbLnVKP x3ro4RS0sqJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeuMygAKCRD2t4JPQmmg czttEACQ2l2oM/feheHfkCJteq36rDV31r/McILK38NIK47znYj0oxSrAw5hQ/rD/WBK3utLNSz uU51Dk0qGnxzXnp9tWkmZE7nFe/lYd8Q+C9D5dn9swyniriVy3qs6wjLnPHRtXme9yQqvdHDBwI 26VgouHTX9yVRSPvg3wieY6bBPQN5xaZCS0e5MADkM7VL52ZohEUBr01ShFBXsEQY/Wz0n0fnbM pUoscKHgk0SeVZJTdiBHHf7TeisUxjZIfNWvuBFKu4W/aj7hMlB2pG+IyrAugMzX4RocyXxbEzP 7p+KaASPLBz4i5Mth/tFPMJuraQwB4NPfAM1E38ccApqmnNwezp19pHEapTd5Qle42eBWjHlJn0 82g/E38JcHUZGtqpY2Zl4OenSeA792E0Ul6rcmw2ezZ9Pqg6wr1VYGOuGIrb1efPHw4/x+aLH58 Gf5Z2ruVRLESJmy4Ynwuk8s01DiUojzIwxOvpzUFZKwuL6wvl6OXKNVDbyoN3FNF8anzdXVB4Vv aPVW6SGPNvP4yzmzudWPiBsqxyhh0HUrRVJ0jh4YcuJ7weTh6B9d1Fxp+QODpu+l+CgJgfFOOkz i00MaZ0Ye/QyOWrImpOdDYBI83cJZqRuOuIZ9A37z2kekwrJGqf7ZXlvMRj4iaasfGTm2fUzRre zN+3kPT+wVrnwng== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang This patch uses the public var KSFT_SKIP in mptcp_lib.sh instead of ksft_skip, and drop 'ksft_skip=4' in mptcp_join.sh. Use KSFT_PASS and KSFT_FAIL macros instead of 0 and 1 after 'exit ' and 'ret=' in all scripts: exit 0 -> exit ${KSFT_PASS} exit 1 -> exit ${KSFT_FAIL} ret=0 -> ret=${KSFT_PASS} ret=1 -> ret=${KSFT_FAIL} Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 18 +++++++++--------- tools/testing/selftests/net/mptcp/mptcp_join.sh | 13 ++++++------- tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 4 ++-- tools/testing/selftests/net/mptcp/pm_netlink.sh | 8 ++++---- tools/testing/selftests/net/mptcp/simult_flows.sh | 4 ++-- tools/testing/selftests/net/mptcp/userspace_pm.sh | 4 ++-- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index cb1837f2761a..4c4248554826 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -65,14 +65,14 @@ while getopts "$optstring" option;do case "$option" in "h") usage $0 - exit 0 + exit ${KSFT_PASS} ;; "d") if [ $OPTARG -ge 0 ];then tc_delay="$OPTARG" else echo "-d requires numeric argument, got \"$OPTARG\"" 1>&2 - exit 1 + exit ${KSFT_FAIL} fi ;; "e") @@ -96,7 +96,7 @@ while getopts "$optstring" option;do sndbuf="$OPTARG" else echo "-S requires numeric argument, got \"$OPTARG\"" 1>&2 - exit 1 + exit ${KSFT_FAIL} fi ;; "R") @@ -104,7 +104,7 @@ while getopts "$optstring" option;do rcvbuf="$OPTARG" else echo "-R requires numeric argument, got \"$OPTARG\"" 1>&2 - exit 1 + exit ${KSFT_FAIL} fi ;; "m") @@ -121,7 +121,7 @@ while getopts "$optstring" option;do ;; "?") usage $0 - exit 1 + exit ${KSFT_FAIL} ;; esac done @@ -263,7 +263,7 @@ check_mptcp_disabled() if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ print $3 }')" -ne 1 ]; then mptcp_lib_pr_fail "net.mptcp.enabled sysctl is not 1 by default" mptcp_lib_result_fail "net.mptcp.enabled sysctl is not 1 by default" - ret=1 + ret=${KSFT_FAIL} return 1 fi ip netns exec ${disabled_ns} sysctl -q net.mptcp.enabled=0 @@ -276,7 +276,7 @@ check_mptcp_disabled() if [ ${err} -eq 0 ]; then mptcp_lib_pr_fail "New MPTCP socket cannot be blocked via sysctl" mptcp_lib_result_fail "New MPTCP socket cannot be blocked via sysctl" - ret=1 + ret=${KSFT_FAIL} return 1 fi @@ -302,7 +302,7 @@ do_ping() if [ $rc -ne 0 ] ; then mptcp_lib_pr_fail "$listener_ns -> $connect_addr connectivity" - ret=1 + ret=${KSFT_FAIL} return 1 fi @@ -821,7 +821,7 @@ log_if_error() mptcp_lib_pr_fail "${msg}" final_ret=${ret} - ret=0 + ret=${KSFT_PASS} return ${final_ret} fi diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 728575fd86ea..5e9211e89825 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -25,7 +25,6 @@ err="" capout="" ns1="" ns2="" -ksft_skip=4 iptables="iptables" ip6tables="ip6tables" timeout_poll=30 @@ -392,15 +391,15 @@ setup_fail_rules() -p tcp \ -m length --length 150:9999 \ -m statistic --mode nth --packet 1 --every 99999 \ - -j MARK --set-mark 42 || return ${ksft_skip} + -j MARK --set-mark 42 || return ${KSFT_SKIP} - tc -n $ns2 qdisc add dev ns2eth$i clsact || return ${ksft_skip} + tc -n $ns2 qdisc add dev ns2eth$i clsact || return ${KSFT_SKIP} tc -n $ns2 filter add dev ns2eth$i egress \ protocol ip prio 1000 \ handle 42 fw \ action pedit munge offset 148 u8 invert \ pipe csum tcp \ - index 100 || return ${ksft_skip} + index 100 || return ${KSFT_SKIP} } reset_with_fail() @@ -414,7 +413,7 @@ reset_with_fail() local rc=0 setup_fail_rules "${@}" || rc=$? - if [ ${rc} -eq ${ksft_skip} ]; then + if [ ${rc} -eq ${KSFT_SKIP} ]; then mark_as_skipped "unable to set the 'fail' rules" return 1 fi @@ -450,7 +449,7 @@ reset_with_tcp_filter() # $1: err msg fail_test() { - ret=1 + ret=${KSFT_FAIL} if [ ${#} -gt 0 ]; then print_fail "${@}" @@ -3632,7 +3631,7 @@ usage() { if [ -n "${1}" ]; then echo "${1}" - ret=1 + ret=${KSFT_FAIL} fi echo "mptcp_join usage:" diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh index 96aa8f71bbb0..e2d70c18786e 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -105,7 +105,7 @@ check_mark() if [ $v -ne 0 ]; then mptcp_lib_pr_fail "got $tables $values in ns $ns," \ "not 0 - not all expected packets marked" - ret=1 + ret=${KSFT_FAIL} return 1 fi done @@ -178,7 +178,7 @@ do_transfer() mptcp_lib_result_fail "transfer ${ip}" - ret=1 + ret=${KSFT_FAIL} return 1 fi if ! mptcp_lib_check_transfer $cin $sout "file received by server"; then diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index 69ffff8b076b..6ab8c5d36340 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -19,11 +19,11 @@ while getopts "$optstring" option;do case "$option" in "h") usage $0 - exit 0 + exit ${KSFT_PASS} ;; "?") usage $0 - exit 1 + exit ${KSFT_FAIL} ;; esac done @@ -57,13 +57,13 @@ check() mptcp_lib_check_output "${err}" "${cmd}" "${expected}" || rc=${?} if [ ${rc} -eq 2 ]; then mptcp_lib_result_fail "${msg} # error ${rc}" - ret=1 + ret=${KSFT_FAIL} elif [ ${rc} -eq 0 ]; then mptcp_lib_print_ok "[ OK ]" mptcp_lib_result_pass "${msg}" elif [ ${rc} -eq 1 ]; then mptcp_lib_result_fail "${msg} # different output" - ret=1 + ret=${KSFT_FAIL} fi } diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh index e62052c3206d..1b2366220388 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -263,7 +263,7 @@ while getopts "bcdh" option;do case "$option" in "h") usage $0 - exit 0 + exit ${KSFT_PASS} ;; "b") bail=1 @@ -276,7 +276,7 @@ while getopts "bcdh" option;do ;; "?") usage $0 - exit 1 + exit ${KSFT_FAIL} ;; esac done diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index 72dca742280f..9e2981f2d7f5 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -89,7 +89,7 @@ test_fail() then mptcp_lib_pr_fail "${@}" fi - ret=1 + ret=${KSFT_FAIL} mptcp_lib_result_fail "${test_name}" } @@ -209,7 +209,7 @@ make_connection() else test_fail "Expected tokens (c:${client_token} - s:${server_token}) and server (c:${client_serverside} - s:${server_serverside})" mptcp_lib_result_print_all_tap - exit 1 + exit ${KSFT_FAIL} fi if [ "$is_v6" = "v6" ]