selftests: mptcp: add invert check in check_transfer

This patch added the invert bytes check for the output data in
check_transfer().

Instead of the file mismatch error:

  [ FAIL ] file received by server does not match (in, out):
  -rw------- 1 root root 45643832 Jan 16 15:04 /tmp/tmp.9xpM6Paivv
  Trailing bytes are:
  MPTCP_TEST_FILE_END_MARKER
  -rw------- 1 root root 45643832 Jan 16 15:04 /tmp/tmp.wnz1Yp4u7Z
  Trailing bytes are:
  MPTCP_TEST_FILE_END_MARKER

Print out the inverted bytes like this:

  file received by server has inverted byte at 7454789
  file received by server has inverted byte at 7454790
  file received by server has inverted byte at 7454791
  file received by server has inverted byte at 7454792

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Geliang Tang 2022-03-04 11:36:34 -08:00 committed by Jakub Kicinski
parent 01542c9bf9
commit 8117dac3e7

View file

@ -15,6 +15,7 @@ timeout_test=$((timeout_poll * 2 + 1))
capture=0 capture=0
checksum=0 checksum=0
ip_mptcp=0 ip_mptcp=0
check_invert=0
do_all_tests=1 do_all_tests=1
init=0 init=0
@ -59,6 +60,8 @@ init_partial()
fi fi
done done
check_invert=0
# ns1 ns2 # ns1 ns2
# ns1eth1 ns2eth1 # ns1eth1 ns2eth1
# ns1eth2 ns2eth2 # ns1eth2 ns2eth2
@ -216,15 +219,21 @@ check_transfer()
out=$2 out=$2
what=$3 what=$3
cmp "$in" "$out" > /dev/null 2>&1 cmp -l "$in" "$out" | while read line; do
if [ $? -ne 0 ] ;then local arr=($line)
echo "[ FAIL ] $what does not match (in, out):"
print_file_err "$in"
print_file_err "$out"
ret=1
return 1 let sum=0${arr[1]}+0${arr[2]}
fi if [ $check_invert -eq 0 ] || [ $sum -ne $((0xff)) ]; then
echo "[ FAIL ] $what does not match (in, out):"
print_file_err "$in"
print_file_err "$out"
ret=1
return 1
else
echo "$what has inverted byte at ${arr[0]}"
fi
done
return 0 return 0
} }