Skip to content

Commit 8f7a69a

Browse files
Geliang Tangkuba-moo
authored andcommitted
selftests: mptcp: use KSFT_SKIP/KSFT_PASS/KSFT_FAIL
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]> Reviewed-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Link: https://lore.kernel.org/r/20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-15-4f42c347b653@kernel.org Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 23a0485 commit 8f7a69a

File tree

6 files changed

+25
-26
lines changed

6 files changed

+25
-26
lines changed

tools/testing/selftests/net/mptcp/mptcp_connect.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ while getopts "$optstring" option;do
6565
case "$option" in
6666
"h")
6767
usage $0
68-
exit 0
68+
exit ${KSFT_PASS}
6969
;;
7070
"d")
7171
if [ $OPTARG -ge 0 ];then
7272
tc_delay="$OPTARG"
7373
else
7474
echo "-d requires numeric argument, got \"$OPTARG\"" 1>&2
75-
exit 1
75+
exit ${KSFT_FAIL}
7676
fi
7777
;;
7878
"e")
@@ -96,15 +96,15 @@ while getopts "$optstring" option;do
9696
sndbuf="$OPTARG"
9797
else
9898
echo "-S requires numeric argument, got \"$OPTARG\"" 1>&2
99-
exit 1
99+
exit ${KSFT_FAIL}
100100
fi
101101
;;
102102
"R")
103103
if [ $OPTARG -ge 0 ];then
104104
rcvbuf="$OPTARG"
105105
else
106106
echo "-R requires numeric argument, got \"$OPTARG\"" 1>&2
107-
exit 1
107+
exit ${KSFT_FAIL}
108108
fi
109109
;;
110110
"m")
@@ -121,7 +121,7 @@ while getopts "$optstring" option;do
121121
;;
122122
"?")
123123
usage $0
124-
exit 1
124+
exit ${KSFT_FAIL}
125125
;;
126126
esac
127127
done
@@ -263,7 +263,7 @@ check_mptcp_disabled()
263263
if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ print $3 }')" -ne 1 ]; then
264264
mptcp_lib_pr_fail "net.mptcp.enabled sysctl is not 1 by default"
265265
mptcp_lib_result_fail "net.mptcp.enabled sysctl is not 1 by default"
266-
ret=1
266+
ret=${KSFT_FAIL}
267267
return 1
268268
fi
269269
ip netns exec ${disabled_ns} sysctl -q net.mptcp.enabled=0
@@ -276,7 +276,7 @@ check_mptcp_disabled()
276276
if [ ${err} -eq 0 ]; then
277277
mptcp_lib_pr_fail "New MPTCP socket cannot be blocked via sysctl"
278278
mptcp_lib_result_fail "New MPTCP socket cannot be blocked via sysctl"
279-
ret=1
279+
ret=${KSFT_FAIL}
280280
return 1
281281
fi
282282

@@ -302,7 +302,7 @@ do_ping()
302302

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

307307
return 1
308308
fi
@@ -821,7 +821,7 @@ log_if_error()
821821
mptcp_lib_pr_fail "${msg}"
822822

823823
final_ret=${ret}
824-
ret=0
824+
ret=${KSFT_PASS}
825825

826826
return ${final_ret}
827827
fi

tools/testing/selftests/net/mptcp/mptcp_join.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ err=""
2525
capout=""
2626
ns1=""
2727
ns2=""
28-
ksft_skip=4
2928
iptables="iptables"
3029
ip6tables="ip6tables"
3130
timeout_poll=30
@@ -392,15 +391,15 @@ setup_fail_rules()
392391
-p tcp \
393392
-m length --length 150:9999 \
394393
-m statistic --mode nth --packet 1 --every 99999 \
395-
-j MARK --set-mark 42 || return ${ksft_skip}
394+
-j MARK --set-mark 42 || return ${KSFT_SKIP}
396395

397-
tc -n $ns2 qdisc add dev ns2eth$i clsact || return ${ksft_skip}
396+
tc -n $ns2 qdisc add dev ns2eth$i clsact || return ${KSFT_SKIP}
398397
tc -n $ns2 filter add dev ns2eth$i egress \
399398
protocol ip prio 1000 \
400399
handle 42 fw \
401400
action pedit munge offset 148 u8 invert \
402401
pipe csum tcp \
403-
index 100 || return ${ksft_skip}
402+
index 100 || return ${KSFT_SKIP}
404403
}
405404

