Message ID | 20240417164554.3651321-6-jiri@resnulli.us (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | selftests: virtio_net: introduce initial testing infrastructure | expand |
Jiri Pirko <jiri@resnulli.us> writes: > 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 edaec12c0575..41c0b0ed430b 100644 > --- a/tools/testing/selftests/net/forwarding/lib.sh > +++ b/tools/testing/selftests/net/forwarding/lib.sh > @@ -745,6 +745,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 I agree with Benjamin's feedback that this should lose the up flag. It looks as if it's waiting for the device to be up. > + if (( $? )); then > + check_err 1 > + log_test wait_for_dev "Interface $dev did not appear." > + exit $EXIT_STATUS > + fi > +} > + > cmd_jq() > { > local cmd=$1
Thu, Apr 18, 2024 at 10:33:13AM CEST, petrm@nvidia.com wrote: > >Jiri Pirko <jiri@resnulli.us> writes: > >> 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 edaec12c0575..41c0b0ed430b 100644 >> --- a/tools/testing/selftests/net/forwarding/lib.sh >> +++ b/tools/testing/selftests/net/forwarding/lib.sh >> @@ -745,6 +745,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 > >I agree with Benjamin's feedback that this should lose the up flag. It >looks as if it's waiting for the device to be up. Ok. > >> + if (( $? )); then >> + check_err 1 >> + log_test wait_for_dev "Interface $dev did not appear." >> + exit $EXIT_STATUS >> + fi >> +} >> + >> cmd_jq() >> { >> local cmd=$1 >
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index edaec12c0575..41c0b0ed430b 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -745,6 +745,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