From: Jiri Pirko Date: Wed, 24 Apr 2024 10:40:48 +0000 (+0200) Subject: selftests: forwarding: add wait_for_dev() helper X-Git-Tag: microblaze-v6.13~1163^2~146^2~1 X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=dae9dd5fd9f35f0e57599148d3655e9d473c8e24;p=linux-2.6-microblaze.git selftests: forwarding: add wait_for_dev() helper The existing setup_wait*() helper family check the status of the interface to be up. Introduce wait_for_dev() to wait for the netdevice to appear, for example after test script does manual device bind. Signed-off-by: Jiri Pirko Reviewed-by: Petr Machata Reviewed-by: Benjamin Poirier Signed-off-by: Paolo Abeni --- diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 2d57912d3973..3353a1745946 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -738,6 +738,19 @@ setup_wait() sleep $WAIT_TIME } +wait_for_dev() +{ + local dev=$1; shift + local timeout=${1:-$WAIT_TIMEOUT}; shift + + slowwait $timeout ip link show dev $dev &> /dev/null + if (( $? )); then + check_err 1 + log_test wait_for_dev "Interface $dev did not appear." + exit $EXIT_STATUS + fi +} + cmd_jq() { local cmd=$1