From nobody Thu Dec 5 02:11:40 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 416466280C for ; Thu, 29 Feb 2024 09:51: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=1709200280; cv=none; b=uIMZ91u1pAnjhBFYGPp381sDZByaHpyvnZh4orCwbpo1opUgKUmFh6thyKGRf55DtLMiHNtD66tkuba59uoZ+pzNXssTfEkgz3XgQ5Co93fxOcBRtc9Ttzaerz5AijOFO1/9K4PSsf+vrpT8fnsNefmuUWkG7ftAMo/zFzO8dzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709200280; c=relaxed/simple; bh=svOKqmJR4D0HNG5CCkun2AVq6cEPN3cvQEIe6SciZ2o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mAOcyVg304t0wYUqijiFsNcDFATauZxQa+jDCUrkkP52UpZGbIEHNne4F/kWuwiIBt12SU1UbAbIaf1MPhPfvH5KrA/yP3o4RW7IjMG2iAI06wU2Rb3mAx4L1hJAW86pixEockHlzoInW+gZLvAX7x/HwA/Nie4LPfnt7F/KVOw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jdakGs50; 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="jdakGs50" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFD68C43390; Thu, 29 Feb 2024 09:51:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709200280; bh=svOKqmJR4D0HNG5CCkun2AVq6cEPN3cvQEIe6SciZ2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jdakGs50GQW/G63KHeW1i+2g4Lhyyw33IRNCCuCaxUbG23D2+jzmiCxQIjizXd7uA Twc3GXkzq2htEO0gWTu/dmER00nT+jdywrbkWL9sCiz5TNLMx/QKK/lmgW1/8of4cJ AOf6iD1OxSdAHH34H4ACS4Bc8uvrXpwIfQfeVhcpschrl4eiDLqQ2vIMDxodBRj/GZ TOupPy96uK5AyqFFAEdt+eHPuCQALbp17sWFmyXFX8gxZTx3fvqS4tIqyRF2J5Dyyr 97zu+NzU2gnM0oDX3uMPrAFIgCfz7l+JRmku0WX3hbCyk9g4reFa5eXArCTEeqtJtq dfZKSoOPlr+eA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-net v7 1/8] selftests: mptcp: diag: return KSFT_FAIL not test_cnt Date: Thu, 29 Feb 2024 17:51:04 +0800 Message-Id: <5e46270779c52504b27c5df251fd1febf36252eb.1709200070.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 test counter 'test_cnt' should not be returned in diag.sh, e.g. what if only the 4th test fail? Will do 'exit 4' which is 'exit ${KSFT_SKIP}', the whole test will be marked as skipped instead of 'failed'! So we should do ret=3D${KSFT_FAIL} instead. Fixes: df62f2ec3df6 ("selftests/mptcp: add diag interface tests") Fixes: 42fb6cddec3b ("selftests: mptcp: more stable diag tests") Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/diag.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/self= tests/net/mptcp/diag.sh index d8f080f934ac..ff02b699840d 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -63,7 +63,7 @@ __chk_nr() else echo "[ fail ] expected $expected found $nr" mptcp_lib_result_fail "${msg}" - ret=3D$test_cnt + ret=3D${KSFT_FAIL} fi else echo "[ ok ]" @@ -118,11 +118,11 @@ wait_msk_nr() if [ $i -ge $timeout ]; then echo "[ fail ] timeout while expecting $expected max $max last $nr" mptcp_lib_result_fail "${msg} # timeout" - ret=3D$test_cnt + ret=3D${KSFT_FAIL} elif [ $nr !=3D $expected ]; then echo "[ fail ] expected $expected found $nr" mptcp_lib_result_fail "${msg} # unexpected result" - ret=3D$test_cnt + ret=3D${KSFT_FAIL} else echo "[ ok ]" mptcp_lib_result_pass "${msg}" --=20 2.40.1 From nobody Thu Dec 5 02:11:40 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 5806C6089C for ; Thu, 29 Feb 2024 09:51: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=1709200282; cv=none; b=RMih/fEJ1uOLDksM3n4A9dFLoqqGmwSDVhb4I3TG8AYe2gVSdHDIWxZsbQySSH4e+MXgUzgUqYg0wN5DuYn6Xgls5GQEYCFwvo30wXtf/JCmYQgcBSiFydn02srX/rhXkfF5jafPjG7NarYZ3rElaeJRWFM7E8QgSbAOD9TNz2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709200282; c=relaxed/simple; bh=CeysPUs859NGxTYkiD7yPGixmyXJEiqppZF4B17j2vo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=A55aQmRiiwQz9EOAqL+wFsp44+2fPxmXZwpQSABBDdqhcupkR5Djgv88IjehhC+LzXtNP+uhyx4UsdjmFSrhNMilo57zv3ZfThn2A1j3PL9rifYaZIfXDM4SnEphC+sHr1BDqV9mivWas+ZLEumli3xmtN7HNMLk4VwpO6JzS8E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SoZAeQWn; 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="SoZAeQWn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1683C433C7; Thu, 29 Feb 2024 09:51:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709200282; bh=CeysPUs859NGxTYkiD7yPGixmyXJEiqppZF4B17j2vo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SoZAeQWncd5e1log0qKzlfAKjKF9gKGLEAEiTmY7mYiFG7+R+DkBSeokmjgYX4Gqs ScIqAsU1sxPzMJewgWvujgk75nlVeUbqmL2N3i61137sPAKBmf5MKRehAQAsXzw50k eg2nqutGCDOVeUQhNzzrfTAyohrN0Wh/QT1pCPZyZc2ZXkTtdjb6Kd5L4AQtomqDHz ho0ZN5GG0QXTSggDjYeR9IUz3rvVgetW2LXkuFYw48627+T4e+Ug6x4Y7+7ESuJ6ut yWpTYczeXZM2EsHk0RxiNHp8P8vlYH6YCUIhn0Qx1+i6khSdijZikuNC89fPiJdKOa nH1TUHYZygkcA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 2/8] selftests: mptcp: connect: add dedicated port counter Date: Thu, 29 Feb 2024 17:51:05 +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 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 0ca2960c9099..4f40221a86cb 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% @@ -314,7 +315,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 @@ -710,7 +711,7 @@ EOF =20 echo "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:11:40 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 314C26089C for ; Thu, 29 Feb 2024 09:51:24 +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=1709200284; cv=none; b=MGwXuSWVkngQ51BGjssWAdjJb++Lc03zvKp7UiwREHNH5pFd9nPimgfXgI0zN4+Kv6dwJWrFy28JjVDHBd1VBJmeDtZRQ4Wscd0dCQEXDx1cJG7l43SEafiXZXN0W4gsZl/79NI58+Pe0a1AcGCwgeLaSc2d1VMkJ7QGZw4jqhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709200284; c=relaxed/simple; bh=vfYKTCtOtdP9a8Xnju6WY2Da+kYlcxBhYFQH4BcpNuo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FatcIEqw++2vv21HwHQf3Cc4B0CAkR9xWTmX/Fq5qa2AIQMeJEx1DxSVaOXztMBiemgjN8o2JnNqBOBioAEK4KM5ATQ/9nrVjPfCbWznFjfPGEM9K/8qHvOHoPJML5HInSiEiY8us7VAUMK2cfymk/SrnzOLCzXpb+Ydf8qH21k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=n0JAXJ97; 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="n0JAXJ97" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3B4DC433F1; Thu, 29 Feb 2024 09:51:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709200284; bh=vfYKTCtOtdP9a8Xnju6WY2Da+kYlcxBhYFQH4BcpNuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n0JAXJ97uIPAdbjJ0RCBpPl4n4BQakM3cujk2TVLqsDcmeLqNSYPfZuhwalhd75dp 9/6Zv36BJ+Tq3+UmrZxbbRG7Bk/kYcPep5t8CzypGLLcH16gF/aQxSxxtEMC+Hz5D9 wIrUQpSsBaX5Dhgrx1XdIlFpzkMW0RCQGCjqgx7XAjye1x1oPlVyBpGyGRQ0wNPnZG /z1elpEKpDlh8ptb39HQojmaG2hKO1M/JUj2yjAwjKpttsk6lAUkvqRa29gOd+nAeI eK3aijfukcUXoQ4wrm9uNooDf6Hyi/JMeP9nK4q7tkB7a1wXQleAaSSEbYeq0kk+6h bwz7GmGi5E7Eg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 3/8] selftests: mptcp: connect: fix misaligned output Date: Thu, 29 Feb 2024 17:51:06 +0800 Message-Id: <7dbd446f210d2d66896275da66567bfd113ee2af.1709200070.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 ] in the output of mptcp_connect.sh misaligns with the others: New MPTCP socket can be blocked via sysctl [ OK ] INFO: validating network environment with pings INFO: Using loss of 0.85% delay 16 ms reorder 95% 70% with delay 4ms on ns1 MPTCP -> ns1 (10.0.1.1:10000 ) MPTCP (duration 184ms) [ OK ] ns1 MPTCP -> ns1 (10.0.1.1:10001 ) TCP (duration 50ms) [ OK ] ns1 TCP -> ns1 (10.0.1.1:10002 ) MPTCP (duration 55ms) [ OK ] This patch aligns them by using 69 chars to display the first two lines, and 50 chars for the other. Since 19 chars are used to display duration time. Also print out a [ OK ] at the end of the 2nd line for consistency. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 8 +++++--- 1 file changed, 5 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 4f40221a86cb..77b0b9d5aca0 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -274,7 +274,8 @@ check_mptcp_disabled() return 1 fi =20 - echo -e "New MPTCP socket can be blocked via sysctl\t\t[ OK ]" + printf "%-69s" "New MPTCP socket can be blocked via sysctl" + echo "[ OK ]" mptcp_lib_result_pass "New MPTCP socket can be blocked via sysctl" return 0 } @@ -343,7 +344,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}" + printf "%-50s" "${result_msg}" =20 if $capture; then local capuser @@ -836,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" +printf "%-69s" "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 @@ -858,6 +859,7 @@ done mptcp_lib_result_code "${ret}" "ping tests" =20 stop_if_error "Could not even run ping tests" +echo "[ OK ]" =20 [ -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 " --=20 2.40.1 From nobody Thu Dec 5 02:11:40 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 1838262154 for ; Thu, 29 Feb 2024 09:51: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=1709200286; cv=none; b=kodjSAD4S3PWAwccaL7vlZYnyeOiYpga2s86bblbpDdWp9lHOqdGrZYKlGFV374c5dE4PEWmZW6iUyxZuPwaC99oisesfZEPieAHsQ5Dz2H5QRHav5rFzmjVh4Ejk66oEtqXLhuCcmgy7jGdyMBFw0k2LzNM5l6f3j672rrbNzE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709200286; c=relaxed/simple; bh=mprnrej/0gLC63Pqw5hE0AB99UEFRq5m2fhCyfBqo8U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q/IP0At8HKUtremeVGaDjgoCF8OZrHlZoH609fyfAUGdciYSkKNfe+3bWlydxLLicRi55NAieTZpf9b5clIxZOLLCg99OohsoHgayNlvvLacjaO9t+5jyYB1MgfNeZ5vFBYX7L1gkgXEo4XP9GQAKLwBRHjiNDv//wFdJtZV6xc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=a9P4yLIJ; 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="a9P4yLIJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E856C433C7; Thu, 29 Feb 2024 09:51:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709200286; bh=mprnrej/0gLC63Pqw5hE0AB99UEFRq5m2fhCyfBqo8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a9P4yLIJUO5ls6mGwV0k/KFwQ/OXtOfKqUtVOn1vR1t3cVyT7pzmWl4tTHp6XJNmm qxNcWT2cxudOYZ/JiF9JOm1l5T0ENy22FW3a9czi/Mtr6MTfRGAuYgn1M7XwScsiIf D/Y5UDwHN/TGexmkLLTmrNZaZgF8PxUV9xnynaStN0UUvAho4uFm5z1SasmA4NjAyn QSimojK9C9lh3bYFDmX+iCZI7Cad9ro2EqPk784tMo+fyokt2Nwiv9zW2MQz6cKNCd zFYbkWIGCRaVHF/VXlAATVPJnwhdLHyzmrn3p1B7aCdwmSd/HYrRCK1mtvXI/bKK9D vtAvXFmf4BpMA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 4/8] selftests: mptcp: simult_flows: fix misaligned output Date: Thu, 29 Feb 2024 17:51:07 +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 last line in the output of simult_flows.sh misaligns with the other lines, and all lines are over maximum 75 chars per line. This patch aligns them by using the newly added print_title() helper, and truncate them within 75 chars per line to allow it to be displayed normally in regular terminals without breaking lines. The new output looks like this: balanced bwidth 7395 max 7906 [ OK ] balanced bwidth - reverse direction 7484 max 7906 [ OK ] balanced bwidth with unbalanced delay 7394 max 7906 [ OK ] balanced bwidth with unbalanced delay - reverse direct 7399 max 7906 [ OK ] unbalanced bwidth 7692 max 7906 [ OK ] unbalanced bwidth - reverse direction 7614 max 7906 [ OK ] unbalanced bwidth with unbalanced delay 7425 max 7906 [ OK ] unbalanced bwidth with unbalanced delay - reverse dire 7473 max 7906 [ OK ] unbalanced bwidth with opposed, unbalanced delay 7639 max 7906 [ OK ] unbalanced bwidth with opposed, unbalanced delay - rev 7611 max 7906 [ OK ] Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/simult_flows.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/test= ing/selftests/net/mptcp/simult_flows.sh index 467feb17e07b..d5f8521b88d5 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -184,7 +184,7 @@ do_transfer() cmp $cin $sout > /dev/null 2>&1 local cmpc=3D$? =20 - printf "%-16s" " max $max_time " + printf "%-10s" " max $max_time " if [ $retc -eq 0 ] && [ $rets -eq 0 ] && \ [ $cmpc -eq 0 ] && [ $cmps -eq 0 ]; then echo "[ OK ]" @@ -249,7 +249,7 @@ run_test() fi =20 msg+=3D" - reverse direction" - printf "%-60s" "${msg}" + printf "%-60s" "$(echo -n ${msg} | cut -c1-54)" do_transfer $large $small $time lret=3D$? mptcp_lib_result_code "${lret}" "${msg}" --=20 2.40.1 From nobody Thu Dec 5 02:11:40 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 160D06089C for ; Thu, 29 Feb 2024 09:51:28 +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=1709200288; cv=none; b=sJIfrPl1wZsx00XmbXx/rc1A1Uhqe7o+/EvisUJrb7m8jATpVUJdPcRaqVPVHpSjFyLAqDydXQOx8Yul5iyrLCIgZiuqxWB9L7wsW/936qQJw4oiVdwfLiWDLlqlLETlDOWpPiqI8ZOWSLfSRZYSowqphyqdWoJ4YsY2ePjlnVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709200288; c=relaxed/simple; bh=efqIyCCvvu+OGLhmZPAwZ5uVwcc9WjfA5yvSi3SkUFE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YHWAbhdel+sWjjS3r06X6vdhIocxVA8XRmdkNuoR/iVhsuvMT+0pHV6AEHa3YFA8/zU6ZLVF214ZM47iU5yKIgEg4fzqYZIwaZVyxdXNFvzj3GK7W7GRVFgaRZoHGfeUkMLH6CYtUNJiwcbVIUnxf7jAqI4oUlHzQpT5GRzr2Ik= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SC20Dyxa; 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="SC20Dyxa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97D2BC433A6; Thu, 29 Feb 2024 09:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709200287; bh=efqIyCCvvu+OGLhmZPAwZ5uVwcc9WjfA5yvSi3SkUFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SC20DyxaJ48bO+QpzRfuSjFuDD20OI6J5OVB096H3sxiQPEUfKf2VZMFnjyATTYbU /XNW9EKsgFartv+F7wmAxOGZBHnYW0QOZelP4zHeQ8h/cPw1nycuU4zk6td+oo+4jw crSfdx6vqs9TFeZ81NwION7I4GDwq3IBCDt4QjzKOueChnQTSPtRalgInRdKAKF69w GS1P2AdOp3G9XN865sQeKQwghPMyabncsPkYiRyHvZfar0Q2327MLRPpC3C2eWjMZ8 l/mPSJgl35Z+Kt3h8tZgu0thayKuli/0gZVZUpyv9baim/mgRryrY6v3xs0bNSRUIs CsdDO0ir8ihuw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 5/8] selftests: mptcp: sockopt: unify ipv4/ipv6 as v4/v6 Date: Thu, 29 Feb 2024 17:51:08 +0800 Message-Id: <80749c1dfc741ca14090559c5a2364b253c03a5a.1709200070.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 ipv4/ipv6 and v4/v6 are mixed in the output of mptcp_sockopt.sh, this patch unifies them as v4/v6. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_sockopt.sh index 6ed4aa32222f..ae59136b5bb4 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -130,10 +130,10 @@ do_transfer() local local_addr ip if mptcp_lib_is_v6 "${connect_addr}"; then local_addr=3D"::" - ip=3Dipv6 + ip=3Dv6 else local_addr=3D"0.0.0.0" - ip=3Dipv4 + ip=3Dv4 fi =20 cmsg=3D"TIMESTAMPNS" @@ -232,7 +232,7 @@ do_mptcp_sockopt_tests() lret=3D$? =20 if [ $lret -ne 0 ]; then - echo "FAIL: SOL_MPTCP getsockopt (ipv6)" 1>&2 + echo "FAIL: SOL_MPTCP getsockopt (v6)" 1>&2 mptcp_lib_result_fail "sockopt v6" ret=3D$lret return --=20 2.40.1 From nobody Thu Dec 5 02:11:40 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 640BC62158 for ; Thu, 29 Feb 2024 09:51:30 +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=1709200291; cv=none; b=FnwMiZQkCk/GK+Oo7jBShQXpT5K6fJgAu5qyxQUBM/bFEedi8uaGtatcON8ves8IZzuduEkQK8vGJbfX4yhFYbXnmMlM5HaqEVF4cO/yEM4tCRBrI09wus9Oiqzdb27riQ42vLO/A8UVZAxVue9VMza1hXia0CySganJIKGnrSk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709200291; c=relaxed/simple; bh=SMAkT3mC2OPIrzgbw+ZxiXQXPSAhsFqPQeWBKPhfYMg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qhrGyjbKQrDQZcu1790GWve6HZAwGu5WjgwgElOve58SsRFF7ruZCY489L1fnXNhQGVhAQw766OqBwSo6w9ZJYOF0JpuLHYIHDAZIbq68OHWL3M8NP+0z+esOuIusUddAPNilqeQqfkVmMZiCY35BkjgOWoxz1Qc8iR/Qt5rqio= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V8UhmG80; 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="V8UhmG80" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A268DC433C7; Thu, 29 Feb 2024 09:51:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709200290; bh=SMAkT3mC2OPIrzgbw+ZxiXQXPSAhsFqPQeWBKPhfYMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V8UhmG80jPPU3NV20CEH6JkFUveM5XGC9bMqW+MltCXriNn91YUCr5rMeCqVsHw9N nepw4SxM6O3iJsFiWmXe72gKwpTmEJTpesLZ+cHX/RXmC/RI07MGWDp8u0sZODYnem YZb/zt/FAt7NcYN+9UpHvWkubshlZYuvorj8zYsxjdZKvFIhIRM4qeOlbhtiMVvlxB 5KWdRSiVmI1e6Q+9PZG3JZ80U1A3Dte4EWzmVNOCR3hxU/AHb0Iig9b798EEK0CUEq KHvM4Sa0gX7i+n7RSElB9ABkiFkraCznS38xhV+rhMlrn3FvA0+G/OQ6L1W9WDmBlz j5oF/zvVo9xcw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 6/8] selftests: mptcp: add test counter helpers Date: Thu, 29 Feb 2024 17:51:09 +0800 Message-Id: <9a31a17605edb4546467a172d8619eff3f15a002.1709200070.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 two vars in mptcp_lib.sh, MPTCP_LIB_TEST_COUNTER for the test counter and MPTCP_LIB_TEST_FORMAT for the test print format. Also add two helpers, mptcp_lib_inc_test_counter(), increase the test counter, and mptcp_lib_pr_title_counter(), print the test title with counter. They are used in mptcp_join.sh first. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 16 ++++++++-------- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 1df2d24979a0..7acc6064eb17 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -48,7 +48,6 @@ declare -A all_tests declare -a only_tests_ids declare -a only_tests_names declare -A failed_tests -TEST_COUNT=3D0 TEST_NAME=3D"" nr_blank=3D6 =20 @@ -172,7 +171,8 @@ cleanup() =20 print_title() { - printf "%03u %s\n" "${TEST_COUNT}" "${TEST_NAME}" + MPTCP_LIB_TEST_FORMAT=3D"%03u %s\n" + mptcp_lib_pr_title_counter "${TEST_NAME}" } =20 print_check() @@ -233,7 +233,7 @@ skip_test() =20 local i for i in "${only_tests_ids[@]}"; do - if [ "${TEST_COUNT}" -eq "${i}" ]; then + if [ "${MPTCP_LIB_TEST_COUNTER}" -eq "${i}" ]; then return 1 fi done @@ -268,7 +268,7 @@ reset() =20 TEST_NAME=3D"${1}" =20 - TEST_COUNT=3D$((TEST_COUNT+1)) + mptcp_lib_inc_test_counter =20 if skip_test; then last_test_ignored=3D1 @@ -462,7 +462,7 @@ fail_test() =20 # just in case a test is marked twice as failed if [ ${last_test_failed} -eq 0 ]; then - failed_tests[${TEST_COUNT}]=3D"${TEST_NAME}" + failed_tests[${MPTCP_LIB_TEST_COUNTER}]=3D"${TEST_NAME}" dump_stats last_test_failed=3D1 fi @@ -973,7 +973,7 @@ do_transfer() local srv_proto=3D"$4" local connect_addr=3D"$5" =20 - local port=3D$((10000 + TEST_COUNT - 1)) + local port=3D$((10000 + MPTCP_LIB_TEST_COUNTER - 1)) local cappid local FAILING_LINKS=3D${FAILING_LINKS:-""} local fastclose=3D${fastclose:-""} @@ -991,9 +991,9 @@ do_transfer() capuser=3D"-Z $SUDO_USER" fi =20 - capfile=3D$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}") + capfile=3D$(printf "mp_join-%02u-%s.pcap" "$MPTCP_LIB_TEST_COUNTER" "${l= istener_ns}") =20 - echo "Capturing traffic for test $TEST_COUNT into $capfile" + echo "Capturing traffic for test $MPTCP_LIB_TEST_COUNTER into $capfile" ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -= w $capfile > "$capout" 2>&1 & cappid=3D$! =20 diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing= /selftests/net/mptcp/mptcp_lib.sh index 763a2989ca6d..cbf0dd2cc4cb 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -411,3 +411,20 @@ mptcp_lib_events() { ip netns exec "${ns}" ./pm_nl_ctl events >> "${evts}" 2>&1 & pid=3D$! } + +MPTCP_LIB_TEST_COUNTER=3D0 +MPTCP_LIB_TEST_FORMAT=3D"" + +mptcp_lib_inc_test_counter() { + : "${MPTCP_LIB_TEST_COUNTER:?}" + + MPTCP_LIB_TEST_COUNTER=3D$((MPTCP_LIB_TEST_COUNTER+1)) +} + +#shellcheck disable=3DSC2059 +mptcp_lib_pr_title_counter() { + : "${MPTCP_LIB_TEST_COUNTER:?}" + : "${MPTCP_LIB_TEST_FORMAT:=3D"%02u %-50s"}" + + printf "${MPTCP_LIB_TEST_FORMAT}" "${MPTCP_LIB_TEST_COUNTER}" "${*}" +} --=20 2.40.1 From nobody Thu Dec 5 02:11:40 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 B80FD6214F for ; Thu, 29 Feb 2024 09:51:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709200292; cv=none; b=N9VTpAJvgpH4aUsthIlTG990zhBOXnY9fxPg3rGAEdS0dHDop5p1TLkMwB6odfOTWP/WbLHQubDFAwSUGsnVjU1pIhve8LZcwC7oYnhZRp3FDr8PZVtPDTybo4qbm2mBrIaEkkLCFlbtYUWaWrYKYhXga/yaiBc5RVY5CeVsu0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709200292; c=relaxed/simple; bh=3aXl6GpvJDrr8xEkI8GCGGYP45vcPy+Oh/B3J7VbaEM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VK3M+U6tA9jqu2y9hIyBKAkAZPwmTNv0q+ayIIwyeeKeJ37zTiuXVzeAAxtQsW5adBVUrUaf5q/OXRc1acAYjp3NqYw4G7R65ACErvnjx8eyRP8kCbSkg4nukFeAtoPQ3m5RoQeiXIuK14OQrYLR9DPn/9CLzj5nuqEFITs5ccI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gDm21zl9; 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="gDm21zl9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2985BC433F1; Thu, 29 Feb 2024 09:51:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709200292; bh=3aXl6GpvJDrr8xEkI8GCGGYP45vcPy+Oh/B3J7VbaEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gDm21zl9nEOX5pOJVhrU+YoNzt3F5r3X9ZtFqxFBioKDgI91GP1KxT2VRdXou3rSO pIvN1N2dYz61N7mbP+5KBAYlbR+0gWqcL615sZYIBQGW7y+IAVho3h1EE5mG8lXzX2 9gs/qiyEy1avwmVULA8J8CF7HMu/4nxnfv1VPEXyLMaR6sJf5/na+xQAp0/FQVtLxf s8VgvFKv6G931xgRVOaF1g778qEcolrdfw1jEJF0pO3HheqzPd6h671kidHxGapSA7 I79hc1OMAXxGcdeKniCSCAcc0cJbhKsNJAnyf6N+1AFLKn0JFD7JSV7E8K1RJuih/G XPJk8V8HW0Hkg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 7/8] selftests: mptcp: print test results with counters Date: Thu, 29 Feb 2024 17:51:10 +0800 Message-Id: <2328092277b37a0b02084860109840f91f128137.1709200070.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_title(), a wrapper of mptcp_lib_inc_test_counter() and mptcp_lib_pr_title_counter(), to print out test counter in each test result and increase the counter. Use this helper to print out test counters for every tests in diag.sh, mptcp_connect.sh, mptcp_sockopt.sh, pm_netlink.sh, simult_flows.sh, and userspace_pm.sh. diag.sh: 01 no msk on netns creation [ ok ] 02 listen match for dport 10000 [ ok ] 03 listen match for sport 10000 [ ok ] 04 listen match for saddr and sport [ ok ] 05 all listen sockets [ ok ] mptcp_connect.sh: 01 New MPTCP socket can be blocked via sysctl [ OK ] 02 Validating network environment with pings [ OK ] INFO: Using loss of 0.85% delay 31 ms reorder .. with delay 7ms on ns3eth4 03 ns1 MPTCP -> ns1 (10.0.1.1:10000 ) MPTCP (duration 69ms) [ OK ] 04 ns1 MPTCP -> ns1 (10.0.1.1:10001 ) TCP (duration 20ms) [ OK ] 05 ns1 TCP -> ns1 (10.0.1.1:10002 ) MPTCP (duration 16ms) [ OK ] mptcp_sockopt.sh: 01 Transfer v4 [ OK ] 02 Mark v4 [ OK ] 03 Transfer v6 [ OK ] 04 Mark v6 [ OK ] 05 SOL_MPTCP sockopt v4 [ OK ] pm_netlink.sh: 01 defaults addr list [ OK ] 02 simple add/get addr [ OK ] 03 dump addrs [ OK ] 04 simple del addr [ OK ] 05 dump addrs after del [ OK ] simult_flows.sh: 01 balanced bwidth 7391 max 8456 [ OK ] 02 balanced bwidth - reverse direction 7403 max 8456 [ OK ] 03 balanced bwidth with unbalanced delay 7429 max 8456 [ OK ] 04 balanced bwidth with unbalanced delay - reverse dir 7485 max 8456 [ OK ] 05 unbalanced bwidth 7549 max 8456 [ OK ] userspace_pm.sh: 01 Created network namespaces ns1, ns2 [ OK ] INFO: Make connections 02 Established IPv4 MPTCP Connection ns2 =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:67 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 | 7 ++----- .../selftests/net/mptcp/mptcp_connect.sh | 10 +++++----- .../testing/selftests/net/mptcp/mptcp_lib.sh | 5 +++++ .../selftests/net/mptcp/mptcp_sockopt.sh | 20 ++++++++++--------- .../testing/selftests/net/mptcp/pm_netlink.sh | 5 +++-- .../selftests/net/mptcp/simult_flows.sh | 14 ++++++++----- .../selftests/net/mptcp/userspace_pm.sh | 3 ++- 7 files changed, 37 insertions(+), 27 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/self= tests/net/mptcp/diag.sh index ff02b699840d..74b19b89d6e6 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -9,7 +9,6 @@ . "$(dirname "${0}")/mptcp_lib.sh" =20 ns=3D"" -test_cnt=3D1 timeout_poll=3D30 timeout_test=3D$((timeout_poll * 2 + 1)) ret=3D0 @@ -55,7 +54,7 @@ __chk_nr() =20 nr=3D$(eval $command) =20 - printf "%-50s" "$msg" + mptcp_lib_print_title "$msg" if [ "$nr" !=3D "$expected" ]; then if [ "$nr" =3D "$skip" ] && ! mptcp_lib_expect_all_features; then echo "[ skip ] Feature probably not supported" @@ -69,7 +68,6 @@ __chk_nr() echo "[ ok ]" mptcp_lib_result_pass "${msg}" fi - test_cnt=3D$((test_cnt+1)) } =20 __chk_msk_nr() @@ -114,7 +112,7 @@ wait_msk_nr() sleep 1 done =20 - printf "%-50s" "$msg" + mptcp_lib_print_title "$msg" if [ $i -ge $timeout ]; then echo "[ fail ] timeout while expecting $expected max $max last $nr" mptcp_lib_result_fail "${msg} # timeout" @@ -127,7 +125,6 @@ wait_msk_nr() echo "[ 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 77b0b9d5aca0..096ff8941c5b 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -131,7 +131,6 @@ ns2=3D"" ns3=3D"" ns4=3D"" =20 -TEST_COUNT=3D0 TEST_GROUP=3D"" =20 # This function is used in the cleanup trap @@ -253,6 +252,7 @@ check_mptcp_disabled() local disabled_ns mptcp_lib_ns_init disabled_ns =20 + mptcp_lib_print_title "New MPTCP socket can be blocked via sysctl" # net.mptcp.enabled should be enabled by default if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ pr= int $3 }')" -ne 1 ]; then echo -e "net.mptcp.enabled sysctl is not 1 by default\t\t[ FAIL ]" @@ -274,7 +274,6 @@ check_mptcp_disabled() return 1 fi =20 - printf "%-69s" "New MPTCP socket can be blocked via sysctl" echo "[ OK ]" mptcp_lib_result_pass "New MPTCP socket can be blocked via sysctl" return 0 @@ -317,7 +316,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" @@ -344,7 +342,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 "%-50s" "${result_msg}" + mptcp_lib_print_title "${result_msg}" =20 if $capture; then local capuser @@ -830,6 +828,7 @@ stop_if_error() fi } =20 +MPTCP_LIB_TEST_FORMAT=3D"%02u %-69s" make_file "$cin" "client" make_file "$sin" "server" =20 @@ -837,7 +836,7 @@ check_mptcp_disabled =20 stop_if_error "The kernel configuration is not valid for MPTCP" =20 -printf "%-69s" "Validating network environment with pings" +mptcp_lib_print_title "Validating network environment with pings" for sender in "$ns1" "$ns2" "$ns3" "$ns4";do do_ping "$ns1" $sender 10.0.1.1 do_ping "$ns1" $sender dead:beef:1::1 @@ -860,6 +859,7 @@ mptcp_lib_result_code "${ret}" "ping tests" =20 stop_if_error "Could not even run ping tests" echo "[ OK ]" +MPTCP_LIB_TEST_FORMAT=3D"%02u %-50s" =20 [ -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 " diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing= /selftests/net/mptcp/mptcp_lib.sh index cbf0dd2cc4cb..358d5b77fc0f 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -428,3 +428,8 @@ mptcp_lib_pr_title_counter() { =20 printf "${MPTCP_LIB_TEST_FORMAT}" "${MPTCP_LIB_TEST_COUNTER}" "${*}" } + +mptcp_lib_print_title() { + mptcp_lib_inc_test_counter + mptcp_lib_pr_title_counter "${*}" +} diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_sockopt.sh index ae59136b5bb4..a797e13d3fe7 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 + mptcp_lib_print_title "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 @@ -174,7 +175,9 @@ do_transfer() ret=3D1 return 1 fi + echo "[ OK ]" =20 + mptcp_lib_print_title "Mark ${ip}" if [ $local_addr =3D "::" ];then check_mark $listener_ns 6 || retc=3D1 check_mark $connector_ns 6 || retc=3D1 @@ -190,8 +193,10 @@ do_transfer() mptcp_lib_result_code "${rets}" "transfer ${ip}" =20 if [ $retc -eq 0 ] && [ $rets -eq 0 ];then + echo "[ OK ]" return 0 fi + echo "FAIL: Mark ${ip}" =20 return 1 } @@ -220,23 +225,27 @@ do_mptcp_sockopt_tests() ip netns exec "$ns_sbox" ./mptcp_sockopt lret=3D$? =20 + mptcp_lib_print_title "SOL_MPTCP 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 + echo "[ OK ]" mptcp_lib_result_pass "sockopt v4" =20 ip netns exec "$ns_sbox" ./mptcp_sockopt -6 lret=3D$? =20 + mptcp_lib_print_title "SOL_MPTCP sockopt v6" if [ $lret -ne 0 ]; then echo "FAIL: SOL_MPTCP getsockopt (v6)" 1>&2 mptcp_lib_result_fail "sockopt v6" ret=3D$lret return fi + echo "[ OK ]" mptcp_lib_result_pass "sockopt v6" } =20 @@ -259,6 +268,7 @@ run_tests() =20 do_tcpinq_test() { + mptcp_lib_print_title "TCP_INQ cmsg/ioctl $*" ip netns exec "$ns_sbox" ./mptcp_inq "$@" local lret=3D$? if [ $lret -ne 0 ];then @@ -268,7 +278,7 @@ do_tcpinq_test() return $lret fi =20 - echo "PASS: TCP_INQ cmsg/ioctl $*" + echo "[ OK ]" mptcp_lib_result_pass "TCP_INQ: $*" return $lret } @@ -314,15 +324,7 @@ trap cleanup EXIT 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" -fi - do_mptcp_sockopt_tests -if [ $ret -eq 0 ];then - echo "PASS: SOL_MPTCP getsockopt has expected information" -fi - do_tcpinq_tests =20 mptcp_lib_result_print_all_tap diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testin= g/selftests/net/mptcp/pm_netlink.sh index 427fc5c70b3c..5b9bc25dfef4 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -53,7 +53,7 @@ check() local msg=3D"$3" local rc=3D0 =20 - printf "%-50s" "$msg" + mptcp_lib_print_title "$msg" mptcp_lib_check_output "${err}" "${cmd}" "${expected}" || rc=3D${?} if [ ${rc} -eq 2 ]; then mptcp_lib_result_fail "${msg} # error ${rc}" @@ -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]" + mptcp_lib_print_title "${st}" + echo "[SKIP]" mptcp_lib_result_skip "${st}" done fi diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/test= ing/selftests/net/mptcp/simult_flows.sh index d5f8521b88d5..212782301c6f 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -14,7 +14,6 @@ ns3=3D"" capture=3Dfalse timeout_poll=3D30 timeout_test=3D$((timeout_poll * 2 + 1)) -test_cnt=3D1 ret=3D0 bail=3D0 slack=3D50 @@ -126,8 +125,7 @@ do_transfer() local sin=3D$2 local max_time=3D$3 local port - port=3D$((10000+test_cnt)) - test_cnt=3D$((test_cnt+1)) + port=3D$((10000+MPTCP_LIB_TEST_COUNTER)) =20 :> "$cout" :> "$sout" @@ -205,6 +203,12 @@ do_transfer() return 1 } =20 +print_title() +{ + MPTCP_LIB_TEST_FORMAT=3D"%02u %-55s" + mptcp_lib_print_title "${*}" +} + run_test() { local rate1=3D$1 @@ -239,7 +243,7 @@ run_test() # completion (see mptcp_connect): 200ms on each side, add some slack time=3D$((time + 400 + slack)) =20 - printf "%-60s" "$msg" + print_title "$msg" do_transfer $small $large $time lret=3D$? mptcp_lib_result_code "${lret}" "${msg}" @@ -249,7 +253,7 @@ run_test() fi =20 msg+=3D" - reverse direction" - printf "%-60s" "$(echo -n ${msg} | cut -c1-54)" + print_title "$(echo -n ${msg} | cut -c1-54)" 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 b0cce8f065d8..62e059e3fb24 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -69,7 +69,8 @@ print_test() { test_name=3D"${1}" =20 - _printf "%-68s" "${test_name}" + MPTCP_LIB_TEST_FORMAT=3D"%02u %-68s" + mptcp_lib_print_title "${test_name}" } =20 print_results() --=20 2.40.1 From nobody Thu Dec 5 02:11:40 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 B0D746089C for ; Thu, 29 Feb 2024 09:51:34 +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=1709200294; cv=none; b=pLfBoiqHU6Wl9AGpWxMm/NXF7i5o3JFqTu+MC6jpkT+7lG4c0ZR6QRENSIOxTkj/Va1NZ5LcbcQRgctZvg7gV0DUQXDE+dALr3W7qI8XFsNRCQJD81SoAUko0miJj7TzCFOpV7tpLEDrZ5UY0j1fk6zgkshFP7tcXpXA7QLmqDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709200294; c=relaxed/simple; bh=MsNlSe2x7/vsK8bOU+yw0YVx39ufWJv6xuDKJ8rgkjo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IgR9kJ8gZJ5cvjjjT8u1D4uWkBn5oKi/ZaG1KpcTrGhFiz4MTIsXP7tE3XAj4bKH7mqlCehNlHPDoaCIMS7nUuKuSHUTJugVb85jZkQ8Wb9h5gtUABRRQM8piXzXb6IBAMSoqwzSFqhakOW1vUFjArIu1vH1nPXqzBiptr3ayd0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tQWXyQMr; 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="tQWXyQMr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2914C43390; Thu, 29 Feb 2024 09:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709200294; bh=MsNlSe2x7/vsK8bOU+yw0YVx39ufWJv6xuDKJ8rgkjo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tQWXyQMrSHE4ueVPKYmpR3zG28IQ/OG2WSHddlfNW2eOmZnJhNIxfluVw+G/N1LJp GdFNyyjnanvNbxdz7KG7LqcX8l7w+TODPlsDCC4XDEXnC5Hs6u+Kp4JBdH0XCuo4e3 l9NEnHWeJyDVXHZZrxKQ49tIrgCS3fYINSw/urpN9z8g74929HpFPEVhVKAgtpwJij oaeK9KCUpcnEaq+fRDjMZZLgyjbW1mZ4YZ0+sffFvW7MsXpc3956COCKiiOoasYF73 WeqAedqxy07GVmrnXEdEBn3pCAd+qiOfd/uHWAfSsoKYHU67cria7aUTPB+O4OZYYe UBqt091hFt2zA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v7 8/8] selftests: mptcp: print test results with colors Date: Thu, 29 Feb 2024 17:51:11 +0800 Message-Id: <81fd6204fc60dd90a4410b3435ab4552402b71c0.1709200070.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 unify the output formats of all test scripts, this patch adds four more helpers: mptcp_lib_pr_ok() mptcp_lib_pr_skip() mptcp_lib_pr_fail() mptcp_lib_pr_info() to print out [ OK ], [SKIP], [FAIL] and 'INFO: ' with colors. Use them in all scripts to print the "ok/skip/fail/info' using the same 'format'. Having colors helps to quickly identify issues when looking at a long list of output logs and results. Note that the mptcp_join.sh tests will now print these keywords with capital letters, like most of the other tests. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/diag.sh | 12 ++-- .../selftests/net/mptcp/mptcp_connect.sh | 61 +++++++++---------- .../testing/selftests/net/mptcp/mptcp_join.sh | 6 +- .../testing/selftests/net/mptcp/mptcp_lib.sh | 35 ++++++++--- .../selftests/net/mptcp/mptcp_sockopt.sh | 25 ++++---- .../testing/selftests/net/mptcp/pm_netlink.sh | 2 +- .../selftests/net/mptcp/simult_flows.sh | 4 +- .../selftests/net/mptcp/userspace_pm.sh | 18 ++---- 8 files changed, 85 insertions(+), 78 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/self= tests/net/mptcp/diag.sh index 74b19b89d6e6..f7a729dfc555 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -57,15 +57,15 @@ __chk_nr() mptcp_lib_print_title "$msg" if [ "$nr" !=3D "$expected" ]; then if [ "$nr" =3D "$skip" ] && ! mptcp_lib_expect_all_features; then - echo "[ skip ] Feature probably not supported" + mptcp_lib_pr_skip "Feature probably not supported" mptcp_lib_result_skip "${msg}" else - echo "[ fail ] expected $expected found $nr" + mptcp_lib_pr_fail "expected $expected found $nr" mptcp_lib_result_fail "${msg}" ret=3D${KSFT_FAIL} fi else - echo "[ ok ]" + mptcp_lib_pr_ok mptcp_lib_result_pass "${msg}" fi } @@ -114,15 +114,15 @@ wait_msk_nr() =20 mptcp_lib_print_title "$msg" if [ $i -ge $timeout ]; then - echo "[ fail ] timeout while expecting $expected max $max last $nr" + mptcp_lib_pr_fail "timeout while expecting $expected max $max last $nr" mptcp_lib_result_fail "${msg} # timeout" ret=3D${KSFT_FAIL} elif [ $nr !=3D $expected ]; then - echo "[ fail ] expected $expected found $nr" + mptcp_lib_pr_fail "expected $expected found $nr" mptcp_lib_result_fail "${msg} # unexpected result" ret=3D${KSFT_FAIL} else - echo "[ ok ]" + mptcp_lib_pr_ok mptcp_lib_result_pass "${msg}" fi } diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_connect.sh index 096ff8941c5b..70acbb19f568 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -218,7 +218,7 @@ set_ethtool_flags() { local flags=3D"$3" =20 if ip netns exec $ns ethtool -K $dev $flags 2>/dev/null; then - echo "INFO: set $ns dev $dev: ethtool -K $flags" + mptcp_lib_pr_info "set $ns dev $dev: ethtool -K $flags" fi } =20 @@ -255,7 +255,7 @@ check_mptcp_disabled() mptcp_lib_print_title "New MPTCP socket can be blocked via sysctl" # net.mptcp.enabled should be enabled by default if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ pr= int $3 }')" -ne 1 ]; then - echo -e "net.mptcp.enabled sysctl is not 1 by default\t\t[ FAIL ]" + mptcp_lib_pr_fail "net.mptcp.enabled sysctl is not 1 by default" mptcp_lib_result_fail "net.mptcp.enabled sysctl is not 1 by default" ret=3D1 return 1 @@ -268,13 +268,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 ]" + mptcp_lib_pr_fail "New MPTCP socket cannot be blocked via sysctl" mptcp_lib_result_fail "New MPTCP socket cannot be blocked via sysctl" ret=3D1 return 1 fi =20 - echo "[ OK ]" + mptcp_lib_pr_ok mptcp_lib_result_pass "New MPTCP socket can be blocked via sysctl" return 0 } @@ -295,7 +295,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 + mptcp_lib_pr_fail "$listener_ns -> $connect_addr connectivity" ret=3D1 =20 return 1 @@ -330,7 +330,7 @@ do_transfer() fi =20 if [ -n "$extra_args" ] && $options_log; then - echo "INFO: extra options: $extra_args" + mptcp_lib_pr_info "extra options: $extra_args" fi options_log=3Dfalse =20 @@ -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 + mptcp_lib_pr_fail "client exit code $retc, server $rets" echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport =3D :$port" cat /tmp/${listener_ns}.out @@ -469,14 +469,14 @@ do_transfer() fi =20 if [ ${stat_synrx_now_l} -lt ${expect_synrx} ]; then - printf "[ FAIL ] lower MPC SYN rx (%d) than expected (%d)\n" \ - "${stat_synrx_now_l}" "${expect_synrx}" 1>&2 + mptcp_lib_pr_fail "lower MPC SYN rx (${stat_synrx_now_l})" \ + "than expected (${expect_synrx})" 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" \ - "${stat_ackrx_now_l}" "${expect_ackrx}" 1>&2 + mptcp_lib_pr_fail "lower MPC ACK rx (${stat_ackrx_now_l})" \ + "than expected (${expect_ackrx})" rets=3D1 else printf "[ Note ] fallback due to TCP OoO" @@ -491,19 +491,19 @@ 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} + mptcp_lib_pr_fail "server got ${csum_err_s_nr} data checksum error[s]" 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} + mptcp_lib_pr_fail "client got ${csum_err_c_nr} data checksum error[s]" retc=3D1 fi fi =20 if [ $retc -eq 0 ] && [ $rets -eq 0 ]; then - printf "[ OK ]" + mptcp_lib_pr_ok mptcp_lib_result_pass "${TEST_GROUP}: ${result_msg}" else mptcp_lib_result_fail "${TEST_GROUP}: ${result_msg}" @@ -534,7 +534,6 @@ do_transfer() "${expect_ackrx}" "${stat_ackrx_now_l}" fi =20 - echo cat "$capout" [ $retc -eq 0 ] && [ $rets -eq 0 ] } @@ -660,7 +659,7 @@ run_test_transparent() # following function has been exported (T). Not great but better than # checking for a specific kernel version. if ! mptcp_lib_kallsyms_has "T __ip_sock_set_tos$"; then - echo "INFO: ${msg} not supported by the kernel: SKIP" + mptcp_lib_pr_skip "INFO: ${msg} not supported by the kernel" mptcp_lib_result_skip "${TEST_GROUP}" return fi @@ -677,7 +676,7 @@ table inet mangle { } EOF then - echo "SKIP: $msg, could not load nft ruleset" + mptcp_lib_pr_skip "$msg, could not load nft ruleset" mptcp_lib_fail_if_expected_feature "nft rules" mptcp_lib_result_skip "${TEST_GROUP}" return @@ -693,7 +692,7 @@ 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_pr_skip "$msg, ip $r6flag rule failed" mptcp_lib_fail_if_expected_feature "ip rule" mptcp_lib_result_skip "${TEST_GROUP}" return @@ -702,13 +701,13 @@ 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_pr_skip "$msg, ip route add local $local_addr failed" mptcp_lib_fail_if_expected_feature "ip route" mptcp_lib_result_skip "${TEST_GROUP}" return fi =20 - echo "INFO: test $msg" + mptcp_lib_pr_info "test $msg" =20 PORT=3D10000 local extra_args=3D"-o TRANSPARENT" @@ -721,12 +720,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_pr_fail "$msg, mptcp connection error" ret=3D$lret return 1 fi =20 - echo "PASS: $msg" + mptcp_lib_pr_info "PASS: $msg" return 0 } =20 @@ -735,7 +734,7 @@ run_tests_peekmode() local peekmode=3D"$1" =20 TEST_GROUP=3D"peek mode: ${peekmode}" - echo "INFO: with peek mode: ${peekmode}" + mptcp_lib_pr_info "with peek mode: ${peekmode}" run_tests_lo "$ns1" "$ns1" 10.0.1.1 1 "-P ${peekmode}" run_tests_lo "$ns1" "$ns1" dead:beef:1::1 1 "-P ${peekmode}" } @@ -745,12 +744,12 @@ run_tests_mptfo() TEST_GROUP=3D"MPTFO" =20 if ! mptcp_lib_kallsyms_has "mptcp_fastopen_"; then - echo "INFO: TFO not supported by the kernel: SKIP" + mptcp_lib_pr_skip "TFO not supported by the kernel" mptcp_lib_result_skip "${TEST_GROUP}" return fi =20 - echo "INFO: with MPTFO start" + mptcp_lib_pr_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 +761,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_pr_info "with MPTFO end" } =20 run_tests_disconnect() @@ -773,7 +772,7 @@ run_tests_disconnect() TEST_GROUP=3D"full disconnect" =20 if ! mptcp_lib_kallsyms_has "mptcp_pm_data_reset$"; then - echo "INFO: Full disconnect not supported: SKIP" + mptcp_lib_pr_skip "Full disconnect not supported" mptcp_lib_result_skip "${TEST_GROUP}" return fi @@ -786,7 +785,7 @@ run_tests_disconnect() cin_disconnect=3D"$old_cin" connect_per_transfer=3D3 =20 - echo "INFO: disconnect" + mptcp_lib_pr_info "disconnect" run_tests_lo "$ns1" "$ns1" 10.0.1.1 1 "-I 3 -i $old_cin" run_tests_lo "$ns1" "$ns1" dead:beef:1::1 1 "-I 3 -i $old_cin" =20 @@ -810,7 +809,7 @@ log_if_error() local msg=3D"$1" =20 if [ ${ret} -ne 0 ]; then - echo "FAIL: ${msg}" 1>&2 + mptcp_lib_pr_fail "${msg}" =20 final_ret=3D${ret} ret=3D0 @@ -858,11 +857,11 @@ done mptcp_lib_result_code "${ret}" "ping tests" =20 stop_if_error "Could not even run ping tests" -echo "[ OK ]" +mptcp_lib_pr_ok MPTCP_LIB_TEST_FORMAT=3D"%02u %-50s" =20 [ -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 " +mptcp_lib_pr_info "Using loss of $tc_loss " test "$tc_delay" -gt 0 && echo -n "delay $tc_delay ms " =20 reorder_delay=3D$((tc_delay / 4)) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 7acc6064eb17..c3654eb45870 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_pr_ok "${@}" } =20 print_fail() { - mptcp_lib_print_err "[fail]${1:+ ${*}}" + mptcp_lib_pr_fail "${@}" } =20 print_skip() { - mptcp_lib_print_warn "[skip]${1:+ ${*}}" + mptcp_lib_pr_skip "${@}" } =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 358d5b77fc0f..53867f9d212d 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -48,6 +48,23 @@ mptcp_lib_print_err() { mptcp_lib_print_color "${MPTCP_LIB_COLOR_RED}${*}" } =20 +#shellcheck disable=3DSC2120 +mptcp_lib_pr_ok() { + mptcp_lib_print_ok "[ OK ]${1:+ ${*}}" +} + +mptcp_lib_pr_skip() { + mptcp_lib_print_warn "[SKIP]${1:+ ${*}}" +} + +mptcp_lib_pr_fail() { + mptcp_lib_print_err "[FAIL]${1:+ ${*}}" +} + +mptcp_lib_pr_info() { + mptcp_lib_print_info "INFO: ${*}" +} + # SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var can be set when validati= ng all # features using the last version of the kernel and the selftests to make = sure # a test is not being skipped by mistake. @@ -78,14 +95,14 @@ mptcp_lib_has_file() { =20 mptcp_lib_check_mptcp() { if ! mptcp_lib_has_file "/proc/sys/net/mptcp/enabled"; then - echo "SKIP: MPTCP support is not available" + mptcp_lib_pr_skip "MPTCP support is not available" exit ${KSFT_SKIP} fi } =20 mptcp_lib_check_kallsyms() { if ! mptcp_lib_has_file "/proc/kallsyms"; then - echo "SKIP: CONFIG_KALLSYMS is missing" + mptcp_lib_pr_skip "CONFIG_KALLSYMS is missing" exit ${KSFT_SKIP} fi } @@ -292,7 +309,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):" + mptcp_lib_pr_fail "$what does not match (in, out):" mptcp_lib_print_file_err "$in" mptcp_lib_print_file_err "$out" =20 @@ -327,24 +344,24 @@ mptcp_lib_check_tools() { case "${tool}" in "ip") if ! ip -Version &> /dev/null; then - mptcp_lib_print_warn "SKIP: Could not run test without ip tool" + mptcp_lib_pr_skip "Could not run test without ip tool" exit ${KSFT_SKIP} fi ;; "ss") if ! ss -h | grep -q MPTCP; then - mptcp_lib_print_warn "SKIP: ss tool does not support MPTCP" + mptcp_lib_pr_skip "ss tool does not support MPTCP" exit ${KSFT_SKIP} fi ;; "iptables"* | "ip6tables"*) if ! "${tool}" -V &> /dev/null; then - mptcp_lib_print_warn "SKIP: Could not run all tests without ${tool}" + mptcp_lib_pr_skip "Could not run all tests without ${tool}" exit ${KSFT_SKIP} fi ;; *) - mptcp_lib_print_err "Internal error: unsupported tool: ${tool}" + mptcp_lib_pr_fail "Internal error: unsupported tool: ${tool}" exit ${KSFT_FAIL} ;; esac @@ -363,13 +380,13 @@ mptcp_lib_check_output() { fi =20 if [ ${cmd_ret} -ne 0 ]; then - mptcp_lib_print_err "[FAIL] command execution '${cmd}' stderr" + mptcp_lib_pr_fail "command execution '${cmd}' stderr" cat "${err}" return 2 elif [ "${out}" =3D "${expected}" ]; then return 0 else - mptcp_lib_print_err "[FAIL] expected '${expected}' got '${out}'" + mptcp_lib_pr_fail "expected '${expected}' got '${out}'" return 1 fi } diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_sockopt.sh index a797e13d3fe7..d695561fbf46 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -103,7 +103,8 @@ check_mark() local v for v in $values; do if [ $v -ne 0 ]; then - echo "FAIL: got $tables $values in ns $ns , not 0 - not all expected pa= ckets marked" 1>&2 + mptcp_lib_pr_fail "got $tables $values in ns $ns," \ + "not 0 - not all expected packets marked" ret=3D1 return 1 fi @@ -175,7 +176,7 @@ do_transfer() ret=3D1 return 1 fi - echo "[ OK ]" + mptcp_lib_pr_ok =20 mptcp_lib_print_title "Mark ${ip}" if [ $local_addr =3D "::" ];then @@ -193,10 +194,10 @@ do_transfer() mptcp_lib_result_code "${rets}" "transfer ${ip}" =20 if [ $retc -eq 0 ] && [ $rets -eq 0 ];then - echo "[ OK ]" + mptcp_lib_pr_ok return 0 fi - echo "FAIL: Mark ${ip}" + mptcp_lib_pr_fail "Mark ${ip}" =20 return 1 } @@ -217,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_pr_skip "MPTCP sockopt not supported" mptcp_lib_result_skip "sockopt" return fi @@ -227,12 +228,12 @@ do_mptcp_sockopt_tests() =20 mptcp_lib_print_title "SOL_MPTCP sockopt v4" if [ $lret -ne 0 ]; then - echo "FAIL: SOL_MPTCP getsockopt" 1>&2 + mptcp_lib_pr_fail "SOL_MPTCP getsockopt" mptcp_lib_result_fail "sockopt v4" ret=3D$lret return fi - echo "[ OK ]" + mptcp_lib_pr_ok mptcp_lib_result_pass "sockopt v4" =20 ip netns exec "$ns_sbox" ./mptcp_sockopt -6 @@ -240,12 +241,12 @@ do_mptcp_sockopt_tests() =20 mptcp_lib_print_title "SOL_MPTCP sockopt v6" if [ $lret -ne 0 ]; then - echo "FAIL: SOL_MPTCP getsockopt (v6)" 1>&2 + mptcp_lib_pr_fail "SOL_MPTCP getsockopt (v6)" mptcp_lib_result_fail "sockopt v6" ret=3D$lret return fi - echo "[ OK ]" + mptcp_lib_pr_ok mptcp_lib_result_pass "sockopt v6" } =20 @@ -273,12 +274,12 @@ do_tcpinq_test() local lret=3D$? if [ $lret -ne 0 ];then ret=3D$lret - echo "FAIL: mptcp_inq $*" 1>&2 + mptcp_lib_pr_fail "mptcp_inq $*" mptcp_lib_result_fail "TCP_INQ: $*" return $lret fi =20 - echo "[ OK ]" + mptcp_lib_pr_ok mptcp_lib_result_pass "TCP_INQ: $*" return $lret } @@ -288,7 +289,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_pr_skip "INFO: TCP_INQ not supported" mptcp_lib_result_skip "TCP_INQ" return fi diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testin= g/selftests/net/mptcp/pm_netlink.sh index 5b9bc25dfef4..69ffff8b076b 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -190,7 +190,7 @@ else for st in fullmesh nofullmesh backup,fullmesh; do st=3D" (${st})" mptcp_lib_print_title "${st}" - echo "[SKIP]" + mptcp_lib_pr_skip mptcp_lib_result_skip "${st}" done fi diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/test= ing/selftests/net/mptcp/simult_flows.sh index 212782301c6f..c5dbe083e47f 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -185,12 +185,12 @@ do_transfer() printf "%-10s" " max $max_time " if [ $retc -eq 0 ] && [ $rets -eq 0 ] && \ [ $cmpc -eq 0 ] && [ $cmps -eq 0 ]; then - echo "[ OK ]" + mptcp_lib_pr_ok cat "$capout" return 0 fi =20 - echo " [ fail ]" + mptcp_lib_pr_fail echo "client exit code $retc, server $rets" 1>&2 echo -e "\nnetns ${ns3} socket stat for $port:" 1>&2 ip netns exec ${ns3} ss -nita 1>&2 -o "sport =3D :$port" diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/test= ing/selftests/net/mptcp/userspace_pm.sh index 62e059e3fb24..0c5ba35f6af4 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_pr_info "${1}" } =20 # $1: test name @@ -73,33 +73,23 @@ print_test() mptcp_lib_print_title "${test_name}" } =20 -print_results() -{ - _printf "[%s]\n" "${1}" -} - test_pass() { - print_results " OK " + mptcp_lib_pr_ok mptcp_lib_result_pass "${test_name}" } =20 test_skip() { - print_results "SKIP" + mptcp_lib_pr_skip mptcp_lib_result_skip "${test_name}" } =20 # $1: msg test_fail() { - print_results "FAIL" + mptcp_lib_pr_fail "${@}" ret=3D1 - - if [ -n "${1}" ]; then - _printf "\t%s\n" "${1}" - fi - mptcp_lib_result_fail "${test_name}" } =20 --=20 2.40.1