From nobody Thu Dec 5 02:33:28 2024 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 8DC48DDDA for ; Sun, 25 Feb 2024 13:04: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=1708866252; cv=none; b=Q8BqpGhAvtAGID0XkNujf8xo9RY7UIcNY6vtvpWhwrgqvkzGzsviHGLrAfrDPXXxT7Gbbwqi7HCcVMAOvN6Bv+oOh7yyPX8coZsIwXgTsSFv3L1vEZMlNtd4BlaNiUFI8Gl4aUZ2OyB+hxz2ZB5nFt1QwPXxKNj4QrYSMgaXlZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708866252; c=relaxed/simple; bh=A3q629OfMfZgv+UL+usHh+LKq2uhgG4x/mpHlKUfmog=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VCHksKFYP/VoGXh1R6vQQVH+GePQR6TS/OAJ5WYd8OYjPyW7B3rI49RuwWhclvKPMdUVU+78TbbEEFXIpqoBQP+A89QxV/p4ee74eaDUVEgU6XEFuhyk2gDY+7hPShpSqyCNRPUMe4L6HTqrSScd5EOVIzui2Gpehwzm5PWSVmA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dZGhx0m2; 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="dZGhx0m2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15E9FC43390; Sun, 25 Feb 2024 13:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708866252; bh=A3q629OfMfZgv+UL+usHh+LKq2uhgG4x/mpHlKUfmog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dZGhx0m2UHqRAQ/rcuF2d9xMab+KQdSoMGLpVdqyWiNsYwkXoOOQ5/2F7k4WbdDEr +1m6L69XmDXfxkmDx6u3y8bNd/c63OTmHCoaCrxKz7cwI41a1XCxPnXXim3RNOC9Ai caVinoe+O6+kTwSFOZbGigt5fAbAwVF79gYH6xhbygHZxu8FsqhpMvYgdhKkfTxpef xsEEnd1XTy+NQwtN1uZ7ccTdunQnRsUAZjd3VL8oGPbYWvbAOz4mF2Y418Jnkrc5Wj Xz89IjGoqTGMchC2bvjqNJPqPjkszer7yzkn1kPxoLVTLu4NhwU0bPUqUz8NrrK+XG IO29ChcW2+6eg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 01/13] selftests: mptcp: capitalize ok/fail/skip Date: Sun, 25 Feb 2024 21:03:49 +0800 Message-Id: <52d42e66e9e5f1dd34220e38ca763ab41ba22f15.1708866087.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Most scripts print uppercase [ OK ], [FAIL] and [SKIP] as test results, but lowercase ones are used in diag.sh, mptcp_join.sh and simult_flows.sh. To maintain consistency with other scripts, this patch capitalizes these lowercase [ ok ], [ fail ] and [ skip ]: [ ok ] -> [ OK ] in diag.sh, mptcp_join.sh [ fail ] -> [FAIL] in diag.sh, mptcp_join.sh, simult_flows.sh [ skip ] -> [SKIP] in diag.sh, mptcp_join.sh Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/diag.sh | 12 ++++++------ .../testing/selftests/net/mptcp/mptcp_connect.sh | 16 ++++++++-------- tools/testing/selftests/net/mptcp/mptcp_join.sh | 6 +++--- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 2 +- .../testing/selftests/net/mptcp/simult_flows.sh | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/self= tests/net/mptcp/diag.sh index d8f080f934ac..aa3fb808fc6d 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -58,15 +58,15 @@ __chk_nr() printf "%-50s" "$msg" if [ "$nr" !=3D "$expected" ]; then if [ "$nr" =3D "$skip" ] && ! mptcp_lib_expect_all_features; then - echo "[ skip ] Feature probably not supported" + echo "[SKIP] Feature probably not supported" mptcp_lib_result_skip "${msg}" else - echo "[ fail ] expected $expected found $nr" + echo "[FAIL] expected $expected found $nr" mptcp_lib_result_fail "${msg}" ret=3D$test_cnt fi else - echo "[ ok ]" + echo "[ OK ]" mptcp_lib_result_pass "${msg}" fi test_cnt=3D$((test_cnt+1)) @@ -116,15 +116,15 @@ wait_msk_nr() =20 printf "%-50s" "$msg" if [ $i -ge $timeout ]; then - echo "[ fail ] timeout while expecting $expected max $max last $nr" + echo "[FAIL] timeout while expecting $expected max $max last $nr" mptcp_lib_result_fail "${msg} # timeout" ret=3D$test_cnt elif [ $nr !=3D $expected ]; then - echo "[ fail ] expected $expected found $nr" + echo "[FAIL] expected $expected found $nr" mptcp_lib_result_fail "${msg} # unexpected result" ret=3D$test_cnt else - echo "[ ok ]" + echo "[ OK ]" mptcp_lib_result_pass "${msg}" fi test_cnt=3D$((test_cnt+1)) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_connect.sh index 0ca2960c9099..ab3bb3b17522 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -254,7 +254,7 @@ check_mptcp_disabled() =20 # net.mptcp.enabled should be enabled by default if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ pr= int $3 }')" -ne 1 ]; then - echo -e "net.mptcp.enabled sysctl is not 1 by default\t\t[ FAIL ]" + echo -e "net.mptcp.enabled sysctl is not 1 by default\t\t[FAIL]" mptcp_lib_result_fail "net.mptcp.enabled sysctl is not 1 by default" ret=3D1 return 1 @@ -267,7 +267,7 @@ check_mptcp_disabled() mptcp_lib_ns_exit "${disabled_ns}" =20 if [ ${err} -eq 0 ]; then - echo -e "New MPTCP socket cannot be blocked via sysctl\t\t[ FAIL ]" + echo -e "New MPTCP socket cannot be blocked via sysctl\t\t[FAIL]" mptcp_lib_result_fail "New MPTCP socket cannot be blocked via sysctl" ret=3D1 return 1 @@ -294,7 +294,7 @@ do_ping() ip netns exec ${connector_ns} ping ${ping_args} $connect_addr >/dev/null = || rc=3D1 =20 if [ $rc -ne 0 ] ; then - echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2 + echo "$listener_ns -> $connect_addr connectivity [FAIL]" 1>&2 ret=3D1 =20 return 1 @@ -427,7 +427,7 @@ do_transfer() result_msg+=3D" # time=3D${duration}ms" printf "(duration %05sms) " "${duration}" if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then - echo "[ FAIL ] client exit code $retc, server $rets" 1>&2 + echo "[FAIL] client exit code $retc, server $rets" 1>&2 echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport =3D :$port" cat /tmp/${listener_ns}.out @@ -469,13 +469,13 @@ do_transfer() fi =20 if [ ${stat_synrx_now_l} -lt ${expect_synrx} ]; then - printf "[ FAIL ] lower MPC SYN rx (%d) than expected (%d)\n" \ + printf "[FAIL] lower MPC SYN rx (%d) than expected (%d)\n" \ "${stat_synrx_now_l}" "${expect_synrx}" 1>&2 retc=3D1 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" \ + printf "[FAIL] lower MPC ACK rx (%d) than expected (%d)\n" \ "${stat_ackrx_now_l}" "${expect_ackrx}" 1>&2 rets=3D1 else @@ -491,13 +491,13 @@ do_transfer() =20 local csum_err_s_nr=3D$((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} + printf "[FAIL]\nserver got %d data checksum error[s]" ${csum_err_s_nr} rets=3D1 fi =20 local csum_err_c_nr=3D$((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} + printf "[FAIL]\nclient got %d data checksum error[s]" ${csum_err_c_nr} retc=3D1 fi fi diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 1df2d24979a0..8e8977031fa0 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -190,17 +190,17 @@ print_info() =20 print_ok() { - mptcp_lib_print_ok "[ ok ]${1:+ ${*}}" + mptcp_lib_print_ok "[ OK ]${1:+ ${*}}" } =20 print_fail() { - mptcp_lib_print_err "[fail]${1:+ ${*}}" + mptcp_lib_print_err "[FAIL]${1:+ ${*}}" } =20 print_skip() { - mptcp_lib_print_warn "[skip]${1:+ ${*}}" + mptcp_lib_print_warn "[SKIP]${1:+ ${*}}" } =20 # [ $1: fail msg ] diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing= /selftests/net/mptcp/mptcp_lib.sh index 763a2989ca6d..7e309493eda2 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -292,7 +292,7 @@ mptcp_lib_check_transfer() { local what=3D"${3}" =20 if ! cmp "$in" "$out" > /dev/null 2>&1; then - echo "[ FAIL ] $what does not match (in, out):" + echo "[FAIL] $what does not match (in, out):" mptcp_lib_print_file_err "$in" mptcp_lib_print_file_err "$out" =20 diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/test= ing/selftests/net/mptcp/simult_flows.sh index 467feb17e07b..58cfdaf1db25 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -192,7 +192,7 @@ do_transfer() return 0 fi =20 - echo " [ fail ]" + echo " [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 =3D :$port" --=20 2.40.1 From nobody Thu Dec 5 02:33:28 2024 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 B8FDADDDA for ; Sun, 25 Feb 2024 13:04:13 +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=1708866253; cv=none; b=LqUyl9FHFw75B0l52fiZbbykcAbKXi56QSiKM0K+pxqDWTPbqfS8783+psdOJYw4eOc2bu1zn4xjxWcw6etZk9FZY34N1C6CkBijUiJzWcjMFoMCt9UBXP9YFOcJJnxpHqIza/I148oKP0d3nh2rqqsSBYV+l9tN00hRLgJ9JYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708866253; c=relaxed/simple; bh=LTtlVZgYotInA94KDfW/ER+WgCskEZLdprctLQWWxEo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QcsGTLr2mOVZd71GrCxNmj7rvUc0hjKpQTcPSdcsa0LRbDLWAaPHlsfpdGXeXYHpeukkF+CAKEbz/WSMw6uEqHoEi9EWKpYC+0ZRpugwYydXnXGOS4/gnUMobz7dOtd57J9JCinmVtwn7B/GG86mfRHWU88SWlcxl0tgtDxXR7Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ymo59Gfo; 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="Ymo59Gfo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7ED5DC433C7; Sun, 25 Feb 2024 13:04:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708866253; bh=LTtlVZgYotInA94KDfW/ER+WgCskEZLdprctLQWWxEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ymo59Gfopvm/yXNxAYkbpyVVJv7EpBS4qlCzzDVFxGvWIMcQpTM4X78DHDwKaXhiZ MgSVWv4JvxYszVg+AFr9vxZrStzaPgvtV41nITd9eOkfmhkyqgUR0IkmYp5ZL4EjRA PmxRdNzb4PjbQxgPuDHmkp6vouTWnSmN4AabpLPqxxmlNzXAKv/Ap//+4xwNTrEmQI DHmrYGan1oGF38NPGGhYpbRkbRY/2URgv+pNGcv2s36bOcgg1fMaacf+DOZbpPEjny Scg4DlbBrovPloa25LGUvisIV+HAZ54KJNTuejqVzK21K5pk6cKVj+IKJ4AOJd7Pag E5T6c7XlMVJ+A== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 02/13] selftests: mptcp: sockopt: print every test result Date: Sun, 25 Feb 2024 21:03:50 +0800 Message-Id: <1aa6a9af7ebd8690e595bfbbdde5f54f684f51e8.1708866087.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 This patch prints more info for every test result in each test group: transfer ipv4 [ OK ] mark ipv4 [ OK ] transfer ipv6 [ OK ] mark ipv6 [ OK ] PASS: all packets had packet mark set sockopt v4 [ OK ] sockopt v6 [ OK ] PASS: SOL_MPTCP getsockopt has expected information TCP_INQ: -t tcp [ OK ] PASS: TCP_INQ cmsg/ioctl -t tcp TCP_INQ: -6 -t tcp [ OK ] PASS: TCP_INQ cmsg/ioctl -6 -t tcp TCP_INQ: -r tcp [ OK ] PASS: TCP_INQ cmsg/ioctl -r tcp TCP_INQ: -6 -r tcp [ OK ] PASS: TCP_INQ cmsg/ioctl -6 -r tcp TCP_INQ: -r tcp -t tcp [ OK ] Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_sockopt.sh index 6ed4aa32222f..f84185b5dc9f 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -161,6 +161,7 @@ do_transfer() wait $spid local rets=3D$? =20 + printf "%-50s" "transfer ${ip}" if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then echo " client exit code $retc, server $rets" 1>&2 echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 @@ -169,12 +170,15 @@ do_transfer() echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2 ip netns exec ${connector_ns} ss -Menita 1>&2 -o "dport =3D :$port" =20 + mptcp_lib_print_err "[FAIL]" mptcp_lib_result_fail "transfer ${ip}" =20 ret=3D1 return 1 fi + mptcp_lib_print_ok "[ OK ]" =20 + printf "%-50s" "mark ${ip}" if [ $local_addr =3D "::" ];then check_mark $listener_ns 6 || retc=3D1 check_mark $connector_ns 6 || retc=3D1 @@ -190,8 +194,10 @@ do_transfer() mptcp_lib_result_code "${rets}" "transfer ${ip}" =20 if [ $retc -eq 0 ] && [ $rets -eq 0 ];then + mptcp_lib_print_ok "[ OK ]" return 0 fi + mptcp_lib_print_err "[FAIL]" =20 return 1 } @@ -220,23 +226,27 @@ do_mptcp_sockopt_tests() ip netns exec "$ns_sbox" ./mptcp_sockopt lret=3D$? =20 + printf "%-50s" "sockopt v4" if [ $lret -ne 0 ]; then echo "FAIL: SOL_MPTCP getsockopt" 1>&2 mptcp_lib_result_fail "sockopt v4" ret=3D$lret return fi + mptcp_lib_print_ok "[ OK ]" mptcp_lib_result_pass "sockopt v4" =20 ip netns exec "$ns_sbox" ./mptcp_sockopt -6 lret=3D$? =20 + printf "%-50s" "sockopt v6" if [ $lret -ne 0 ]; then echo "FAIL: SOL_MPTCP getsockopt (ipv6)" 1>&2 mptcp_lib_result_fail "sockopt v6" ret=3D$lret return fi + mptcp_lib_print_ok "[ OK ]" mptcp_lib_result_pass "sockopt v6" } =20 @@ -259,6 +269,7 @@ run_tests() =20 do_tcpinq_test() { + printf "%-50s" "TCP_INQ: $*" ip netns exec "$ns_sbox" ./mptcp_inq "$@" local lret=3D$? if [ $lret -ne 0 ];then @@ -267,6 +278,7 @@ do_tcpinq_test() mptcp_lib_result_fail "TCP_INQ: $*" return $lret fi + mptcp_lib_print_ok "[ OK ]" =20 echo "PASS: TCP_INQ cmsg/ioctl $*" mptcp_lib_result_pass "TCP_INQ: $*" --=20 2.40.1 From nobody Thu Dec 5 02:33:28 2024 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 A0986DDDA for ; Sun, 25 Feb 2024 13:04:14 +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=1708866254; cv=none; b=J1PiAiLbVgHzKsueUPzrvCGVPi/fbEM9k2W/aSoB3v2oreMZkuIO10AgdAxeZ5P24fN9W1wI5OCraKP8I/C+yrueZQ3mQXtoddS4Ue/Kf9jXaSoevYKZDnaqy3pr0Kgoz6xQuUuW6dawlHMSyrmzOxRTOxxaMNXVtJf0AM0XuWY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708866254; c=relaxed/simple; bh=AsYKZHM4Vkh2vInRTD66a/lR6QtG8JnarTaSy0Wg31I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=X3vk8Z9Om4/fHH8UlJ93FVZ1MHu7KD27jal8XwryXYdDNI03BfrNuuFfTknfsh5EGm5eJOaEysrrtfT6vXdE+cm1pCbLXPHr98pd/kN0S45ucAHU7lpXNN4KAVH1Z3lh7wcWM99inMTZlEUiqpROepYssRDYxrX43zWUUa2/GLw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=npoxUe0w; 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="npoxUe0w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B68A6C43390; Sun, 25 Feb 2024 13:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708866254; bh=AsYKZHM4Vkh2vInRTD66a/lR6QtG8JnarTaSy0Wg31I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=npoxUe0wysWjfIFaWXXq4MGgUeb6df7uH+XvV50xnHpl/6al1oLyT/1t+hQcb2ODa HMN5I4GG80YX2/3sSQtaEMenbVnR8K2Mtgk8hDqXXOJy3B0ShW/gS8NRjWw8WXQgqs PQZv1UwNlVn4uU/HorAaBEw/RQ9giYGhftyk5SThdeZ2R4npuzdp1sO8k5AV39PwUY P3fqdksQailIW5pRITmpWMQ8s7GAHS+U2Zn0TpkZdj2Xv/xuuRysS65yICZcoJBky0 AKOjHq2BRH0hg+ZEKaW4WWCAR9kUuDcG5OZInCkCwNCc+8kbWT3QmflgCKr7nUqi8f KWJ4+IJ4tpFfQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 03/13] selftests: mptcp: connect: fix misaligned OK/FAIL Date: Sun, 25 Feb 2024 21:03:51 +0800 Message-Id: <57d3e04f51798ad454f1f028cd9a59a5066f0a96.1708866087.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang The first [ OK ] and [FAIL] in the output of mptcp_connect.sh misalign 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 fixes them. Signed-off-by: Geliang Tang --- 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/tes= ting/selftests/net/mptcp/mptcp_connect.sh index ab3bb3b17522..72be905bab1f 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -254,7 +254,7 @@ check_mptcp_disabled() =20 # net.mptcp.enabled should be enabled by default if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ pr= int $3 }')" -ne 1 ]; then - echo -e "net.mptcp.enabled sysctl is not 1 by default\t\t[FAIL]" + echo -e "net.mptcp.enabled sysctl is not 1 by default\t\t\t [FAIL]" mptcp_lib_result_fail "net.mptcp.enabled sysctl is not 1 by default" ret=3D1 return 1 @@ -267,13 +267,13 @@ check_mptcp_disabled() mptcp_lib_ns_exit "${disabled_ns}" =20 if [ ${err} -eq 0 ]; then - echo -e "New MPTCP socket cannot be blocked via sysctl\t\t[FAIL]" + echo -e "New MPTCP socket cannot be blocked via sysctl\t\t\t [FAIL]" mptcp_lib_result_fail "New MPTCP socket cannot be blocked via sysctl" ret=3D1 return 1 fi =20 - echo -e "New MPTCP socket can be blocked via sysctl\t\t[ OK ]" + echo -e "New MPTCP socket can be blocked via sysctl\t\t\t [ OK ]" mptcp_lib_result_pass "New MPTCP socket can be blocked via sysctl" return 0 } --=20 2.40.1 From nobody Thu Dec 5 02:33:28 2024 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 1F53F10A3C for ; Sun, 25 Feb 2024 13:04: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=1708866256; cv=none; b=GXU5zfjLwqeL+a0O5/LEYk73pnH2faqplkvwCrtLXJg3QllbeRc5aD4H1ADWMfoVgBwp5bsFTt9i5AHFOjzyKIcKu0HM/8QK6taCiiSupO9cm7F82nzz3taMhBPkVVApf0WiwH1uU8nF85tw8FdM3imVzXrYDP0RFQfKXC0daqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708866256; c=relaxed/simple; bh=T4MmkKHM/NoFIeBDbfWyu70AGnNA1CXbMKM4l72JipA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=d/B7ashHPIZNFE2ZJ3IASMZMiNiLPlVj4Ue/CaqF+NyDecB0PTPyktGoNR/ZpXMVlMwu8qXJwUybvZNSlDmd329eHcAJd50U1UUjWJjH3eYgCHgh7YbnSxG+EQOh5LReAJvFhSTeA9d6+7zSqbDGlP1Ha4CLmBLv5D0XvtnWmxU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=naW5tanY; 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="naW5tanY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE3A1C433C7; Sun, 25 Feb 2024 13:04:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708866255; bh=T4MmkKHM/NoFIeBDbfWyu70AGnNA1CXbMKM4l72JipA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=naW5tanY8HzDtSqCubuatFScJ+cNuIcxGxBdH0JLXjaGF5dSYOUadnzt4tQWEVCfj QkMZU8gLhRdgkAGZqFp5IqPn/r57/p4jo4niSYLZyKG51tlOlJLRR8RQGdsb7gwmIz TGpyZDi0YOey5aQ1KGu/QBOYtbwDnaJVBcUSZcLwDjwrMyAddXJY99y1uQ4aGxn3Sg J4T9/D8v/usl62J1hRuAMmaVCLkpJ1X2NRIrOTYR0Q7sKfOoE4iAX7p31pRuHZ6qXo B350ICmj8H9KriJmviOUND+mS+nLftTyeSaLugUjFf62v6Gs1w89A49l0UgBoGSL9B YUPzZnxn8DhBA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 04/13] selftests: mptcp: print test results with colors Date: Sun, 25 Feb 2024 21:03:52 +0800 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang The helper mptcp_lib_verify_listener_events() will be added latter in mptcp_lib.sh, and be used by mptcp_join.sh and userspace_pm.sh. The former prints colored output while the latter is not. It makes sense to unify them. This patch uses mptcp_lib_print_ok(), _warn(), _err() and _info() helpers in scripts diag.sh, mptcp_connect.sh, mptcp_sockopt.sh, pm_netlink.sh, simult_flows.sh and userspace_pm.sh to print test results with colors. Having colors helps to quickly identify issues when looking at a long list of output logs and results. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/diag.sh | 12 ++++---- .../selftests/net/mptcp/mptcp_connect.sh | 28 ++++++++++--------- .../selftests/net/mptcp/mptcp_sockopt.sh | 16 +++++------ .../testing/selftests/net/mptcp/pm_netlink.sh | 3 +- .../selftests/net/mptcp/simult_flows.sh | 4 +-- .../selftests/net/mptcp/userspace_pm.sh | 13 +++------ 6 files changed, 37 insertions(+), 39 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/self= tests/net/mptcp/diag.sh index aa3fb808fc6d..f9f62a8f41e3 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -58,15 +58,15 @@ __chk_nr() printf "%-50s" "$msg" if [ "$nr" !=3D "$expected" ]; then if [ "$nr" =3D "$skip" ] && ! mptcp_lib_expect_all_features; then - echo "[SKIP] Feature probably not supported" + mptcp_lib_print_warn "[SKIP] Feature probably not supported" mptcp_lib_result_skip "${msg}" else - echo "[FAIL] expected $expected found $nr" + mptcp_lib_print_err "[FAIL] expected $expected found $nr" mptcp_lib_result_fail "${msg}" ret=3D$test_cnt fi else - echo "[ OK ]" + mptcp_lib_print_ok "[ OK ]" mptcp_lib_result_pass "${msg}" fi test_cnt=3D$((test_cnt+1)) @@ -116,15 +116,15 @@ wait_msk_nr() =20 printf "%-50s" "$msg" if [ $i -ge $timeout ]; then - echo "[FAIL] timeout while expecting $expected max $max last $nr" + mptcp_lib_print_err "[FAIL] timeout while expecting $expected max $max l= ast $nr" mptcp_lib_result_fail "${msg} # timeout" ret=3D$test_cnt elif [ $nr !=3D $expected ]; then - echo "[FAIL] expected $expected found $nr" + mptcp_lib_print_err "[FAIL] expected $expected found $nr" mptcp_lib_result_fail "${msg} # unexpected result" ret=3D$test_cnt else - echo "[ OK ]" + mptcp_lib_print_ok "[ OK ]" mptcp_lib_result_pass "${msg}" fi test_cnt=3D$((test_cnt+1)) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_connect.sh index 72be905bab1f..c7483902026b 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -254,7 +254,8 @@ check_mptcp_disabled() =20 # net.mptcp.enabled should be enabled by default if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ pr= int $3 }')" -ne 1 ]; then - echo -e "net.mptcp.enabled sysctl is not 1 by default\t\t\t [FAIL]" + echo -n -e "net.mptcp.enabled sysctl is not 1 by default" + mptcp_lib_print_err "\t\t\t [FAIL]" mptcp_lib_result_fail "net.mptcp.enabled sysctl is not 1 by default" ret=3D1 return 1 @@ -267,13 +268,15 @@ check_mptcp_disabled() mptcp_lib_ns_exit "${disabled_ns}" =20 if [ ${err} -eq 0 ]; then - echo -e "New MPTCP socket cannot be blocked via sysctl\t\t\t [FAIL]" + echo -n -e "New MPTCP socket cannot be blocked via sysctl" + mptcp_lib_print_err "\t\t\t [FAIL]" mptcp_lib_result_fail "New MPTCP socket cannot be blocked via sysctl" ret=3D1 return 1 fi =20 - echo -e "New MPTCP socket can be blocked via sysctl\t\t\t [ OK ]" + echo -n -e "New MPTCP socket can be blocked via sysctl" + mptcp_lib_print_ok "\t\t\t [ OK ]" mptcp_lib_result_pass "New MPTCP socket can be blocked via sysctl" return 0 } @@ -503,7 +506,7 @@ do_transfer() fi =20 if [ $retc -eq 0 ] && [ $rets -eq 0 ]; then - printf "[ OK ]" + mptcp_lib_print_ok "[ OK ]" mptcp_lib_result_pass "${TEST_GROUP}: ${result_msg}" else mptcp_lib_result_fail "${TEST_GROUP}: ${result_msg}" @@ -534,7 +537,6 @@ do_transfer() "${expect_ackrx}" "${stat_ackrx_now_l}" fi =20 - echo cat "$capout" [ $retc -eq 0 ] && [ $rets -eq 0 ] } @@ -708,7 +710,7 @@ EOF return fi =20 - echo "INFO: test $msg" + mptcp_lib_print_info "INFO: test $msg" =20 TEST_COUNT=3D10000 local extra_args=3D"-o TRANSPARENT" @@ -721,12 +723,12 @@ EOF ip -net "$listener_ns" route del local $local_addr/0 dev lo table 100 =20 if [ $lret -ne 0 ]; then - echo "FAIL: $msg, mptcp connection error" 1>&2 + mptcp_lib_print_err "FAIL: $msg, mptcp connection error" 1>&2 ret=3D$lret return 1 fi =20 - echo "PASS: $msg" + mptcp_lib_print_ok "PASS: $msg" return 0 } =20 @@ -735,7 +737,7 @@ run_tests_peekmode() local peekmode=3D"$1" =20 TEST_GROUP=3D"peek mode: ${peekmode}" - echo "INFO: with peek mode: ${peekmode}" + mptcp_lib_print_info "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}" } @@ -750,7 +752,7 @@ run_tests_mptfo() return fi =20 - echo "INFO: with MPTFO start" + mptcp_lib_print_info "INFO: with MPTFO start" ip netns exec "$ns1" sysctl -q net.ipv4.tcp_fastopen=3D2 ip netns exec "$ns2" sysctl -q net.ipv4.tcp_fastopen=3D1 =20 @@ -762,7 +764,7 @@ run_tests_mptfo() =20 ip netns exec "$ns1" sysctl -q net.ipv4.tcp_fastopen=3D0 ip netns exec "$ns2" sysctl -q net.ipv4.tcp_fastopen=3D0 - echo "INFO: with MPTFO end" + mptcp_lib_print_info "INFO: with MPTFO end" } =20 run_tests_disconnect() @@ -786,7 +788,7 @@ run_tests_disconnect() cin_disconnect=3D"$old_cin" connect_per_transfer=3D3 =20 - echo "INFO: disconnect" + mptcp_lib_print_info "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" =20 @@ -835,7 +837,7 @@ check_mptcp_disabled =20 stop_if_error "The kernel configuration is not valid for MPTCP" =20 -echo "INFO: validating network environment with pings" +mptcp_lib_print_info "INFO: 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 diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_sockopt.sh index f84185b5dc9f..cfa0cfb918f4 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -218,7 +218,7 @@ do_mptcp_sockopt_tests() local lret=3D0 =20 if ! mptcp_lib_kallsyms_has "mptcp_diag_fill_info$"; then - echo "INFO: MPTCP sockopt not supported: SKIP" + mptcp_lib_print_warn "INFO: MPTCP sockopt not supported: SKIP" mptcp_lib_result_skip "sockopt" return fi @@ -228,7 +228,7 @@ do_mptcp_sockopt_tests() =20 printf "%-50s" "sockopt v4" if [ $lret -ne 0 ]; then - echo "FAIL: SOL_MPTCP getsockopt" 1>&2 + mptcp_lib_print_err "FAIL: SOL_MPTCP getsockopt" mptcp_lib_result_fail "sockopt v4" ret=3D$lret return @@ -241,7 +241,7 @@ do_mptcp_sockopt_tests() =20 printf "%-50s" "sockopt v6" if [ $lret -ne 0 ]; then - echo "FAIL: SOL_MPTCP getsockopt (ipv6)" 1>&2 + mptcp_lib_print_err "FAIL: SOL_MPTCP getsockopt (ipv6)" mptcp_lib_result_fail "sockopt v6" ret=3D$lret return @@ -274,13 +274,13 @@ do_tcpinq_test() local lret=3D$? if [ $lret -ne 0 ];then ret=3D$lret - echo "FAIL: mptcp_inq $*" 1>&2 + mptcp_lib_print_err "FAIL: mptcp_inq $*" 1>&2 mptcp_lib_result_fail "TCP_INQ: $*" return $lret fi mptcp_lib_print_ok "[ OK ]" =20 - echo "PASS: TCP_INQ cmsg/ioctl $*" + mptcp_lib_print_info "PASS: TCP_INQ cmsg/ioctl $*" mptcp_lib_result_pass "TCP_INQ: $*" return $lret } @@ -290,7 +290,7 @@ do_tcpinq_tests() local lret=3D0 =20 if ! mptcp_lib_kallsyms_has "mptcp_ioctl$"; then - echo "INFO: TCP_INQ not supported: SKIP" + mptcp_lib_print_warn "INFO: TCP_INQ not supported: SKIP" mptcp_lib_result_skip "TCP_INQ" return fi @@ -327,12 +327,12 @@ run_tests $ns1 $ns2 10.0.1.1 run_tests $ns1 $ns2 dead:beef:1::1 =20 if [ $ret -eq 0 ];then - echo "PASS: all packets had packet mark set" + mptcp_lib_print_info "PASS: all packets had packet mark set" fi =20 do_mptcp_sockopt_tests if [ $ret -eq 0 ];then - echo "PASS: SOL_MPTCP getsockopt has expected information" + mptcp_lib_print_info "PASS: SOL_MPTCP getsockopt has expected information" fi =20 do_tcpinq_tests diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testin= g/selftests/net/mptcp/pm_netlink.sh index 427fc5c70b3c..68fad278ac59 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -189,7 +189,8 @@ subflow,backup,fullmesh 10.0.1.1" " (backup,fu= llmesh)" else for st in fullmesh nofullmesh backup,fullmesh; do st=3D" (${st})" - printf "%-50s%s\n" "${st}" "[SKIP]" + printf "%-50s" "${st}" + mptcp_lib_print_warn "[SKIP]" mptcp_lib_result_skip "${st}" done fi diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/test= ing/selftests/net/mptcp/simult_flows.sh index 58cfdaf1db25..79cb377ee0bd 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_print_ok "[ OK ]" cat "$capout" return 0 fi =20 - echo " [FAIL]" + mptcp_lib_print_err " [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 =3D :$port" diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/test= ing/selftests/net/mptcp/userspace_pm.sh index b0cce8f065d8..33bbb0d5807f 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -61,7 +61,7 @@ _printf() { =20 print_title() { - _printf "INFO: %s\n" "${1}" + mptcp_lib_print_info "INFO: ${1}" } =20 # $1: test name @@ -72,27 +72,22 @@ print_test() _printf "%-68s" "${test_name}" } =20 -print_results() -{ - _printf "[%s]\n" "${1}" -} - test_pass() { - print_results " OK " + mptcp_lib_print_ok "[ OK ]" mptcp_lib_result_pass "${test_name}" } =20 test_skip() { - print_results "SKIP" + mptcp_lib_print_warn "[SKIP]" mptcp_lib_result_skip "${test_name}" } =20 # $1: msg test_fail() { - print_results "FAIL" + mptcp_lib_print_err "[FAIL]${1:+ ${*}}" ret=3D1 =20 if [ -n "${1}" ]; then --=20 2.40.1 From nobody Thu Dec 5 02:33:28 2024 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 E007410A3C for ; Sun, 25 Feb 2024 13:04:16 +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=1708866257; cv=none; b=m8qVxtI8EmEumy1nb4yMYbRz4AmYq5CCtyoVPEBcxxRf5w0s7quOgO7lvogY+oMRDIf3oLRtSq7rHXEHJKxIg7L0unTlvEziJ7fbysNLGUxwUaY0i/5vm5Lj0vjA8QjYVJQjxy0i/2bRlp0C3pkLsjj143pc9ok1W9XMepu2B0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708866257; c=relaxed/simple; bh=bFzDe6XLpSP5eoyrm0uiE68aAhpO/U+AbiYwDW/HntQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=raFgCIn2Yc9ttJq42Ln5bBRZWxIir9R4SZMON3L5wkGPg15n1rE66fSZMp24dLR8NceatRk5C3R0Uj7eqRyHGvWk+q18VVddRiVNuP33Q5tfL7COrBpU7deIt2tw4SwXKbnIpOSPY2nMpYDtu1CeK2otFC86LVIZbBaMK1GUsKI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UWddSwJH; 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="UWddSwJH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A6F4C433F1; Sun, 25 Feb 2024 13:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708866256; bh=bFzDe6XLpSP5eoyrm0uiE68aAhpO/U+AbiYwDW/HntQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UWddSwJHoJWTlMTAfeXDTFoCG9QQlxdbIKGZBqaUjW5suHv1ZeZAZT5TyS4CfxY4h oYZttF1UKHlfK/SDriB3Ox7JiM3ABXvUExyLq29DupJXBKU1zbHMwDzoTsq0ot3EIh q/nygYawG/db0braPT4pOS24BJUc/TbCANsFidZ1wk+e2BCbpInkUqI18wLjXsOxK0 6v2gzVlOUkYhjDTiOUNokVH6xuCB4eifA2ZXSILIKBnkmFiGxxW5v0B59bZRKqbiuT a5olw0vGaD0R9ajXU+Ce24EIwAjqK9w2omjzHIxoLa+qaYqJDpBPX3yFNg4FWf+A+Q vCuN/mQns0Zow== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 05/13] selftests: mptcp: connect: add dedicated port counter Date: Sun, 25 Feb 2024 21:03:53 +0800 Message-Id: <932e4723bdbe01f37eb0f65e04f01a40ec7dd780.1708866087.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_connect.sh index c7483902026b..68073b255983 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=3D0 checksum=3Dfalse filesize=3D0 connect_per_transfer=3D1 +PORT=3D0 =20 if [ $tc_loss -eq 100 ];then tc_loss=3D1% @@ -317,7 +318,7 @@ do_transfer() local extra_args=3D"$7" =20 local port - port=3D$((10000+TEST_COUNT)) + port=3D$((10000+PORT++)) TEST_COUNT=3D$((TEST_COUNT+1)) =20 if [ "$rcvbuf" -gt 0 ]; then @@ -712,7 +713,7 @@ EOF =20 mptcp_lib_print_info "INFO: test $msg" =20 - TEST_COUNT=3D10000 + PORT=3D10000 local extra_args=3D"-o TRANSPARENT" do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP \ ${connect_addr} ${local_addr} "${extra_args}" --=20 2.40.1 From nobody Thu Dec 5 02:33:28 2024 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 42D8D10A3C for ; Sun, 25 Feb 2024 13:04:17 +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=1708866258; cv=none; b=Gz1Zmez/IS/6V0OmqDtr/XRZwU4RFK1JKjMUZ++F7a8PDkPCuzoX4c7AwP8Q2903RJM4bnwe21detNTVzdh+AtoV/a6QKjt9zE08lmrutbtH/GxiLXKq86+0euTZyU8YdDsMahTidSUJgMYyl1PX7OYPVHGuyB0MnKs7F+UQOAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708866258; c=relaxed/simple; bh=YCRuwPv2m6CeZPP+NG6N29G4rt/80odeq0ZRthN18Do=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=raAmeDT89HIbdWjn6atmNaKUSqGIayT1v9jLaH7TR836k3MeX/iTAwHyEZ7GiDlED+jsR3p3/dt3L+R0KG6rFzx894BIAShLFA6XPGVCuUW8qRkyMSFZSzkN35G2R59KAzDTsvIeSxj8qBPtd58WBzNWiauqfRmLtXykTK10/RE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dWcRia8F; 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="dWcRia8F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33F5EC433C7; Sun, 25 Feb 2024 13:04:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708866257; bh=YCRuwPv2m6CeZPP+NG6N29G4rt/80odeq0ZRthN18Do=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dWcRia8Frhw5xKPxTNZv04kq+iVnbM0ZqnEgYOE2dZbeMbyR2UkzRkpTnfq9eGrVu wIVKNTLXaYkdYK2kqks09YmGIJCvXJeSbQfp+FvYJ1y2h+iJe7xmno28DCa8Qg8lKl bzDTdGZHANWA7gL2pCbzf64lsLAoFHCt6dSNWbmKJKnEohhtA3eUDKx4Orm+IjiDEp hCUxWAXsFXtN4cMBV+q+iLPLtiRqh5gm43yuFChgOr1fHu1X255nWvRmuuL709CS21 GTX6aP6toGfpSmTNXQotPztHlyg3Ar849DpTiHfWpkXYiaBk5xVO0mJdONF3GQjWOk g0cieg6sl28PQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 06/13] selftests: mptcp: connect: print out ping tests info Date: Sun, 25 Feb 2024 21:03:54 +0800 Message-Id: <77c1b641cefdf9832b96759e2544e41330161a7c.1708866087.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang 'ping tests' shows in the test results of mptcp_connect.sh: 1..68 ok 1 - mptcp_connect: New MPTCP socket can be blocked via sysctl ok 2 - mptcp_connect: ping tests ok 3 - mptcp_connect: loopback v4: ns1 MPTCP -> ns1 (10.0.1.1:10000) MPTCP ok 4 - mptcp_connect: loopback v4: ns1 MPTCP -> ns1 (10.0.1.1:10001) TCP But not in the test output of this script: New MPTCP socket can be blocked via sysctl [ OK ] INFO: validating network environment with pings INFO: Using loss of 0.01% delay 30 ms reorder 94% 9% with delay 7ms on ns1 MPTCP -> ns1 (10.0.1.1:10000 ) MPTCP (duration 79ms) [ OK ] ns1 MPTCP -> ns1 (10.0.1.1:10001 ) TCP (duration 49ms) [ OK ] This patch fixes this by adding ping tests in test output. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_connect.sh index 68073b255983..06e945914ace 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -861,6 +861,9 @@ mptcp_lib_result_code "${ret}" "ping tests" =20 stop_if_error "Could not even run ping tests" =20 +echo -e "ping tests" +mptcp_lib_print_ok "\t\t\t\t\t\t\t\t [ 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 " --=20 2.40.1 From nobody Thu Dec 5 02:33:28 2024 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 00E3010A3C for ; Sun, 25 Feb 2024 13:04:18 +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=1708866259; cv=none; b=Z5AKtEycC6YkJcsdaLimBg86Bt4kbVoLh5s+N9a4bSEypt4+uqT4RlcZYhw2MjmnEbNjbGaQOTD5Zmk7frpf/TbOaLcmyS3U4tOf8Svwk9l/uGtJsnS1OwUdkX1GhVJhwSf/Cni0d/4MAz7EAmW2qtN4/TVpwmPCPA8fLZDYePY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708866259; c=relaxed/simple; bh=NtWI8hoNQSNaM0fU3cCbGBOP47t4ETz5d7bgpU8oqjs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DpJvnT9nvENbJ09W+7N/QvdO/Ng/FpTOp3DATKzUcYMHeKEeTjXxM0MMeL0Q1Il/x1AiPqJ2fptIx6bwWhoGSbNy7l6XRU/UoEHvXSV/gGvkdFxtT7A3uL6XdMhE//RjGEWZU0LH19LXXnatP7rNllzyuDhZ0IU5DyGmqlk3XAo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M6ts20Yb; 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="M6ts20Yb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E241C433F1; Sun, 25 Feb 2024 13:04:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708866258; bh=NtWI8hoNQSNaM0fU3cCbGBOP47t4ETz5d7bgpU8oqjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M6ts20YbT9xLowQ3APdgTdwiHNRjSOYvYx0a7JYx/PjL6ctgX//a99StfTr9nl+bo bixeXWct/AJZBO77UR4K5eP7PcsdP0UW+f3Gbx9vE+SQl/OoFiPxdT4drO1RslaIBU LGyi+1lpqy7gc+heZNneMib01mV2EuKnKGCkCtNjj5qOrUfq6GKyo+sktfjE4Wn5D7 O5XUNua/ijeBjvsa4e9tc3EebdT2W+C9kY6rWd/21y4Q1Y4doWCvAwX3judC/JpKTE JfHYWXoxlXdU1Ou3Xean6rC6JEYRWh7gtw6372+OCAYOiVFEojNchSfHAkhfrHGMWI R8TJlGuLvJ8rw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 07/13] selftests: mptcp: add mptcp_lib_print_test_counter Date: Sun, 25 Feb 2024 21:03:55 +0800 Message-Id: <2a4cf49beb3327717f2dbcba38a693879893fbd6.1708866087.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang This patch adds a new helper mptcp_lib_print_test_counter() to print out test counter in each test result and increase the counter. The counter digits of most tests are 2, only mptcp_join.sh is 3. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 6 ++---- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 9 +++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 8e8977031fa0..abd5fb4704d1 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -48,7 +48,7 @@ declare -A all_tests declare -a only_tests_ids declare -a only_tests_names declare -A failed_tests -TEST_COUNT=3D0 +TEST_COUNT=3D1 TEST_NAME=3D"" nr_blank=3D6 =20 @@ -172,7 +172,7 @@ cleanup() =20 print_title() { - printf "%03u %s\n" "${TEST_COUNT}" "${TEST_NAME}" + mptcp_lib_print_test_counter TEST_COUNT "%s\n" "${TEST_NAME}" 3 } =20 print_check() @@ -268,8 +268,6 @@ reset() =20 TEST_NAME=3D"${1}" =20 - TEST_COUNT=3D$((TEST_COUNT+1)) - if skip_test; then last_test_ignored=3D1 return 1 diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing= /selftests/net/mptcp/mptcp_lib.sh index 7e309493eda2..630fecb942e4 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -411,3 +411,12 @@ mptcp_lib_events() { ip netns exec "${ns}" ./pm_nl_ctl events >> "${evts}" 2>&1 & pid=3D$! } + +mptcp_lib_print_test_counter() { + declare -n counter=3D"${1}" + local fmt=3D"${2}" + local msg=3D"${3}" + local digit=3D"${4-2}" + + printf "%0${digit}u ${fmt}" "$((counter++))" "${msg}" +} --=20 2.40.1 From nobody Thu Dec 5 02:33:28 2024 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 81930DDDA for ; Sun, 25 Feb 2024 13:04:20 +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=1708866260; cv=none; b=DGkJYT8KGk0MXFSz2n7bz3lcZHsYKsWnfXHZtlIX5Ibgcd/pQFiGYn+YHlMcmGnymWI1NihSw+Z1aTuI63kK6Y/BUgDiimNH8Juw/CcTgXDRULbBzhyU5+iERchYPCcHOyCMr8JJTQ+MM30ceFRqz4VUG4mupNxRwBsJOd1WU0c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708866260; c=relaxed/simple; bh=Y6W/+N3TB0eCf8X+89HS1wryIzi2EX4QG1CBJPG4q/c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g3HEMWXphyRoT1mkkTgFXInTBhIRTAZVgbq5HqF4gU88Ux1xbxMm14BTcnUPSp1e4Ej/VqpmKm2iAoWBELYZfTG6Ixkk/EI9DUZhHz2FVFyKF2P1JsWk/lOq/OKqT392IzIKEKDBCogwH0C8pBlhOG6i/LpGZiOuMmfaadUxgGk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UWQj3Vcv; 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="UWQj3Vcv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A9B3C433C7; Sun, 25 Feb 2024 13:04:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708866260; bh=Y6W/+N3TB0eCf8X+89HS1wryIzi2EX4QG1CBJPG4q/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UWQj3Vcv9vTtjHTH9vGHNZ0wmcWIEAQCr305pMlBrUzJ4agdrvrDYsvAMQAS9beRm mV9utVEBX+nSwkWaRmHoPrNugeSf7rp3f6bhRWpi8XArvlxuBOOcwqEBLzSpE9adil DonscSfm0EPEbsUQm1bZWVx4TKB/yf1004DcLpsIzE4rAZLfcpkBUaMqaNSbEiqFam Wz8jMkobm7p5zVsObG01HSuxm1m5aO1x3mBuwu9qiIXjHqPpQlRvdeBm86p8hoaUJy txpMLPkjxu6uJzXIeM1gXv/Sf/VQcpnKU1fjWHPaSSxhgQcXXr5DkEw9vIvMlgksCb a+3YjbTSNek5w== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 08/13] selftests: mptcp: print test results with counters Date: Sun, 25 Feb 2024 21:03:56 +0800 Message-Id: <9f16a663e25f6df32bab18f6b42be3bcf942d747.1708866087.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang This patch prints 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. Each output looks like: 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 ] INFO: validating network environment with pings 02 ping tests [ OK ] INFO: Using loss of 0.16% delay 25 ms reorder .. with delay 6ms on ns3eth4 03 ns1 MPTCP -> ns1 (10.0.1.1:10000 ) MPTCP (duration 116ms) [ OK ] 04 ns1 MPTCP -> ns1 (10.0.1.1:10001 ) TCP (duration 33ms) [ OK ] 05 ns1 TCP -> ns1 (10.0.1.1:10002 ) MPTCP (duration 25ms) [ OK ] 06 ns1 MPTCP -> ns1 (dead:beef:1::1:10003) MPTCP (duration 128ms) [ OK ] 07 ns1 MPTCP -> ns1 (dead:beef:1::1:10004) TCP (duration 31ms) [ OK ] mptcp_sockopt.sh 01 transfer ipv4 [ OK ] 02 mark ipv4 [ OK ] 03 transfer ipv6 [ OK ] 04 mark ipv6 [ OK ] PASS: all packets had packet mark set 05 sockopt v4 [ OK ] 06 sockopt v6 [ OK ] PASS: SOL_MPTCP getsockopt has expected information 07 TCP_INQ: -t tcp [ OK ] PASS: TCP_INQ cmsg/ioctl -t tcp 08 TCP_INQ: -6 -t tcp [ OK ] PASS: TCP_INQ cmsg/ioctl -6 -t tcp 09 TCP_INQ: -r tcp [ OK ] PASS: TCP_INQ cmsg/ioctl -r tcp 10 TCP_INQ: -6 -r tcp [ 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 ] 06 duplicate addr [ OK ] 07 id addr increment [ OK ] 08 hard addr limit [ OK ] 09 above hard addr limit [ OK ] simult_flows.sh 01 balanced bwidth 7411 max 8456 [ OK ] 02 balanced bwidth - reverse direction 7380 max 8456 [ OK ] 03 balanced bwidth with unbalanced delay 7434 max 8456 [ OK ] userspace_pm.sh INFO: Init 01 Created network namespaces ns1, ns2 [ OK ] INFO: Make connections 02 Established IPv4 MPTCP Connection ns2 =3D> ns1 [ OK ] 03 Established IPv6 MPTCP Connection ns2 =3D> ns1 [ OK ] INFO: Announce tests 04 ADD_ADDR 10.0.2.2 (ns2) =3D> ns1, invalid token [ OK ] 05 ADD_ADDR id:14 10.0.2.2 (ns2) =3D> 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 --- tools/testing/selftests/net/mptcp/diag.sh | 6 ++-- .../selftests/net/mptcp/mptcp_connect.sh | 35 +++++++++++-------- .../selftests/net/mptcp/mptcp_sockopt.sh | 12 ++++--- .../testing/selftests/net/mptcp/pm_netlink.sh | 6 ++-- .../selftests/net/mptcp/simult_flows.sh | 5 ++- .../selftests/net/mptcp/userspace_pm.sh | 3 +- 6 files changed, 38 insertions(+), 29 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/self= tests/net/mptcp/diag.sh index f9f62a8f41e3..79188664ed40 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -55,7 +55,7 @@ __chk_nr() =20 nr=3D$(eval $command) =20 - printf "%-50s" "$msg" + mptcp_lib_print_test_counter test_cnt "%-50s" "$msg" if [ "$nr" !=3D "$expected" ]; then if [ "$nr" =3D "$skip" ] && ! mptcp_lib_expect_all_features; then mptcp_lib_print_warn "[SKIP] Feature probably not supported" @@ -69,7 +69,6 @@ __chk_nr() mptcp_lib_print_ok "[ OK ]" mptcp_lib_result_pass "${msg}" fi - test_cnt=3D$((test_cnt+1)) } =20 __chk_msk_nr() @@ -114,7 +113,7 @@ wait_msk_nr() sleep 1 done =20 - printf "%-50s" "$msg" + mptcp_lib_print_test_counter test_cnt "%-50s" "$msg" if [ $i -ge $timeout ]; then mptcp_lib_print_err "[FAIL] timeout while expecting $expected max $max l= ast $nr" mptcp_lib_result_fail "${msg} # timeout" @@ -127,7 +126,6 @@ wait_msk_nr() mptcp_lib_print_ok "[ OK ]" mptcp_lib_result_pass "${msg}" fi - test_cnt=3D$((test_cnt+1)) } =20 chk_msk_fallback_nr() diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_connect.sh index 06e945914ace..a3316590b989 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -131,7 +131,8 @@ ns2=3D"" ns3=3D"" ns4=3D"" =20 -TEST_COUNT=3D0 +#shellcheck disable=3DSC2034 +TEST_COUNT=3D1 TEST_GROUP=3D"" =20 # This function is used in the cleanup trap @@ -255,8 +256,9 @@ check_mptcp_disabled() =20 # net.mptcp.enabled should be enabled by default if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ pr= int $3 }')" -ne 1 ]; then - echo -n -e "net.mptcp.enabled sysctl is not 1 by default" - mptcp_lib_print_err "\t\t\t [FAIL]" + mptcp_lib_print_test_counter TEST_COUNT "%s" \ + "net.mptcp.enabled sysctl is not 1 by default" + mptcp_lib_print_err "\t\t\t\t [FAIL]" mptcp_lib_result_fail "net.mptcp.enabled sysctl is not 1 by default" ret=3D1 return 1 @@ -269,15 +271,17 @@ check_mptcp_disabled() mptcp_lib_ns_exit "${disabled_ns}" =20 if [ ${err} -eq 0 ]; then - echo -n -e "New MPTCP socket cannot be blocked via sysctl" - mptcp_lib_print_err "\t\t\t [FAIL]" + mptcp_lib_print_test_counter TEST_COUNT "%s" \ + "New MPTCP socket cannot be blocked via sysctl" + mptcp_lib_print_err "\t\t\t\t [FAIL]" mptcp_lib_result_fail "New MPTCP socket cannot be blocked via sysctl" ret=3D1 return 1 fi =20 - echo -n -e "New MPTCP socket can be blocked via sysctl" - mptcp_lib_print_ok "\t\t\t [ OK ]" + mptcp_lib_print_test_counter TEST_COUNT "%s" \ + "New MPTCP socket can be blocked via sysctl" + mptcp_lib_print_ok "\t\t\t\t [ OK ]" mptcp_lib_result_pass "New MPTCP socket can be blocked via sysctl" return 0 } @@ -319,7 +323,6 @@ do_transfer() =20 local port port=3D$((10000+PORT++)) - TEST_COUNT=3D$((TEST_COUNT+1)) =20 if [ "$rcvbuf" -gt 0 ]; then extra_args=3D"$extra_args -R $rcvbuf" @@ -346,7 +349,7 @@ do_transfer() addr_port=3D$(printf "%s:%d" ${connect_addr} ${port}) local result_msg result_msg=3D"$(printf "%.3s %-5s -> %.3s (%-20s) %-5s" ${connector_ns} $= {cl_proto} ${listener_ns} ${addr_port} ${srv_proto})" - printf "%s\t" "${result_msg}" + mptcp_lib_print_test_counter TEST_COUNT "%s\t" "${result_msg}" =20 if $capture; then local capuser @@ -663,7 +666,8 @@ 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_print_test_counter TEST_COUNT "%s\n" \ + "INFO: ${msg} not supported by the kernel: SKIP" mptcp_lib_result_skip "${TEST_GROUP}" return fi @@ -680,7 +684,8 @@ table inet mangle { } EOF then - echo "SKIP: $msg, could not load nft ruleset" + mptcp_lib_print_test_counter TEST_COUNT "%s\n" \ + "SKIP: $msg, could not load nft ruleset" mptcp_lib_fail_if_expected_feature "nft rules" mptcp_lib_result_skip "${TEST_GROUP}" return @@ -696,7 +701,8 @@ EOF =20 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_print_test_counter TEST_COUNT "%s\n" \ + "SKIP: $msg, ip $r6flag rule failed" mptcp_lib_fail_if_expected_feature "ip rule" mptcp_lib_result_skip "${TEST_GROUP}" return @@ -705,7 +711,8 @@ EOF if ! ip -net "$listener_ns" route add local $local_addr/0 dev lo table 10= 0; 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_print_test_counter TEST_COUNT "%s\n" \ + "SKIP: $msg, ip route add local $local_addr failed" mptcp_lib_fail_if_expected_feature "ip route" mptcp_lib_result_skip "${TEST_GROUP}" return @@ -861,7 +868,7 @@ mptcp_lib_result_code "${ret}" "ping tests" =20 stop_if_error "Could not even run ping tests" =20 -echo -e "ping tests" +mptcp_lib_print_test_counter TEST_COUNT "%s" "ping tests" mptcp_lib_print_ok "\t\t\t\t\t\t\t\t [ OK ]" =20 [ -n "$tc_loss" ] && tc -net "$ns2" qdisc add dev ns2eth3 root netem loss = random $tc_loss delay ${tc_delay}ms diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_sockopt.sh index cfa0cfb918f4..5943ec8145f9 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -17,6 +17,8 @@ timeout_poll=3D30 timeout_test=3D$((timeout_poll * 2 + 1)) iptables=3D"iptables" ip6tables=3D"ip6tables" +#shellcheck disable=3DSC2034 +test_cnt=3D1 =20 ns1=3D"" ns2=3D"" @@ -161,7 +163,7 @@ do_transfer() wait $spid local rets=3D$? =20 - printf "%-50s" "transfer ${ip}" + mptcp_lib_print_test_counter test_cnt "%-50s" "transfer ${ip}" if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then echo " client exit code $retc, server $rets" 1>&2 echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 @@ -178,7 +180,7 @@ do_transfer() fi mptcp_lib_print_ok "[ OK ]" =20 - printf "%-50s" "mark ${ip}" + mptcp_lib_print_test_counter test_cnt "%-50s" "mark ${ip}" if [ $local_addr =3D "::" ];then check_mark $listener_ns 6 || retc=3D1 check_mark $connector_ns 6 || retc=3D1 @@ -226,7 +228,7 @@ do_mptcp_sockopt_tests() ip netns exec "$ns_sbox" ./mptcp_sockopt lret=3D$? =20 - printf "%-50s" "sockopt v4" + mptcp_lib_print_test_counter test_cnt "%-50s" "sockopt v4" if [ $lret -ne 0 ]; then mptcp_lib_print_err "FAIL: SOL_MPTCP getsockopt" mptcp_lib_result_fail "sockopt v4" @@ -239,7 +241,7 @@ do_mptcp_sockopt_tests() ip netns exec "$ns_sbox" ./mptcp_sockopt -6 lret=3D$? =20 - printf "%-50s" "sockopt v6" + mptcp_lib_print_test_counter test_cnt "%-50s" "sockopt v6" if [ $lret -ne 0 ]; then mptcp_lib_print_err "FAIL: SOL_MPTCP getsockopt (ipv6)" mptcp_lib_result_fail "sockopt v6" @@ -269,7 +271,7 @@ run_tests() =20 do_tcpinq_test() { - printf "%-50s" "TCP_INQ: $*" + mptcp_lib_print_test_counter test_cnt "%-50s" "TCP_INQ: $*" ip netns exec "$ns_sbox" ./mptcp_inq "$@" local lret=3D$? if [ $lret -ne 0 ];then diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testin= g/selftests/net/mptcp/pm_netlink.sh index 68fad278ac59..435e1b0eb071 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -9,6 +9,8 @@ . "$(dirname "${0}")/mptcp_lib.sh" =20 ret=3D0 +#shellcheck disable=3DSC2034 +test_cnt=3D1 =20 usage() { echo "Usage: $0 [ -h ]" @@ -53,7 +55,7 @@ check() local msg=3D"$3" local rc=3D0 =20 - printf "%-50s" "$msg" + mptcp_lib_print_test_counter test_cnt "%-50s" "$msg" mptcp_lib_check_output "${err}" "${cmd}" "${expected}" || rc=3D${?} if [ ${rc} -eq 2 ]; then mptcp_lib_result_fail "${msg} # error ${rc}" @@ -189,7 +191,7 @@ subflow,backup,fullmesh 10.0.1.1" " (backup,fu= llmesh)" else for st in fullmesh nofullmesh backup,fullmesh; do st=3D" (${st})" - printf "%-50s" "${st}" + mptcp_lib_print_test_counter test_cnt "%-50s" "${st}" mptcp_lib_print_warn "[SKIP]" mptcp_lib_result_skip "${st}" done diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/test= ing/selftests/net/mptcp/simult_flows.sh index 79cb377ee0bd..d2be6a3c9c28 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -127,7 +127,6 @@ do_transfer() local max_time=3D$3 local port port=3D$((10000+test_cnt)) - test_cnt=3D$((test_cnt+1)) =20 :> "$cout" :> "$sout" @@ -239,7 +238,7 @@ run_test() # completion (see mptcp_connect): 200ms on each side, add some slack time=3D$((time + 400 + slack)) =20 - printf "%-60s" "$msg" + mptcp_lib_print_test_counter test_cnt "%-60s" "$msg" do_transfer $small $large $time lret=3D$? mptcp_lib_result_code "${lret}" "${msg}" @@ -249,7 +248,7 @@ run_test() fi =20 msg+=3D" - reverse direction" - printf "%-60s" "${msg}" + mptcp_lib_print_test_counter test_cnt "%-60s" "${msg}" do_transfer $large $small $time lret=3D$? mptcp_lib_result_code "${lret}" "${msg}" diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/test= ing/selftests/net/mptcp/userspace_pm.sh index 33bbb0d5807f..e173a5e6569a 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -53,6 +53,7 @@ server_addr_id=3D${RANDOM:0:2} ns1=3D"" ns2=3D"" ret=3D0 +test_cnt=3D1 test_name=3D"" =20 _printf() { @@ -69,7 +70,7 @@ print_test() { test_name=3D"${1}" =20 - _printf "%-68s" "${test_name}" + mptcp_lib_print_test_counter test_cnt "%-68s" "${test_name}" } =20 test_pass() --=20 2.40.1 From nobody Thu Dec 5 02:33:28 2024 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 9DD6FDDDA for ; Sun, 25 Feb 2024 13:04:21 +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=1708866261; cv=none; b=BIDn2sQ5zdNsXPIWd6z/Rhm2YCNdZPt79LawYvmYyPQz0mkTP3nv3VI5fW2VI0w5tv6yHckMfmjp7PGpjVJBDrpFXewgAE/BAk8j6u1U8KbP110hntWFAJxJ8TOOuARQGmDCcth3wpc8nkP9jlNgqYPSRCUUEznjWqHGBO2GAYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708866261; c=relaxed/simple; bh=tF0QObIedMoOr1NWG6q3pFb8Y4fOSGuD94Idpxh1gxc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EQ7SdzUQAvCqMSAwmV9eUxf9q9HGlV+M/i67Autcb/g/cW/K+YtDp983+DDkJREluxpLBYOANDUCD7WwEiolYABV3NCiRiY/X/n5owwNjiNocoxkko/Zz8bVDYS9ZucvD3LggaU2kenkxIBPOs2c61r/M3ILZ1lPbIiHSnkilo0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ApwYaiiu; 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="ApwYaiiu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94A4BC43390; Sun, 25 Feb 2024 13:04:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708866261; bh=tF0QObIedMoOr1NWG6q3pFb8Y4fOSGuD94Idpxh1gxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ApwYaiiuEETU5pB/u3wLLsePpWgo7E+MHKM1/x5mrXnvjqvcAqkhRGmJCdQDtCXiY WvaLG6GIEW/I913rzLKPAuMgr7ZU7CRknp2ssLz/B0hJx7k69t5p03Ya0a43657/ju cH3NP3/LhymzI7rBH6OXuD5+Fe1eWMkj7P2dpKAJSVRrhVqCeb/3ZNoCPMmu/oxyv8 X9yBJ+gknl7NTugdv0fbU9SMQ0G8Xmp9eX+Gogz0luUnfR8tiSQW6R0qf0lnQ/784b +CEYF5Ix8Zsg+81bTK9lxyX48FqY7KAx+P899e0ICdIYmo8it0xf6StmYMJXKWm5Og XpJEzKp9lik1g== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 09/13] selftests: mptcp: move test_fail out of check_expected_one Date: Sun, 25 Feb 2024 21:03:57 +0800 Message-Id: <694d9be19d5c4a9f242355aae3beada5b0433f9c.1708866087.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang This patch moves test_fail out of check_expected_one(), since test_fail is a private function in userspace_pm.sh, and check_expected_one will be exported in mptcp_lib.sh in the next commit. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/userspace_pm.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/test= ing/selftests/net/mptcp/userspace_pm.sh index e173a5e6569a..ced72741ed56 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -247,7 +247,7 @@ check_expected_one() =20 if [ "${prev_ret}" =3D "0" ] then - test_fail + return 2 fi =20 _printf "\tExpected value for '%s': '%s', got '%s'.\n" \ @@ -263,13 +263,20 @@ check_expected() =20 for var in "${@}" do - check_expected_one "${var}" "${rc}" || rc=3D1 + check_expected_one "${var}" "${rc}" || rc=3D"${?}" + if [ "${rc}" -eq 2 ] + then + break + fi done =20 if [ ${rc} -eq 0 ] then test_pass return 0 + elif [ "${rc}" -eq 2 ] + then + test_fail fi =20 return 1 --=20 2.40.1 From nobody Thu Dec 5 02:33:28 2024 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 CA4FADDDA for ; Sun, 25 Feb 2024 13:04:22 +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=1708866262; cv=none; b=t3putAZJX/s7BvEeDLM7OiEXuU4bQ1WPKKDtzvd1GOQo92e3EG33XUb5sd1xRePBvTJZtLV3MhWUz7ZlSEQybpPmGNtHckUxPTQRCrA4mq6Fu+TTm40miHYHlJmxE+8V2hzZAr3v7qHyfYRZdEtbZAWUeidzT98jtplik1QKMSM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708866262; c=relaxed/simple; bh=cG7LtClUGrTY7Xbzxsz9KBip+L2lbEGjEmbXiGPrnC0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tpy4x2czEXl/9BIWg9+UM96bnxwUZR66xlHOO1IEx8eYRhr5X2Guekj3ekLGagk6mqEFPQABe6LbPkloDDYiEW9rkiPEwYhfO74sORqnvCRq1bHwKNXnnihqBLM4UTJef43b2O0/HY4SCGNzviEMz1zQ/Mg9ZdWG8sN2FCVNslc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lNr21TZ3; 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="lNr21TZ3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A897AC433C7; Sun, 25 Feb 2024 13:04:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708866262; bh=cG7LtClUGrTY7Xbzxsz9KBip+L2lbEGjEmbXiGPrnC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lNr21TZ3tekfLTzV9cL1wvKdGbAlNGk+6G4+eCDMumxZ/Czbn9Re6TTZ9uGkTNaHb zsoO505tFlcZszOWb+P5/doZE7LjhG7JnLStLnpoIkd6Vqu3vTP6NlJASx2cdwp2to K1H3FyglLWl9xsoe19m/WJRXOJZ/TqqKEPo7zOlnoHKy6EsAEGy2lRK2IUbOB50GQr IEW0oHWXzH8S2ceM/0+4aQjDt5DV2ZJpef2je3rAfhGiMR7dFVPFI1Ey/flhRNvE/Z qt2/LU+rLSIcVKzVtg/GvU4OT9kDECezRzczlHbnO4icCqAbJWmsAHvQRrjN7H+lp8 klh3rvDHI2VJg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 10/13] selftests: mptcp: extract mptcp_lib_check_expected Date: Sun, 25 Feb 2024 21:03:58 +0800 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 a sub function of mptcp_lib_check_expected(). Signed-off-by: Geliang Tang --- .../testing/selftests/net/mptcp/mptcp_lib.sh | 48 +++++++++++++++++++ .../selftests/net/mptcp/userspace_pm.sh | 39 ++------------- 2 files changed, 52 insertions(+), 35 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing= /selftests/net/mptcp/mptcp_lib.sh index 630fecb942e4..5dfdb054371d 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -1,6 +1,9 @@ #! /bin/bash # SPDX-License-Identifier: GPL-2.0 =20 +# Some variables are used below but indirectly, see check_expected_one() +#shellcheck disable=3DSC2034 + readonly KSFT_PASS=3D0 readonly KSFT_FAIL=3D1 readonly KSFT_SKIP=3D4 @@ -420,3 +423,48 @@ mptcp_lib_print_test_counter() { =20 printf "%0${digit}u ${fmt}" "$((counter++))" "${msg}" } + +# $@: all var names to check +mptcp_lib_check_expected() { + # $1: var name ; $2: prev ret + check_expected_one() { + local var=3D"${1}" + local exp=3D"e_${var}" + local prev_ret=3D"${2}" + + if [ "${!var}" =3D "${!exp}" ] + then + return 0 + fi + + if [ "${prev_ret}" =3D "0" ] + then + return 2 + fi + + printf "\tExpected value for '%s': '%s', got '%s'.\n" \ + "${var}" "${!exp}" "${!var}" + return 1 + } + + local rc=3D0 + local var + + for var in "${@}" + do + check_expected_one "${var}" "${rc}" || rc=3D"${?}" + if [ "${rc}" -eq 2 ] + then + break + fi + done + unset -f check_expected_one + + if [ ${rc} -eq 0 ] + then + mptcp_lib_print_ok "[ OK ]" + return 0 + fi + + return "${rc}" +} diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/test= ing/selftests/net/mptcp/userspace_pm.sh index ced72741ed56..702484199dd2 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=3DSC2086 =20 -# Some variables are used below but indirectly, see check_expected_one() +# Some variables are used below but indirectly #shellcheck disable=3DSC2034 =20 . "$(dirname "${0}")/mptcp_lib.sh" @@ -233,46 +233,15 @@ make_connection() fi } =20 -# $1: var name ; $2: prev ret -check_expected_one() -{ - local var=3D"${1}" - local exp=3D"e_${var}" - local prev_ret=3D"${2}" - - if [ "${!var}" =3D "${!exp}" ] - then - return 0 - fi - - if [ "${prev_ret}" =3D "0" ] - then - return 2 - fi - - _printf "\tExpected value for '%s': '%s', got '%s'.\n" \ - "${var}" "${!exp}" "${!var}" - return 1 -} - # $@: all var names to check check_expected() { local rc=3D0 - local var =20 - for var in "${@}" - do - check_expected_one "${var}" "${rc}" || rc=3D"${?}" - if [ "${rc}" -eq 2 ] - then - break - fi - done - - if [ ${rc} -eq 0 ] + mptcp_lib_check_expected "${@}" || rc=3D"${?}" + if [ "${rc}" -eq 0 ] then - test_pass + mptcp_lib_result_pass "${test_name}" return 0 elif [ "${rc}" -eq 2 ] then --=20 2.40.1 From nobody Thu Dec 5 02:33:28 2024 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 CF0F7DDDA for ; Sun, 25 Feb 2024 13:04:23 +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=1708866263; cv=none; b=PvKy9NWJ44/zZ9wevV13iwt41g4r5pdWpBNk+kD8ocPvawcL0PisnCQz8CbCEkl2YbCmWow69PwpTulH6JMY/vevXbN9QL8qUCUZam5374mmZRpXQCtlHcaZnJWNOIV4cHzzW4sK7MIJCO3S2gsycxFVmJEXMf50Zs3bOPmK740= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708866263; c=relaxed/simple; bh=0ltaDYn0RNu54rUNYIrHrltvS4f/yMiUhrhzqESauYM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q5QdI5wPbOkfSUw4vtqyWum/HrpSmAAdWsnypMZeGDYUf+Tvc44AEcYqP7iqc3BxxlgBKYVIPTr/evErNT8J4WG9NeOyefxICV250S6eYll/ytL8YY6H3FQCaCxf7N4axreEKSoWCf8b/aNSUHGgc5ptjIQAEClH5w49gO2xQpI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jrlQ7cic; 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="jrlQ7cic" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB436C433F1; Sun, 25 Feb 2024 13:04:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708866263; bh=0ltaDYn0RNu54rUNYIrHrltvS4f/yMiUhrhzqESauYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jrlQ7cicZtoJ3uzUV9po0d3tInhL24xz7pw5FsKRFPJhicm8BYAs0j51gXX55fa7g giLYF5AVYRvrHVMCkMSQJ3sn4RQd+w35jQRTPLw8NmGN9Pu0U+E0I/5w82OXo22pNm uFvcaEbcKUJQ2og4x9N6jawHeDvWu7187YfCminp8orDeG120X7IildycNEKFQ/Lcl ypoSlnEPd1RAas4sJdhkQ69G0Gym6qaSNhfa6hlQ4UhnK0AJX67TKQdf7Wh7H/79I3 qC7Hlpz6ZO9TshwYaoY1QEMCSWGOeNwoFnB/dRpeHIBO7IOhK3tBX0Is8CgmrQrtCI ctm7DirdBXCQQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 11/13] selftests: mptcp: export event macros in mptcp_lib Date: Sun, 25 Feb 2024 21:03:59 +0800 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang SUB_ESTABLISHED, LISTENER_CREATED, LISTENER_CLOSED, AF_INET and AF_INET6 are defined in both mptcp_join.sh and userspace_pm.sh, export all event macros into mptcp_lib.sh. Add MPTCP_LIB_ prefix for the first three and add readonly for the last two. Signed-off-by: Geliang Tang --- .../testing/selftests/net/mptcp/mptcp_join.sh | 23 ++-- .../testing/selftests/net/mptcp/mptcp_lib.sh | 11 ++ .../selftests/net/mptcp/userspace_pm.sh | 121 +++++++++--------- 3 files changed, 80 insertions(+), 75 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index abd5fb4704d1..14f79300e1f8 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -2787,13 +2787,6 @@ backup_tests() fi } =20 -SUB_ESTABLISHED=3D10 # MPTCP_EVENT_SUB_ESTABLISHED -LISTENER_CREATED=3D15 #MPTCP_EVENT_LISTENER_CREATED -LISTENER_CLOSED=3D16 #MPTCP_EVENT_LISTENER_CLOSED - -AF_INET=3D2 -AF_INET6=3D10 - verify_listener_events() { local evt=3D$1 @@ -2807,9 +2800,9 @@ verify_listener_events() local sport local name =20 - if [ $e_type =3D $LISTENER_CREATED ]; then + if [ $e_type =3D $MPTCP_LIB_LISTENER_CREATED ]; then name=3D"LISTENER_CREATED" - elif [ $e_type =3D $LISTENER_CLOSED ]; then + elif [ $e_type =3D $MPTCP_LIB_LISTENER_CLOSED ]; then name=3D"LISTENER_CLOSED " else name=3D"$e_type" @@ -2876,8 +2869,10 @@ add_addr_ports_tests() chk_add_nr 1 1 1 chk_rm_nr 1 1 invert =20 - verify_listener_events $evts_ns1 $LISTENER_CREATED $AF_INET 10.0.2.1 101= 00 - verify_listener_events $evts_ns1 $LISTENER_CLOSED $AF_INET 10.0.2.1 10100 + verify_listener_events $evts_ns1 $MPTCP_LIB_LISTENER_CREATED \ + $AF_INET 10.0.2.1 10100 + verify_listener_events $evts_ns1 $MPTCP_LIB_LISTENER_CLOSED \ + $AF_INET 10.0.2.1 10100 kill_events_pids fi =20 @@ -3483,11 +3478,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_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_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 @@ -3514,7 +3509,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_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 5dfdb054371d..83175166968b 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -2,6 +2,7 @@ # SPDX-License-Identifier: GPL-2.0 =20 # Some variables are used below but indirectly, see check_expected_one() +# MPTCP_LIB_ANNOUNCED and AF_INET #shellcheck disable=3DSC2034 =20 readonly KSFT_PASS=3D0 @@ -11,6 +12,16 @@ readonly KSFT_SKIP=3D4 # shellcheck disable=3DSC2155 # declare and assign separately readonly KSFT_TEST=3D"${MPTCP_LIB_KSFT_TEST:-$(basename "${0}" .sh)}" =20 +MPTCP_LIB_ANNOUNCED=3D6 # MPTCP_EVENT_ANNOUNCED +MPTCP_LIB_REMOVED=3D7 # MPTCP_EVENT_REMOVED +MPTCP_LIB_SUB_ESTABLISHED=3D10 # MPTCP_EVENT_SUB_ESTABLISHED +MPTCP_LIB_SUB_CLOSED=3D11 # MPTCP_EVENT_SUB_CLOSED +MPTCP_LIB_LISTENER_CREATED=3D15 #MPTCP_EVENT_LISTENER_CREATED +MPTCP_LIB_LISTENER_CLOSED=3D16 #MPTCP_EVENT_LISTENER_CLOSED + +readonly AF_INET=3D2 +readonly AF_INET6=3D10 + MPTCP_LIB_SUBTESTS=3D() MPTCP_LIB_SUBTESTS_DUPLICATED=3D0 =20 diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/test= ing/selftests/net/mptcp/userspace_pm.sh index 702484199dd2..05e0dff5397f 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -19,16 +19,6 @@ if ! mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; t= hen fi mptcp_lib_check_tools ip =20 -ANNOUNCED=3D6 # MPTCP_EVENT_ANNOUNCED -REMOVED=3D7 # MPTCP_EVENT_REMOVED -SUB_ESTABLISHED=3D10 # MPTCP_EVENT_SUB_ESTABLISHED -SUB_CLOSED=3D11 # MPTCP_EVENT_SUB_CLOSED -LISTENER_CREATED=3D15 #MPTCP_EVENT_LISTENER_CREATED -LISTENER_CLOSED=3D16 #MPTCP_EVENT_LISTENER_CLOSED - -AF_INET=3D2 -AF_INET6=3D10 - file=3D"" server_evts=3D"" client_evts=3D"" @@ -309,8 +299,8 @@ test_announce() ns2eth1 print_test "ADD_ADDR id:${client_addr_id} 10.0.2.2 (ns2) =3D> ns1, reuse = port" sleep 0.5 - verify_announce_event $server_evts $ANNOUNCED $server4_token "10.0.2.2" $= client_addr_id \ - "$client4_port" + verify_announce_event $server_evts $MPTCP_LIB_ANNOUNCED $server4_token \ + "10.0.2.2" $client_addr_id "$client4_port" =20 # ADD_ADDR6 from the client to server machine reusing the subflow port :>"$server_evts" @@ -318,8 +308,8 @@ test_announce() dead:beef:2::2 token "$client6_token" id $client_addr_id dev ns2eth1 print_test "ADD_ADDR6 id:${client_addr_id} dead:beef:2::2 (ns2) =3D> ns1,= reuse port" sleep 0.5 - verify_announce_event "$server_evts" "$ANNOUNCED" "$server6_token" "dead:= beef:2::2"\ - "$client_addr_id" "$client6_port" "v6" + verify_announce_event "$server_evts" "$MPTCP_LIB_ANNOUNCED" "$server6_tok= en" \ + "dead:beef:2::2" "$client_addr_id" "$client6_port" "v6" =20 # ADD_ADDR from the client to server machine using a new port :>"$server_evts" @@ -328,7 +318,7 @@ test_announce() $client_addr_id dev ns2eth1 port $new4_port print_test "ADD_ADDR id:${client_addr_id} 10.0.2.2 (ns2) =3D> ns1, new po= rt" sleep 0.5 - verify_announce_event "$server_evts" "$ANNOUNCED" "$server4_token" "10.0.= 2.2"\ + verify_announce_event "$server_evts" "$MPTCP_LIB_ANNOUNCED" "$server4_tok= en" "10.0.2.2"\ "$client_addr_id" "$new4_port" =20 # Capture events on the network namespace running the client @@ -339,7 +329,7 @@ test_announce() $server_addr_id dev ns1eth2 print_test "ADD_ADDR id:${server_addr_id} 10.0.2.1 (ns1) =3D> ns2, reuse = port" sleep 0.5 - verify_announce_event "$client_evts" "$ANNOUNCED" "$client4_token" "10.0.= 2.1"\ + verify_announce_event "$client_evts" "$MPTCP_LIB_ANNOUNCED" "$client4_tok= en" "10.0.2.1"\ "$server_addr_id" "$app4_port" =20 # ADD_ADDR6 from the server to client machine reusing the subflow port @@ -348,8 +338,8 @@ test_announce() $server_addr_id dev ns1eth2 print_test "ADD_ADDR6 id:${server_addr_id} dead:beef:2::1 (ns1) =3D> ns2,= reuse port" sleep 0.5 - verify_announce_event "$client_evts" "$ANNOUNCED" "$client6_token" "dead:= beef:2::1"\ - "$server_addr_id" "$app6_port" "v6" + verify_announce_event "$client_evts" "$MPTCP_LIB_ANNOUNCED" "$client6_tok= en" \ + "dead:beef:2::1" "$server_addr_id" "$app6_port" "v6" =20 # ADD_ADDR from the server to client machine using a new port :>"$client_evts" @@ -358,7 +348,7 @@ test_announce() $server_addr_id dev ns1eth2 port $new4_port print_test "ADD_ADDR id:${server_addr_id} 10.0.2.1 (ns1) =3D> ns2, new po= rt" sleep 0.5 - verify_announce_event "$client_evts" "$ANNOUNCED" "$client4_token" "10.0.= 2.1"\ + verify_announce_event "$client_evts" "$MPTCP_LIB_ANNOUNCED" "$client4_tok= en" "10.0.2.1"\ "$server_addr_id" "$new4_port" } =20 @@ -419,7 +409,7 @@ test_remove() $client_addr_id print_test "RM_ADDR id:${client_addr_id} ns2 =3D> ns1" sleep 0.5 - verify_remove_event "$server_evts" "$REMOVED" "$server4_token" "$client_a= ddr_id" + verify_remove_event "$server_evts" "$MPTCP_LIB_REMOVED" "$server4_token" = "$client_addr_id" =20 # RM_ADDR from the client to server machine :>"$server_evts" @@ -428,7 +418,7 @@ test_remove() $client_addr_id print_test "RM_ADDR id:${client_addr_id} ns2 =3D> ns1" sleep 0.5 - verify_remove_event "$server_evts" "$REMOVED" "$server4_token" "$client_a= ddr_id" + verify_remove_event "$server_evts" "$MPTCP_LIB_REMOVED" "$server4_token" = "$client_addr_id" =20 # RM_ADDR6 from the client to server machine :>"$server_evts" @@ -436,7 +426,7 @@ test_remove() $client_addr_id print_test "RM_ADDR6 id:${client_addr_id} ns2 =3D> ns1" sleep 0.5 - verify_remove_event "$server_evts" "$REMOVED" "$server6_token" "$client_a= ddr_id" + verify_remove_event "$server_evts" "$MPTCP_LIB_REMOVED" "$server6_token" = "$client_addr_id" =20 # Capture events on the network namespace running the client :>"$client_evts" @@ -446,7 +436,7 @@ test_remove() $server_addr_id print_test "RM_ADDR id:${server_addr_id} ns1 =3D> ns2" sleep 0.5 - verify_remove_event "$client_evts" "$REMOVED" "$client4_token" "$server_a= ddr_id" + verify_remove_event "$client_evts" "$MPTCP_LIB_REMOVED" "$client4_token" = "$server_addr_id" =20 # RM_ADDR from the server to client machine :>"$client_evts" @@ -455,7 +445,7 @@ test_remove() $server_addr_id print_test "RM_ADDR id:${server_addr_id} ns1 =3D> ns2" sleep 0.5 - verify_remove_event "$client_evts" "$REMOVED" "$client4_token" "$server_a= ddr_id" + verify_remove_event "$client_evts" "$MPTCP_LIB_REMOVED" "$client4_token" = "$server_addr_id" =20 # RM_ADDR6 from the server to client machine :>"$client_evts" @@ -463,7 +453,7 @@ test_remove() $server_addr_id print_test "RM_ADDR6 id:${server_addr_id} ns1 =3D> ns2" sleep 0.5 - verify_remove_event "$client_evts" "$REMOVED" "$client6_token" "$server_a= ddr_id" + verify_remove_event "$client_evts" "$MPTCP_LIB_REMOVED" "$client6_token" = "$server_addr_id" } =20 verify_subflow_events() @@ -492,7 +482,7 @@ verify_subflow_events() =20 info=3D"${e_saddr} (${e_from}) =3D> ${e_daddr}:${e_dport} (${e_to})" =20 - if [ "$e_type" =3D "$SUB_ESTABLISHED" ] + if [ "$e_type" =3D "$MPTCP_LIB_SUB_ESTABLISHED" ] then if [ "$e_family" =3D "$AF_INET6" ] then @@ -549,22 +539,24 @@ test_subflows() ip netns exec "$ns1" ./pm_nl_ctl csf lip 10.0.2.1 lid 23 rip 10.0.2.2\ rport "$client4_port" token "$server4_token" sleep 0.5 - verify_subflow_events $server_evts $SUB_ESTABLISHED $server4_token $AF_IN= ET "10.0.2.1" \ - "10.0.2.2" "$client4_port" "23" "$client_addr_id" "ns1" "ns2" + verify_subflow_events $server_evts $MPTCP_LIB_SUB_ESTABLISHED $server4_to= ken \ + $AF_INET "10.0.2.1" "10.0.2.2" "$client4_port" "23" \ + "$client_addr_id" "ns1" "ns2" =20 # Delete the listener from the client ns, if one was created mptcp_lib_kill_wait $listener_pid =20 local sport - sport=3D$(mptcp_lib_evts_get_info sport "$server_evts" $SUB_ESTABLISHED) + sport=3D$(mptcp_lib_evts_get_info sport "$server_evts" $MPTCP_LIB_SUB_EST= ABLISHED) =20 # DESTROY_SUBFLOW from server to client machine :>"$server_evts" ip netns exec "$ns1" ./pm_nl_ctl dsf lip 10.0.2.1 lport "$sport" rip 10.0= .2.2 rport\ "$client4_port" token "$server4_token" sleep 0.5 - verify_subflow_events "$server_evts" "$SUB_CLOSED" "$server4_token" "$AF_= INET" "10.0.2.1"\ - "10.0.2.2" "$client4_port" "23" "$client_addr_id" "ns1" "ns2" + verify_subflow_events "$server_evts" "$MPTCP_LIB_SUB_CLOSED" "$server4_to= ken" \ + "$AF_INET" "10.0.2.1" "10.0.2.2" "$client4_port" "23" \ + "$client_addr_id" "ns1" "ns2" =20 # RM_ADDR from client to server machine ip netns exec "$ns2" ./pm_nl_ctl rem id $client_addr_id token\ @@ -587,21 +579,21 @@ test_subflows() ip netns exec "$ns1" ./pm_nl_ctl csf lip dead:beef:2::1 lid 23 rip\ dead:beef:2::2 rport "$client6_port" token "$server6_token" sleep 0.5 - verify_subflow_events "$server_evts" "$SUB_ESTABLISHED" "$server6_token" = "$AF_INET6"\ - "dead:beef:2::1" "dead:beef:2::2" "$client6_port" "23"\ - "$client_addr_id" "ns1" "ns2" + verify_subflow_events "$server_evts" "$MPTCP_LIB_SUB_ESTABLISHED" "$serve= r6_token" \ + "$AF_INET6" "dead:beef:2::1" "dead:beef:2::2" "$client6_port" \ + "23" "$client_addr_id" "ns1" "ns2" =20 # Delete the listener from the client ns, if one was created mptcp_lib_kill_wait $listener_pid =20 - sport=3D$(mptcp_lib_evts_get_info sport "$server_evts" $SUB_ESTABLISHED) + sport=3D$(mptcp_lib_evts_get_info sport "$server_evts" $MPTCP_LIB_SUB_EST= ABLISHED) =20 # DESTROY_SUBFLOW6 from server to client machine :>"$server_evts" ip netns exec "$ns1" ./pm_nl_ctl dsf lip dead:beef:2::1 lport "$sport" ri= p\ dead:beef:2::2 rport "$client6_port" token "$server6_token" sleep 0.5 - verify_subflow_events "$server_evts" "$SUB_CLOSED" "$server6_token" "$AF_= INET6"\ + verify_subflow_events "$server_evts" "$MPTCP_LIB_SUB_CLOSED" "$server6_to= ken" "$AF_INET6"\ "dead:beef:2::1" "dead:beef:2::2" "$client6_port" "23"\ "$client_addr_id" "ns1" "ns2" =20 @@ -626,22 +618,23 @@ test_subflows() ip netns exec "$ns1" ./pm_nl_ctl csf lip 10.0.2.1 lid 23 rip 10.0.2.2 rpo= rt\ $new4_port token "$server4_token" sleep 0.5 - verify_subflow_events "$server_evts" "$SUB_ESTABLISHED" "$server4_token" = "$AF_INET"\ - "10.0.2.1" "10.0.2.2" "$new4_port" "23"\ + verify_subflow_events "$server_evts" "$MPTCP_LIB_SUB_ESTABLISHED" "$serve= r4_token" \ + "$AF_INET" "10.0.2.1" "10.0.2.2" "$new4_port" "23" \ "$client_addr_id" "ns1" "ns2" =20 # Delete the listener from the client ns, if one was created mptcp_lib_kill_wait $listener_pid =20 - sport=3D$(mptcp_lib_evts_get_info sport "$server_evts" $SUB_ESTABLISHED) + sport=3D$(mptcp_lib_evts_get_info sport "$server_evts" $MPTCP_LIB_SUB_EST= ABLISHED) =20 # DESTROY_SUBFLOW from server to client machine :>"$server_evts" ip netns exec "$ns1" ./pm_nl_ctl dsf lip 10.0.2.1 lport "$sport" rip 10.0= .2.2 rport\ $new4_port token "$server4_token" sleep 0.5 - verify_subflow_events "$server_evts" "$SUB_CLOSED" "$server4_token" "$AF_= INET" "10.0.2.1"\ - "10.0.2.2" "$new4_port" "23" "$client_addr_id" "ns1" "ns2" + verify_subflow_events "$server_evts" "$MPTCP_LIB_SUB_CLOSED" "$server4_to= ken" \ + "$AF_INET" "10.0.2.1" "10.0.2.2" "$new4_port" "23" \ + "$client_addr_id" "ns1" "ns2" =20 # RM_ADDR from client to server machine ip netns exec "$ns2" ./pm_nl_ctl rem id $client_addr_id token\ @@ -665,21 +658,22 @@ test_subflows() ip netns exec "$ns2" ./pm_nl_ctl csf lip 10.0.2.2 lid 23 rip 10.0.2.1 rpo= rt\ $app4_port token "$client4_token" sleep 0.5 - verify_subflow_events $client_evts $SUB_ESTABLISHED $client4_token $AF_IN= ET "10.0.2.2"\ - "10.0.2.1" "$app4_port" "23" "$server_addr_id" "ns2" "ns1" + verify_subflow_events $client_evts $MPTCP_LIB_SUB_ESTABLISHED $client4_to= ken $AF_INET \ + "10.0.2.2" "10.0.2.1" "$app4_port" "23" "$server_addr_id" "ns2" "= ns1" =20 # Delete the listener from the server ns, if one was created mptcp_lib_kill_wait $listener_pid =20 - sport=3D$(mptcp_lib_evts_get_info sport "$client_evts" $SUB_ESTABLISHED) + sport=3D$(mptcp_lib_evts_get_info sport "$client_evts" $MPTCP_LIB_SUB_EST= ABLISHED) =20 # DESTROY_SUBFLOW from client to server machine :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0= .2.1 rport\ $app4_port token "$client4_token" sleep 0.5 - verify_subflow_events "$client_evts" "$SUB_CLOSED" "$client4_token" "$AF_= INET" "10.0.2.2"\ - "10.0.2.1" "$app4_port" "23" "$server_addr_id" "ns2" "ns1" + verify_subflow_events "$client_evts" "$MPTCP_LIB_SUB_CLOSED" "$client4_to= ken" \ + "$AF_INET" "10.0.2.2" "10.0.2.1" "$app4_port" "23" \ + "$server_addr_id" "ns2" "ns1" =20 # RM_ADDR from server to client machine ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\ @@ -702,7 +696,7 @@ test_subflows() ip netns exec "$ns2" ./pm_nl_ctl csf lip dead:beef:2::2 lid 23 rip\ dead:beef:2::1 rport $app6_port token "$client6_token" sleep 0.5 - verify_subflow_events "$client_evts" "$SUB_ESTABLISHED" "$client6_token"\ + verify_subflow_events "$client_evts" "$MPTCP_LIB_SUB_ESTABLISHED" "$clien= t6_token"\ "$AF_INET6" "dead:beef:2::2"\ "dead:beef:2::1" "$app6_port" "23"\ "$server_addr_id" "ns2" "ns1" @@ -710,15 +704,16 @@ test_subflows() # Delete the listener from the server ns, if one was created mptcp_lib_kill_wait $listener_pid =20 - sport=3D$(mptcp_lib_evts_get_info sport "$client_evts" $SUB_ESTABLISHED) + sport=3D$(mptcp_lib_evts_get_info sport "$client_evts" $MPTCP_LIB_SUB_EST= ABLISHED) =20 # DESTROY_SUBFLOW6 from client to server machine :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl dsf lip dead:beef:2::2 lport "$sport" ri= p\ dead:beef:2::1 rport $app6_port token "$client6_token" sleep 0.5 - verify_subflow_events $client_evts $SUB_CLOSED $client6_token $AF_INET6 "= dead:beef:2::2"\ - "dead:beef:2::1" "$app6_port" "23" "$server_addr_id" "ns2" "ns1" + verify_subflow_events $client_evts $MPTCP_LIB_SUB_CLOSED $client6_token \ + $AF_INET6 "dead:beef:2::2" "dead:beef:2::1" "$app6_port" \ + "23" "$server_addr_id" "ns2" "ns1" =20 # RM_ADDR6 from server to client machine ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\ @@ -741,21 +736,23 @@ test_subflows() ip netns exec "$ns2" ./pm_nl_ctl csf lip 10.0.2.2 lid 23 rip 10.0.2.1 rpo= rt\ $new4_port token "$client4_token" sleep 0.5 - verify_subflow_events "$client_evts" "$SUB_ESTABLISHED" "$client4_token" = "$AF_INET"\ - "10.0.2.2" "10.0.2.1" "$new4_port" "23" "$server_addr_id" "ns2" "= ns1" + verify_subflow_events "$client_evts" "$MPTCP_LIB_SUB_ESTABLISHED" "$clien= t4_token" \ + "$AF_INET" "10.0.2.2" "10.0.2.1" "$new4_port" "23" \ + "$server_addr_id" "ns2" "ns1" =20 # Delete the listener from the server ns, if one was created mptcp_lib_kill_wait $listener_pid =20 - sport=3D$(mptcp_lib_evts_get_info sport "$client_evts" $SUB_ESTABLISHED) + sport=3D$(mptcp_lib_evts_get_info sport "$client_evts" $MPTCP_LIB_SUB_EST= ABLISHED) =20 # DESTROY_SUBFLOW from client to server machine :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0= .2.1 rport\ $new4_port token "$client4_token" sleep 0.5 - verify_subflow_events "$client_evts" "$SUB_CLOSED" "$client4_token" "$AF_= INET" "10.0.2.2"\ - "10.0.2.1" "$new4_port" "23" "$server_addr_id" "ns2" "ns1" + verify_subflow_events "$client_evts" "$MPTCP_LIB_SUB_CLOSED" "$client4_to= ken" \ + "$AF_INET" "10.0.2.2" "10.0.2.1" "$new4_port" "23" \ + "$server_addr_id" "ns2" "ns1" =20 # RM_ADDR from server to client machine ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\ @@ -778,7 +775,7 @@ test_subflows_v4_v6_mix() $server_addr_id dev ns1eth2 print_test "ADD_ADDR4 id:${server_addr_id} 10.0.2.1 (ns1) =3D> ns2, reuse= port" sleep 0.5 - verify_announce_event "$client_evts" "$ANNOUNCED" "$client6_token" "10.0.= 2.1"\ + verify_announce_event "$client_evts" "$MPTCP_LIB_ANNOUNCED" "$client6_tok= en" "10.0.2.1"\ "$server_addr_id" "$app6_port" =20 # CREATE_SUBFLOW from client to server machine @@ -786,21 +783,21 @@ test_subflows_v4_v6_mix() ip netns exec "$ns2" ./pm_nl_ctl csf lip 10.0.2.2 lid 23 rip 10.0.2.1 rpo= rt\ $app6_port token "$client6_token" sleep 0.5 - verify_subflow_events "$client_evts" "$SUB_ESTABLISHED" "$client6_token"\ + verify_subflow_events "$client_evts" "$MPTCP_LIB_SUB_ESTABLISHED" "$clien= t6_token"\ "$AF_INET" "10.0.2.2" "10.0.2.1" "$app6_port" "23"\ "$server_addr_id" "ns2" "ns1" =20 # Delete the listener from the server ns, if one was created mptcp_lib_kill_wait $listener_pid =20 - sport=3D$(mptcp_lib_evts_get_info sport "$client_evts" $SUB_ESTABLISHED) + sport=3D$(mptcp_lib_evts_get_info sport "$client_evts" $MPTCP_LIB_SUB_EST= ABLISHED) =20 # DESTROY_SUBFLOW from client to server machine :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0= .2.1 rport\ $app6_port token "$client6_token" sleep 0.5 - verify_subflow_events "$client_evts" "$SUB_CLOSED" "$client6_token" \ + verify_subflow_events "$client_evts" "$MPTCP_LIB_SUB_CLOSED" "$client6_to= ken" \ "$AF_INET" "10.0.2.2" "10.0.2.1" "$app6_port" "23"\ "$server_addr_id" "ns2" "ns1" =20 @@ -892,7 +889,8 @@ test_listener() local listener_pid=3D$! =20 sleep 0.5 - verify_listener_events $client_evts $LISTENER_CREATED $AF_INET 10.0.2.2 $= client4_port + verify_listener_events $client_evts $MPTCP_LIB_LISTENER_CREATED \ + $AF_INET 10.0.2.2 $client4_port =20 # ADD_ADDR from client to server machine reusing the subflow port ip netns exec $ns2 ./pm_nl_ctl ann 10.0.2.2 token $client4_token id\ @@ -908,7 +906,8 @@ test_listener() mptcp_lib_kill_wait $listener_pid =20 sleep 0.5 - verify_listener_events $client_evts $LISTENER_CLOSED $AF_INET 10.0.2.2 $c= lient4_port + verify_listener_events $client_evts $MPTCP_LIB_LISTENER_CLOSED \ + $AF_INET 10.0.2.2 $client4_port } =20 print_title "Make connections" --=20 2.40.1 From nobody Thu Dec 5 02:33:28 2024 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 17A2BDDDA for ; Sun, 25 Feb 2024 13:04: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=1708866265; cv=none; b=JyOn69xFSVnP8+6Z2VTPUElhVF8y1665OzSLSQ65d3E+QiUlAAxZ5yMtV9dVAAQDa8jtYlrT/re6ZrZMGgjnGeTODndpKlT5OW/EeGGuvGjvWoIdK3TvYjsF+ZVBTgR1FDbWRBm+jWtSaqgTo+8qrzkq0AvGOubxXwSwznkAang= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708866265; c=relaxed/simple; bh=Yxs+ucCitKsQT7IVVM9kRiZKjC6iLc/B9fxGl6+hU4c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kDqLDrMtgJCAXwaQ/dJVR582lryhfLBas88YNZSbkLygVMTo+bkb9okXZ6wyM3N6kdoLdhXE7Z0VHeTDjSdluwstsMO90UgjzHReSk2pm2GIXdTAljr5M7L4EInoWxRIWK2cyS3SKCvXd0qK+emat7Gs/X1jH+wQxvXZrZl+Wjw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hAnBG4lu; 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="hAnBG4lu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F169C433C7; Sun, 25 Feb 2024 13:04:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708866265; bh=Yxs+ucCitKsQT7IVVM9kRiZKjC6iLc/B9fxGl6+hU4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hAnBG4luif5goK/vqSGlFZMjT8gP77dq2k0KAxaSBjreyQXduIX3DdotLMtIeaiVm z0d3ck9qntMkKJjuZttWYXvFE9S7Mcn0hBLN445W22HLc7QKUDanaNCXgG6l//l3t1 l/iP5HDGWwhd005SVDjiuw4HMjokR94vRcn6uzVJjciBiQsfNxr+ZwVRhp8yRUGunD lUk7ZOq251b5uQzbvZD42eeUCiaPP3dwAtNjURNR2d7NSYouSsIgWiks/WMe3vDn7u 92IGgEuetKuEl7Dh/48xu0XJ5NuTEeZQEQrUWYYk+K6NoK0HB4r8Yj6Qc6Q3PASTpp vIIWFl2AJxdfA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 12/13] selftests: mptcp: add mptcp_lib_verify_listener_events Date: Sun, 25 Feb 2024 21:04:00 +0800 Message-Id: <7ad28da76354a7cb8ad63e854f8eef8e4bbf37f2.1708866087.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- .../testing/selftests/net/mptcp/mptcp_join.sh | 25 +++------------ .../testing/selftests/net/mptcp/mptcp_lib.sh | 25 +++++++++++++++ .../selftests/net/mptcp/userspace_pm.sh | 31 +++++-------------- 3 files changed, 38 insertions(+), 43 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 14f79300e1f8..71d345f15209 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -2789,16 +2789,12 @@ backup_tests() =20 verify_listener_events() { - local evt=3D$1 local e_type=3D$2 local e_family=3D$3 local e_saddr=3D$4 local e_sport=3D$5 - local type - local family - local saddr - local sport local name + local rc=3D0 =20 if [ $e_type =3D $MPTCP_LIB_LISTENER_CREATED ]; then name=3D"LISTENER_CREATED" @@ -2815,23 +2811,12 @@ verify_listener_events() return fi =20 - type=3D$(mptcp_lib_evts_get_info type "$evt" "$e_type") - family=3D$(mptcp_lib_evts_get_info family "$evt" "$e_type") - sport=3D$(mptcp_lib_evts_get_info sport "$evt" "$e_type") - if [ $family ] && [ $family =3D $AF_INET6 ]; then - saddr=3D$(mptcp_lib_evts_get_info saddr6 "$evt" "$e_type") - else - saddr=3D$(mptcp_lib_evts_get_info saddr4 "$evt" "$e_type") - fi - - if [ $type ] && [ $type =3D $e_type ] && - [ $family ] && [ $family =3D $e_family ] && - [ $saddr ] && [ $saddr =3D $e_saddr ] && - [ $sport ] && [ $sport =3D $e_sport ]; then - print_ok + mptcp_lib_verify_listener_events "${@}" || rc=3D"${?}" + if [ "${rc}" -eq 0 ] + then return 0 fi - fail_test "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$spor= t" + fail_test "$e_type $e_family $e_saddr $e_sport" } =20 add_addr_ports_tests() diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing= /selftests/net/mptcp/mptcp_lib.sh index 83175166968b..cc8703dce8c0 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -479,3 +479,28 @@ mptcp_lib_check_expected() { =20 return "${rc}" } + +mptcp_lib_verify_listener_events() { + local evt=3D$1 + local e_type=3D$2 + local e_family=3D$3 + local e_saddr=3D$4 + local e_sport=3D$5 + local type + local family + local saddr + local sport + local rc=3D0 + + type=3D$(mptcp_lib_evts_get_info type "$evt" "$e_type") + family=3D$(mptcp_lib_evts_get_info family "$evt" "$e_type") + if [ "$family" ] && [ "$family" =3D $AF_INET6 ]; then + saddr=3D$(mptcp_lib_evts_get_info saddr6 "$evt" "$e_type") + else + saddr=3D$(mptcp_lib_evts_get_info saddr4 "$evt" "$e_type") + fi + sport=3D$(mptcp_lib_evts_get_info sport "$evt" "$e_type") + + mptcp_lib_check_expected "type" "family" "saddr" "sport" || rc=3D"${?}" + return "${rc}" +} diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/test= ing/selftests/net/mptcp/userspace_pm.sh index 05e0dff5397f..b36c42a55f03 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -842,32 +842,15 @@ test_prio() =20 verify_listener_events() { - local evt=3D$1 - local e_type=3D$2 - local e_family=3D$3 - local e_saddr=3D$4 - local e_sport=3D$5 - local type - local family - local saddr - local sport - - if [ $e_type =3D $LISTENER_CREATED ]; then - print_test "CREATE_LISTENER $e_saddr:$e_sport" - elif [ $e_type =3D $LISTENER_CLOSED ]; then - print_test "CLOSE_LISTENER $e_saddr:$e_sport" - fi + local rc=3D0 =20 - type=3D$(mptcp_lib_evts_get_info type $evt $e_type) - family=3D$(mptcp_lib_evts_get_info family $evt $e_type) - sport=3D$(mptcp_lib_evts_get_info sport $evt $e_type) - if [ $family ] && [ $family =3D $AF_INET6 ]; then - saddr=3D$(mptcp_lib_evts_get_info saddr6 $evt $e_type) + mptcp_lib_verify_listener_events "${@}" || rc=3D"${?}" + if [ "${rc}" -eq 0 ] + then + mptcp_lib_result_pass "${test_name}" else - saddr=3D$(mptcp_lib_evts_get_info saddr4 $evt $e_type) + test_fail fi - - check_expected "type" "family" "saddr" "sport" } =20 test_listener() @@ -883,6 +866,7 @@ test_listener() # Capture events on the network namespace running the client :>$client_evts =20 + print_test "Listener event LISTENER_CREATED 10.0.2.2:$client4_port" # Attempt to add a listener at 10.0.2.2: ip netns exec $ns2 ./pm_nl_ctl listen 10.0.2.2\ $client4_port & @@ -902,6 +886,7 @@ test_listener() rport $client4_port token $server4_token sleep 0.5 =20 + print_test "Listener event LISTENER_CLOSED 10.0.2.2:$client4_port" # Delete the listener from the client ns, if one was created mptcp_lib_kill_wait $listener_pid =20 --=20 2.40.1 From nobody Thu Dec 5 02:33:28 2024 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 4F8D2DDDA for ; Sun, 25 Feb 2024 13:04:26 +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=1708866266; cv=none; b=uS3xO6iOAumJeOrZXVSbZGzSo9eNSRe8rwjSunayuqkkq1APXkVgZ81tx4ttyDsi9ayn7YFWWhMcU3Jfr5QHf37oFj/f/dRT8hJWl0FO/cVcBUC3mtf9g0w3KhYTocikU7U2jPIZl4NN87YOUkqGOz7A16mVopK8UovljWIQ5dY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708866266; c=relaxed/simple; bh=A77LoFKQPcYYGpDJROrFX/2KFGUgjzW7DYcgC4PTqcM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=r7PHvoDB33iFf7czdkOkyt+P+fYP0P8KpdatqxEfmUtTS+njTnPAQlsRrTakMXwa6jqYPjg7kfByZEnb9bYWAa4gWv8K+n7nbzY7UC8DGOtfOzJerP7VkBh5DkvqAd+fJ9vNhY0jkBmDc5LH9UHxMcBCXqQrIhQg2R3kixm2Dcc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DynygQfk; 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="DynygQfk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66E07C433F1; Sun, 25 Feb 2024 13:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708866266; bh=A77LoFKQPcYYGpDJROrFX/2KFGUgjzW7DYcgC4PTqcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DynygQfk+FwAwdffxnV9yqvI7djRgu5I7QzB8Q3C5U1fD1M14BEd02OAWGgz8ErmB dXudLEVLe1NzfrkT0gptAtJjFrwG+bY83VelFDh19uYN+NywD7dvmzlerXolbXwTh2 XiBqcgC+To5tL8b2Ip9tdi5/GjSGIVUn6TGBAaUJ/kMNAFFiYkajXiz7xNC4nenLaY 0xDGYnDdsKDFnID22OGFati9UvvljexOtxQbU+ymvpwAZHxSUft2HPfJEOe2mgMBg+ iyQLNPkLbPMjkmIfD2Vb4rOq6Se0sclMAJE6pGMWJDfEomjDfPsdUVCVyatZNgznoW T8was2SpDArfA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 13/13] selftests: mptcp: use KSFT_SKIP/KSFT_PASS/KSFT_FAIL Date: Sun, 25 Feb 2024 21:04:01 +0800 Message-Id: <53f87e57c38fe571ca2d41bdf7a225357a6d05ad.1708866087.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang This patch uses the public var KSFT_SKIP in mptcp_lib.sh instead of ksft_skip, and drop 'ksft_skip=3D4' in mptcp_join.sh. Use KSFT_PASS and KSFT_FAIL macros instead of 0 and 1 after 'exit ' and 'ret=3D' in all scripts: exit 0 -> exit ${KSFT_PASS} exit 1 -> exit ${KSFT_FAIL} ret=3D0 -> ret=3D${KSFT_PASS} ret=3D1 -> ret=3D${KSFT_FAIL} Signed-off-by: Geliang Tang --- .../selftests/net/mptcp/mptcp_connect.sh | 18 +++++++++--------- .../testing/selftests/net/mptcp/mptcp_join.sh | 13 ++++++------- .../selftests/net/mptcp/mptcp_sockopt.sh | 4 ++-- .../testing/selftests/net/mptcp/pm_netlink.sh | 4 ++-- .../selftests/net/mptcp/simult_flows.sh | 4 ++-- .../selftests/net/mptcp/userspace_pm.sh | 4 ++-- 6 files changed, 23 insertions(+), 24 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_connect.sh index a3316590b989..3aefa269c921 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=3D"$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=3D"$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=3D"$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 @@ -260,7 +260,7 @@ check_mptcp_disabled() "net.mptcp.enabled sysctl is not 1 by default" mptcp_lib_print_err "\t\t\t\t [FAIL]" mptcp_lib_result_fail "net.mptcp.enabled sysctl is not 1 by default" - ret=3D1 + ret=3D${KSFT_FAIL} return 1 fi ip netns exec ${disabled_ns} sysctl -q net.mptcp.enabled=3D0 @@ -275,7 +275,7 @@ check_mptcp_disabled() "New MPTCP socket cannot be blocked via sysctl" mptcp_lib_print_err "\t\t\t\t [FAIL]" mptcp_lib_result_fail "New MPTCP socket cannot be blocked via sysctl" - ret=3D1 + ret=3D${KSFT_FAIL} return 1 fi =20 @@ -303,7 +303,7 @@ do_ping() =20 if [ $rc -ne 0 ] ; then echo "$listener_ns -> $connect_addr connectivity [FAIL]" 1>&2 - ret=3D1 + ret=3D${KSFT_FAIL} =20 return 1 fi @@ -823,7 +823,7 @@ log_if_error() echo "FAIL: ${msg}" 1>&2 =20 final_ret=3D${ret} - ret=3D0 + ret=3D${KSFT_PASS} =20 return ${final_ret} fi diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 71d345f15209..27119f5288a8 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -25,7 +25,6 @@ err=3D"" capout=3D"" ns1=3D"" ns2=3D"" -ksft_skip=3D4 iptables=3D"iptables" ip6tables=3D"ip6tables" timeout_poll=3D30 @@ -396,15 +395,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} =20 - 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} } =20 reset_with_fail() @@ -418,7 +417,7 @@ reset_with_fail() local rc=3D0 setup_fail_rules "${@}" || rc=3D$? =20 - if [ ${rc} -eq ${ksft_skip} ]; then + if [ ${rc} -eq ${KSFT_SKIP} ]; then mark_as_skipped "unable to set the 'fail' rules" return 1 fi @@ -454,7 +453,7 @@ reset_with_tcp_filter() # $1: err msg fail_test() { - ret=3D1 + ret=3D${KSFT_FAIL} =20 print_fail "${@}" =20 @@ -3637,7 +3636,7 @@ usage() { if [ -n "${1}" ]; then echo "${1}" - ret=3D1 + ret=3D${KSFT_FAIL} fi =20 echo "mptcp_join usage:" diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_sockopt.sh index 5943ec8145f9..ef26919f15b8 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -106,7 +106,7 @@ check_mark() for v in $values; do if [ $v -ne 0 ]; then echo "FAIL: got $tables $values in ns $ns , not 0 - not all expected pa= ckets marked" 1>&2 - ret=3D1 + ret=3D${KSFT_FAIL} return 1 fi done @@ -175,7 +175,7 @@ do_transfer() mptcp_lib_print_err "[FAIL]" mptcp_lib_result_fail "transfer ${ip}" =20 - ret=3D1 + ret=3D${KSFT_FAIL} return 1 fi mptcp_lib_print_ok "[ OK ]" diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testin= g/selftests/net/mptcp/pm_netlink.sh index 435e1b0eb071..b50ad2d469b4 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -21,11 +21,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 diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/test= ing/selftests/net/mptcp/simult_flows.sh index d2be6a3c9c28..4607c074b632 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -262,7 +262,7 @@ while getopts "bcdh" option;do case "$option" in "h") usage $0 - exit 0 + exit ${KSFT_PASS} ;; "b") bail=3D1 @@ -275,7 +275,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/test= ing/selftests/net/mptcp/userspace_pm.sh index b36c42a55f03..2cd197d47fff 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -79,7 +79,7 @@ test_skip() test_fail() { mptcp_lib_print_err "[FAIL]${1:+ ${*}}" - ret=3D1 + ret=3D${KSFT_FAIL} =20 if [ -n "${1}" ]; then _printf "\t%s\n" "${1}" @@ -204,7 +204,7 @@ make_connection() else test_fail "Expected tokens (c:${client_token} - s:${server_token}) and s= erver (c:${client_serverside} - s:${server_serverside})" mptcp_lib_result_print_all_tap - exit 1 + exit ${KSFT_FAIL} fi =20 if [ "$is_v6" =3D "v6" ] --=20 2.40.1