Skip to content

Commit

Permalink
selftests: mptcp: use KSFT_SKIP/KSFT_PASS/KSFT_FAIL
Browse files Browse the repository at this point in the history
This patch uses the public var KSFT_SKIP in mptcp_lib.sh instead of
ksft_skip, and drop 'ksft_skip=4' in mptcp_join.sh.

Use KSFT_PASS and KSFT_FAIL macros instead of 0 and 1 after 'exit '
and 'ret=' in all scripts:

        exit 0 -> exit ${KSFT_PASS}
        exit 1 -> exit ${KSFT_FAIL}
         ret=0 ->  ret=${KSFT_PASS}
         ret=1 ->  ret=${KSFT_FAIL}

Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang authored and intel-lab-lkp committed Mar 7, 2024
1 parent d0d64e8 commit 5ab0741
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 28 deletions.
18 changes: 9 additions & 9 deletions tools/testing/selftests/net/mptcp/mptcp_connect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ while getopts "$optstring" option;do
case "$option" in
"h")
usage $0
exit 0
exit ${KSFT_PASS}
;;
"d")
if [ $OPTARG -ge 0 ];then
tc_delay="$OPTARG"
else
echo "-d requires numeric argument, got \"$OPTARG\"" 1>&2
exit 1
exit ${KSFT_FAIL}
fi
;;
"e")
Expand All @@ -96,15 +96,15 @@ while getopts "$optstring" option;do
sndbuf="$OPTARG"
else
echo "-S requires numeric argument, got \"$OPTARG\"" 1>&2
exit 1
exit ${KSFT_FAIL}
fi
;;
"R")
if [ $OPTARG -ge 0 ];then
rcvbuf="$OPTARG"
else
echo "-R requires numeric argument, got \"$OPTARG\"" 1>&2
exit 1
exit ${KSFT_FAIL}
fi
;;
"m")
Expand All @@ -121,7 +121,7 @@ while getopts "$optstring" option;do
;;
"?")
usage $0
exit 1
exit ${KSFT_FAIL}
;;
esac
done
Expand Down Expand Up @@ -263,7 +263,7 @@ check_mptcp_disabled()
if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ print $3 }')" -ne 1 ]; then
mptcp_lib_pr_fail "net.mptcp.enabled sysctl is not 1 by default"
mptcp_lib_result_fail "net.mptcp.enabled sysctl is not 1 by default"
ret=1
ret=${KSFT_FAIL}
return 1
fi
ip netns exec ${disabled_ns} sysctl -q net.mptcp.enabled=0
Expand All @@ -276,7 +276,7 @@ check_mptcp_disabled()
if [ ${err} -eq 0 ]; then
mptcp_lib_pr_fail "New MPTCP socket cannot be blocked via sysctl"
mptcp_lib_result_fail "New MPTCP socket cannot be blocked via sysctl"
ret=1
ret=${KSFT_FAIL}
return 1
fi

Expand All @@ -302,7 +302,7 @@ do_ping()

if [ $rc -ne 0 ] ; then
mptcp_lib_pr_fail "$listener_ns -> $connect_addr connectivity"
ret=1
ret=${KSFT_FAIL}

return 1
fi
Expand Down Expand Up @@ -821,7 +821,7 @@ log_if_error()
mptcp_lib_pr_fail "${msg}"

final_ret=${ret}
ret=0
ret=${KSFT_PASS}

return ${final_ret}
fi
Expand Down
13 changes: 6 additions & 7 deletions tools/testing/selftests/net/mptcp/mptcp_join.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ err=""
capout=""
ns1=""
ns2=""
ksft_skip=4
iptables="iptables"
ip6tables="ip6tables"
timeout_poll=30
Expand Down Expand Up @@ -392,15 +391,15 @@ setup_fail_rules()
-p tcp \
-m length --length 150:9999 \
-m statistic --mode nth --packet 1 --every 99999 \
-j MARK --set-mark 42 || return ${ksft_skip}
-j MARK --set-mark 42 || return ${KSFT_SKIP}

tc -n $ns2 qdisc add dev ns2eth$i clsact || return ${ksft_skip}
tc -n $ns2 qdisc add dev ns2eth$i clsact || return ${KSFT_SKIP}
tc -n $ns2 filter add dev ns2eth$i egress \
protocol ip prio 1000 \
handle 42 fw \
action pedit munge offset 148 u8 invert \
pipe csum tcp \
index 100 || return ${ksft_skip}
index 100 || return ${KSFT_SKIP}
}

