Commit 04fb19d9 authored by Geliang Tang's avatar Geliang Tang Committed by Geliang Tang
Browse files

selftests: mptcp: export TEST_COUNTER variable

mainline inclusion
from mainline-v6.9-rc1
commit 9e6a39ecb9a11603c1c28e5463008f2e0af56085
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9VYQ9
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=9e6a39ecb9a11603c1c28e5463008f2e0af56085



--------------------------------

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: default avatarGeliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: default avatarMatthieu 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: default avatarJakub Kicinski <kuba@kernel.org>
Reviewed-by: default avatarJackie Liu <liuyun01@kylinos.cn>
Signed-off-by: default avatarGeliang Tang <tanggeliang@kylinos.cn>
parent a7fbaaf1
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -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()
+1 −2
Original line number Diff line number Diff line
@@ -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+=" -R $rcvbuf"
+7 −8
Original line number Diff line number Diff line
@@ -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
@@ -463,7 +462,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
@@ -974,7 +973,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:-""}
@@ -992,9 +991,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=$!

+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ declare -rx MPTCP_LIB_AF_INET6=10

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" ]; } &&
+2 −3
Original line number Diff line number Diff line
@@ -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"