.../testing/selftests/net/mptcp/mptcp_join.sh | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-)
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>
---
v3:
- add the check_invert flag, do the invert bytes check only when this flag
is set.
- use 0xff directly.
- update the output log.
v2:
- instead of adding a new function is_invert, add the invert bytes
check in check_transfer().
---
.../testing/selftests/net/mptcp/mptcp_join.sh | 25 +++++++++++++------
1 file changed, 17 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..4f8ee8a9a8f2 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -15,6 +15,7 @@ timeout_test=$((timeout_poll * 2 + 1))
mptcp_connect=""
capture=0
checksum=0
+check_invert=0
do_all_tests=1
TEST_COUNT=0
@@ -58,6 +59,8 @@ init()
fi
done
+ check_invert=0
+
# ns1 ns2
# ns1eth1 ns2eth1
# ns1eth2 ns2eth2
@@ -193,15 +196,21 @@ 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)
- return 1
- fi
+ let sum=0${arr[1]}+0${arr[2]}
+ 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
}
--
2.31.1
On Wed, 19 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 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> > --- > v3: > - add the check_invert flag, do the invert bytes check only when this flag > is set. > - use 0xff directly. > - update the output log. Hi Geliang - Looks good to me, thanks for the updates! Please update "selftests: mptcp: add mp_fail testcases" for the inversion check. Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.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 | 25 +++++++++++++------ > 1 file changed, 17 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..4f8ee8a9a8f2 100755 > --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh > +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh > @@ -15,6 +15,7 @@ timeout_test=$((timeout_poll * 2 + 1)) > mptcp_connect="" > capture=0 > checksum=0 > +check_invert=0 > do_all_tests=1 > > TEST_COUNT=0 > @@ -58,6 +59,8 @@ init() > fi > done > > + check_invert=0 > + > # ns1 ns2 > # ns1eth1 ns2eth1 > # ns1eth2 ns2eth2 > @@ -193,15 +196,21 @@ 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) > > - return 1 > - fi > + let sum=0${arr[1]}+0${arr[2]} > + 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 > } > -- > 2.31.1 > > > -- Mat Martineau Intel
Hi Geliang, Mat, On 20/01/2022 01:06, Mat Martineau wrote: > On Wed, 19 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 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> >> --- >> v3: >> - add the check_invert flag, do the invert bytes check only when this >> flag >> is set. >> - use 0xff directly. >> - update the output log. > > Hi Geliang - > > Looks good to me, thanks for the updates! Please update "selftests: > mptcp: add mp_fail testcases" for the inversion check. Thank you for the patch and the review! I just applied this patch at the end of the "MP_FAIL" series in our tree as it is there for the future "selftests: mptcp: add mp_fail testcases" patch I guess. - c118cb35a603: selftests: mptcp: add invert check in check_transfer - Results: e974a42412b3..750c4599c0cf Builds and tests are now in progress: https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20220120T150902 https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export Cheers, Matt -- Tessares | Belgium | Hybrid Access Solutions www.tessares.net
© 2016 - 2024 Red Hat, Inc.