From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson To: passt-dev@passt.top Subject: Re: [PATCH 01/12] test: Add wait_for() shell helper Date: Sat, 24 Sep 2022 12:59:48 +1000 Message-ID: In-Reply-To: <20220924010746.6577473f@elisabeth> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4772681815422132476==" --===============4772681815422132476== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Sat, Sep 24, 2022 at 01:07:46AM +0200, Stefano Brivio wrote: > On Fri, 23 Sep 2022 17:20:27 +1000 > David Gibson wrote: >=20 > > Add a shell helper function to wait for some command to succeed - typical= ly > > a test for something to be done by a background process. Use it in the > > context code which waits for the guest to respond to ssh-over-vsock > > connections. > >=20 > > Signed-off-by: David Gibson > > --- > > test/lib/context | 4 +--- > > test/lib/util | 8 ++++++++ > > 2 files changed, 9 insertions(+), 3 deletions(-) > >=20 > > diff --git a/test/lib/context b/test/lib/context > > index 43b00dd..ee6b683 100644 > > --- a/test/lib/context > > +++ b/test/lib/context > > @@ -63,9 +63,7 @@ EOF > > echo "ssh -F ${__ssh} ${__name}" > "${__enter}" > > =20 > > # Wait for the guest to be booted and accepting connections > > - while ! ssh -F "${__ssh}" "${__name}" :; do > > - sleep 0.1 > > - done > > + wait_for ssh -F "${__ssh}" "${__name}" : > > } > > =20 > > # context_teardown() - Remove a context (leave log files intact) > > diff --git a/test/lib/util b/test/lib/util > > index dee6c8d..72023ab 100755 > > --- a/test/lib/util > > +++ b/test/lib/util > > @@ -123,3 +123,11 @@ get_info_cols() { > > __j=3D$((__j + 1)) > > done > > } > > + > > +# wait_for() - Retry a command until it succeeds > > +# $@: Command to run > > +wait_for() { > > + while ! "$@"; do > > + sleep 0.1 >=20 > While at it, could we replace this with sleep 0.1 || sleep 1, just in > case we happen to run in an environment not supporting sleep 0.1? Good idea, I'll respin with that change. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --===============4772681815422132476== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSXpCQUVCQ0FBZEZpRUVvVUx4V3U0L1dz MGRCK1h0Z3lwWTRnRXdZU0lGQW1NdWNwMEFDZ2tRZ3lwWTRnRXcKWVNMNW1nLy9jY3Rac3lGQXh2 R3J5U0pCQWN5UFBnaHZkc1BTU1NlM1BFdy84ODdRR29TOWpweEpUR0d2TUpDdgpwN1BRenNMSVZt bEFzZ0tweUVYKzNxZXlUTGRxUGxwZG1tNWxrN1ZYcENDeDNuZEdzVko0aTJRTHpBRFJxU2VNClZ5 YnJPRVdWbTQvLzBMMDJSTUlmVU14WHR0ak1qYWlWVWV2MmliOGhadDlQSGNmVGk5SUdjWTA5cjVu Z1NKQUwKUWF5QytZTk9WTUNhY2JoM1BvUTBHNWM5aUNBamZnRkRLV21xOXRkYk1IY0lKUjFXR0ht SXpQcU16bEVRUDVUSgp0b2Nrc0ZSMHNzUTRoN041SU53eVBpYytmQjI3ckxtY2kxVUFlQUFBWkdM ckVFd0NncDI5dTUrRDFIaE1nUVAyCmVMMUJRcFYrVC9vVXRUdi9MMHF1ZnpBcGV3bmNOWW1TS0pa OUNPdGpFZU1RRzhmUCtTdmpPM2ZLK2k2T0dudmUKV2VtY1FBaTJkWFlzR09FVStmNnJmcmM4ZW5Q TXJpMHVQRGxCME43RWZFck5WWGxwR2ljS3VvdkJRYnViVGNyagpOS25QMTBpRFRzaEx4OVkvV3dt TjgyM2JrUzB2bVZkclB1ZktWZWtYWjdjYjNxbnJsZjNuYVpra25Gb1dzaDJlCnRVWGgrNmNrZTYr aHAvdkg2R0R1ZTgrZFRXbXI0TllaNEZ4YTl3dW1TWXpyRlBCbjdNQlJuMHlnWkVKcjRYWnYKZjla aGdGWnhuMjBPK3A3QTZuaGpvTC91ZTFmM0oxMHN2R3FhNDZDSFY3VmMvR3g1R2ZwMFRiRWw0NGV2 by9EbQp0Yk9zeng3YXUzNnovTUFvdDNkMks2OFgrN1pLZnJjVkJ1clhvUWU0cU1GSkRabStsQjQ9 Cj1QblBXCi0tLS0tRU5EIFBHUCBTSUdOQVRVUkUtLS0tLQo= --===============4772681815422132476==--