[PATCH mptcp-next] selftests: mptcp: implement is_invert

Geliang Tang posted 1 patch 2 years, 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/821a371e8b3abd990a426eeabe244113a88bbb14.1642261584.git.geliang.tang@suse.com
Maintainers: "David S. Miller" <davem@davemloft.net>, Mat Martineau <mathew.j.martineau@linux.intel.com>, Jakub Kicinski <kuba@kernel.org>, Shuah Khan <shuah@kernel.org>, Matthieu Baerts <matthieu.baerts@tessares.net>
.../testing/selftests/net/mptcp/mptcp_join.sh | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
[PATCH mptcp-next] selftests: mptcp: implement is_invert
Posted by Geliang Tang 2 years, 3 months ago
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