This patch implemented a new function is_invert() to check whether
the output data has the inverted bytes of the input.
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
.../testing/selftests/net/mptcp/mptcp_join.sh | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 2be3cad4b52b..b0e4c5be9d38 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -180,6 +180,22 @@ if [ $? -ne 0 ];then
exit $ksft_skip
fi
+is_invert()
+{
+ in=$1
+ out=$2
+
+ cmp -l "$in" "$out" | while read line; do
+ local arr=($line)
+
+ let sum=${arr[1]}+${arr[2]}
+ # Octal 377 is 0xFF
+ if [ $sum -ne 377 ]; then
+ return 1
+ fi
+ done
+}
+
print_file_err()
{
ls -l "$1" 1>&2
@@ -195,6 +211,11 @@ check_transfer()
cmp "$in" "$out" > /dev/null 2>&1
if [ $? -ne 0 ] ;then
+ is_invert "$in" "$out"
+ if [ $? -eq 0 ]; then
+ echo "[ FAIL ] $what has inverted bytes (in, out)"
+ return 0
+ fi
echo "[ FAIL ] $what does not match (in, out):"
print_file_err "$in"
print_file_err "$out"
--
2.31.1