diff options
author | Stuart Haslam <stuart.haslam@linaro.org> | 2015-03-16 12:27:43 +0000 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2015-03-17 13:01:03 +0300 |
commit | 678923038507d20e7509fdcffb33ab79ab055602 (patch) | |
tree | 6f0ec67666c21d60cb2e2fa4bd083f4ad94d2dd2 /test | |
parent | 071470adf350079bdf68eaf0cc9551455250c74a (diff) |
validation: pktio: prevent race when using veth pair
There's a potential race condition whereby the test case could start
running before the virtual ethernet interfaces are fully brought up.
So replace the the arbitrary delay with a check for the interface's
operational state before kicking off the test.
Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
Reviewed-and-tested-by: Mike Holmes <mike.holmes@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'test')
-rwxr-xr-x | test/validation/odp_pktio_run | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/test/validation/odp_pktio_run b/test/validation/odp_pktio_run index 6177caa0e..204b440e3 100755 --- a/test/validation/odp_pktio_run +++ b/test/validation/odp_pktio_run @@ -34,6 +34,28 @@ IF1=pktio-p1 # exit codes expected by automake for skipped tests TEST_SKIPPED=77 +# wait for a network interface's operational state to be "up" +wait_for_iface_up() +{ + iface=$1 + cnt=0 + + while [ $cnt -lt 50 ]; do + read operstate < /sys/class/net/$iface/operstate + + if [ $? != 0 ]; then + break + elif [ "$operstate" = "up" ]; then + return 0 + fi + + sleep 0.1 + cnt=`expr $cnt + 1` + done + + return 1 +} + setup_env1() { ip link show $IF0 2> /dev/null @@ -61,8 +83,14 @@ setup_env1() ifconfig $IF0 -arp ifconfig $IF1 -arp - # network needs a little time to come up - sleep 1 + # check that the interface has come up before starting the test + for iface in $IF0 $IF1; do + wait_for_iface_up $iface + if [ $? != 0 ]; then + echo "pktio: interface $iface failed to come up" + exit 1 + fi + done } cleanup_env1() |