To maintain consistency with other scripts, this patch renames some
variables:
test_name -> TEST_NAME in userspace_pm.sh
test_cnt -> TEST_COUNT in diag.sh, simult_flows.sh
ns -> ns1 in diag.sh
ns_sbox -> ns3 in mptcp_sockopt.sh
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
tools/testing/selftests/net/mptcp/diag.sh | 58 +++++++++----------
.../selftests/net/mptcp/mptcp_sockopt.sh | 12 ++--
.../selftests/net/mptcp/simult_flows.sh | 6 +-
.../selftests/net/mptcp/userspace_pm.sh | 12 ++--
4 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh
index e59d3b33bb22..043e199b0c62 100755
--- a/tools/testing/selftests/net/mptcp/diag.sh
+++ b/tools/testing/selftests/net/mptcp/diag.sh
@@ -5,9 +5,9 @@
sec=$(date +%s)
rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
-ns="ns1-$rndh"
+ns1="ns1-$rndh"
ksft_skip=4
-test_cnt=1
+TEST_COUNT=1
timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1))
ret=0
@@ -18,19 +18,19 @@ flush_pids()
# give it some time
sleep 1.1
- ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGUSR1 &>/dev/null
+ ip netns pids "${ns1}" | xargs --no-run-if-empty kill -SIGUSR1 &>/dev/null
for _ in $(seq 10); do
- [ -z "$(ip netns pids "${ns}")" ] && break
+ [ -z "$(ip netns pids "${ns1}")" ] && break
sleep 0.1
done
}
cleanup()
{
- ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGKILL &>/dev/null
+ ip netns pids "${ns1}" | xargs --no-run-if-empty kill -SIGKILL &>/dev/null
- ip netns del $ns
+ ip netns del $ns1
}
mptcp_lib_check_mptcp
@@ -48,7 +48,7 @@ fi
get_msk_inuse()
{
- ip netns exec $ns cat /proc/net/protocols | awk '$1~/^MPTCP$/{print $3}'
+ ip netns exec $ns1 cat /proc/net/protocols | awk '$1~/^MPTCP$/{print $3}'
}
__chk_nr()
@@ -69,13 +69,13 @@ __chk_nr()
else
echo "[ fail ] expected $expected found $nr"
mptcp_lib_result_fail "${msg}"
- ret=$test_cnt
+ ret=$TEST_COUNT
fi
else
echo "[ ok ]"
mptcp_lib_result_pass "${msg}"
fi
- test_cnt=$((test_cnt+1))
+ TEST_COUNT=$((TEST_COUNT+1))
}
__chk_msk_nr()
@@ -83,7 +83,7 @@ __chk_msk_nr()
local condition=$1
shift 1
- __chk_nr "ss -inmHMN $ns | $condition" "$@"
+ __chk_nr "ss -inmHMN $ns1 | $condition" "$@"
}
chk_msk_nr()
@@ -104,7 +104,7 @@ wait_msk_nr()
msg=$*
while [ $i -lt $timeout ]; do
- nr=$(ss -inmHMN $ns | $condition)
+ nr=$(ss -inmHMN $ns1 | $condition)
[ $nr == $expected ] && break;
[ $nr -gt $max ] && max=$nr
i=$((i + 1))
@@ -115,16 +115,16 @@ wait_msk_nr()
if [ $i -ge $timeout ]; then
echo "[ fail ] timeout while expecting $expected max $max last $nr"
mptcp_lib_result_fail "${msg} # timeout"
- ret=$test_cnt
+ ret=$TEST_COUNT
elif [ $nr != $expected ]; then
echo "[ fail ] expected $expected found $nr"
mptcp_lib_result_fail "${msg} # unexpected result"
- ret=$test_cnt
+ ret=$TEST_COUNT
else
echo "[ ok ]"
mptcp_lib_result_pass "${msg}"
fi
- test_cnt=$((test_cnt+1))
+ TEST_COUNT=$((TEST_COUNT+1))
}
chk_msk_fallback_nr()
@@ -143,7 +143,7 @@ __chk_listen()
local expected=$2
local msg="$3"
- __chk_nr "ss -N $ns -Ml '$filter' | grep -c LISTEN" "$expected" "$msg" 0
+ __chk_nr "ss -N $ns1 -Ml '$filter' | grep -c LISTEN" "$expected" "$msg" 0
}
chk_msk_listen()
@@ -169,7 +169,7 @@ chk_msk_inuse()
local msg="$2"
local listen_nr
- listen_nr=$(ss -N "${ns}" -Ml | grep -c LISTEN)
+ listen_nr=$(ss -N "${ns1}" -Ml | grep -c LISTEN)
expected=$((expected + listen_nr))
for _ in $(seq 10); do
@@ -197,24 +197,24 @@ wait_connected()
}
trap cleanup EXIT
-ip netns add $ns
-ip -n $ns link set dev lo up
+ip netns add $ns1
+ip -n $ns1 link set dev lo up
echo "a" | \
timeout ${timeout_test} \
- ip netns exec $ns \
+ ip netns exec $ns1 \
./mptcp_connect -p 10000 -l -t ${timeout_poll} -w 20 \
0.0.0.0 >/dev/null &
-mptcp_lib_wait_local_port_listen $ns 10000
+mptcp_lib_wait_local_port_listen $ns1 10000
chk_msk_nr 0 "no msk on netns creation"
chk_msk_listen 10000
echo "b" | \
timeout ${timeout_test} \
- ip netns exec $ns \
+ ip netns exec $ns1 \
./mptcp_connect -p 10000 -r 0 -t ${timeout_poll} -w 20 \
127.0.0.1 >/dev/null &
-wait_connected $ns 10000
+wait_connected $ns1 10000
chk_msk_nr 2 "after MPC handshake "
chk_msk_remote_key_nr 2 "....chk remote_key"
chk_msk_fallback_nr 0 "....chk no fallback"
@@ -225,16 +225,16 @@ chk_msk_inuse 0 "....chk 0 msk in use after flush"
echo "a" | \
timeout ${timeout_test} \
- ip netns exec $ns \
+ ip netns exec $ns1 \
./mptcp_connect -p 10001 -l -s TCP -t ${timeout_poll} -w 20 \
0.0.0.0 >/dev/null &
-mptcp_lib_wait_local_port_listen $ns 10001
+mptcp_lib_wait_local_port_listen $ns1 10001
echo "b" | \
timeout ${timeout_test} \
- ip netns exec $ns \
+ ip netns exec $ns1 \
./mptcp_connect -p 10001 -r 0 -t ${timeout_poll} -w 20 \
127.0.0.1 >/dev/null &
-wait_connected $ns 10001
+wait_connected $ns1 10001
chk_msk_fallback_nr 1 "check fallback"
chk_msk_inuse 1 "....chk 1 msk in use"
flush_pids
@@ -245,16 +245,16 @@ NR_CLIENTS=100
for I in `seq 1 $NR_CLIENTS`; do
echo "a" | \
timeout ${timeout_test} \
- ip netns exec $ns \
+ ip netns exec $ns1 \
./mptcp_connect -p $((I+10001)) -l -w 20 \
-t ${timeout_poll} 0.0.0.0 >/dev/null &
done
-mptcp_lib_wait_local_port_listen $ns $((NR_CLIENTS + 10001))
+mptcp_lib_wait_local_port_listen $ns1 $((NR_CLIENTS + 10001))
for I in `seq 1 $NR_CLIENTS`; do
echo "b" | \
timeout ${timeout_test} \
- ip netns exec $ns \
+ ip netns exec $ns1 \
./mptcp_connect -p $((I+10001)) -w 20 \
-t ${timeout_poll} 127.0.0.1 >/dev/null &
done
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
index c643872ddf47..3008f15c04f9 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
@@ -18,7 +18,7 @@ sec=$(date +%s)
rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
ns1="ns1-$rndh"
ns2="ns2-$rndh"
-ns_sbox="ns_sbox-$rndh"
+ns3="ns3-$rndh"
add_mark_rules()
{
@@ -41,7 +41,7 @@ add_mark_rules()
init()
{
local netns
- for netns in "$ns1" "$ns2" "$ns_sbox";do
+ for netns in "$ns1" "$ns2" "$ns3";do
ip netns add $netns || exit $ksft_skip
ip -net $netns link set lo up
ip netns exec $netns sysctl -q net.mptcp.enabled=1
@@ -80,7 +80,7 @@ init()
cleanup()
{
local netns
- for netns in "$ns1" "$ns2" "$ns_sbox"; do
+ for netns in "$ns1" "$ns2" "$ns3"; do
ip netns del $netns
done
rm -f "$cin" "$cout"
@@ -240,7 +240,7 @@ do_mptcp_sockopt_tests()
return
fi
- ip netns exec "$ns_sbox" ./mptcp_sockopt
+ ip netns exec "$ns3" ./mptcp_sockopt
lret=$?
if [ $lret -ne 0 ]; then
@@ -251,7 +251,7 @@ do_mptcp_sockopt_tests()
fi
mptcp_lib_result_pass "sockopt v4"
- ip netns exec "$ns_sbox" ./mptcp_sockopt -6
+ ip netns exec "$ns3" ./mptcp_sockopt -6
lret=$?
if [ $lret -ne 0 ]; then
@@ -282,7 +282,7 @@ run_tests()
do_tcpinq_test()
{
- ip netns exec "$ns_sbox" ./mptcp_inq "$@"
+ ip netns exec "$ns3" ./mptcp_inq "$@"
local lret=$?
if [ $lret -ne 0 ];then
ret=$lret
diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh
index ae8ad5d6fb9d..6fc0e08985d2 100755
--- a/tools/testing/selftests/net/mptcp/simult_flows.sh
+++ b/tools/testing/selftests/net/mptcp/simult_flows.sh
@@ -12,7 +12,7 @@ capture=false
ksft_skip=4
timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1))
-test_cnt=1
+TEST_COUNT=1
ret=0
bail=0
slack=50
@@ -129,8 +129,8 @@ do_transfer()
local sin=$2
local max_time=$3
local port
- port=$((10000+$test_cnt))
- test_cnt=$((test_cnt+1))
+ port=$((10000+$TEST_COUNT))
+ TEST_COUNT=$((TEST_COUNT+1))
:> "$cout"
:> "$sout"
diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh
index 5921589f0db9..601421ed4e49 100755
--- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
+++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
@@ -49,7 +49,7 @@ rndh=$(printf %x "$sec")-$(mktemp -u XXXXXX)
ns1="ns1-$rndh"
ns2="ns2-$rndh"
ret=0
-test_name=""
+TEST_NAME=""
_printf() {
stdbuf -o0 -e0 printf "${@}"
@@ -63,9 +63,9 @@ print_title()
# $1: test name
print_test()
{
- test_name="${1}"
+ TEST_NAME="${1}"
- _printf "%-63s" "${test_name}"
+ _printf "%-63s" "${TEST_NAME}"
}
print_results()
@@ -76,13 +76,13 @@ print_results()
test_pass()
{
print_results " OK "
- mptcp_lib_result_pass "${test_name}"
+ mptcp_lib_result_pass "${TEST_NAME}"
}
test_skip()
{
print_results "SKIP"
- mptcp_lib_result_skip "${test_name}"
+ mptcp_lib_result_skip "${TEST_NAME}"
}
# $1: msg
@@ -95,7 +95,7 @@ test_fail()
_printf "\t%s\n" "${1}"
fi
- mptcp_lib_result_fail "${test_name}"
+ mptcp_lib_result_fail "${TEST_NAME}"
}
# This function is used in the cleanup trap
--
2.35.3