Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: mptcp: join: avoid using 'cmp --bytes'

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: 6bf41020b72b ("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>

authored by

Matthieu Baerts and committed by
Paolo Abeni
d328fe87 1919b39f

+11 -2
+11 -2
tools/testing/selftests/net/mptcp/mptcp_join.sh
··· 17 17 cin="" 18 18 cinfail="" 19 19 cinsent="" 20 + tmpfile="" 20 21 cout="" 21 22 capout="" 22 23 ns1="" ··· 176 175 { 177 176 rm -f "$cin" "$cout" "$sinfail" 178 177 rm -f "$sin" "$sout" "$cinsent" "$cinfail" 178 + rm -f "$tmpfile" 179 179 rm -rf $evts_ns1 $evts_ns2 180 180 cleanup_partial 181 181 } ··· 385 383 fail_test 386 384 return 1 387 385 fi 388 - bytes="--bytes=${bytes}" 386 + 387 + # note: BusyBox's "cmp" command doesn't support --bytes 388 + tmpfile=$(mktemp) 389 + head --bytes="$bytes" "$in" > "$tmpfile" 390 + mv "$tmpfile" "$in" 391 + head --bytes="$bytes" "$out" > "$tmpfile" 392 + mv "$tmpfile" "$out" 393 + tmpfile="" 389 394 fi 390 - cmp -l "$in" "$out" ${bytes} | while read -r i a b; do 395 + cmp -l "$in" "$out" | while read -r i a b; do 391 396 local sum=$((0${a} + 0${b})) 392 397 if [ $check_invert -eq 0 ] || [ $sum -ne $((0xff)) ]; then 393 398 echo "[ FAIL ] $what does not match (in, out):"