]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: forwarding: add wait_for_dev() helper
authorJiri Pirko <jiri@nvidia.com>
Wed, 24 Apr 2024 10:40:48 +0000 (12:40 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Fri, 26 Apr 2024 11:26:53 +0000 (13:26 +0200)
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 <jiri@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
tools/testing/selftests/net/forwarding/lib.sh

index 2d57912d39735c21ddaa18f1c8421ceacfa29fe3..3353a17459465f5deda2ddd42677164218b95cb1 100644 (file)
@@ -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