Message ID | 20240415162530.3594670-6-jiri@resnulli.us (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | selftests: virtio_net: introduce initial testing infrastructure | expand |
On 2024-04-15 18:25 +0200, Jiri Pirko wrote: > From: Jiri Pirko <jiri@nvidia.com> > > 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> > --- > v1->v2: > - reworked wait_for_dev() helper to use slowwait() helper > --- > tools/testing/selftests/net/forwarding/lib.sh | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh > index 254698c6ba56..e85b361dc85d 100644 > --- a/tools/testing/selftests/net/forwarding/lib.sh > +++ b/tools/testing/selftests/net/forwarding/lib.sh > @@ -746,6 +746,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 up &> /dev/null Sorry, I just noticed that this includes the "up" flag. I was confused for a while until I realized that `ip` returns success even if the interface is not up: # ip link set dev eth1 down # ip link show dev eth1 up # echo $? 0 So wait_for_dev() really does just wait for the device to appear, not for it to be up. If you agree, please remove the 'up' keyword to avoid confusion.
Mon, Apr 15, 2024 at 11:39:42PM CEST, benjamin.poirier@gmail.com wrote: >On 2024-04-15 18:25 +0200, Jiri Pirko wrote: >> From: Jiri Pirko <jiri@nvidia.com> >> >> 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> >> --- >> v1->v2: >> - reworked wait_for_dev() helper to use slowwait() helper >> --- >> tools/testing/selftests/net/forwarding/lib.sh | 13 +++++++++++++ >> 1 file changed, 13 insertions(+) >> >> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh >> index 254698c6ba56..e85b361dc85d 100644 >> --- a/tools/testing/selftests/net/forwarding/lib.sh >> +++ b/tools/testing/selftests/net/forwarding/lib.sh >> @@ -746,6 +746,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 up &> /dev/null > >Sorry, I just noticed that this includes the "up" flag. I was confused >for a while until I realized that `ip` returns success even if the >interface is not up: > ># ip link set dev eth1 down ># ip link show dev eth1 up ># echo $? >0 > >So wait_for_dev() really does just wait for the device to appear, not >for it to be up. If you agree, please remove the 'up' keyword to avoid >confusion. That is the intension :) I don't care about it being up, I just need to have it in the system.
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 254698c6ba56..e85b361dc85d 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -746,6 +746,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 up &> /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