All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mptcp-next 0/2] mptcp: selftests: join: support BusyBox and ShellCheck
@ 2023-04-04 14:55 Matthieu Baerts
  2023-04-04 14:55 ` [PATCH mptcp-next 1/2] selftests: mptcp: join: avoid using 'cmp --bytes' Matthieu Baerts
  2023-04-04 14:56 ` [PATCH mptcp-next 2/2] selftests: mptcp: join: fix ShellCheck warnings Matthieu Baerts
  0 siblings, 2 replies; 4+ messages in thread
From: Matthieu Baerts @ 2023-04-04 14:55 UTC (permalink / raw)
  To: mptcp; +Cc: Matthieu Baerts, Paolo Abeni

Here are two simple modifications, not really fixing anything for us but
fixing issues for those using BusyBox like LKFT.

At least the first patch fixes a bug they have. They might switch to a
different version of cmp at some points but it doesn't seem easy. So
probably best to have this patch flagged as a fix to have it backported
in order to detect when other mptcp_join.sh subtests are failing.

The second patch fixes ShellCheck warnings: it was reporting issues for
most lines of the script. Best to fix these warnings to easily spot new
warnings that could be linked to real issues. But no need to backport
this one I suppose.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
Matthieu Baerts (2):
      selftests: mptcp: join: avoid using 'cmp --bytes'
      selftests: mptcp: join: fix ShellCheck warnings

 tools/testing/selftests/net/mptcp/mptcp_join.sh | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
---
base-commit: 73fd52db48d9eff550fef735066f742acc2bf0e6
change-id: 20230404-mptcp-selftests-join-busybox-shellcheck-ec239f8d4e8f

Best regards,
-- 
Matthieu Baerts <matthieu.baerts@tessares.net>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH mptcp-next 1/2] selftests: mptcp: join: avoid using 'cmp --bytes'
  2023-04-04 14:55 [PATCH mptcp-next 0/2] mptcp: selftests: join: support BusyBox and ShellCheck Matthieu Baerts
@ 2023-04-04 14:55 ` Matthieu Baerts
  2023-04-04 14:56 ` [PATCH mptcp-next 2/2] selftests: mptcp: join: fix ShellCheck warnings Matthieu Baerts
  1 sibling, 0 replies; 4+ messages in thread
From: Matthieu Baerts @ 2023-04-04 14:55 UTC (permalink / raw)
  To: mptcp; +Cc: Matthieu Baerts, Paolo Abeni

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=1024'
    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.

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-cases")
Link: https://qa-reports.linaro.org/lkft/linux-mainline-master/build/v6.3-rc5-5-g148341f0a2f5/testrun/16088933/suite/kselftest-net-mptcp/test/net_mptcp_userspace_pm_sh/log [1]
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index fafd19ec7e1f..b0b0931379b3 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -378,9 +378,12 @@ check_transfer()
 			fail_test
 			return 1
 		fi
-		bytes="--bytes=${bytes}"
+		# note: BusyBox's "cmp" command doesn't support --bytes
+		bytes=(head --bytes="${bytes}")
+	else
+		bytes=(cat)
 	fi
