summaryrefslogtreecommitdiff
path: root/tools/testing/selftests
diff options
context:
space:
mode:
authorGeliang Tang <tanggeliang@kylinos.cn>2024-03-08 23:10:12 +0100
committerJakub Kicinski <kuba@kernel.org>2024-03-11 15:07:26 -0700
commit9e6a39ecb9a11603c1c28e5463008f2e0af56085 (patch)
treec06308a573daffe05cf27a4e5e6e32c55d5931e2 /tools/testing/selftests
parentfd959262c1bb09eac288445ff90696087e0d063f (diff)
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>
Diffstat (limited to 'tools/testing/selftests')
-rwxr-xr-xtools/testing/selftests/net/mptcp/diag.sh5
-rwxr-xr-xtools/testing/selftests/net/mptcp/mptcp_connect.sh3
-rwxr-xr-xtools/testing/selftests/net/mptcp/mptcp_join.sh15
-rw-r--r--tools/testing/selftests/net/mptcp/mptcp_lib.sh2
-rwxr-xr-xtools/testing/selftests/net/mptcp/simult_flows.sh5
5 files changed, 14 insertions, 16 deletions
diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh
index afe862895946..b63510ce2327 100755
--- a/tools/testing/selftests/net/mptcp/diag.sh
+++ b/tools/testing/selftests/net/mptcp/diag.sh
@@ -9,7 +9,6 @@
. "$(dirname "${0}")/mptcp_lib.sh"
ns=""
-test_cnt=1
timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1))
ret=0
@@ -69,7 +68,7 @@ __chk_nr()
echo "[ ok ]"
mptcp_lib_result_pass "${msg}"
fi
- test_cnt=$((test_cnt+1))
+ MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
}
__chk_msk_nr()
@@ -127,7 +126,7 @@ wait_msk_nr()
echo "[ ok ]"
mptcp_lib_result_pass "${msg}"
fi
- test_cnt=$((test_cnt+1))
+ MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
}
chk_msk_fallback_nr()
diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index ce9342b241cd..915faee77e25 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
@@ -131,7 +131,6 @@ ns2=""
ns3=""
ns4=""
-TEST_COUNT=0
TEST_GROUP=""
# This function is used in the cleanup trap
@@ -321,7 +320,7 @@ do_transfer()
local extra_args="$7"
port=$((port + 1))
- TEST_COUNT=$((TEST_COUNT+1))
+ MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
if [ "$rcvbuf" -gt 0 ]; then
extra_args="$extra_args -R $rcvbuf"
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 1df2d24979a0..4ef0d5ae9dae 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -48,7 +48,6 @@ declare -A all_tests
declare -a only_tests_ids
declare -a only_tests_names
declare -A failed_tests
-TEST_COUNT=0
TEST_NAME=""
nr_blank=6
@@ -172,7 +171,7 @@ cleanup()
print_title()
{
- printf "%03u %s\n" "${TEST_COUNT}" "${TEST_NAME}"
+ printf "%03u %s\n" "${MPTCP_LIB_TEST_COUNTER}" "${TEST_NAME}"
}
print_check()
@@ -233,7 +232,7 @@ skip_test()
local i
for i in "${only_tests_ids[@]}"; do
- if [ "${TEST_COUNT}" -eq "${i}" ]; then
+ if [ "${MPTCP_LIB_TEST_COUNTER}" -eq "${i}" ]; then
return 1
fi
done
@@ -268,7 +267,7 @@ reset()
TEST_NAME="${1}"
- TEST_COUNT=$((TEST_COUNT+1))
+ MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
if skip_test; then
last_test_ignored=1
@@ -462,7 +461,7 @@ fail_test()
# just in case a test is marked twice as failed
if [ ${last_test_failed} -eq 0 ]; then
- failed_tests[${TEST_COUNT}]="${TEST_NAME}"
+ failed_tests[${MPTCP_LIB_TEST_COUNTER}]="${TEST_NAME}"
dump_stats
last_test_failed=1
fi
@@ -973,7 +972,7 @@ do_transfer()
local srv_proto="$4"
local connect_addr="$5"
- local port=$((10000 + TEST_COUNT - 1))
+ local port=$((10000 + MPTCP_LIB_TEST_COUNTER - 1))
local cappid
local FAILING_LINKS=${FAILING_LINKS:-""}
local fastclose=${fastclose:-""}
@@ -991,9 +990,9 @@ do_transfer()
capuser="-Z $SUDO_USER"
fi
- capfile=$(printf "mp_join-%02u-%s.pcap" "$TEST_COUNT" "${listener_ns}")
+ capfile=$(printf "mp_join-%02u-%s.pcap" "$MPTCP_LIB_TEST_COUNTER" "${listener_ns}")
- echo "Capturing traffic for test $TEST_COUNT into $capfile"
+ echo "Capturing traffic for test $MPTCP_LIB_TEST_COUNTER into $capfile"
ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 &
cappid=$!
diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index 5d071b6eb780..63abf4431993 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -10,6 +10,8 @@ readonly KSFT_TEST="${MPTCP_LIB_KSFT_TEST:-$(basename "${0}" .sh)}"
MPTCP_LIB_SUBTESTS=()
MPTCP_LIB_SUBTESTS_DUPLICATED=0
+# shellcheck disable=SC2034 # unused at this moment
+MPTCP_LIB_TEST_COUNTER=0
# only if supported (or forced) and not disabled, see no-color.org
if { [ -t 1 ] || [ "${SELFTESTS_MPTCP_LIB_COLOR_FORCE:-}" = "1" ]; } &&
diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh
index 365fb3d6ef55..3ad663e38c42 100755
--- a/tools/testing/selftests/net/mptcp/simult_flows.sh
+++ b/tools/testing/selftests/net/mptcp/simult_flows.sh
@@ -14,7 +14,6 @@ ns3=""
capture=false
timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1))
-test_cnt=1
ret=0
bail=0
slack=50
@@ -126,8 +125,8 @@ do_transfer()
local sin=$2
local max_time=$3
local port
- port=$((10000+test_cnt))
- test_cnt=$((test_cnt+1))
+ port=$((10000+MPTCP_LIB_TEST_COUNTER))
+ MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
:> "$cout"
:> "$sout"