From: Geliang Tang <tanggeliang@kylinos.cn>
Similar to check() in pm_netlink.sh, add a new helper check_output()
in mptcp_join.sh to check the output of the given commands.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
.../testing/selftests/net/mptcp/mptcp_join.sh | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 915ec79f5030..f4043baa59c6 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -21,6 +21,7 @@ cinfail=""
cinsent=""
tmpfile=""
cout=""
+check_output_err=""
capout=""
ns1=""
ns2=""
@@ -186,6 +187,7 @@ init() {
cout=$(mktemp)
evts_ns1=$(mktemp)
evts_ns2=$(mktemp)
+ check_output_err=$(mktemp)
trap cleanup EXIT
@@ -199,6 +201,7 @@ cleanup()
rm -f "$sin" "$sout" "$cinsent" "$cinfail"
rm -f "$tmpfile"
rm -rf $evts_ns1 $evts_ns2
+ rm -f $check_output_err
cleanup_partial
}
@@ -3358,6 +3361,30 @@ userspace_pm_rm_sf()
wait_rm_sf $1 "${cnt}"
}
+check_output()
+{
+ local cmd="$1"
+ local expected="$2"
+ local msg="$3"
+ local out=`$cmd 2>$check_output_err`
+ local cmd_ret=$?
+
+ printf "%-42s" "$msg"
+ if [ $cmd_ret -ne 0 ]; then
+ mptcp_lib_print_err "[ FAIL ] command execution '$cmd' stderr "
+ cat $check_output_err
+ ret=${KSFT_FAIL}
+ return $cmd_ret
+ elif [ "$out" = "$expected" ]; then
+ mptcp_lib_print_ok "[ OK ]"
+ return 0
+ else
+ mptcp_lib_print_err "[ FAIL ] expected '$expected' got '$out'"
+ ret=${KSFT_FAIL}
+ return 1
+ fi
+}
+
userspace_tests()
{
# userspace pm type prevents add_addr
--
2.40.1