Skip to content

Commit

Permalink
selftests: forwarding: lib: Split out setup_wait_dev()
Browse files Browse the repository at this point in the history
Split out of setup_wait() a function setup_wait_dev() that waits for a
single device. This gives tests the opportunity to wait for a selected
device after they tinkered with its upness.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Petr Machata authored and David S. Miller committed Jun 30, 2018
1 parent b330219 commit 010079b
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions tools/testing/selftests/net/forwarding/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,25 @@ log_info()
echo "INFO: $msg"
}

setup_wait_dev()
{
local dev=$1; shift

while true; do
ip link show dev $dev up \
| grep 'state UP' &> /dev/null
if [[ $? -ne 0 ]]; then
sleep 1
else
break
fi
done
}

setup_wait()
{
for i in $(eval echo {1..$NUM_NETIFS}); do
while true; do
ip link show dev ${NETIFS[p$i]} up \
| grep 'state UP' &> /dev/null
if [[ $? -ne 0 ]]; then
sleep 1
else
break
fi
done
setup_wait_dev ${NETIFS[p$i]}
done

# Make sure links are ready.
Expand Down

0 comments on commit 010079b

Please sign in to comment.