From nobody Sun May 12 20:26:43 2024 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFC902F3B for ; Wed, 12 Apr 2023 09:20:37 +0000 (UTC) Received: by mail-wr1-f54.google.com with SMTP id d9so10261131wrb.11 for ; Wed, 12 Apr 2023 02:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1681291236; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=TAQjicgVP7wqxQ8Cn8cjgHvnZfLNLlLzvDBKDNrU2qo=; b=6Iut8u4XNAsz+/+rX2WZFirmbhLCS7/C4WYZ5YtVkY4H6OHx7bB5jg5oUi1h7H4Pfk hJ4YX2oZjPg4hHYQHur7ZmVRV5byJaHvKPF3Mg5QAwDuXONRKnsR1OzlyeCIS+M8MtMH 3y+LntZ70Yw8hP7u80RA+5jFhX37vALs+SH+ybCWARtTA7PzeMs8M6HJuxqxi1/p6Ztn MhGVyOOvwKpepWpl1/DOoKX3NTWu6sNAlHNiQXAuQgWZ1nbPvbr4mKxDSO1PTG4M0ACS fYaL/UkNr/6k9Rh8LIB5uJzahPtuS/QCWMDbcvCGhn6AwmWsdtThnzq4XO2+5IU7svcL txmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681291236; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TAQjicgVP7wqxQ8Cn8cjgHvnZfLNLlLzvDBKDNrU2qo=; b=JfB1HGGA0+dcgI4iYnQTlRTKqgHm2NFdwCi9IFKlCRYNC3MnEUSHJ+mban37YsOLhK shhJ7FGlM+s22qLvlvTCfcEzgi2wvqAOEfk3S/gD+MRSZv1Qn9RkuQ/r0IMwU7OKmVWG oAqVknAD+Dz8NcXJ+FUl9v+uVLXpjJUfxo8aFwaQtOOu4UzEDRqY15s6OdBdaYHtMjMm CfPIrmuzPVTVI00njXjmpEKPvedt72LYChzEvWvmKrITkeialI7HRag9KYihzhJmefTK sDU8MIQy2jkbEsB1nN+Ux0PcZ8mCDRQJIKGUR4wchy8fBEmeSsqUDiHokEEZnFvQo5cj SIfw== X-Gm-Message-State: AAQBX9f9V5VCrVr8zNDVPkJ23z2xh1z1+1bT1lknz8PJwZ5W8ScJW0cf WdpXDcUs3EocLAOAugU28MUMGw== X-Google-Smtp-Source: AKy350azFbWQ6vfo0STwrVGrzh2nQ9l6MPaaLvZ2pBibQDUmUn/VLhRYivL7ndsHjgAPMMO5FefrOQ== X-Received: by 2002:adf:e386:0:b0:2ce:a6be:2bd with SMTP id e6-20020adfe386000000b002cea6be02bdmr4301939wrm.1.1681291235932; Wed, 12 Apr 2023 02:20:35 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id k1-20020adfe3c1000000b002f01e181c4asm8981069wrm.5.2023.04.12.02.20.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 02:20:35 -0700 (PDT) From: Matthieu Baerts Date: Wed, 12 Apr 2023 11:20:12 +0200 Subject: [PATCH mptcp-net v3 1/2] selftests: mptcp: join: avoid using 'cmp --bytes' Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230404-mptcp-selftests-join-busybox-shellcheck-v3-1-eab5dd7bc996@tessares.net> References: <20230404-mptcp-selftests-join-busybox-shellcheck-v3-0-eab5dd7bc996@tessares.net> In-Reply-To: <20230404-mptcp-selftests-join-busybox-shellcheck-v3-0-eab5dd7bc996@tessares.net> To: mptcp@lists.linux.dev Cc: Matthieu Baerts , Paolo Abeni X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2523; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=Qqv4VPDAvCc+KPNEC0MK7+YIobeMOVhGeL61CItDkj4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkNnfikwyZqU7OyJsew1Fk8t2a7kElw/1c7LF51 0Kxi7Ecn5KJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZDZ34gAKCRD2t4JPQmmg c00iD/wKKRL7eZR74toOKjJzAqQEWajGgOqEmjCWt3Xuok5dhxKvg/8kGB4rNjqwEwcwpSI4/vo 9jROXWKH6YkLiUQHliFuxSmyVqqBwSKm2EJOz5DB5JW8u+00yZZszqiCHXStYOXw+JrAueUId98 cyGN/XNaW6/SToJKtJ7yupU9RlIzS9MQZirsd37mEcvFmbe/chgqDKTgR7KN6jtX0cGzZrD91YF DeL7ROqSoPWOhkvwp2qrpQV1qwmSwxBuicqIT4x68KpT3HOT5l/kkIqWpCv+sk4HqcrG7QHV3Jm nILLjelt8b9cCAlfB61f07tMz4Pk5OeNlqBksAJEj9Yu351+5DZeTAs9MtQD3zRo8pW/NoDLGIh 9bMm5mbZlC3/YEIR9pcSD4aY2g7eUSBaH4M0WlmEhaD6iFYkRhi/QCGP1xcNz+EtTStAhfvSXLq X1De/lhMXnLmg7PWwjQk2FefvUn9jvRNPzvKm0PbTBmqmKynJhwMgYd/mbpd8gf60qoPxk2UmDP YiN3AgUpxSVk4ElwFTNiAkA6zT2F3+D61YY65EgEu2cY04sWs89JCsg+fS/jDV7JVsjo5ELexjf P/Jcne8RUTOcx77MUFC58nSRXA4zNhcHlcNz8fNoyoZGKmR4515fv3Yk+3o1/VlT0TUd4zE84Jt N7Y42/AkZXk2H8Q== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 BusyBox's 'cmp' command doesn't support the '--bytes' parameter. Some CIs -- i.e. LKFT -- use BusyBox and have the mptcp_join.sh test failing [1] because their 'cmp' command doesn't support this '--bytes' option: cmp: unrecognized option '--bytes=3D1024' BusyBox v1.35.0 () multi-call binary. Usage: cmp [-ls] [-n NUM] FILE1 [FILE2] Instead, 'head --bytes' can be used as this option is supported by BusyBox. A temporary file is needed for this operation. Because it is apparently quite common to use BusyBox, it is certainly better to backport this fix to impacted kernels. Fixes: 6bf41020b72b ("selftests: mptcp: update and extend fastclose test-ca= ses") Link: https://qa-reports.linaro.org/lkft/linux-mainline-master/build/v6.3-r= c5-5-g148341f0a2f5/testrun/16088933/suite/kselftest-net-mptcp/test/net_mptc= p_userspace_pm_sh/log [1] Suggested-by: Paolo Abeni Signed-off-by: Matthieu Baerts Reviewed-by: Mat Martineau --- v3: - use a temp file and remove it in the cleanup phase (if we are really unlucky), from Paolo. v2: - limit the input file, not the output of cmp... (strange that on my side, I didn't reproduce the issue but the CI did) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index fafd19ec7e1f..555781826289 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -13,6 +13,7 @@ sout=3D"" cin=3D"" cinfail=3D"" cinsent=3D"" +tmpfile=3D"" cout=3D"" capout=3D"" ns1=3D"" @@ -171,6 +172,7 @@ cleanup() { rm -f "$cin" "$cout" "$sinfail" rm -f "$sin" "$sout" "$cinsent" "$cinfail" + rm -f "$tmpfile" rm -rf $evts_ns1 $evts_ns2 cleanup_partial } @@ -378,9 +380,16 @@ check_transfer() fail_test return 1 fi - bytes=3D"--bytes=3D${bytes}" + + # note: BusyBox's "cmp" command doesn't support --bytes + tmpfile=3D$(mktemp) + head --bytes=3D"$bytes" "$in" > "$tmpfile" + mv "$tmpfile" "$in" + head --bytes=3D"$bytes" "$out" > "$tmpfile" + mv "$tmpfile" "$out" + tmpfile=3D"" fi - cmp -l "$in" "$out" ${bytes} | while read -r i a b; do + cmp -l "$in" "$out" | while read -r i a b; do local sum=3D$((0${a} + 0${b})) if [ $check_invert -eq 0 ] || [ $sum -ne $((0xff)) ]; then echo "[ FAIL ] $what does not match (in, out):" --=20 2.39.2 From nobody Sun May 12 20:26:43 2024 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1DF12F41 for ; Wed, 12 Apr 2023 09:20:38 +0000 (UTC) Received: by mail-wr1-f49.google.com with SMTP id w24so571391wra.10 for ; Wed, 12 Apr 2023 02:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1681291236; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=57LCbEmSbEn3cmFK86PSZdg+TXjeEyLRMiwDBLi06xo=; b=QGs6Io4J+yipd9ZxoSzJwCu/YcWcrSWv8Soa1jWSR7G+jFOylp4Tjlv2H8Wrye3ZMA 1bFMwbhH5jWxYAHkO8Q6i3xBq9u5Azl9nQkbRTrk//dlOMcrM9pXxBML4CrDN0LKmrg2 JAQ36RokbzeJvxml6rLOPQF+8/yp+tbNPAWjLZXxQHfD7Cox4MUvWJdxarmn/Y5S/An+ 0bM8Lh0umozPo9tANmTdFApY/xc44HhhY/Jdea4OvAL36xBj43lUhgbvJWlG/SRDD8VV hnF4LwWL7WqBUMrVdhcMFDNHISdY6UM9iS11i/HDK6ENCaohpIM4Pv+y/WvIMk+eDSil O0nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681291236; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=57LCbEmSbEn3cmFK86PSZdg+TXjeEyLRMiwDBLi06xo=; b=vdU6xZuuQ5VWHv7OsabG+eofqiGgchHWXzq3NVE0X7etsJaW+XdQe6Ot7vcUiuhdjF tBHuksLR1hIVfR8/H7Q9wJczrASTTrD8mhNGkumqcMzNpzfc2RtP1Y3D3CsOmwnO3p9D GjgFR1yHLgimnpXfaaNwsBVDXQqtYxrNQ4+v/Yce/yZ8AsPSfh+9E7Z4ZWZtNeJhF38q JS18yLWoae1FXJH6jh04/R2G9J/jwdzOVmy7gjIx3Vky5yWR3TNagQJUH3OiLqQ/ixKm c/MdW1HvmJ7h0DY/kmUX0ZdKa7GPT70RrZwHU8jd8F8D/xqJ3jEKb3Le1xFsnw4IUL1t dbeg== X-Gm-Message-State: AAQBX9da0Qg0ciyrh+bC0YpORDNy6rY5iZ4iYeqEpK19oBZrmYoz2bZr Y3l7+NM3x4yxRc54SECLpqM6p4dN+WrCpfAy3MXIzw== X-Google-Smtp-Source: AKy350aXXEQZb/r650js9bhWbfD4vJ1WTqEZzjO60BmLa0hMz8Acj89X5HklBBVVp+BCBeHAH767DA== X-Received: by 2002:a5d:4581:0:b0:2ef:aeb7:5add with SMTP id p1-20020a5d4581000000b002efaeb75addmr10704271wrq.68.1681291236645; Wed, 12 Apr 2023 02:20:36 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id k1-20020adfe3c1000000b002f01e181c4asm8981069wrm.5.2023.04.12.02.20.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 02:20:36 -0700 (PDT) From: Matthieu Baerts Date: Wed, 12 Apr 2023 11:20:13 +0200 Subject: [PATCH mptcp-net v3 2/2] selftests: mptcp: join: fix ShellCheck warnings Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230404-mptcp-selftests-join-busybox-shellcheck-v3-2-eab5dd7bc996@tessares.net> References: <20230404-mptcp-selftests-join-busybox-shellcheck-v3-0-eab5dd7bc996@tessares.net> In-Reply-To: <20230404-mptcp-selftests-join-busybox-shellcheck-v3-0-eab5dd7bc996@tessares.net> To: mptcp@lists.linux.dev Cc: Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2487; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=ojtyXhuz6XXZ1uUuC7M9Zik0E19LX3n2dRoDaBQWh/0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkNnfiNiYwoOFFzpfGwAGYIwep82qOtyvZq5043 AOLgumL9QOJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZDZ34gAKCRD2t4JPQmmg c7jsEADHW4PqLmJUcfZNzBlhi2KX9DBDna65cRk4TobEZTlrnsqDpgAux+wn73tQP+9zpcnkyzG fv3hkQs6fvNSgClEaYqAuviZQEypmScFaVMR9cVTrLjjJYdXvXBq+Jx6dTqTzifKQfMgf+EyL8o oQsMCkHzMQ5zRhvL4TawpZ1RO+/gRgMvkRa09xkLbNnaKM8jHC2vb1xXOdsdFxolZCG/MXVI+UX CfFDm6Bj5hHM/4+ixY31tl3g8kcGZ8aVIaW4bPcuLYonBt/qGzq6ghnM/H0LoOD3I7kojEPwerw Pva3uIhPXTf3AZqa3deqLdW4DoA9x+8P/w+bgRTpPIH58VR+16n9idHuuP1SQLltH6x7lsN9z84 6cUf6OkQgQ9IXZ93+Dwxu24ULqriNlk5FaBoHaOCc9xtfAneIt/sQGj+cxnDTpjs6GuZlNAtv/y 0yPZkfUBz+FYDs3bVzSXtpYpXm3z3fkFV6IDuhfPJ5wXC89oJR2H0bb+DITv9vBdW6V6qAzZEHa t93OBA9IcGajCNIrUDL1Xdnxbro9xsWcOQHkiQdjr8NWad2j7/bM4woeLdB5Zw/gU+HGkECCG4W HmsHHjzGpl7iyEfpn3MHuKacfKeYNP7tDoyJUkUZiZO5QeW8nfYlEUjNSW1Csnri2U6qjmL49k0 ixha9cRoDdlYoEg== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Most of the code had an issue according to ShellCheck. That's mainly due to the fact it incorrectly believes most of the code was unreachable because it's invoked by variable name, see how the "tests" array is used. Once SC2317 has been ignored, three small warnings were still visible: - SC2155: Declare and assign separately to avoid masking return values. - SC2046: Quote this to prevent word splitting: can be ignored because "ip netns pids" can display more than one pid. - SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined. This probably didn't fix any actual issues but it might help spotting new interesting warnings reported by ShellCheck as just before, ShellCheck was reporting issues for most lines making it a bit useless. Signed-off-by: Matthieu Baerts --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 555781826289..4f3fe45f8f71 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -6,6 +6,10 @@ # address all other issues detected by shellcheck. #shellcheck disable=3DSC2086 =20 +# ShellCheck incorrectly believes that most of the code here is unreachable +# because it's invoked by variable name, see how the "tests" array is used +#shellcheck disable=3DSC2317 + ret=3D0 sin=3D"" sinfail=3D"" @@ -373,8 +377,9 @@ check_transfer() =20 local line if [ -n "$bytes" ]; then + local out_size # when truncating we must check the size explicitly - local out_size=3D$(wc -c $out | awk '{print $1}') + out_size=3D$(wc -c $out | awk '{print $1}') if [ $out_size -ne $bytes ]; then echo "[ FAIL ] $what output file has wrong size ($out_size, $bytes)" fail_test @@ -509,6 +514,7 @@ kill_events_pids() =20 kill_tests_wait() { + #shellcheck disable=3DSC2046 kill -SIGUSR1 $(ip netns pids $ns2) $(ip netns pids $ns1) wait } @@ -1712,7 +1718,7 @@ chk_subflow_nr() =20 cnt1=3D$(ss -N $ns1 -tOni | grep -c token) cnt2=3D$(ss -N $ns2 -tOni | grep -c token) - if [ "$cnt1" !=3D "$subflow_nr" -o "$cnt2" !=3D "$subflow_nr" ]; then + if [ "$cnt1" !=3D "$subflow_nr" ] || [ "$cnt2" !=3D "$subflow_nr" ]; then echo "[fail] got $cnt1:$cnt2 subflows expected $subflow_nr" fail_test dump_stats=3D1 --=20 2.39.2