reset_with_fail()
Expand All @@ -414,7 +413,7 @@ reset_with_fail()
local rc=0
setup_fail_rules "${@}" || rc=$?

if [ ${rc} -eq ${ksft_skip} ]; then
if [ ${rc} -eq ${KSFT_SKIP} ]; then
mark_as_skipped "unable to set the 'fail' rules"
return 1
fi
Expand Down Expand Up @@ -450,7 +449,7 @@ reset_with_tcp_filter()
# $1: err msg
fail_test()
{
ret=1
ret=${KSFT_FAIL}

print_fail "${@}"

Expand Down Expand Up @@ -3633,7 +3632,7 @@ usage()
{
if [ -n "${1}" ]; then
echo "${1}"
ret=1
ret=${KSFT_FAIL}
fi

echo "mptcp_join usage:"
Expand Down
4 changes: 2 additions & 2 deletions tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ check_mark()
if [ $v -ne 0 ]; then
mptcp_lib_pr_fail "got $tables $values in ns $ns," \
"not 0 - not all expected packets marked"
ret=1
ret=${KSFT_FAIL}
return 1
fi
done
Expand Down Expand Up @@ -178,7 +178,7 @@ do_transfer()

mptcp_lib_result_fail "transfer ${ip}"

ret=1
ret=${KSFT_FAIL}
return 1
fi
if ! mptcp_lib_check_transfer $cin $sout "file received by server"; then
Expand Down
8 changes: 4 additions & 4 deletions tools/testing/selftests/net/mptcp/pm_netlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ while getopts "$optstring" option;do
case "$option" in
"h")
usage $0
exit 0
exit ${KSFT_PASS}
;;
"?")
usage $0
exit 1
exit ${KSFT_FAIL}
;;
esac
done
Expand Down Expand Up @@ -57,13 +57,13 @@ check()
mptcp_lib_check_output "${err}" "${cmd}" "${expected}" || rc=${?}
if [ ${rc} -eq 2 ]; then
mptcp_lib_result_fail "${msg} # error ${rc}"
ret=1
ret=${KSFT_FAIL}
elif [ ${rc} -eq 0 ]; then
mptcp_lib_print_ok "[ OK ]"
mptcp_lib_result_pass "${msg}"
elif [ ${rc} -eq 1 ]; then
mptcp_lib_result_fail "${msg} # different output"
ret=1
ret=${KSFT_FAIL}
fi
}

Expand Down
4 changes: 2 additions & 2 deletions tools/testing/selftests/net/mptcp/simult_flows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ while getopts "bcdh" option;do
case "$option" in
"h")
usage $0
exit 0
exit ${KSFT_PASS}
;;
"b")
bail=1
Expand All @@ -276,7 +276,7 @@ while getopts "bcdh" option;do
;;
"?")
usage $0
exit 1
exit ${KSFT_FAIL}
;;
esac
done
Expand Down
8 changes: 4 additions & 4 deletions tools/testing/selftests/net/mptcp/userspace_pm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ test_skip()
test_fail()
{
mptcp_lib_pr_fail "${@}"
ret=1
ret=${KSFT_FAIL}
mptcp_lib_result_fail "${test_name}"
}

Expand Down Expand Up @@ -206,7 +206,7 @@ make_connection()
else
test_fail "Expected tokens (c:${client_token} - s:${server_token}) and server (c:${client_serverside} - s:${server_serverside})"
mptcp_lib_result_print_all_tap
exit 1
exit ${KSFT_FAIL}
fi

if [ "$is_v6" = "v6" ]
Expand Down Expand Up @@ -237,7 +237,7 @@ check_expected()
return 0
fi

ret=1
ret=${KSFT_FAIL}
mptcp_lib_result_fail "${test_name}"
return 1
}
Expand Down Expand Up @@ -842,7 +842,7 @@ verify_listener_events()
if [ "${rc}" -eq 0 ]; then
test_pass
else
ret=1
ret=${KSFT_FAIL}
mptcp_lib_result_fail "${test_name}"
fi
}
Expand Down

0 comments on commit 5ab0741

Please sign in to comment.