On Sun, 16 Jan 2022, Geliang Tang wrote:
> 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 bytes at 7454789 (in, out)
> file received by server has inverted bytes at 7454790 (in, out)
> file received by server has inverted bytes at 7454791 (in, out)
> file received by server has inverted bytes at 7454792 (in, out)
>
Thanks Geliang! This is really close to what I was looking for. Can you
also make sure the bit flips are only allowed in the few tests where they
are expected?
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
> v2:
> - instead of adding a new function is_invert, add the invert bytes
> check in check_transfer().
> ---
> .../testing/selftests/net/mptcp/mptcp_join.sh | 23 ++++++++++++-------
> 1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index 2be3cad4b52b..de6589d1c541 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -193,15 +193,22 @@ check_transfer()
> out=$2
> what=$3
>
> - cmp "$in" "$out" > /dev/null 2>&1
> - if [ $? -ne 0 ] ;then
> - echo "[ FAIL ] $what does not match (in, out):"
> - print_file_err "$in"
> - print_file_err "$out"
> - ret=1
> + cmp -l "$in" "$out" | while read line; do
> + local arr=($line)
> +
> + let sum=${arr[1]}+${arr[2]}
bash is interpreting the values as decimal here, would be best to
interpret them as octal by adding a leading '0' to each value:
let sum=0${arr[1]}+0${arr[2]}
> + # Octal 377 is 0xFF
> + if [ $sum -ne 377 ]; then
Can also change this to use hexadecimal directly:
if [ $sum -ne $((0xff)) ]; then
> + echo "[ FAIL ] $what does not match (in, out):"
> + print_file_err "$in"
> + print_file_err "$out"
> + ret=1
>
> - return 1
> - fi
> + return 1
> + else
> + echo "$what has inverted bytes at ${arr[0]} (in, out)"
What's the meaning of "(in, out)" here?
-Mat
> + fi
> + done
>
> return 0
> }
> --
> 2.31.1
>
>
>
--
Mat Martineau
Intel