Skip to content

Commit

Permalink
selftests: mptcp: join: avoid using 'cmp --bytes'
Browse files Browse the repository at this point in the history
commit d328fe8 upstream.

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. 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: 6bf4102 ("selftests: mptcp: update and extend fastclose test-cases")
Cc: stable@vger.kernel.org
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>
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
matttbe authored and gregkh committed Jun 9, 2023
1 parent fbb6db5 commit 84683a2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tools/testing/selftests/net/mptcp/mptcp_join.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sout=""
cin=""
cinfail=""
cinsent=""
tmpfile=""
cout=""
capout=""
ns1=""
Expand Down Expand Up @@ -168,6 +169,7 @@ cleanup()
{
rm -f "$cin" "$cout" "$sinfail"
rm -f "$sin" "$sout" "$cinsent" "$cinfail"
rm -f "$tmpfile"
cleanup_partial
}

Expand Down Expand Up @@ -362,9 +364,16 @@ check_transfer()
fail_test
return 1
fi
bytes="--bytes=${bytes}"

# note: BusyBox's "cmp" command doesn't support --bytes
tmpfile=$(mktemp)
head --bytes="$bytes" "$in" > "$tmpfile"
mv "$tmpfile" "$in"
head --bytes="$bytes" "$out" > "$tmpfile"
mv "$tmpfile" "$out"
tmpfile=""
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=$((0${a} + 0${b}))
if [ $check_invert -eq 0 ] || [ $sum -ne $((0xff)) ]; then
echo "[ FAIL ] $what does not match (in, out):"
Expand Down

0 comments on commit 84683a2

Please sign in to comment.