add helpers and vars in mptcp_lib.sh, part 4
Subsystems (3)
Geliang Tang
reviewercover add helpers and vars in mptcp_lib.sh, part 4
From: Geliang Tang <[email protected]>
MPTCP events related patches and two cleanups.
Geliang Tang (5):
selftests: mptcp: extract mptcp_lib_check_expected
selftests: mptcp: add mptcp_lib_verify_listener_events
selftests: mptcp: export event macros in mptcp_lib
selftests: mptcp: use KSFT_SKIP/KSFT_PASS/KSFT_FAIL
selftests: mptcp: join: use += operator to append strings
.../selftests/net/mptcp/mptcp_connect.sh | 18 ++-- .../testing/selftests/net/mptcp/mptcp_join.sh | 93 +++++++------------ .../testing/selftests/net/mptcp/mptcp_lib.sh | 74 +++++++++++++++ .../selftests/net/mptcp/mptcp_sockopt.sh | 4 +- .../testing/selftests/net/mptcp/pm_netlink.sh | 8 +- .../selftests/net/mptcp/simult_flows.sh | 4 +- .../selftests/net/mptcp/userspace_pm.sh | 85 +++++------------ 7 files changed, 150 insertions(+), 136 deletions(-)
Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH 1/5 selftests: mptcp: extract mptcp_lib_check_expected
From: Geliang Tang <[email protected]>
Extract the main part of check_expected() in userspace_pm.sh to a new function mptcp_lib_check_expected() in mptcp_lib.sh. It will be used in both mptcp_john.sh and userspace_pm.sh. check_expected_one() is moved into mptcp_lib.sh too as mptcp_lib_check_expected_one().
--- .../testing/selftests/net/mptcp/mptcp_lib.sh | 30 ++++++++++++++++ .../selftests/net/mptcp/userspace_pm.sh | 34 +++---------------- 2 files changed, 35 insertions(+), 29 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_lib.sh +30 -0
@@ -438,3 +438,33 @@ mptcp_lib_print_title() { # shellcheck disable=SC2059 # the format is in a variable printf "${MPTCP_LIB_TEST_FORMAT}" "$((++MPTCP_LIB_TEST_COUNTER))" "${*}" } + +# $1: var name ; $2: prev ret +mptcp_lib_check_expected_one() { + local var="${1}" + local exp="e_${var}" + local prev_ret="${2}" + + if [ "${!var}" = "${!exp}" ]; then + return 0 + fi + + if [ "${prev_ret}" = "0" ]; then + mptcp_lib_pr_fail + fi + + mptcp_lib_print_err "Expected value for '${var}': '${!exp}', got '${!var}'." + return 1 +} + +# $@: all var names to check +mptcp_lib_check_expected() { + local rc=0 + local var + + for var in "${@}"; do + mptcp_lib_check_expected_one "${var}" "${rc}" || rc=1 + done + + return "${rc}" +}
tools/testing/selftests/net/mptcp/userspace_pm.sh +5 -29
@@ -5,7 +5,7 @@ # code but we accept it. #shellcheck disable=SC2086 -# Some variables are used below but indirectly, see check_expected_one() +# Some variables are used below but indirectly, see verify_*_event() #shellcheck disable=SC2034 . "$(dirname "${0}")/mptcp_lib.sh"
@@ -225,44 +225,20 @@ make_connection() fi } -# $1: var name ; $2: prev ret -check_expected_one() -{ - local var="${1}" - local exp="e_${var}" - local prev_ret="${2}" - - if [ "${!var}" = "${!exp}" ] - then - return 0 - fi - - if [ "${prev_ret}" = "0" ] - then - test_fail - fi - - mptcp_lib_print_err "\tExpected value for '${var}': '${!exp}', got '${!var}'." - return 1 -} - # $@: all var names to check check_expected() { local rc=0 - local var - for var in "${@}" - do - check_expected_one "${var}" "${rc}" || rc=1 - done - - if [ ${rc} -eq 0 ] + mptcp_lib_check_expected "${@}" || rc=1 + if [ "${rc}" -eq 0 ] then test_pass return 0 fi + ret=1 + mptcp_lib_result_fail "${test_name}" return 1 }
Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH 2/5 selftests: mptcp: add mptcp_lib_verify_listener_events
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
To avoid duplicated code in different MPTCP selftests, we can add and use helpers defined in mptcp_lib.sh.
The helper verify_listener_events() is defined both in mptcp_join.sh and userspace_pm.sh, export it into mptcp_lib.sh and rename it with mptcp_lib_ prefix. Use this new helper in both scripts.
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 23 +++----------- .../testing/selftests/net/mptcp/mptcp_lib.sh | 26 ++++++++++++++++ .../selftests/net/mptcp/userspace_pm.sh | 31 +++++-------------- 3 files changed, 38 insertions(+), 42 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +4 -19
@@ -2792,16 +2792,12 @@ AF_INET6=10 verify_listener_events() { - local evt=$1 local e_type=$2 local e_family=$3 local e_saddr=$4 local e_sport=$5 - local type - local family - local saddr - local sport local name + local rc=0 if [ $e_type = $LISTENER_CREATED ]; then name="LISTENER_CREATED"
@@ -2818,23 +2814,12 @@ verify_listener_events() return fi - type=$(mptcp_lib_evts_get_info type "$evt" "$e_type") - family=$(mptcp_lib_evts_get_info family "$evt" "$e_type") - sport=$(mptcp_lib_evts_get_info sport "$evt" "$e_type") - if [ $family ] && [ $family = $AF_INET6 ]; then - saddr=$(mptcp_lib_evts_get_info saddr6 "$evt" "$e_type") - else - saddr=$(mptcp_lib_evts_get_info saddr4 "$evt" "$e_type") - fi - - if [ $type ] && [ $type = $e_type ] && - [ $family ] && [ $family = $e_family ] && - [ $saddr ] && [ $saddr = $e_saddr ] && - [ $sport ] && [ $sport = $e_sport ]; then + mptcp_lib_verify_listener_events "${@}" || rc="${?}" + if [ "${rc}" -eq 0 ]; then print_ok return 0 fi - fail_test "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$sport" + fail_test "$e_type $e_family $e_saddr $e_sport" } add_addr_ports_tests()
tools/testing/selftests/net/mptcp/mptcp_lib.sh +26 -0
@@ -468,3 +468,29 @@ mptcp_lib_check_expected() { return "${rc}" } + +# shellcheck disable=SC2034 +mptcp_lib_verify_listener_events() { + local evt=$1 + local e_type=$2 + local e_family=$3 + local e_saddr=$4 + local e_sport=$5 + local type + local family + local saddr + local sport + local rc=0 + + type=$(mptcp_lib_evts_get_info type "$evt" "$e_type") + family=$(mptcp_lib_evts_get_info family "$evt" "$e_type") + if [ "$family" ] && [ "$family" = "$AF_INET6" ]; then + saddr=$(mptcp_lib_evts_get_info saddr6 "$evt" "$e_type") + else + saddr=$(mptcp_lib_evts_get_info saddr4 "$evt" "$e_type") + fi + sport=$(mptcp_lib_evts_get_info sport "$evt" "$e_type") + + mptcp_lib_check_expected "type" "family" "saddr" "sport" || rc="${?}" + return "${rc}" +}
tools/testing/selftests/net/mptcp/userspace_pm.sh +8 -23
@@ -836,32 +836,15 @@ test_prio() verify_listener_events() { - local evt=$1 - local e_type=$2 - local e_family=$3 - local e_saddr=$4 - local e_sport=$5 - local type - local family - local saddr - local sport - - if [ $e_type = $LISTENER_CREATED ]; then - print_test "CREATE_LISTENER $e_saddr:$e_sport" - elif [ $e_type = $LISTENER_CLOSED ]; then - print_test "CLOSE_LISTENER $e_saddr:$e_sport" - fi + local rc=0 - type=$(mptcp_lib_evts_get_info type $evt $e_type) - family=$(mptcp_lib_evts_get_info family $evt $e_type) - sport=$(mptcp_lib_evts_get_info sport $evt $e_type) - if [ $family ] && [ $family = $AF_INET6 ]; then - saddr=$(mptcp_lib_evts_get_info saddr6 $evt $e_type) + mptcp_lib_verify_listener_events "${@}" || rc="${?}" + if [ "${rc}" -eq 0 ]; then + test_pass else - saddr=$(mptcp_lib_evts_get_info saddr4 $evt $e_type) + ret=1 + mptcp_lib_result_fail "${test_name}" fi - - check_expected "type" "family" "saddr" "sport" } test_listener()
@@ -877,6 +860,7 @@ test_listener() # Capture events on the network namespace running the client :>$client_evts + print_test "Listener event LISTENER_CREATED 10.0.2.2:$client4_port" # Attempt to add a listener at 10.0.2.2:<subflow-port> ip netns exec $ns2 ./pm_nl_ctl listen 10.0.2.2\ $client4_port &
@@ -895,6 +879,7 @@ test_listener() rport $client4_port token $server4_token sleep 0.5 + print_test "Listener event LISTENER_CLOSED 10.0.2.2:$client4_port" # Delete the listener from the client ns, if one was created mptcp_lib_kill_wait $listener_pid
Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH 3/5 selftests: mptcp: export event macros in mptcp_lib
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
SUB_ESTABLISHED, LISTENER_CREATED, LISTENER_CLOSED, AF_INET and AF_INET6 are defined in both mptcp_join.sh and userspace_pm.sh, export all event macros into mptcp_lib.sh. Add MPTCP_LIB_ prefix for the first three and add readonly for the last two.
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 23 ++++++++----------- .../testing/selftests/net/mptcp/mptcp_lib.sh | 18 +++++++++++++++ .../selftests/net/mptcp/userspace_pm.sh | 18 +++++++-------- 3 files changed, 36 insertions(+), 23 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +9 -14
@@ -2783,13 +2783,6 @@ backup_tests() fi } -SUB_ESTABLISHED=10 # MPTCP_EVENT_SUB_ESTABLISHED -LISTENER_CREATED=15 #MPTCP_EVENT_LISTENER_CREATED -LISTENER_CLOSED=16 #MPTCP_EVENT_LISTENER_CLOSED - -AF_INET=2 -AF_INET6=10 - verify_listener_events() { local e_type=$2
@@ -2799,9 +2792,9 @@ verify_listener_events() local name local rc=0 - if [ $e_type = $LISTENER_CREATED ]; then + if [ $e_type = $MPTCP_LIB_EVENT_LISTENER_CREATED ]; then name="LISTENER_CREATED" - elif [ $e_type = $LISTENER_CLOSED ]; then + elif [ $e_type = $MPTCP_LIB_EVENT_LISTENER_CLOSED ]; then name="LISTENER_CLOSED " else name="$e_type"
@@ -2857,8 +2850,10 @@ add_addr_ports_tests() chk_add_nr 1 1 1 chk_rm_nr 1 1 invert - verify_listener_events $evts_ns1 $LISTENER_CREATED $AF_INET 10.0.2.1 10100 - verify_listener_events $evts_ns1 $LISTENER_CLOSED $AF_INET 10.0.2.1 10100 + verify_listener_events $evts_ns1 $MPTCP_LIB_EVENT_LISTENER_CREATED \ + $MPTCP_LIB_AF_INET 10.0.2.1 10100 + verify_listener_events $evts_ns1 $MPTCP_LIB_EVENT_LISTENER_CLOSED \ + $MPTCP_LIB_AF_INET 10.0.2.1 10100 kill_events_pids fi
@@ -3464,11 +3459,11 @@ userspace_tests() userspace_pm_chk_get_addr "${ns1}" "10" "id 10 flags signal 10.0.2.1" userspace_pm_chk_get_addr "${ns1}" "20" "id 20 flags signal 10.0.3.1" userspace_pm_rm_addr $ns1 10 - userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $SUB_ESTABLISHED + userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $MPTCP_LIB_EVENT_SUB_ESTABLISHED userspace_pm_chk_dump_addr "${ns1}" \ "id 20 flags signal 10.0.3.1" "after rm_addr 10" userspace_pm_rm_addr $ns1 20 - userspace_pm_rm_sf $ns1 10.0.3.1 $SUB_ESTABLISHED + userspace_pm_rm_sf $ns1 10.0.3.1 $MPTCP_LIB_EVENT_SUB_ESTABLISHED userspace_pm_chk_dump_addr "${ns1}" "" "after rm_addr 20" chk_rm_nr 2 2 invert chk_mptcp_info subflows 0 subflows 0
@@ -3495,7 +3490,7 @@ userspace_tests() "subflow" userspace_pm_chk_get_addr "${ns2}" "20" "id 20 flags subflow 10.0.3.2" userspace_pm_rm_addr $ns2 20 - userspace_pm_rm_sf $ns2 10.0.3.2 $SUB_ESTABLISHED + userspace_pm_rm_sf $ns2 10.0.3.2 $MPTCP_LIB_EVENT_SUB_ESTABLISHED userspace_pm_chk_dump_addr "${ns2}" \ "" \ "after rm_addr 20"
tools/testing/selftests/net/mptcp/mptcp_lib.sh +18 -0
@@ -8,6 +8,24 @@ readonly KSFT_SKIP=4 # shellcheck disable=SC2155 # declare and assign separately readonly KSFT_TEST="${MPTCP_LIB_KSFT_TEST:-$(basename "${0}" .sh)}" +# shellcheck disable=SC2034 +readonly MPTCP_LIB_EVENT_ANNOUNCED=6 # MPTCP_EVENT_ANNOUNCED +# shellcheck disable=SC2034 +readonly MPTCP_LIB_EVENT_REMOVED=7 # MPTCP_EVENT_REMOVED +# shellcheck disable=SC2034 +readonly MPTCP_LIB_EVENT_SUB_ESTABLISHED=10 # MPTCP_EVENT_SUB_ESTABLISHED +# shellcheck disable=SC2034 +readonly MPTCP_LIB_EVENT_SUB_CLOSED=11 # MPTCP_EVENT_SUB_CLOSED +# shellcheck disable=SC2034 +readonly MPTCP_LIB_EVENT_LISTENER_CREATED=15 # MPTCP_EVENT_LISTENER_CREATED +# shellcheck disable=SC2034 +readonly MPTCP_LIB_EVENT_LISTENER_CLOSED=16 # MPTCP_EVENT_LISTENER_CLOSED + +# shellcheck disable=SC2034 +readonly MPTCP_LIB_AF_INET=2 +# shellcheck disable=SC2034 +readonly MPTCP_LIB_AF_INET6=10 + MPTCP_LIB_SUBTESTS=() MPTCP_LIB_SUBTESTS_DUPLICATED=0 MPTCP_LIB_TEST_COUNTER=0
tools/testing/selftests/net/mptcp/userspace_pm.sh +9 -9
@@ -19,15 +19,15 @@ if ! mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then fi mptcp_lib_check_tools ip -ANNOUNCED=6 # MPTCP_EVENT_ANNOUNCED -REMOVED=7 # MPTCP_EVENT_REMOVED -SUB_ESTABLISHED=10 # MPTCP_EVENT_SUB_ESTABLISHED -SUB_CLOSED=11 # MPTCP_EVENT_SUB_CLOSED -LISTENER_CREATED=15 #MPTCP_EVENT_LISTENER_CREATED -LISTENER_CLOSED=16 #MPTCP_EVENT_LISTENER_CLOSED - -AF_INET=2 -AF_INET6=10 +ANNOUNCED=${MPTCP_LIB_EVENT_ANNOUNCED} +REMOVED=${MPTCP_LIB_EVENT_REMOVED} +SUB_ESTABLISHED=${MPTCP_LIB_EVENT_SUB_ESTABLISHED} +SUB_CLOSED=${MPTCP_LIB_EVENT_SUB_CLOSED} +LISTENER_CREATED=${MPTCP_LIB_EVENT_LISTENER_CREATED} +LISTENER_CLOSED=${MPTCP_LIB_EVENT_LISTENER_CLOSED} + +AF_INET=${MPTCP_LIB_AF_INET} +AF_INET6=${MPTCP_LIB_AF_INET6} file="" server_evts=""
Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH 4/5 selftests: mptcp: use KSFT_SKIP/KSFT_PASS/KSFT_FAIL
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
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}--- .../selftests/net/mptcp/mptcp_connect.sh | 18 +++++++++--------- .../testing/selftests/net/mptcp/mptcp_join.sh | 13 ++++++------- .../selftests/net/mptcp/mptcp_sockopt.sh | 4 ++-- .../testing/selftests/net/mptcp/pm_netlink.sh | 8 ++++---- .../selftests/net/mptcp/simult_flows.sh | 4 ++-- .../selftests/net/mptcp/userspace_pm.sh | 8 ++++---- 6 files changed, 27 insertions(+), 28 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +9 -9
@@ -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")
@@ -96,7 +96,7 @@ while getopts "$optstring" option;do sndbuf="$OPTARG" else echo "-S requires numeric argument, got \"$OPTARG\"" 1>&2 - exit 1 + exit ${KSFT_FAIL} fi ;; "R")
@@ -104,7 +104,7 @@ while getopts "$optstring" option;do rcvbuf="$OPTARG" else echo "-R requires numeric argument, got \"$OPTARG\"" 1>&2 - exit 1 + exit ${KSFT_FAIL} fi ;; "m")
@@ -121,7 +121,7 @@ while getopts "$optstring" option;do ;; "?") usage $0 - exit 1 + exit ${KSFT_FAIL} ;; esac done
@@ -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
@@ -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
@@ -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
@@ -821,7 +821,7 @@ log_if_error() mptcp_lib_pr_fail "${msg}" final_ret=${ret} - ret=0 + ret=${KSFT_PASS} return ${final_ret} fi
tools/testing/selftests/net/mptcp/mptcp_join.sh +6 -7
@@ -25,7 +25,6 @@ err="" capout="" ns1="" ns2="" -ksft_skip=4 iptables="iptables" ip6tables="ip6tables" timeout_poll=30
@@ -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()
@@ -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
@@ -450,7 +449,7 @@ reset_with_tcp_filter() # $1: err msg fail_test() { - ret=1 + ret=${KSFT_FAIL} print_fail "${@}"
@@ -3633,7 +3632,7 @@ usage() { if [ -n "${1}" ]; then echo "${1}" - ret=1 + ret=${KSFT_FAIL} fi echo "mptcp_join usage:"
tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +2 -2
@@ -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
@@ -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
tools/testing/selftests/net/mptcp/pm_netlink.sh +4 -4
@@ -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
@@ -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 }
tools/testing/selftests/net/mptcp/simult_flows.sh +2 -2
@@ -263,7 +263,7 @@ while getopts "bcdh" option;do case "$option" in "h") usage $0 - exit 0 + exit ${KSFT_PASS} ;; "b") bail=1
@@ -276,7 +276,7 @@ while getopts "bcdh" option;do ;; "?") usage $0 - exit 1 + exit ${KSFT_FAIL} ;; esac done
tools/testing/selftests/net/mptcp/userspace_pm.sh +4 -4
@@ -86,7 +86,7 @@ test_skip() test_fail() { mptcp_lib_pr_fail "${@}" - ret=1 + ret=${KSFT_FAIL} mptcp_lib_result_fail "${test_name}" }
@@ -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" ]
@@ -237,7 +237,7 @@ check_expected() return 0 fi - ret=1 + ret=${KSFT_FAIL} mptcp_lib_result_fail "${test_name}" return 1 }
@@ -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 }
Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH 5/5 selftests: mptcp: join: use += operator to append strings
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
This patch uses addition assignment operator (+=) to append strings instead of open-coding in mptcp_join.sh. This can make the statements shorter.
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +17 -17
@@ -753,18 +753,18 @@ pm_nl_check_endpoint() line="${line% }" # the dump order is: address id flags port dev [ -n "$addr" ] && expected_line="$addr" - expected_line="$expected_line $id" - [ -n "$_flags" ] && expected_line="$expected_line ${_flags//","/" "}" - [ -n "$dev" ] && expected_line="$expected_line $dev" - [ -n "$port" ] && expected_line="$expected_line $port" + expected_line+=" $id" + [ -n "$_flags" ] && expected_line+=" ${_flags//","/" "}" + [ -n "$dev" ] && expected_line+=" $dev" + [ -n "$port" ] && expected_line+=" $port" else line=$(ip netns exec $ns ./pm_nl_ctl get $_id) # the dump order is: id flags dev address port expected_line="$id" - [ -n "$flags" ] && expected_line="$expected_line $flags" - [ -n "$dev" ] && expected_line="$expected_line $dev" - [ -n "$addr" ] && expected_line="$expected_line $addr" - [ -n "$_port" ] && expected_line="$expected_line $_port" + [ -n "$flags" ] && expected_line+=" $flags" + [ -n "$dev" ] && expected_line+=" $dev" + [ -n "$addr" ] && expected_line+=" $addr" + [ -n "$_port" ] && expected_line+=" $_port" fi if [ "$line" = "$expected_line" ]; then print_ok
@@ -1032,7 +1032,7 @@ do_transfer() fi fi - extra_srv_args="$extra_args $extra_srv_args" + extra_srv_args+=" $extra_args" if [ "$test_linkfail" -gt 1 ];then timeout ${timeout_test} \ ip netns exec ${listener_ns} \
@@ -1048,7 +1048,7 @@ do_transfer() mptcp_lib_wait_local_port_listen "${listener_ns}" "${port}" - extra_cl_args="$extra_args $extra_cl_args" + extra_cl_args+=" $extra_args" if [ "$test_linkfail" -eq 0 ];then timeout ${timeout_test} \ ip netns exec ${connector_ns} \
@@ -1215,7 +1215,7 @@ chk_csum_nr() print_check "sum" count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtDataCsumErr") if [ "$count" != "$csum_ns1" ]; then - extra_msg="$extra_msg ns1=$count" + extra_msg+=" ns1=$count" fi if [ -z "$count" ]; then print_skip
@@ -1228,7 +1228,7 @@ chk_csum_nr() print_check "csum" count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtDataCsumErr") if [ "$count" != "$csum_ns2" ]; then - extra_msg="$extra_msg ns2=$count" + extra_msg+=" ns2=$count" fi if [ -z "$count" ]; then print_skip
@@ -1272,7 +1272,7 @@ chk_fail_nr() print_check "ftx" count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPFailTx") if [ "$count" != "$fail_tx" ]; then - extra_msg="$extra_msg,tx=$count" + extra_msg+=",tx=$count" fi if [ -z "$count" ]; then print_skip
@@ -1286,7 +1286,7 @@ chk_fail_nr() print_check "failrx" count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtMPFailRx") if [ "$count" != "$fail_rx" ]; then - extra_msg="$extra_msg,rx=$count" + extra_msg+=",rx=$count" fi if [ -z "$count" ]; then print_skip
@@ -1321,7 +1321,7 @@ chk_fclose_nr() if [ -z "$count" ]; then print_skip elif [ "$count" != "$fclose_tx" ]; then - extra_msg="$extra_msg,tx=$count" + extra_msg+=",tx=$count" fail_test "got $count MP_FASTCLOSE[s] TX expected $fclose_tx" else print_ok
@@ -1332,7 +1332,7 @@ chk_fclose_nr() if [ -z "$count" ]; then print_skip elif [ "$count" != "$fclose_rx" ]; then - extra_msg="$extra_msg,rx=$count" + extra_msg+=",rx=$count" fail_test "got $count MP_FASTCLOSE[s] RX expected $fclose_rx" else print_ok
@@ -1701,7 +1701,7 @@ chk_rm_nr() count=$((count + cnt)) if [ "$count" != "$rm_subflow_nr" ]; then suffix="$count in [$rm_subflow_nr:$((rm_subflow_nr*2))]" - extra_msg="$extra_msg simult" + extra_msg+=" simult" fi if [ $count -ge "$rm_subflow_nr" ] && \ [ "$count" -le "$((rm_subflow_nr *2 ))" ]; then
Signature · 1 line
2.40.1
Re: selftests: mptcp: join: use += operator to append strings: Tests Results
Hi Geliang,
Thank you for your modifications, that's great!
Our CI (GitHub Action) did some validations and here is its report:
- KVM Validation: normal: Success! ✅
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/8188604631
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/43ce1abbfb36
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Matthieu Baerts
maintainerHi Geliang,
Quoted 3 lines · Geliang Tang
From: Geliang Tang <[email protected]>
MPTCP events related patches and two cleanups.
Thank you for the patches!
I just did a first review. Please check my different replies.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Matthieu Baerts
maintainerRe: [PATCH mptcp-next 1/5] selftests: mptcp: extract mptcp_lib_check_expected
In reply to Geliang TangHi Geliang,
Quoted 27 lines · Geliang Tang
From: Geliang Tang <[email protected]>
Extract the main part of
check_expected()inuserspace_pm.shto a new functionmptcp_lib_check_expected()inmptcp_lib.sh. It will be used in bothmptcp_john.shanduserspace_pm.sh.check_expected_one()is moved intomptcp_lib.shtoo asmptcp_lib_check_expected_one().Signed-off-by Geliang Tang <[email protected]>--- .../testing/selftests/net/mptcp/mptcp_lib.sh | 30 ++++++++++++++++ .../selftests/net/mptcp/userspace_pm.sh | 34 +++---------------- 2 files changed, 35 insertions(+), 29 deletions(-)tools/testing/selftests/net/mptcp/mptcp_lib.sh +6
-0@@ -438,3 +438,33 @@ mptcp_lib_print_title() { # shellcheck disable=SC2059 # the format is in a variable printf "${MPTCP_LIB_TEST_FORMAT}" "$((++MPTCP_LIB_TEST_COUNTER))" "${*}" } + +# $1: var name ; $2: prev ret +mptcp_lib_check_expected_one() { + local var="${1}" + local exp="e_${var}" + local prev_ret="${2}"
tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_print_title() { · line 456
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +10
-0+ + if [ "${!var}" = "${!exp}" ]; then + return 0 + fi + + if [ "${prev_ret}" = "0" ]; then + mptcp_lib_pr_fail + fi + + mptcp_lib_print_err "Expected value for '${var}': '${!exp}', got '${!var}'."
Maybe keep the tab like before? Please check how it looks like when there is a failure in mptcp_join.sh and userspace_pm.sh.
Quoted 56 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +14
-0+ return 1 +} + +# $@: all var names to check +mptcp_lib_check_expected() { + local rc=0 + local var + + for var in "${@}"; do + mptcp_lib_check_expected_one "${var}" "${rc}" || rc=1 + done + + return "${rc}" +}tools/testing/selftests/net/mptcp/userspace_pm.sh +1
-22@@ -5,7 +5,7 @@ # code but we accept it. #shellcheck disable=SC2086 -# Some variables are used below but indirectly, see check_expected_one() +# Some variables are used below but indirectly, see verify_*_event() #shellcheck disable=SC2034 . "$(dirname "${0}")/mptcp_lib.sh"@@ -225,44 +225,20 @@ make_connection() fi } -# $1: var name ; $2: prev ret -check_expected_one() -{ - local var="${1}" - local exp="e_${var}" - local prev_ret="${2}" - - if [ "${!var}" = "${!exp}" ] - then - return 0 - fi - - if [ "${prev_ret}" = "0" ] - then - test_fail - fi - - mptcp_lib_print_err "\tExpected value for '${var}': '${!exp}', got '${!var}'." - return 1 -} - # $@: all var names to check check_expected() { local rc=0
tools/testing/selftests/net/mptcp/userspace_pm.sh make_connection() · line 234
Quoted 10 lines
tools/testing/selftests/net/mptcp/userspace_pm.sh +2
-7- local var - for var in "${@}" - do - check_expected_one "${var}" "${rc}" || rc=1 - done - - if [ ${rc} -eq 0 ] + mptcp_lib_check_expected "${@}" || rc=1 + if [ "${rc}" -eq 0 ]
I guess you no longer need "rc":
if mptcp_lib_check_expected "${@}"
then
test_pass
return 0
fitools/testing/selftests/net/mptcp/userspace_pm.sh make_connection() · line 241
Quoted 7 lines
tools/testing/selftests/net/mptcp/userspace_pm.sh +2
-0then test_pass return 0 fi + ret=1 + mptcp_lib_result_fail "${test_name}"
Mmh, you should keep using test_fail(): best to keep using a single helper in case of failure, because we need to do these two actions, and for sure, we will miss one later in new code by accident.
Instead, I suggest modifying test_fail() to call "mptcp_lib_pr_fail" only if there are arguments (if [ ${#} -gt 0 ]). But then, you will have to add arguments when calling test_fail() from test_remove() → e.g. "unexpected type: ${type}" (it even makes sense to print that any way to help to understand what's wrong)
tools/testing/selftests/net/mptcp/userspace_pm.sh make_connection() · line 244
Quoted 3 lines
tools/testing/selftests/net/mptcp/userspace_pm.sh +0
-0return 1 }
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Matthieu Baerts
maintainerRe: [PATCH mptcp-next 2/5] selftests: mptcp: add mptcp_lib_verify_listener_events
In reply to Geliang TangHi Geliang,
Quoted 47 lines · Geliang Tang
From: Geliang Tang <[email protected]>
To avoid duplicated code in different MPTCP selftests, we can add and use helpers defined in
mptcp_lib.sh.The helper
verify_listener_events()is defined both inmptcp_join.shanduserspace_pm.sh, export it intomptcp_lib.shand rename it withmptcp_lib_prefix. Use this new helper in both scripts.Signed-off-by Geliang Tang <[email protected]>--- .../testing/selftests/net/mptcp/mptcp_join.sh | 23 +++----------- .../testing/selftests/net/mptcp/mptcp_lib.sh | 26 ++++++++++++++++ .../selftests/net/mptcp/userspace_pm.sh | 31 +++++-------------- 3 files changed, 38 insertions(+), 42 deletions(-)tools/testing/selftests/net/mptcp/mptcp_join.sh +1
-10@@ -2792,16 +2792,12 @@ AF_INET6=10 verify_listener_events() { - local evt=$1 local e_type=$2 local e_family=$3 local e_saddr=$4 local e_sport=$5 - local type - local family - local saddr - local sport local name + local rc=0 if [ $e_type = $LISTENER_CREATED ]; then name="LISTENER_CREATED"@@ -2818,23 +2814,12 @@ verify_listener_events() return fi - type=$(mptcp_lib_evts_get_info type "$evt" "$e_type") - family=$(mptcp_lib_evts_get_info family "$evt" "$e_type") - sport=$(mptcp_lib_evts_get_info sport "$evt" "$e_type") - if [ $family ] && [ $family = $AF_INET6 ]; then - saddr=$(mptcp_lib_evts_get_info saddr6 "$evt" "$e_type")
tools/testing/selftests/net/mptcp/mptcp_join.sh verify_listener_events() · line 2818
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +2
-8- else - saddr=$(mptcp_lib_evts_get_info saddr4 "$evt" "$e_type") - fi - - if [ $type ] && [ $type = $e_type ] && - [ $family ] && [ $family = $e_family ] && - [ $saddr ] && [ $saddr = $e_saddr ] && - [ $sport ] && [ $sport = $e_sport ]; then + mptcp_lib_verify_listener_events "${@}" || rc="${?}" + if [ "${rc}" -eq 0 ]; then
Same here, you don't need 'rc':
if mptcp_lib_verify_listener_events "${@}"; then
(...)tools/testing/selftests/net/mptcp/mptcp_join.sh verify_listener_events() · line 2822
Quoted 5 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +1
-1print_ok return 0 fi - fail_test "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$sport" + fail_test "$e_type $e_family $e_saddr $e_sport"
Mmh, this will call "mptcp_lib_pr_fail" again, with info that have already been displayed, no?
What about calling "fail_test" without argument, and adapt this helper not to call "print_fail" in this case, no?
if [ ${#} -gt 0 ]; then
print_fail "${@}"
fitools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_check_expected() { · line 472
Quoted 13 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +0
-0} add_addr_ports_tests()tools/testing/selftests/net/mptcp/mptcp_lib.sh +2
-0@@ -468,3 +468,29 @@ mptcp_lib_check_expected() { return "${rc}" } + +# shellcheck disable=SC2034
Please *always* document why you need to disable a check
# shellcheck disable=(...) # <why> (or above it is a long description)
tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_check_expected() { · line 478
Quoted 6 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +6
-0+mptcp_lib_verify_listener_events() { + local evt=$1 + local e_type=$2 + local e_family=$3 + local e_saddr=$4 + local e_sport=$5
Please use {} around the variable name in mptcp_lib.sh: same style as the rest of the code in this file.
Quoted 4 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +4
-0+ local type + local family + local saddr + local sport
tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_check_expected() { · line 492
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +10
-0+ local rc=0 + + type=$(mptcp_lib_evts_get_info type "$evt" "$e_type") + family=$(mptcp_lib_evts_get_info family "$evt" "$e_type") + if [ "$family" ] && [ "$family" = "$AF_INET6" ]; then + saddr=$(mptcp_lib_evts_get_info saddr6 "$evt" "$e_type") + else + saddr=$(mptcp_lib_evts_get_info saddr4 "$evt" "$e_type") + fi + sport=$(mptcp_lib_evts_get_info sport "$evt" "$e_type")
Same here above for the whole block for the {}.
Quoted 26 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +4
-0+ + mptcp_lib_check_expected "type" "family" "saddr" "sport" || rc="${?}" + return "${rc}" +}tools/testing/selftests/net/mptcp/userspace_pm.sh +0
-14@@ -836,32 +836,15 @@ test_prio() verify_listener_events() { - local evt=$1 - local e_type=$2 - local e_family=$3 - local e_saddr=$4 - local e_sport=$5 - local type - local family - local saddr - local sport - - if [ $e_type = $LISTENER_CREATED ]; then - print_test "CREATE_LISTENER $e_saddr:$e_sport" - elif [ $e_type = $LISTENER_CLOSED ]; then - print_test "CLOSE_LISTENER $e_saddr:$e_sport"
tools/testing/selftests/net/mptcp/userspace_pm.sh test_prio() · line 842
Quoted 10 lines
tools/testing/selftests/net/mptcp/userspace_pm.sh +3
-6- fi + local rc=0 - type=$(mptcp_lib_evts_get_info type $evt $e_type) - family=$(mptcp_lib_evts_get_info family $evt $e_type) - sport=$(mptcp_lib_evts_get_info sport $evt $e_type) - if [ $family ] && [ $family = $AF_INET6 ]; then - saddr=$(mptcp_lib_evts_get_info saddr6 $evt $e_type) + mptcp_lib_verify_listener_events "${@}" || rc="${?}" + if [ "${rc}" -eq 0 ]; then
Same here for 'rc': not needed
tools/testing/selftests/net/mptcp/userspace_pm.sh test_prio() · line 846
Quoted 5 lines
tools/testing/selftests/net/mptcp/userspace_pm.sh +3
-1+ test_pass else - saddr=$(mptcp_lib_evts_get_info saddr4 $evt $e_type) + ret=1 + mptcp_lib_result_fail "${test_name}"
Same here for ret=1: don't do that, use test_fail without parameters
tools/testing/selftests/net/mptcp/userspace_pm.sh test_listener() · line 863
Quoted 11 lines
tools/testing/selftests/net/mptcp/userspace_pm.sh +1
-2fi - - check_expected "type" "family" "saddr" "sport" } test_listener()@@ -877,6 +860,7 @@ test_listener() # Capture events on the network namespace running the client :>$client_evts + print_test "Listener event LISTENER_CREATED 10.0.2.2:$client4_port"
Please don't change the name, it is used in the TAP output.
tools/testing/selftests/net/mptcp/userspace_pm.sh test_listener() · line 882
Quoted 8 lines
tools/testing/selftests/net/mptcp/userspace_pm.sh +1
-0# Attempt to add a listener at 10.0.2.2:<subflow-port> ip netns exec $ns2 ./pm_nl_ctl listen 10.0.2.2\ $client4_port &@@ -895,6 +879,7 @@ test_listener() rport $client4_port token $server4_token sleep 0.5 + print_test "Listener event LISTENER_CLOSED 10.0.2.2:$client4_port"
Same here, keep the same name.
tools/testing/selftests/net/mptcp/userspace_pm.sh test_listener() · line 885
Quoted 3 lines
tools/testing/selftests/net/mptcp/userspace_pm.sh +0
-0# Delete the listener from the client ns, if one was created mptcp_lib_kill_wait $listener_pid
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Matthieu Baerts
maintainerRe: [PATCH mptcp-next 3/5] selftests: mptcp: export event macros in mptcp_lib
In reply to Geliang TangHi Geliang,
Quoted 6 lines · Geliang Tang
From: Geliang Tang <[email protected]>
SUB_ESTABLISHED,LISTENER_CREATED,LISTENER_CLOSED,AF_INETandAF_INET6are defined in bothmptcp_join.shanduserspace_pm.sh, export all event macros intomptcp_lib.sh. AddMPTCP_LIB_prefix for the first three and add readonly for the last two.
The last sentence is not correct any more.
Please also add the reason (e.g. not to duplicate code).
(...)
tools/testing/selftests/net/mptcp/mptcp_lib.sh readonly KSFT_SKIP=4 · line 11
Quoted 9 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +1
-0@@ -8,6 +8,24 @@ readonly KSFT_SKIP=4 # shellcheck disable=SC2155 # declare and assign separately readonly KSFT_TEST="${MPTCP_LIB_KSFT_TEST:-$(basename "${0}" .sh)}" +# shellcheck disable=SC2034
If you export them, you tell shellcheck it will be used elsewhere, you no longer need to disable this check. Please note that you cannot use 'export readonly' together, see:
https://www.shellcheck.net/wiki/SC2316
But you can use 'declare -rx'
# These variables are used in some selftests, read-only
declare -rx MPTCP_LIB_EVENT_ANNOUNCED=6 (...)
declare -rx MPTCP_LIB_EVENT_REMOVED=7 (...)
(...)
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +10
-0+readonly MPTCP_LIB_EVENT_ANNOUNCED=6 # MPTCP_EVENT_ANNOUNCED +# shellcheck disable=SC2034 +readonly MPTCP_LIB_EVENT_REMOVED=7 # MPTCP_EVENT_REMOVED +# shellcheck disable=SC2034 +readonly MPTCP_LIB_EVENT_SUB_ESTABLISHED=10 # MPTCP_EVENT_SUB_ESTABLISHED +# shellcheck disable=SC2034 +readonly MPTCP_LIB_EVENT_SUB_CLOSED=11 # MPTCP_EVENT_SUB_CLOSED +# shellcheck disable=SC2034 +readonly MPTCP_LIB_EVENT_LISTENER_CREATED=15 # MPTCP_EVENT_LISTENER_CREATED +# shellcheck disable=SC2034
tools/testing/selftests/net/mptcp/mptcp_lib.sh readonly KSFT_SKIP=4 · line 31
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +7
-0+readonly MPTCP_LIB_EVENT_LISTENER_CLOSED=16 # MPTCP_EVENT_LISTENER_CLOSED + +# shellcheck disable=SC2034 +readonly MPTCP_LIB_AF_INET=2 +# shellcheck disable=SC2034 +readonly MPTCP_LIB_AF_INET6=10 + MPTCP_LIB_SUBTESTS=() MPTCP_LIB_SUBTESTS_DUPLICATED=0 MPTCP_LIB_TEST_COUNTER=0
(...)
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Matthieu Baerts
maintainerRe: [PATCH mptcp-next 5/5] selftests: mptcp: join: use += operator to append strings
In reply to Geliang TangHi Geliang,
Quoted 42 lines · Geliang Tang
From: Geliang Tang <[email protected]>
This patch uses addition assignment operator (+=) to append strings instead of open-coding in
mptcp_join.sh. This can make the statements shorter.Signed-off-by Geliang Tang <[email protected]>--- .../testing/selftests/net/mptcp/mptcp_join.sh | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-)tools/testing/selftests/net/mptcp/mptcp_join.sh +8
-8@@ -753,18 +753,18 @@ pm_nl_check_endpoint() line="${line% }" # the dump order is: address id flags port dev [ -n "$addr" ] && expected_line="$addr" - expected_line="$expected_line $id" - [ -n "$_flags" ] && expected_line="$expected_line ${_flags//","/" "}" - [ -n "$dev" ] && expected_line="$expected_line $dev" - [ -n "$port" ] && expected_line="$expected_line $port" + expected_line+=" $id" + [ -n "$_flags" ] && expected_line+=" ${_flags//","/" "}" + [ -n "$dev" ] && expected_line+=" $dev" + [ -n "$port" ] && expected_line+=" $port" else line=$(ip netns exec $ns ./pm_nl_ctl get $_id) # the dump order is: id flags dev address port expected_line="$id" - [ -n "$flags" ] && expected_line="$expected_line $flags" - [ -n "$dev" ] && expected_line="$expected_line $dev" - [ -n "$addr" ] && expected_line="$expected_line $addr" - [ -n "$_port" ] && expected_line="$expected_line $_port" + [ -n "$flags" ] && expected_line+=" $flags" + [ -n "$dev" ] && expected_line+=" $dev" + [ -n "$addr" ] && expected_line+=" $addr" + [ -n "$_port" ] && expected_line+=" $_port" fi if [ "$line" = "$expected_line" ]; then print_ok
tools/testing/selftests/net/mptcp/mptcp_join.sh do_transfer() · line 1035
Quoted 5 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +1
-1@@ -1032,7 +1032,7 @@ do_transfer() fi fi - extra_srv_args="$extra_args $extra_srv_args" + extra_srv_args+=" $extra_args"
Here, you are changing the order. Just to be sure, is it still OK with the new order?
If yes, please add a comment in the commit message to explain why this change of behaviour is OK (any behaviour changes in such refactoring should be mentioned, otherwise it might look like an accident, reviewers will ask questions or lose time trying to understand why it would be OK, etc.)
tools/testing/selftests/net/mptcp/mptcp_join.sh do_transfer() · line 1051
Quoted 9 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +1
-1if [ "$test_linkfail" -gt 1 ];then timeout ${timeout_test} \ ip netns exec ${listener_ns} \@@ -1048,7 +1048,7 @@ do_transfer() mptcp_lib_wait_local_port_listen "${listener_ns}" "${port}" - extra_cl_args="$extra_args $extra_cl_args" + extra_cl_args+=" $extra_args"
Same here for the order.
tools/testing/selftests/net/mptcp/mptcp_join.sh do_transfer() · line 1054
Quoted 3 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +0
-0if [ "$test_linkfail" -eq 0 ];then timeout ${timeout_test} \ ip netns exec ${connector_ns} \
(...)
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Re: selftests: mptcp: join: use += operator to append strings: Tests Results
In reply to Geliang TangHi Geliang,
Thank you for your modifications, that's great!
Our CI (Cirrus) did some validations with a debug kernel and here is its report:
- KVM Validation: debug (except selftest_mptcp_join):
- Unstable: 1 failed test(s): packetdrill_regressions 🔴:
- Task: https://cirrus-ci.com/task/6379905680670720
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6379905680670720/summary/summary.txt
- KVM Validation: debug (only selftest_mptcp_join):
- Unstable: 1 failed test(s): selftest_mptcp_join 🔴:
- Task: https://cirrus-ci.com/task/4972530797117440
- Summary: https://api.cirrus-ci.com/v1/artifact/task/4972530797117440/summary/summary.txt
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/43ce1abbfb36
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-debugFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)