diff options
author | djm <djm> | 2014-07-09 03:22:03 +0000 |
---|---|---|
committer | djm <djm> | 2014-07-09 03:22:03 +0000 |
commit | 6ef7ecd8a81664b51d79ca35f63fd4c0dea815cc (patch) | |
tree | f0440162c7ccde99222d54d1757c67477c557b3c /regress | |
parent | 19da12bd6ebc6101561a323862d5369fbd53955b (diff) | |
download | openssh-6ef7ecd8a81664b51d79ca35f63fd4c0dea815cc.tar.gz |
- djm@cvs.openbsd.org 2014/07/06 07:42:03
[multiplex.sh test-exec.sh]
add a hook to the cleanup() function to kill $SSH_PID if it is set
use it to kill the mux master started in multiplex.sh (it was being left
around on fatal failures)
Diffstat (limited to 'regress')
-rw-r--r-- | regress/multiplex.sh | 17 | ||||
-rw-r--r-- | regress/test-exec.sh | 11 |
2 files changed, 20 insertions, 8 deletions
diff --git a/regress/multiplex.sh b/regress/multiplex.sh index 3e697e69..bc286b5e 100644 --- a/regress/multiplex.sh +++ b/regress/multiplex.sh @@ -1,4 +1,4 @@ -# $OpenBSD: multiplex.sh,v 1.21 2013/05/17 04:29:14 dtucker Exp $ +# $OpenBSD: multiplex.sh,v 1.22 2014/07/06 07:42:03 djm Exp $ # Placed in the Public Domain. CTL=/tmp/openssh.regress.ctl-sock.$$ @@ -29,7 +29,8 @@ start_mux_master() trace "start master, fork to background" ${SSH} -Nn2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" somehost \ -E $TEST_REGRESS_LOGFILE 2>&1 & - MASTER_PID=$! + # NB. $SSH_PID will be killed by test-exec.sh:cleanup on fatal errors. + SSH_PID=$! wait_for_mux_master_ready } @@ -44,6 +45,8 @@ if [ $? -ne 0 ]; then fail "environment not found" fi +fatal ok + verbose "test $tid: transfer" rm -f ${COPY} trace "ssh transfer over multiplexed connection and check result" @@ -120,8 +123,8 @@ ${SSH} -F $OBJ/ssh_config -S $CTL -Oexit otherhost >>$TEST_REGRESS_LOGFILE 2>&1 || fail "send exit command failed" # Wait for master to exit -wait $MASTER_PID -kill -0 $MASTER_PID >/dev/null 2>&1 && fail "exit command failed" +wait $SSH_PID +kill -0 $SSH_PID >/dev/null 2>&1 && fail "exit command failed" # Restart master and test -O stop command with master using -N verbose "test $tid: cmd stop" @@ -138,6 +141,8 @@ ${SSH} -F $OBJ/ssh_config -S $CTL -Ostop otherhost >>$TEST_REGRESS_LOGFILE 2>&1 # wait until both long-running command and master have exited. wait $SLEEP_PID [ $! != 0 ] || fail "waiting for concurrent command" -wait $MASTER_PID +wait $SSH_PID [ $! != 0 ] || fail "waiting for master stop" -kill -0 $MASTER_PID >/dev/null 2>&1 && fail "stop command failed" +kill -0 $SSH_PID >/dev/null 2>&1 && fatal "stop command failed" +SSH_PID="" # Already gone, so don't kill in cleanup + diff --git a/regress/test-exec.sh b/regress/test-exec.sh index aac8aa5c..a1bab832 100644 --- a/regress/test-exec.sh +++ b/regress/test-exec.sh @@ -1,4 +1,4 @@ -# $OpenBSD: test-exec.sh,v 1.47 2013/11/09 05:41:34 dtucker Exp $ +# $OpenBSD: test-exec.sh,v 1.48 2014/07/06 07:42:03 djm Exp $ # Placed in the Public Domain. #SUDO=sudo @@ -240,13 +240,20 @@ md5 () { # helper cleanup () { + if [ "x$SSH_PID" != "x" ]; then + if [ $SSH_PID -lt 2 ]; then + echo bad pid for ssh: $SSH_PID + else + kill $SSH_PID + fi + fi if [ -f $PIDFILE ]; then pid=`$SUDO cat $PIDFILE` if [ "X$pid" = "X" ]; then echo no sshd running else if [ $pid -lt 2 ]; then - echo bad pid for ssh: $pid + echo bad pid for sshd: $pid else $SUDO kill $pid trace "wait for sshd to exit" |