diff options
author | Darren Tucker <dtucker@cvs.openbsd.org> | 2012-09-10 01:51:20 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@cvs.openbsd.org> | 2012-09-10 01:51:20 +0000 |
commit | 7a10f57313678474bbea7dac7a1da9438bbcd6e0 (patch) | |
tree | 6f898185e7a32001a0c6e93ab02a845e89d81e41 /regress/usr.bin | |
parent | eb744d9d40f02414d35437f9ef397b127027955b (diff) |
use -Ocheck and waiting for completions by PID to make multiplexing test
less racy and (hopefully) more reliable on slow hardware.
Diffstat (limited to 'regress/usr.bin')
-rw-r--r-- | regress/usr.bin/ssh/multiplex.sh | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/regress/usr.bin/ssh/multiplex.sh b/regress/usr.bin/ssh/multiplex.sh index 9eaf3eaf877..2bb8e30b647 100644 --- a/regress/usr.bin/ssh/multiplex.sh +++ b/regress/usr.bin/ssh/multiplex.sh @@ -1,4 +1,4 @@ -# $OpenBSD: multiplex.sh,v 1.15 2012/09/10 00:49:21 dtucker Exp $ +# $OpenBSD: multiplex.sh,v 1.16 2012/09/10 01:51:19 dtucker Exp $ # Placed in the Public Domain. CTL=$OBJ/ctl-sock @@ -8,14 +8,22 @@ tid="connection multiplexing" DATA=/bin/ls COPY=$OBJ/ls.copy +wait_for_mux_master_ready() +{ + for i in 1 2 3 4 5; do + ${SSH} -F $OBJ/ssh_config -S $CTL -Ocheck otherhost \ + >/dev/null 2>&1 && return 0 + sleep $i + done + fatal "mux master never becomes ready" +} + start_sshd trace "start master, fork to background" ${SSH} -Nn2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" somehost & MASTER_PID=$! - -# Wait for master to start and authenticate -sleep 5 +wait_for_mux_master_ready verbose "test $tid: envpass" trace "env passing over multiplexed connection" @@ -82,21 +90,26 @@ ${SSH} -F $OBJ/ssh_config -S $CTL -Oexit otherhost >>$TEST_SSH_LOGFILE 2>&1 \ || fail "send exit command failed" # Wait for master to exit -sleep 2 - +wait $MASTER_PID ps -p $MASTER_PID >/dev/null && fail "exit command failed" # Restart master and test -O stop command with master using -N -trace "start master, fork to background" +verbose "test $tid: cmd stop" +trace "restart master, fork to background" ${SSH} -Nn2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" somehost & MASTER_PID=$! -sleep 5 # Wait for master to start and authenticate -verbose "test $tid: cmd stop" -${SSH} -F $OBJ/ssh_config -S $CTL otherhost "sleep 10; exit 0" & +wait_for_mux_master_ready + +# start a long-running command then immediately request a stop +${SSH} -F $OBJ/ssh_config -S $CTL otherhost "sleep 10; exit 0" \ + >>$TEST_SSH_LOGFILE 2>&1 & SLEEP_PID=$! ${SSH} -F $OBJ/ssh_config -S $CTL -Ostop otherhost >>$TEST_SSH_LOGFILE 2>&1 \ || fail "send stop command failed" -sleep 12 # Wait for master to exit + +# wait until both long-running command and master have exited. wait $SLEEP_PID -[ $! != 0 ] || fail "stop with concurrent command" +[ $! != 0 ] || fail "waiting for concurrent command" +wait $MASTER_PID +[ $! != 0 ] || fail "waiting for master stop" ps -p $MASTER_PID >/dev/null && fail "stop command failed" |