Skip to content

Commit 9e6a39e

Browse files
Geliang Tangkuba-moo
authored andcommitted
selftests: mptcp: export TEST_COUNTER variable
Variable TEST_COUNT are used in mptcp_connect.sh and mptcp_join.sh as test counters, which are initialized to 0, while variable test_cnt are used in diag.sh and simult_flows.sh, which are initialized to 1. To maintain consistency, this patch renames them all as MPTCP_LIB_TEST_COUNTER, initializes it to 1, and exports it into mptcp_lib.sh. Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://lore.kernel.org/r/20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-5-4f42c347b653@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent fd95926 commit 9e6a39e

5 files changed

Lines changed: 14 additions & 16 deletions

File tree

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
. "$(dirname "${0}")/mptcp_lib.sh"
1010

1111
ns=""
12-
test_cnt=1
1312
timeout_poll=30
1413
timeout_test=$((timeout_poll * 2 + 1))
1514
ret=0
@@ -69,7 +68,7 @@ __chk_nr()
6968
echo "[ ok ]"
7069
mptcp_lib_result_pass "${msg}"
7170
fi
72-
test_cnt=$((test_cnt+1))
71+
MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
7372
}
7473

7574
__chk_msk_nr()
@@ -127,7 +126,7 @@ wait_msk_nr()
127126
echo "[ ok ]"
128127
mptcp_lib_result_pass "${msg}"
129128
fi
130-
test_cnt=$((test_cnt+1))
129+
MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
131130
}
132131

133132
chk_msk_fallback_nr()

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ ns2=""
131131
ns3=""
132132
ns4=""
133133

134-
TEST_COUNT=0
135134
TEST_GROUP=""
136135

137136
# This function is used in the cleanup trap
@@ -321,7 +320,7 @@ do_transfer()
321320
local extra_args="$7"
322321

323322
port=$((port + 1))
324-
TEST_COUNT=$((TEST_COUNT+1))
323+
MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
325324

326325
if [ "$rcvbuf" -gt 0 ]; then
327326
extra_args="$extra_args -R $rcvbuf"

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ declare -A all_tests
4848
declare -a only_tests_ids
4949
declare -a only_tests_names
5050
declare -A failed_tests
51-
TEST_COUNT=0
5251
TEST_NAME=""
5352
nr_blank=6
5453

@@ -172,7 +171,7 @@ cleanup()
172171

173172
print_title()
174173
{
175-
printf "%03u %s\n" "${TEST_COUNT}" "${TEST_NAME}"
174+
printf "%03u %s\n" "${MPTCP_LIB_TEST_COUNTER}" "${TEST_NAME}"
176175
}
177176

178177
print_check()
@@ -233,7 +232,7 @@ skip_test()
233232

234233
local i
235234
for i in "${only_tests_ids[@]}"; do
236-
if [ "${TEST_COUNT}" -eq "${i}" ]; then
235+
if [ "${MPTCP_LIB_TEST_COUNTER}" -eq "${i}" ]; then
237236
return 1
238237
fi
239238
done
@@ -268,7 +267,7 @@ reset()
268267

269268
TEST_NAME="${1}"
270269

271-
TEST_COUNT=$((TEST_COUNT+1))
270+
MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
272271

273272
if skip_test; then
274273
last_test_ignored=1
@@ -462,7 +461,7 @@ fail_test()
462461

463462
# just in case a test is marked twice as failed
464463
if [ ${last_test_failed} -eq 0 ]; then
465-
failed_tests[${TEST_COUNT}]="${TEST_NAME}"
464+
failed_tests[${MPTCP_LIB_TEST_COUNTER}]="${TEST_NAME}"
466465
dump_stats
467466
last_test_failed=1
468467
fi
@@ -973,7 +972,7 @@ do_transfer()
973972
local srv_proto="$4"
974973
local connect_addr="$5"
975974

976-
local port=$((10000 + TEST_COUNT - 1))
975+
local port=$((10000 + MPTCP_LIB_TEST_COUNTER - 1))
977976
local cappid
978977
local FAILING_LINKS=${FAILING_LINKS:-""}
979978
local fastclose=${fastclose:-""}
@@ -991,9 +990,9 @@ do_transfer()
991990
capuser="-Z $SUDO_USER"
992991
fi
993992

994-
capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}")
993+
capfile=$(printf "mp_join-%02u-%s.pcap" "$MPTCP_LIB_TEST_COUNTER" "${listener_ns}")
995994

996-
echo "Capturing traffic for test $TEST_COUNT into $capfile"
995+
echo "Capturing traffic for test $MPTCP_LIB_TEST_COUNTER into $capfile"
997996
ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 &
998997
cappid=$!
999998

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ readonly KSFT_TEST="${MPTCP_LIB_KSFT_TEST:-$(basename "${0}" .sh)}"
1010

1111
MPTCP_LIB_SUBTESTS=()
1212
MPTCP_LIB_SUBTESTS_DUPLICATED=0
13+
# shellcheck disable=SC2034 # unused at this moment
14+
MPTCP_LIB_TEST_COUNTER=0
1315

1416
# only if supported (or forced) and not disabled, see no-color.org
1517
if { [ -t 1 ] || [ "${SELFTESTS_MPTCP_LIB_COLOR_FORCE:-}" = "1" ]; } &&

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ ns3=""
1414
capture=false
1515
timeout_poll=30
1616
timeout_test=$((timeout_poll * 2 + 1))
17-
test_cnt=1
1817
ret=0
1918
bail=0
2019
slack=50
@@ -126,8 +125,8 @@ do_transfer()
126125
local sin=$2
127126
local max_time=$3
128127
local port
129-
port=$((10000+test_cnt))
130-
test_cnt=$((test_cnt+1))
128+
port=$((10000+MPTCP_LIB_TEST_COUNTER))
129+
MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
131130

132131
:> "$cout"
133132
:> "$sout"

0 commit comments

Comments
 (0)