406405
reset_with_fail()
@@ -414,7 +413,7 @@ reset_with_fail()
414413
local rc=0
415414
setup_fail_rules "${@}" || rc=$?
416415

417-
if [ ${rc} -eq ${ksft_skip} ]; then
416+
if [ ${rc} -eq ${KSFT_SKIP} ]; then
418417
mark_as_skipped "unable to set the 'fail' rules"
419418
return 1
420419
fi
@@ -450,7 +449,7 @@ reset_with_tcp_filter()
450449
# $1: err msg
451450
fail_test()
452451
{
453-
ret=1
452+
ret=${KSFT_FAIL}
454453

455454
if [ ${#} -gt 0 ]; then
456455
print_fail "${@}"
@@ -3632,7 +3631,7 @@ usage()
36323631
{
36333632
if [ -n "${1}" ]; then
36343633
echo "${1}"
3635-
ret=1
3634+
ret=${KSFT_FAIL}
36363635
fi
36373636

36383637
echo "mptcp_join usage:"

tools/testing/selftests/net/mptcp/mptcp_sockopt.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ check_mark()
105105
if [ $v -ne 0 ]; then
106106
mptcp_lib_pr_fail "got $tables $values in ns $ns," \
107107
"not 0 - not all expected packets marked"
108-
ret=1
108+
ret=${KSFT_FAIL}
109109
return 1
110110
fi
111111
done
@@ -178,7 +178,7 @@ do_transfer()
178178

179179
mptcp_lib_result_fail "transfer ${ip}"
180180

181-
ret=1
181+
ret=${KSFT_FAIL}
182182
return 1
183183
fi
184184
if ! mptcp_lib_check_transfer $cin $sout "file received by server"; then

tools/testing/selftests/net/mptcp/pm_netlink.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ while getopts "$optstring" option;do
1919
case "$option" in
2020
"h")
2121
usage $0
22-
exit 0
22+
exit ${KSFT_PASS}
2323
;;
2424
"?")
2525
usage $0
26-
exit 1
26+
exit ${KSFT_FAIL}
2727
;;
2828
esac
2929
done
@@ -57,13 +57,13 @@ check()
5757
mptcp_lib_check_output "${err}" "${cmd}" "${expected}" || rc=${?}
5858
if [ ${rc} -eq 2 ]; then
5959
mptcp_lib_result_fail "${msg} # error ${rc}"
60-
ret=1
60+
ret=${KSFT_FAIL}
6161
elif [ ${rc} -eq 0 ]; then
6262
mptcp_lib_print_ok "[ OK ]"
6363
mptcp_lib_result_pass "${msg}"
6464
elif [ ${rc} -eq 1 ]; then
6565
mptcp_lib_result_fail "${msg} # different output"
66-
ret=1
66+
ret=${KSFT_FAIL}
6767
fi
6868
}
6969

tools/testing/selftests/net/mptcp/simult_flows.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ while getopts "bcdh" option;do
263263
case "$option" in
264264
"h")
265265
usage $0
266-
exit 0
266+
exit ${KSFT_PASS}
267267
;;
268268
"b")
269269
bail=1
@@ -276,7 +276,7 @@ while getopts "bcdh" option;do
276276
;;
277277
"?")
278278
usage $0
279-
exit 1
279+
exit ${KSFT_FAIL}
280280
;;
281281
esac
282282
done

tools/testing/selftests/net/mptcp/userspace_pm.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ test_fail()
8989
then
9090
mptcp_lib_pr_fail "${@}"
9191
fi
92-
ret=1
92+
ret=${KSFT_FAIL}
9393
mptcp_lib_result_fail "${test_name}"
9494
}
9595

@@ -209,7 +209,7 @@ make_connection()
209209
else
210210
test_fail "Expected tokens (c:${client_token} - s:${server_token}) and server (c:${client_serverside} - s:${server_serverside})"
211211
mptcp_lib_result_print_all_tap
212-
exit 1
212+
exit ${KSFT_FAIL}
213213
fi
214214

215215
if [ "$is_v6" = "v6" ]

0 commit comments

Comments
 (0)