[LTP] [RFC PATCH v9 3/7] network/stress: Simplify make_background_tcp_traffic usage
Petr Vorel
pvorel@suse.cz
Fri Aug 25 01:44:32 CEST 2017
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/network/stress/interface/if-addr-adddel | 6 +-----
testcases/network/stress/interface/if-addr-addlarge | 6 +-----
testcases/network/stress/interface/if-mtu-change | 7 ++-----
testcases/network/stress/interface/if-route-adddel | 7 ++-----
testcases/network/stress/interface/if-route-addlarge | 6 +-----
testcases/network/stress/ns-tools/test_net_stress.sh | 2 ++
6 files changed, 9 insertions(+), 25 deletions(-)
diff --git a/testcases/network/stress/interface/if-addr-adddel b/testcases/network/stress/interface/if-addr-adddel
index 42c2d5afa..3b1ab50bb 100644
--- a/testcases/network/stress/interface/if-addr-adddel
+++ b/testcases/network/stress/interface/if-addr-adddel
@@ -53,10 +53,9 @@ test_body()
return
fi
- make_background_tcp_traffic
-
local cnt=1
while [ $cnt -le $NS_TIMES ]; do
+ make_background_tcp_traffic
case $cmd_type in
if_cmd)
@@ -85,9 +84,6 @@ test_body()
cnt=$(($cnt + 1))
- # Check the background TCP traffic
- pgrep -x netstress > /dev/null || make_background_tcp_traffic
-
case $cmd_type in
if_cmd)
if [ "$TST_IPV6" ]; then
diff --git a/testcases/network/stress/interface/if-addr-addlarge b/testcases/network/stress/interface/if-addr-addlarge
index e667d9138..c3cdb8fa9 100644
--- a/testcases/network/stress/interface/if-addr-addlarge
+++ b/testcases/network/stress/interface/if-addr-addlarge
@@ -47,8 +47,6 @@ test_body()
return
fi
- make_background_tcp_traffic
-
local x=1
local y=1
local cnt=1
@@ -61,6 +59,7 @@ test_body()
fi
while [ $cnt -le $IP_TOTAL ]; do
+ make_background_tcp_traffic
if [ "$TST_IPV6" ]; then
local hex_x=$(printf '%x' $x)
@@ -95,9 +94,6 @@ test_body()
check_connectivity_interval $cnt || return
- # Check the background TCP traffic
- pgrep -x netstress > /dev/null || make_background_tcp_traffic
-
case $cmd_type in
if_cmd)
if [ "$TST_IPV6" ]; then
diff --git a/testcases/network/stress/interface/if-mtu-change b/testcases/network/stress/interface/if-mtu-change
index 03e6ba9d6..9a13e4f43 100644
--- a/testcases/network/stress/interface/if-mtu-change
+++ b/testcases/network/stress/interface/if-mtu-change
@@ -62,8 +62,6 @@ test_body()
tst_resm TINFO "'$cmd_name changes MTU $MTU_CHANGE_TIMES times" \
"every $CHANGE_INTERVAL seconds"
- make_background_tcp_traffic
-
mtu_array_len=$(echo $CHANGE_VALUES | wc -w)
local cnt=0
while [ $cnt -lt $MTU_CHANGE_TIMES ]; do
@@ -73,6 +71,8 @@ test_body()
mtu=$(echo $CHANGE_VALUES | cut -d ' ' -f $field)
[ $cnt -eq $MTU_CHANGE_TIMES ] && mtu="$saved_mtu"
+ make_background_tcp_traffic
+
tst_resm TINFO "set MTU to $mtu $cnt/$MTU_CHANGE_TIMES"
local ret=0
case $cmd_type in
@@ -92,9 +92,6 @@ test_body()
tst_sleep $CHANGE_INTERVAL
EXPECT_PASS tst_ping $(tst_ipaddr) $(tst_ipaddr rhost) "1 1000 65507"
-
- # Check the background TCP traffic
- pgrep -x netstress > /dev/null || make_background_tcp_traffic
done
}
diff --git a/testcases/network/stress/interface/if-route-adddel b/testcases/network/stress/interface/if-route-adddel
index e207c5d79..64366fc52 100644
--- a/testcases/network/stress/interface/if-route-adddel
+++ b/testcases/network/stress/interface/if-route-adddel
@@ -57,10 +57,10 @@ test_body()
return
fi
- make_background_tcp_traffic
-
local cnt=1
while [ $cnt -le $NS_TIMES ]; do
+ make_background_tcp_traffic
+
case $cmd_type in
rt_cmd) route -A $inet add ${new_rt}${opt_rt} dev $iface ;;
ip_cmd) ip route add ${new_rt}${opt_rt} dev $iface ;;
@@ -81,9 +81,6 @@ test_body()
check_connectivity_interval $cnt || return
- # Check the background TCP traffic
- pgrep -x netstress > /dev/null || make_background_tcp_traffic
-
cnt=$(($cnt + 1))
done
diff --git a/testcases/network/stress/interface/if-route-addlarge b/testcases/network/stress/interface/if-route-addlarge
index 3337b7225..b7e6952c2 100644
--- a/testcases/network/stress/interface/if-route-addlarge
+++ b/testcases/network/stress/interface/if-route-addlarge
@@ -54,8 +54,6 @@ test_body()
return
fi
- make_background_tcp_traffic
-
local x=1
local y=1
local cnt=1
@@ -68,6 +66,7 @@ test_body()
fi
while [ $cnt -le $ROUTE_TOTAL ]; do
+ make_background_tcp_traffic
if [ "$TST_IPV6" ]; then
local hex_x=$(printf '%x' $x)
@@ -88,9 +87,6 @@ test_body()
check_connectivity_interval $cnt || return
- # Check the background TCP traffic
- pgrep -x netstress > /dev/null || make_background_tcp_traffic
-
cnt=$(($cnt + 1))
y=$(($y + 1))
if [ $y -gt $xymax ]; then
diff --git a/testcases/network/stress/ns-tools/test_net_stress.sh b/testcases/network/stress/ns-tools/test_net_stress.sh
index 065bc666f..472524731 100644
--- a/testcases/network/stress/ns-tools/test_net_stress.sh
+++ b/testcases/network/stress/ns-tools/test_net_stress.sh
@@ -128,6 +128,8 @@ check_connectivity_interval()
# IP: server IP; Default value is $(tst_ipaddr).
make_background_tcp_traffic()
{
+ pgrep -x netstress > /dev/null && return
+
local ip="${1:-$(tst_ipaddr)}"
local port=$(tst_get_unused_port ipv${ipver} stream)
--
2.14.0
More information about the ltp
mailing list