[LTP] [RFC PATCH v7 03/11] network/stress: Simplify make_background_tcp_traffic usage

Petr Vorel
2017-07-25T10:12:26Z

Hi Alexey,

> > - 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

> Does 'make_background_tcp_traffic()' function check that background
> traffic is not running already?

Sure, I just moved your pgrep check into function (it's in the same commit):
make_background_tcp_traffic()
{
pgrep -x netstress > /dev/null && return

local port=$(tst_get_unused_port ipv${ipver} stream)
local ip="${1:-$(tst_ipaddr)}"

netstress -R 3 -g $port > /dev/null 2>&1 &
tst_rhost_run -s -c "netstress -l -H $ip -g $port"
}

Kind regards,
Petr