* [PATCH mptcp-next] selftests: mptcp: implement is_invert
@ 2022-01-15 15:47 Geliang Tang
0 siblings, 0 replies; only message in thread
From: Geliang Tang @ 2022-01-15 15:47 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-15 15:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-15 15:47 [PATCH mptcp-next] selftests: mptcp: implement is_invert Geliang Tang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.