summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2014-07-09 13:22:03 +1000
committerDamien Miller <djm@mindrot.org>2014-07-09 13:22:03 +1000
commit612f965239a30fe536b11ece1834d9f470aeb029 (patch)
tree6c05fe13a46c0b356d76f12af5c2f360208585f1
parentd0bb950485ba121e43a77caf434115ed6417b46f (diff)
- 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)
-rw-r--r--ChangeLog6
-rw-r--r--regress/multiplex.sh17
-rw-r--r--regress/test-exec.sh11
3 files changed, 26 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index d62022871..9d40c3193 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,12 @@
12 [key.c] 12 [key.c]
13 downgrade more error() to debug() to better match what old authfile.c 13 downgrade more error() to debug() to better match what old authfile.c
14 did; suppresses spurious errors with hostbased authentication enabled 14 did; suppresses spurious errors with hostbased authentication enabled
15 - djm@cvs.openbsd.org 2014/07/06 07:42:03
16 [multiplex.sh test-exec.sh]
17 add a hook to the cleanup() function to kill $SSH_PID if it is set
18
19 use it to kill the mux master started in multiplex.sh (it was being left
20 around on fatal failures)
15 21
1620140706 2220140706
17 - OpenBSD CVS Sync 23 - OpenBSD CVS Sync
diff --git a/regress/multiplex.sh b/regress/multiplex.sh
index 3e697e691..bc286b5e9 100644
--- a/regress/multiplex.sh
+++ b/regress/multiplex.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: multiplex.sh,v 1.21 2013/05/17 04:29:14 dtucker Exp $ 1# $OpenBSD: multiplex.sh,v 1.22 2014/07/06 07:42:03 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4CTL=/tmp/openssh.regress.ctl-sock.$$ 4CTL=/tmp/openssh.regress.ctl-sock.$$
@@ -29,7 +29,8 @@ start_mux_master()
29 trace "start master, fork to background" 29 trace "start master, fork to background"
30 ${SSH} -Nn2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" somehost \ 30 ${SSH} -Nn2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" somehost \
31 -E $TEST_REGRESS_LOGFILE 2>&1 & 31 -E $TEST_REGRESS_LOGFILE 2>&1 &
32 MASTER_PID=$! 32 # NB. $SSH_PID will be killed by test-exec.sh:cleanup on fatal errors.
33 SSH_PID=$!
33 wait_for_mux_master_ready 34 wait_for_mux_master_ready
34} 35}
35 36
@@ -44,6 +45,8 @@ if [ $? -ne 0 ]; then
44 fail "environment not found" 45 fail "environment not found"
45fi 46fi
46 47
48fatal ok
49
47verbose "test $tid: transfer" 50verbose "test $tid: transfer"
48rm -f ${COPY} 51rm -f ${COPY}
49trace "ssh transfer over multiplexed connection and check result" 52trace "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
120 || fail "send exit command failed" 123 || fail "send exit command failed"
121 124
122# Wait for master to exit 125# Wait for master to exit
123wait $MASTER_PID 126wait $SSH_PID
124kill -0 $MASTER_PID >/dev/null 2>&1 && fail "exit command failed" 127kill -0 $SSH_PID >/dev/null 2>&1 && fail "exit command failed"
125 128
126# Restart master and test -O stop command with master using -N 129# Restart master and test -O stop command with master using -N
127verbose "test $tid: cmd stop" 130verbose "test $tid: cmd stop"
@@ -138,6 +141,8 @@ ${SSH} -F $OBJ/ssh_config -S $CTL -Ostop otherhost >>$TEST_REGRESS_LOGFILE 2>&1
138# wait until both long-running command and master have exited. 141# wait until both long-running command and master have exited.
139wait $SLEEP_PID 142wait $SLEEP_PID
140[ $! != 0 ] || fail "waiting for concurrent command" 143[ $! != 0 ] || fail "waiting for concurrent command"
141wait $MASTER_PID 144wait $SSH_PID
142[ $! != 0 ] || fail "waiting for master stop" 145[ $! != 0 ] || fail "waiting for master stop"
143kill -0 $MASTER_PID >/dev/null 2>&1 && fail "stop command failed" 146kill -0 $SSH_PID >/dev/null 2>&1 && fatal "stop command failed"
147SSH_PID="" # Already gone, so don't kill in cleanup
148
diff --git a/regress/test-exec.sh b/regress/test-exec.sh
index aac8aa5c2..a1bab832f 100644
--- a/regress/test-exec.sh
+++ b/regress/test-exec.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: test-exec.sh,v 1.47 2013/11/09 05:41:34 dtucker Exp $ 1# $OpenBSD: test-exec.sh,v 1.48 2014/07/06 07:42:03 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4#SUDO=sudo 4#SUDO=sudo
@@ -240,13 +240,20 @@ md5 () {
240# helper 240# helper
241cleanup () 241cleanup ()
242{ 242{
243 if [ "x$SSH_PID" != "x" ]; then
244 if [ $SSH_PID -lt 2 ]; then
245 echo bad pid for ssh: $SSH_PID
246 else
247 kill $SSH_PID
248 fi
249 fi
243 if [ -f $PIDFILE ]; then 250 if [ -f $PIDFILE ]; then
244 pid=`$SUDO cat $PIDFILE` 251 pid=`$SUDO cat $PIDFILE`
245 if [ "X$pid" = "X" ]; then 252 if [ "X$pid" = "X" ]; then
246 echo no sshd running 253 echo no sshd running
247 else 254 else
248 if [ $pid -lt 2 ]; then 255 if [ $pid -lt 2 ]; then
249 echo bad pid for ssh: $pid 256 echo bad pid for sshd: $pid
250 else 257 else
251 $SUDO kill $pid 258 $SUDO kill $pid
252 trace "wait for sshd to exit" 259 trace "wait for sshd to exit"