-	cmp -l "$in" "$out" ${bytes} | while read -r i a b; do
+	cmp -l "$in" "$out" 2>/dev/null | "${bytes[@]}" | while read -r i a b; do
 		local sum=$((0${a} + 0${b}))
 		if [ $check_invert -eq 0 ] || [ $sum -ne $((0xff)) ]; then
 			echo "[ FAIL ] $what does not match (in, out):"

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH mptcp-next 2/2] selftests: mptcp: join: fix ShellCheck warnings
  2023-04-04 14:55 [PATCH mptcp-next 0/2] mptcp: selftests: join: support BusyBox and ShellCheck Matthieu Baerts
  2023-04-04 14:55 ` [PATCH mptcp-next 1/2] selftests: mptcp: join: avoid using 'cmp --bytes' Matthieu Baerts
@ 2023-04-04 14:56 ` Matthieu Baerts
  2023-04-04 15:47   ` selftests: mptcp: join: fix ShellCheck warnings: Tests Results MPTCP CI
  1 sibling, 1 reply; 4+ messages in thread
From: Matthieu Baerts @ 2023-04-04 14:56 UTC (permalink / raw)
  To: mptcp; +Cc: Matthieu Baerts

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 <matthieu.baerts@tessares.net>
---
 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/testing/selftests/net/mptcp/mptcp_join.sh
index b0b0931379b3..c18981c8f172 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=SC2086
 
+# 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=SC2317
+
 ret=0
 sin=""
 sinfail=""
@@ -371,8 +375,9 @@ check_transfer()
 
 	local line
 	if [ -n "$bytes" ]; then
+		local out_size
 		# when truncating we must check the size explicitly
-		local out_size=$(wc -c $out | awk '{print $1}')
+		out_size=$(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
@@ -503,6 +508,7 @@ kill_events_pids()
 
 kill_tests_wait()
 {
+	#shellcheck disable=SC2046
 	kill -SIGUSR1 $(ip netns pids $ns2) $(ip netns pids $ns1)
 	wait
 }
@@ -1706,7 +1712,7 @@ chk_subflow_nr()
 
 	cnt1=$(ss -N $ns1 -tOni | grep -c token)
 	cnt2=$(ss -N $ns2 -tOni | grep -c token)
-	if [ "$cnt1" != "$subflow_nr" -o "$cnt2" != "$subflow_nr" ]; then
+	if [ "$cnt1" != "$subflow_nr" ] || [ "$cnt2" != "$subflow_nr" ]; then
 		echo "[fail] got $cnt1:$cnt2 subflows expected $subflow_nr"
 		fail_test
 		dump_stats=1

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: selftests: mptcp: join: fix ShellCheck warnings: Tests Results
  2023-04-04 14:56 ` [PATCH mptcp-next 2/2] selftests: mptcp: join: fix ShellCheck warnings Matthieu Baerts
@ 2023-04-04 15:47   ` MPTCP CI
  0 siblings, 0 replies; 4+ messages in thread
From: MPTCP CI @ 2023-04-04 15:47 UTC (permalink / raw)
  To: Matthieu Baerts; +Cc: mptcp

Hi Matthieu,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join):
  - Success! ✅:
  - Task: https://cirrus-ci.com/task/6207163090075648
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/6207163090075648/summary/summary.txt

- KVM Validation: normal (only selftest_mptcp_join):
  - Unstable: 1 failed test(s): selftest_mptcp_join 🔴:
  - Task: https://cirrus-ci.com/task/4799788206522368
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/4799788206522368/summary/summary.txt

- KVM Validation: debug (only selftest_mptcp_join):
  - Success! ✅:
  - Task: https://cirrus-ci.com/task/5362738159943680
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/5362738159943680/summary/summary.txt

- KVM Validation: debug (except selftest_mptcp_join):
  - Success! ✅:
  - Task: https://cirrus-ci.com/task/5925688113364992
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/5925688113364992/summary/summary.txt

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/a9e891b9e4a3


If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-debug

For more details:

    https://github.com/multipath-tcp/mptcp-upstream-virtme-docker


Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-04 15:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-04 14:55 [PATCH mptcp-next 0/2] mptcp: selftests: join: support BusyBox and ShellCheck Matthieu Baerts
2023-04-04 14:55 ` [PATCH mptcp-next 1/2] selftests: mptcp: join: avoid using 'cmp --bytes' Matthieu Baerts
2023-04-04 14:56 ` [PATCH mptcp-next 2/2] selftests: mptcp: join: fix ShellCheck warnings Matthieu Baerts
2023-04-04 15:47   ` selftests: mptcp: join: fix ShellCheck warnings: Tests Results MPTCP CI

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.