From nobody Wed Dec 4 18:53:44 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 B0A0AE555 for ; Fri, 8 Mar 2024 05:57:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709877466; cv=none; b=CPZWVRx0MmQOh7lZogQ5uRsZSJgF2LEv2CiLWxXnkLOKPAfXMWCAPPol4+XoWNqbj9Ew6ez288dR1lHUrFvA5LM4jzn/wCSz+Y3zzgYQO8yPtZRhM3tqXsQsTaycDPit1LYpPFAMSGNVzHj7o9/w8yMPZ6j8ubk0vQ8YWTLDMIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709877466; c=relaxed/simple; bh=0f7AVl2hAegExFa8381DUjNXVylId3k6XGe6FEuGoT0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WMXdWGJtwEVOiyK7zvQtU/PdKRt5km7AAX0EbQEFumc8myDNQCD03fyrAqHFQUim8P4LzWADzYpzL39hS1mWNqHS/eQfus2QfVUCr/cDQAerwKRuLcMrikGe1ixL1h3OiplX3462zNf7EKqPO8sqRpxEoJt8O19kbaOPfsu1Utc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MLsJXHP9; 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="MLsJXHP9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AE1DC43390; Fri, 8 Mar 2024 05:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709877466; bh=0f7AVl2hAegExFa8381DUjNXVylId3k6XGe6FEuGoT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MLsJXHP9zOuCRs0A6JLv3mXrLEGXpvG8hwJaWXtjiT2SYbC6DFw0LMkAoW4YiEQcS 01RCB/XqnZmYJ7GM3Paz2/eTNs9W2xZYhaiqlK/aIABkTsvIolUsoLjJA0/xY4wI5R sVWw4t3HifVDAipsqLyZYWw5gkeuPZuA6WR7NH0Go+xJ6F1V1LiCOdlliWyyyoy9he ziI9mZD0Ao+NlRm4CbmOfNWSpWD0/wdHASQW42u5ZN60dmcc1DEDbZ3m8+0IhJIWYx waWcl7pzwF9Bx7pm8DY3SiBM0oiMFPfM4nhMDNa8NsNowqQCRodVNFPRVe+Im3Usu6 I5RIT+2dVkzSA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 1/7] selftests: mptcp: call test_fail without argument Date: Fri, 8 Mar 2024 13:57:34 +0800 Message-Id: <4852453633fd9591d2108344d83f9dbf2674b797.1709876991.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 modifies test_fail() to call mptcp_lib_pr_fail() only if there are arguments (if [ ${#} -gt 0 ]) in userspace_pm.sh, add arguments "unexpected type: ${type}" when calling test_fail() from test_remove(). Then mptcp_lib_pr_fail() can be used in check_expected_one() instead of test_fail(). The same in mptcp_join.sh, calling fail_test() without argument, and adapt this helper not to call print_fail() in this case. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 7 +++++-- tools/testing/selftests/net/mptcp/userspace_pm.sh | 12 ++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index cecf09d14f46..7392fc9f5ea1 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -452,7 +452,9 @@ fail_test() { ret=3D1 =20 - print_fail "${@}" + if [ ${#} -gt 0 ]; then + print_fail "${@}" + fi =20 # just in case a test is marked twice as failed if [ ${last_test_failed} -eq 0 ]; then @@ -2834,7 +2836,8 @@ verify_listener_events() print_ok return 0 fi - fail_test "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$spor= t" + print_fail "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$spo= rt" + fail_test } =20 add_addr_ports_tests() diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/test= ing/selftests/net/mptcp/userspace_pm.sh index 4e29aa9c2529..bc2f0184b1eb 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -85,7 +85,10 @@ test_skip() # $1: msg test_fail() { - mptcp_lib_pr_fail "${@}" + if [ ${#} -gt 0 ] + then + mptcp_lib_pr_fail "${@}" + fi ret=3D1 mptcp_lib_result_fail "${test_name}" } @@ -239,7 +242,7 @@ check_expected_one() =20 if [ "${prev_ret}" =3D "0" ] then - test_fail + mptcp_lib_pr_fail fi =20 mptcp_lib_print_err "\tExpected value for '${var}': '${!exp}', got '${!va= r}'." @@ -263,6 +266,7 @@ check_expected() return 0 fi =20 + test_fail return 1 } =20 @@ -412,7 +416,7 @@ test_remove() then test_pass else - test_fail + test_fail "unexpected type: ${type}" fi =20 # RM_ADDR using an invalid addr id should result in no action @@ -425,7 +429,7 @@ test_remove() then test_pass else - test_fail + test_fail "unexpected type: ${type}" fi =20 # RM_ADDR from the client to server machine --=20 2.40.1 From nobody Wed Dec 4 18:53:44 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 E90C428E2B for ; Fri, 8 Mar 2024 05:57:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709877468; cv=none; b=h9WFft5i2Bw9q1OHFCIgdRTWk4SLRbW3C5PEyIfdkItBMgTssW/Jiekp12yvmJNQmUngrthFdBsxXv4cLCpjphepA2vkGOK3FEG3b8/2CY9bXycmE/hgS1g+mhikCZtBFyXIo188WzeHNg3mfQr08BhrXRQJqA9ztJUeGanCRZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709877468; c=relaxed/simple; bh=g3cCTfrQ484c1X1ZXJ9ZCqnUD8fekNETgnDcvgb3ETE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uwPAaaAsu9r2/s4Eagdede7TEa7dx6sfAHqMWPexUVrX+0bp8TE1BPieQ1rhDvPP0+FwjcWAjexE1i1YLTD7+XbdkmUYdL9jaOO1OfLXUYORswDYGGwGyq9ZBBK9mE08oXutU2rZIssNmTR6To+DqScHLdusWwc4CqmQyKSEXIk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lQRC0hH7; 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="lQRC0hH7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEFFDC433C7; Fri, 8 Mar 2024 05:57:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709877467; bh=g3cCTfrQ484c1X1ZXJ9ZCqnUD8fekNETgnDcvgb3ETE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lQRC0hH7rr3p+3NhyfqW6TVZjoxL5Ll6mMUNi5CMXxHiDZIxp8si0dYESiABiL2RX OXDILAVUdJxftiFhiE82QpxjerSM50NIXmbcv810hywvnz5IWRNL+FwwVooPHMI7Hy 66FEMNDu2vPvbVDbonEfrzKmfEDD3T5feXLJXCrG39dnP70arYfPgV6MnQfpXx4Lfv ukItDJ1fitwc/Vq4y2u9HdalcR29Apy1RHiTvKIYWQe18ow2G8WUri6X4sG/t7ukh8 sagUKd1b+nBpQ4RPCr3U+k4X4J+ZP+TFzHxwhWwT8Wjf8Ot7PMPL4c4ODdoQaRVP9s uu5CnWzKAdtBg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 2/7] selftests: mptcp: extract mptcp_lib_check_expected Date: Fri, 8 Mar 2024 13:57:35 +0800 Message-Id: <32ad4d66ad8049f668373985bdf6019c03cf35e2.1709876991.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 Extract the main part of check_expected() in userspace_pm.sh to a new function mptcp_lib_check_expected() in mptcp_lib.sh. It will be used in both mptcp_john.sh and userspace_pm.sh. check_expected_one() is moved into mptcp_lib.sh too as mptcp_lib_check_expected_one(). Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) --- .../testing/selftests/net/mptcp/mptcp_lib.sh | 30 +++++++++++++++++ .../selftests/net/mptcp/userspace_pm.sh | 33 ++----------------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing= /selftests/net/mptcp/mptcp_lib.sh index ea39392c68e7..44491f18ed17 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -438,3 +438,33 @@ mptcp_lib_print_title() { # shellcheck disable=3DSC2059 # the format is in a variable printf "${MPTCP_LIB_TEST_FORMAT}" "$((++MPTCP_LIB_TEST_COUNTER))" "${*}" } + +# $1: var name ; $2: prev ret +mptcp_lib_check_expected_one() { + local var=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 + mptcp_lib_pr_fail + fi + + mptcp_lib_print_err "Expected value for '${var}': '${!exp}', got '${!var}= '." + return 1 +} + +# $@: all var names to check +mptcp_lib_check_expected() { + local rc=3D0 + local var + + for var in "${@}"; do + mptcp_lib_check_expected_one "${var}" "${rc}" || rc=3D1 + done + + return "${rc}" +} diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/test= ing/selftests/net/mptcp/userspace_pm.sh index bc2f0184b1eb..6d0862a1b68d 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -5,7 +5,7 @@ # code but we accept it. #shellcheck disable=3DSC2086 =20 -# Some variables are used below but indirectly, see check_expected_one() +# Some variables are used below but indirectly, see verify_*_event() #shellcheck disable=3DSC2034 =20 . "$(dirname "${0}")/mptcp_lib.sh" @@ -228,39 +228,10 @@ 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 - mptcp_lib_pr_fail - fi - - mptcp_lib_print_err "\tExpected value for '${var}': '${!exp}', got '${!va= r}'." - return 1 -} - # $@: all var names to check check_expected() { - local rc=3D0 - local var - - for var in "${@}" - do - check_expected_one "${var}" "${rc}" || rc=3D1 - done - - if [ ${rc} -eq 0 ] + if mptcp_lib_check_expected "${@}" then test_pass return 0 --=20 2.40.1 From nobody Wed Dec 4 18:53:44 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 D36F728E2B for ; Fri, 8 Mar 2024 05:57:48 +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=1709877468; cv=none; b=aOpP0bbWakF2GlvBZqU96ZUrvJEP47zwXFJ5oYSvx+HILggMsiEp1Vf2R4HKj28Pg+YEMEjZnQn3RxdO3qwGLHEsOYVoXHSH5qgjPfHg+NAOT/5RIh4t8m4NWoeML9+A0YllCqFewkAtOn6ifgpRZe5Wk+nCnCtRldbx8Gf0zes= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709877468; c=relaxed/simple; bh=hio6xgdqPN32b2eEdu9W9KqBjgHSEbHZIBqnbl2nfiM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hItwhkYVdeD2qOTCWqogXtaYDy5hNPtEXJktlnlaHrlW8+PoVSsWGKp01dd+0huSpfPAmKd5+9kMEuR3hDo/Cy22amb/XOwNEF5cxq2ydq4sga11rt8JWnhh1D643V6B1pgyduSnshopdl29KGxjv8nqqXNYuI3pJ+q90K9BuCU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f5g7MAMj; 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="f5g7MAMj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2FB5C43390; Fri, 8 Mar 2024 05:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709877468; bh=hio6xgdqPN32b2eEdu9W9KqBjgHSEbHZIBqnbl2nfiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f5g7MAMj4vggJyJgFb8TLtnVdcbV4Y0Bnmzfl7AVWy7w9ThQ6nSTDpNjOV1Aa9Apr v5OdydPYCJY7HEHxxgIQIui2xImlBxhcam2rzuztUsU21r6wlztFkXZKb8pWueTGwK 1MvWAeaHEm/V1eNhUG2A41HDLh/w/7gsmfLRgJpP2RIlzqJSG11zH0uD5cklT0xRfA 1hpsiVteX8XcWqfm9FZjNiH7zfeoQOe0bIvTMRjNd6w/NeqBjbyRpGB63qvgGMNK93 XeKcPef9yE1HDrLmITK43DudswD86TWiuEU6uyMFvKB6D6EDtiS3ntu4qEnyficfwD cjjYGND1HH0RQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 3/7] selftests: mptcp: print_test out of verify_listener_events Date: Fri, 8 Mar 2024 13:57:36 +0800 Message-Id: <2bffcdde5610631b9f3b715d83d42420996c0fc2.1709876991.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 verify_listener_events() helper will be exported into mptcp_lib.sh as a public function, but print_test() is invoked in it, which is a private function in userspace_pm.sh only. So this patch moves print_test() out of verify_listener_events(). Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/userspace_pm.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/test= ing/selftests/net/mptcp/userspace_pm.sh index 6d0862a1b68d..e9aea44edee5 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -845,12 +845,6 @@ verify_listener_events() local saddr local sport =20 - 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 - 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) @@ -882,6 +876,7 @@ test_listener() local listener_pid=3D$! =20 sleep 0.5 + print_test "CREATE_LISTENER 10.0.2.2:$client4_port" verify_listener_events $client_evts $LISTENER_CREATED $AF_INET 10.0.2.2 $= client4_port =20 # ADD_ADDR from client to server machine reusing the subflow port @@ -898,6 +893,7 @@ test_listener() mptcp_lib_kill_wait $listener_pid =20 sleep 0.5 + print_test "CLOSE_LISTENER 10.0.2.2:$client4_port" verify_listener_events $client_evts $LISTENER_CLOSED $AF_INET 10.0.2.2 $c= lient4_port } =20 --=20 2.40.1 From nobody Wed Dec 4 18:53:44 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 71D7928DD8 for ; Fri, 8 Mar 2024 05:57:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709877470; cv=none; b=VZKT5E8rj10APysBUQ2bXsF1+NT7P/9L/g6cziHy80tj+QvsRISFTNBdzfn2iASuvv3v1/LtWAT4kcQWqWTkNPCHPTpqi/qsb3nVnPffh30OdlzRaMSkIEJRjpr4eEcIfypogydsVrJUK513e2ZLTQUvQRO8x88W2O1zgPtIZrw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709877470; c=relaxed/simple; bh=iVZpIiTrtKmAMo20+IlE3Qc/HKa2V0dZaajdvjPQZHw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RuZYF6VqnHnDQCXs9+xMNBSH3ZV7l+a4Xw2aRAkmDdvoy9fbZgqy6GT8HXmt6OcsZMuEgzbravRpoMZWP3gq+UniKzisWWWH4nuf3Yyl/LIP2ErfsYf5UolXiQXZPq6jCc8FNbESmDBrFjqZs9+W3TrCarKlXowYRVrxGfmwtKc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Pw17YkW5; 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="Pw17YkW5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36F69C433F1; Fri, 8 Mar 2024 05:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709877470; bh=iVZpIiTrtKmAMo20+IlE3Qc/HKa2V0dZaajdvjPQZHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pw17YkW5u3ayIoW3EMpmwN6XCIZkB931vMC3e6nPrtomIQC7J1IT1oQuPxa1GZqY6 6Vy8U9v2ISeOsmhlQRPDN3GNX8uMqCzKPW+6qPFSZFSbRkofreJCdXl/FTob2MN3Sn dYjsNuWVHHcfWeIkEE6oNwPFwyhXaWf3bhXUaQ8GI1hJLCPcZTtkTgKfDE947CT/ga ah5ph/ckIXU52lpxi8Ga0ZXAzyTcQry1nlIRRk48hux0hFufHXshgz9VwsdOanScRX MlPrFOZqCw+fVCLTF4t4i7AqUN6O3xPMVlVLKEyUGIgk00DSYFkowTnIIFc3UDzBAY THYGDUOol8IMQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 4/7] selftests: mptcp: add mptcp_lib_verify_listener_events Date: Fri, 8 Mar 2024 13:57:37 +0800 Message-Id: <4676dcb821323288c4cc6317f053ac5bef403f20.1709876991.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 Reviewed-by: Matthieu Baerts (NGI0) --- .../testing/selftests/net/mptcp/mptcp_join.sh | 21 +-------------- .../testing/selftests/net/mptcp/mptcp_lib.sh | 26 +++++++++++++++++++ .../selftests/net/mptcp/userspace_pm.sh | 21 +++------------ 3 files changed, 30 insertions(+), 38 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 7392fc9f5ea1..84eb01a16fb8 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -2794,15 +2794,9 @@ AF_INET6=3D10 =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 =20 if [ $e_type =3D $LISTENER_CREATED ]; then @@ -2820,23 +2814,10 @@ 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 + if mptcp_lib_verify_listener_events "${@}"; then print_ok return 0 fi - print_fail "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$spo= rt" fail_test } =20 diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing= /selftests/net/mptcp/mptcp_lib.sh index 44491f18ed17..a977a722fb3d 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -468,3 +468,29 @@ mptcp_lib_check_expected() { =20 return "${rc}" } + +# shellcheck disable=3DSC2034 # Some variables are used below but indirect= ly +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 e9aea44edee5..1e0b39e5525c 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -835,26 +835,11 @@ test_prio() =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 - - 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) + if mptcp_lib_verify_listener_events "${@}"; then + test_pass else - saddr=3D$(mptcp_lib_evts_get_info saddr4 $evt $e_type) + test_fail fi - - check_expected "type" "family" "saddr" "sport" } =20 test_listener() --=20 2.40.1 From nobody Wed Dec 4 18:53:44 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 631E01E4A4 for ; Fri, 8 Mar 2024 05:57:51 +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=1709877471; cv=none; b=UHqI21GPzQC3388DKavVQ4Z7xdm2vSsTm9d9fETJkKYfPXKW9OZ92jyyvjUIPNhREQuAOauv5GQ5Z4b9Ur9BgxT/11Fw37XRWrnoQFxc1Ohy4xYMRBHMfZy5Zh3WdMXD7oEwUlpf4l+umx6t3tYfT4gHy6Jc7Ps220MMUwsn+sk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709877471; c=relaxed/simple; bh=OiNh0YszO+yerRwenGf2K9Kp6HVoH8nrbGt9dzasREw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JnKpnSuS3/3Flh8uLBlKTw5XaDqTlQG+ezyn9C/a1R1muY4cPhzHZbyRp/J7T0/VtVWjVX/SN1ip7OMRFYk1r0xawht/dSQNMDzmi21WRRhH6/5bA8sWekH69cB4dhbob7MQQP/QYFg+SvsnUmw3rr+JaDNTIXobn9CZMZIrYBk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TgIMYwg2; 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="TgIMYwg2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B498C433C7; Fri, 8 Mar 2024 05:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709877471; bh=OiNh0YszO+yerRwenGf2K9Kp6HVoH8nrbGt9dzasREw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TgIMYwg2FunaLqIUsESG4zfdTYgfOUc2NvOghMUKyZtvYUE0IIjXHP2ECxLlc+HIk 0yP8YlVB0pevhuopNeH795FFuqNf8Vi8ZRkWwJg3XiBG2mvAYomTlzEq/7JszfIdDB sTq7kdPo1yGwLQPQe8rIzJV8mlgu0qx0RFvhQKpTtW2E3bDOu2M2EwdUls4wm0+X0l uxgIb+K8wNR7KHUxJY503rXrqld6fze2EWS06+uPuoncmA9dGyRiBvYfpJrXOjyQL3 sBKKrkVCZ7um43qYxjEmLydxKdaQV28hO4nTX5jppPfuuOV9/u1DjWe2Xc2WcnTLOA uHJ5noTbRxFQw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 5/7] selftests: mptcp: declare event macros in mptcp_lib Date: Fri, 8 Mar 2024 13:57:38 +0800 Message-Id: <7cc6459e3032ff3a8cb9c35c9628b828524305f3.1709876991.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 MPTCP event macros (SUB_ESTABLISHED, LISTENER_CREATED, LISTENER_CLOSED), and the protocol family macros (AF_INET, AF_INET6) are defined in both mptcp_join.sh and userspace_pm.sh. In order not to duplicate code, this patch declares them all in mptcp_lib.sh with MPTCP_LIB_ prefixs. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) --- .../testing/selftests/net/mptcp/mptcp_join.sh | 23 ++++++++----------- .../testing/selftests/net/mptcp/mptcp_lib.sh | 11 +++++++++ .../selftests/net/mptcp/userspace_pm.sh | 18 +++++++-------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 84eb01a16fb8..fc301789a8b5 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -2785,13 +2785,6 @@ backup_tests() fi } =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 e_type=3D$2 @@ -2799,9 +2792,9 @@ verify_listener_events() local e_sport=3D$5 local name =20 - if [ $e_type =3D $LISTENER_CREATED ]; then + if [ $e_type =3D $MPTCP_LIB_EVENT_LISTENER_CREATED ]; then name=3D"LISTENER_CREATED" - elif [ $e_type =3D $LISTENER_CLOSED ]; then + elif [ $e_type =3D $MPTCP_LIB_EVENT_LISTENER_CLOSED ]; then name=3D"LISTENER_CLOSED " else name=3D"$e_type" @@ -2856,8 +2849,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_EVENT_LISTENER_CREATED \ + $MPTCP_LIB_AF_INET 10.0.2.1 10100 + verify_listener_events $evts_ns1 $MPTCP_LIB_EVENT_LISTENER_CLOSED \ + $MPTCP_LIB_AF_INET 10.0.2.1 10100 kill_events_pids fi =20 @@ -3463,11 +3458,11 @@ userspace_tests() userspace_pm_chk_get_addr "${ns1}" "10" "id 10 flags signal 10.0.2.1" userspace_pm_chk_get_addr "${ns1}" "20" "id 20 flags signal 10.0.3.1" userspace_pm_rm_addr $ns1 10 - userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $SUB_ESTABLISHED + userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $MPTCP_LIB_EVENT_SUB_ESTABLISH= ED userspace_pm_chk_dump_addr "${ns1}" \ "id 20 flags signal 10.0.3.1" "after rm_addr 10" userspace_pm_rm_addr $ns1 20 - userspace_pm_rm_sf $ns1 10.0.3.1 $SUB_ESTABLISHED + userspace_pm_rm_sf $ns1 10.0.3.1 $MPTCP_LIB_EVENT_SUB_ESTABLISHED userspace_pm_chk_dump_addr "${ns1}" "" "after rm_addr 20" chk_rm_nr 2 2 invert chk_mptcp_info subflows 0 subflows 0 @@ -3494,7 +3489,7 @@ userspace_tests() "subflow" userspace_pm_chk_get_addr "${ns2}" "20" "id 20 flags subflow 10.0.3.2" userspace_pm_rm_addr $ns2 20 - userspace_pm_rm_sf $ns2 10.0.3.2 $SUB_ESTABLISHED + userspace_pm_rm_sf $ns2 10.0.3.2 $MPTCP_LIB_EVENT_SUB_ESTABLISHED userspace_pm_chk_dump_addr "${ns2}" \ "" \ "after rm_addr 20" diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing= /selftests/net/mptcp/mptcp_lib.sh index a977a722fb3d..d529b4b37af8 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -8,6 +8,17 @@ readonly KSFT_SKIP=3D4 # shellcheck disable=3DSC2155 # declare and assign separately readonly KSFT_TEST=3D"${MPTCP_LIB_KSFT_TEST:-$(basename "${0}" .sh)}" =20 +# These variables are used in some selftests, read-only +declare -rx MPTCP_LIB_EVENT_ANNOUNCED=3D6 # MPTCP_EVENT_ANNOUNCED +declare -rx MPTCP_LIB_EVENT_REMOVED=3D7 # MPTCP_EVENT_REMOVED +declare -rx MPTCP_LIB_EVENT_SUB_ESTABLISHED=3D10 # MPTCP_EVENT_SUB_ESTABL= ISHED +declare -rx MPTCP_LIB_EVENT_SUB_CLOSED=3D11 # MPTCP_EVENT_SUB_CLOSED +declare -rx MPTCP_LIB_EVENT_LISTENER_CREATED=3D15 # MPTCP_EVENT_LISTENER_C= REATED +declare -rx MPTCP_LIB_EVENT_LISTENER_CLOSED=3D16 # MPTCP_EVENT_LISTENER_C= LOSED + +declare -rx MPTCP_LIB_AF_INET=3D2 +declare -rx MPTCP_LIB_AF_INET6=3D10 + MPTCP_LIB_SUBTESTS=3D() MPTCP_LIB_SUBTESTS_DUPLICATED=3D0 MPTCP_LIB_TEST_COUNTER=3D0 diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/test= ing/selftests/net/mptcp/userspace_pm.sh index 1e0b39e5525c..72dca742280f 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -19,15 +19,15 @@ if ! mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; = then fi mptcp_lib_check_tools ip =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 +ANNOUNCED=3D${MPTCP_LIB_EVENT_ANNOUNCED} +REMOVED=3D${MPTCP_LIB_EVENT_REMOVED} +SUB_ESTABLISHED=3D${MPTCP_LIB_EVENT_SUB_ESTABLISHED} +SUB_CLOSED=3D${MPTCP_LIB_EVENT_SUB_CLOSED} +LISTENER_CREATED=3D${MPTCP_LIB_EVENT_LISTENER_CREATED} +LISTENER_CLOSED=3D${MPTCP_LIB_EVENT_LISTENER_CLOSED} + +AF_INET=3D${MPTCP_LIB_AF_INET} +AF_INET6=3D${MPTCP_LIB_AF_INET6} =20 file=3D"" server_evts=3D"" --=20 2.40.1 From nobody Wed Dec 4 18:53:44 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 8AB641E4A4 for ; Fri, 8 Mar 2024 05:57:52 +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=1709877472; cv=none; b=sGDtkFRgX8uktQodFbgRypxrxApjzbQw7+aphvj1o54f3aIBGLYmy/Q2njGSBUj8GPcg1/8IDayiZs1ZfsvKTN0S8JpXjYuq8w/bvrRhsvJ+qXnMb5ysxK6BirzkbI8CnG4k5bntDkvw5XhATNtCM31v49wZgJopoveE/aEZnb4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709877472; c=relaxed/simple; bh=ul1l5+lLFH9mjztpvqCfZRZM6zmYLJeXWgzMLeQGO0k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q7Ee1bUKkRqV630Q7VPFHi6ndT4IlNrc6XJT7BSw+Qy28XOIk17U9eVlNx13jMVtxOyH/JUDN1HckcTfDmq/R1GdWKct//YN/uQ5CAZyrhHtwLYnwdpGDYrAB+nfSACw8tkne5JQ45cve3pD325IVZ4ndHBZRHkJmazUHESvx3U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YGVC3q6d; 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="YGVC3q6d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FC19C433C7; Fri, 8 Mar 2024 05:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709877472; bh=ul1l5+lLFH9mjztpvqCfZRZM6zmYLJeXWgzMLeQGO0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YGVC3q6daZipZV7iMSkZjI7l6s2uEfEiw7HXNB3KcizlpCSoQoSnBojjYdlEZPoXo 8yG9QXFQgAdWiQttj7KYOz1vgbab0sW2k1su4TPrw4mYDkdOqIpPffGKpd29u99FP4 ml2OWyp3Pg+xHZEl27lsL6R6rl0Z3W6BawJQT6rD9X+sOzS9OOiOhuXHfUKbxrC2ol nFxHgUGnK2ceLZM5e9KF74Dsiub2fxzaBPvX70fBRzIjdjPgEDrICWELTotpF9j0Pn /hsANObfvl/8XeIdL3w9HgWsBUUosS1OnW4z0F+ZTXYZPQtESub/Fg+ozKucmrw3LW KXlAG8aYWctdw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 6/7] selftests: mptcp: use KSFT_SKIP/KSFT_PASS/KSFT_FAIL Date: Fri, 8 Mar 2024 13:57:39 +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 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 Reviewed-by: Matthieu Baerts (NGI0) --- .../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 | 8 ++++---- .../selftests/net/mptcp/simult_flows.sh | 4 ++-- .../selftests/net/mptcp/userspace_pm.sh | 4 ++-- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/tes= ting/selftests/net/mptcp/mptcp_connect.sh index cb1837f2761a..4c4248554826 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -65,14 +65,14 @@ while getopts "$optstring" option;do case "$option" in "h") usage $0 - exit 0 + exit ${KSFT_PASS} ;; "d") if [ $OPTARG -ge 0 ];then tc_delay=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 @@ -263,7 +263,7 @@ check_mptcp_disabled() if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ pr= int $3 }')" -ne 1 ]; then mptcp_lib_pr_fail "net.mptcp.enabled sysctl is not 1 by default" mptcp_lib_result_fail "net.mptcp.enabled sysctl is not 1 by default" - ret=3D1 + ret=3D${KSFT_FAIL} return 1 fi ip netns exec ${disabled_ns} sysctl -q net.mptcp.enabled=3D0 @@ -276,7 +276,7 @@ check_mptcp_disabled() if [ ${err} -eq 0 ]; then mptcp_lib_pr_fail "New MPTCP socket cannot be blocked via sysctl" mptcp_lib_result_fail "New MPTCP socket cannot be blocked via sysctl" - ret=3D1 + ret=3D${KSFT_FAIL} return 1 fi =20 @@ -302,7 +302,7 @@ do_ping() =20 if [ $rc -ne 0 ] ; then mptcp_lib_pr_fail "$listener_ns -> $connect_addr connectivity" - ret=3D1 + ret=3D${KSFT_FAIL} =20 return 1 fi @@ -821,7 +821,7 @@ log_if_error() mptcp_lib_pr_fail "${msg}" =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 fc301789a8b5..140d80289b51 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 @@ -392,15 +391,15 @@ setup_fail_rules() -p tcp \ -m length --length 150:9999 \ -m statistic --mode nth --packet 1 --every 99999 \ - -j MARK --set-mark 42 || return ${ksft_skip} + -j MARK --set-mark 42 || return ${KSFT_SKIP} =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() @@ -414,7 +413,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 @@ -450,7 +449,7 @@ reset_with_tcp_filter() # $1: err msg fail_test() { - ret=3D1 + ret=3D${KSFT_FAIL} =20 if [ ${#} -gt 0 ]; then print_fail "${@}" @@ -3632,7 +3631,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 96aa8f71bbb0..e2d70c18786e 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -105,7 +105,7 @@ check_mark() if [ $v -ne 0 ]; then mptcp_lib_pr_fail "got $tables $values in ns $ns," \ "not 0 - not all expected packets marked" - ret=3D1 + ret=3D${KSFT_FAIL} return 1 fi done @@ -178,7 +178,7 @@ do_transfer() =20 mptcp_lib_result_fail "transfer ${ip}" =20 - ret=3D1 + ret=3D${KSFT_FAIL} return 1 fi if ! mptcp_lib_check_transfer $cin $sout "file received by server"; then diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testin= g/selftests/net/mptcp/pm_netlink.sh index 69ffff8b076b..6ab8c5d36340 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -19,11 +19,11 @@ while getopts "$optstring" option;do case "$option" in "h") usage $0 - exit 0 + exit ${KSFT_PASS} ;; "?") usage $0 - exit 1 + exit ${KSFT_FAIL} ;; esac done @@ -57,13 +57,13 @@ check() mptcp_lib_check_output "${err}" "${cmd}" "${expected}" || rc=3D${?} if [ ${rc} -eq 2 ]; then mptcp_lib_result_fail "${msg} # error ${rc}" - ret=3D1 + ret=3D${KSFT_FAIL} elif [ ${rc} -eq 0 ]; then mptcp_lib_print_ok "[ OK ]" mptcp_lib_result_pass "${msg}" elif [ ${rc} -eq 1 ]; then mptcp_lib_result_fail "${msg} # different output" - ret=3D1 + ret=3D${KSFT_FAIL} fi } =20 diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/test= ing/selftests/net/mptcp/simult_flows.sh index 4ee18406ee50..68ee92eccccb 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -263,7 +263,7 @@ while getopts "bcdh" option;do case "$option" in "h") usage $0 - exit 0 + exit ${KSFT_PASS} ;; "b") bail=3D1 @@ -276,7 +276,7 @@ while getopts "bcdh" option;do ;; "?") usage $0 - exit 1 + exit ${KSFT_FAIL} ;; esac done diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/test= ing/selftests/net/mptcp/userspace_pm.sh index 72dca742280f..9e2981f2d7f5 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -89,7 +89,7 @@ test_fail() then mptcp_lib_pr_fail "${@}" fi - ret=3D1 + ret=3D${KSFT_FAIL} mptcp_lib_result_fail "${test_name}" } =20 @@ -209,7 +209,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 From nobody Wed Dec 4 18:53:44 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 B2DD21E4A4 for ; Fri, 8 Mar 2024 05:57:53 +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=1709877473; cv=none; b=MH1dcpBv4SzFpEmM2LImzwnshwBoQS9qC5s6Ukn9nTIa3nsqMuoxl7FdoxGcjWe2IeLN8JElXgU6N0aUfcCuD48PMQxdtbgEmh8EanOUa3Nuduitp2GzemCDs4flGD82q6vMMxh/4zMaZum8H0/cXpGuUnGvju1eVePwQhzyJWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709877473; c=relaxed/simple; bh=8dyLYRWHnpeNesunCPEBQgcjDgxjnWitLLRu72WpwiI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g8H7kVGxG5f5/e3+vQ3ig7Zptbrbuq8StWxnTXVQZWVfba4ct1pyK1GRU0fr6eMjkkzHWBzrN9NPgWpWglQF/SQrV+CjgU6X+jW1ER8+hQDD0m3CB+HWnAV87jHAGSZzc2D6YwENvTTFzvdIJCfdyqwqSsXPaS9Sz4YQlHTKu7I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QvWVwzZQ; 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="QvWVwzZQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3CF0C433F1; Fri, 8 Mar 2024 05:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709877473; bh=8dyLYRWHnpeNesunCPEBQgcjDgxjnWitLLRu72WpwiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QvWVwzZQLRYr1gGeqGwcu3oUFptQbpltJBZuO8jEsi7DG96/SfucWWymBDnncRYft z3c3EFOf99LsMVVaKK1OGNmFdKiiv/Z29o6/yp7DIgoM6aY2kVKTqPca7IFZcPBg4G 7wAzNZbVsOhU2CofZWBSTpCrSCO94m8FjV+ppXNz16cs50+cvtAVP3GaFCk1WZAZ11 g/2Z3yhPZeVyqajtF0/lZCIQa/292g4z+q4IqLZx85orBcvj6Xu/BDf3jpwuYW3Tkw mHJSFyJSz421hhltLjB+RChYi2xeKV9hKmg+l9eSWVDzlTH53D43z/s5/P88MW0inG xn6Q1BHfNvZow== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 7/7] selftests: mptcp: join: use += operator to append strings Date: Fri, 8 Mar 2024 13:57:40 +0800 Message-Id: <1cbccb38bedfa1f606d0fd71ca992bc569f4cea5.1709876991.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 addition assignment operator (+=3D) to append strings inste= ad of open-coding in mptcp_join.sh. This can make the statements shorter. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) --- .../testing/selftests/net/mptcp/mptcp_join.sh | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 140d80289b51..5e9211e89825 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -755,18 +755,18 @@ pm_nl_check_endpoint() line=3D"${line% }" # the dump order is: address id flags port dev [ -n "$addr" ] && expected_line=3D"$addr" - expected_line=3D"$expected_line $id" - [ -n "$_flags" ] && expected_line=3D"$expected_line ${_flags//","/" "}" - [ -n "$dev" ] && expected_line=3D"$expected_line $dev" - [ -n "$port" ] && expected_line=3D"$expected_line $port" + expected_line+=3D" $id" + [ -n "$_flags" ] && expected_line+=3D" ${_flags//","/" "}" + [ -n "$dev" ] && expected_line+=3D" $dev" + [ -n "$port" ] && expected_line+=3D" $port" else line=3D$(ip netns exec $ns ./pm_nl_ctl get $_id) # the dump order is: id flags dev address port expected_line=3D"$id" - [ -n "$flags" ] && expected_line=3D"$expected_line $flags" - [ -n "$dev" ] && expected_line=3D"$expected_line $dev" - [ -n "$addr" ] && expected_line=3D"$expected_line $addr" - [ -n "$_port" ] && expected_line=3D"$expected_line $_port" + [ -n "$flags" ] && expected_line+=3D" $flags" + [ -n "$dev" ] && expected_line+=3D" $dev" + [ -n "$addr" ] && expected_line+=3D" $addr" + [ -n "$_port" ] && expected_line+=3D" $_port" fi if [ "$line" =3D "$expected_line" ]; then print_ok @@ -1217,7 +1217,7 @@ chk_csum_nr() print_check "sum" count=3D$(mptcp_lib_get_counter ${ns1} "MPTcpExtDataCsumErr") if [ "$count" !=3D "$csum_ns1" ]; then - extra_msg=3D"$extra_msg ns1=3D$count" + extra_msg+=3D" ns1=3D$count" fi if [ -z "$count" ]; then print_skip @@ -1230,7 +1230,7 @@ chk_csum_nr() print_check "csum" count=3D$(mptcp_lib_get_counter ${ns2} "MPTcpExtDataCsumErr") if [ "$count" !=3D "$csum_ns2" ]; then - extra_msg=3D"$extra_msg ns2=3D$count" + extra_msg+=3D" ns2=3D$count" fi if [ -z "$count" ]; then print_skip @@ -1274,7 +1274,7 @@ chk_fail_nr() print_check "ftx" count=3D$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPFailTx") if [ "$count" !=3D "$fail_tx" ]; then - extra_msg=3D"$extra_msg,tx=3D$count" + extra_msg+=3D",tx=3D$count" fi if [ -z "$count" ]; then print_skip @@ -1288,7 +1288,7 @@ chk_fail_nr() print_check "failrx" count=3D$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtMPFailRx") if [ "$count" !=3D "$fail_rx" ]; then - extra_msg=3D"$extra_msg,rx=3D$count" + extra_msg+=3D",rx=3D$count" fi if [ -z "$count" ]; then print_skip @@ -1323,7 +1323,7 @@ chk_fclose_nr() if [ -z "$count" ]; then print_skip elif [ "$count" !=3D "$fclose_tx" ]; then - extra_msg=3D"$extra_msg,tx=3D$count" + extra_msg+=3D",tx=3D$count" fail_test "got $count MP_FASTCLOSE[s] TX expected $fclose_tx" else print_ok @@ -1334,7 +1334,7 @@ chk_fclose_nr() if [ -z "$count" ]; then print_skip elif [ "$count" !=3D "$fclose_rx" ]; then - extra_msg=3D"$extra_msg,rx=3D$count" + extra_msg+=3D",rx=3D$count" fail_test "got $count MP_FASTCLOSE[s] RX expected $fclose_rx" else print_ok @@ -1703,7 +1703,7 @@ chk_rm_nr() count=3D$((count + cnt)) if [ "$count" !=3D "$rm_subflow_nr" ]; then suffix=3D"$count in [$rm_subflow_nr:$((rm_subflow_nr*2))]" - extra_msg=3D"$extra_msg simult" + extra_msg+=3D" simult" fi if [ $count -ge "$rm_subflow_nr" ] && \ [ "$count" -le "$((rm_subflow_nr *2 ))" ]; then --=20 2.40.1