diff options
author | Darren Tucker <dtucker@cvs.openbsd.org> | 2011-05-20 05:19:51 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@cvs.openbsd.org> | 2011-05-20 05:19:51 +0000 |
commit | 2be2340fa611218ba8705e854853f31db4721818 (patch) | |
tree | ebdd65f4c225c0077e3e77c5dcc8511640cf9e40 /regress/usr.bin | |
parent | 3d41ed1f361d65793c862bc3c75ce7d4fa66d3d1 (diff) |
Prevent races in dynamic forwarding test; ok djm
Diffstat (limited to 'regress/usr.bin')
-rw-r--r-- | regress/usr.bin/ssh/dynamic-forward.sh | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/regress/usr.bin/ssh/dynamic-forward.sh b/regress/usr.bin/ssh/dynamic-forward.sh index 7d93f536704..170fa123ea0 100644 --- a/regress/usr.bin/ssh/dynamic-forward.sh +++ b/regress/usr.bin/ssh/dynamic-forward.sh @@ -1,4 +1,4 @@ -# $OpenBSD: dynamic-forward.sh,v 1.4 2004/06/22 22:55:56 dtucker Exp $ +# $OpenBSD: dynamic-forward.sh,v 1.5 2011/05/20 05:19:50 dtucker Exp $ # Placed in the Public Domain. tid="dynamic forwarding" @@ -19,8 +19,21 @@ start_sshd for p in 1 2; do trace "start dynamic forwarding, fork to background" - ${SSH} -$p -F $OBJ/ssh_config -f -D $FWDPORT -q somehost \ - exec sh -c \'"echo \$\$ > $OBJ/remote_pid; exec sleep 444"\' + rm -f $OBJ/remote_pid + ${SSH} -$p -F $OBJ/ssh_config -D $FWDPORT -q somehost \ + exec sh -c \'"echo \$\$ > $OBJ/remote_pid; exec sleep 444"\' & + client_pid=$! + + # Wait for ssh to start + n=0 + while test ! -f $OBJ/remote_pid; do + sleep 1 + n=`expr $n + 1` + if test $n > 60; then + kill $client_pid + fail "Timed out waiting for client to connect" + fi + done for s in 4 5; do for h in 127.0.0.1 localhost; do @@ -39,7 +52,11 @@ for p in 1 2; do if [ $remote -gt 1 ]; then kill -HUP $remote fi + rm -f $OBJ/remote_pid else fail "no pid file: $OBJ/remote_pid" fi + + # Wait for listening ssh to terminate + wait done |