summaryrefslogtreecommitdiff
path: root/regress/multiplex.sh
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2012-10-05 12:04:10 +1000
committerDarren Tucker <dtucker@zip.com.au>2012-10-05 12:04:10 +1000
commitee4ad778d778c8a19c763738a0851afb9c6ccf16 (patch)
treee735869ca9f893b8679877604ecf2620dbadd9ec /regress/multiplex.sh
parent9b2c0360cf7de7b460f1740b4eb247c27da4630f (diff)
- dtucker@cvs.openbsd.org 2012/09/10 01:51:19
[regress/multiplex.sh] 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/multiplex.sh')
-rw-r--r--regress/multiplex.sh41
1 files changed, 27 insertions, 14 deletions
diff --git a/regress/multiplex.sh b/regress/multiplex.sh
index 9169656dd..f93ac9a41 100644
--- a/regress/multiplex.sh
+++ b/regress/multiplex.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: multiplex.sh,v 1.15 2012/09/10 00:49:21 dtucker Exp $ 1# $OpenBSD: multiplex.sh,v 1.16 2012/09/10 01:51:19 dtucker 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.$$
@@ -13,14 +13,22 @@ fi
13DATA=/bin/ls${EXEEXT} 13DATA=/bin/ls${EXEEXT}
14COPY=$OBJ/ls.copy 14COPY=$OBJ/ls.copy
15 15
16wait_for_mux_master_ready()
17{
18 for i in 1 2 3 4 5; do
19 ${SSH} -F $OBJ/ssh_config -S $CTL -Ocheck otherhost \
20 >/dev/null 2>&1 && return 0
21 sleep $i
22 done
23 fatal "mux master never becomes ready"
24}
25
16start_sshd 26start_sshd
17 27
18trace "start master, fork to background" 28trace "start master, fork to background"
19${SSH} -Nn2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" somehost & 29${SSH} -Nn2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" somehost &
20MASTER_PID=$! 30MASTER_PID=$!
21 31wait_for_mux_master_ready
22# Wait for master to start and authenticate
23sleep 5
24 32
25verbose "test $tid: envpass" 33verbose "test $tid: envpass"
26trace "env passing over multiplexed connection" 34trace "env passing over multiplexed connection"
@@ -87,21 +95,26 @@ ${SSH} -F $OBJ/ssh_config -S $CTL -Oexit otherhost >>$TEST_SSH_LOGFILE 2>&1 \
87 || fail "send exit command failed" 95 || fail "send exit command failed"
88 96
89# Wait for master to exit 97# Wait for master to exit
90sleep 2 98wait $MASTER_PID
91 99kill -0 $MASTER_PID >/dev/null && fail "exit command failed"
92kill -0 $MASTER_PID >/dev/null 2>&1 && fail "exit command failed"
93 100
94# Restart master and test -O stop command with master using -N 101# Restart master and test -O stop command with master using -N
95trace "start master, fork to background" 102verbose "test $tid: cmd stop"
103trace "restart master, fork to background"
96${SSH} -Nn2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" somehost & 104${SSH} -Nn2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" somehost &
97MASTER_PID=$! 105MASTER_PID=$!
98sleep 5 # Wait for master to start and authenticate 106wait_for_mux_master_ready
99verbose "test $tid: cmd stop" 107
100${SSH} -F $OBJ/ssh_config -S $CTL otherhost "sleep 10; exit 0" & 108# start a long-running command then immediately request a stop
109${SSH} -F $OBJ/ssh_config -S $CTL otherhost "sleep 10; exit 0" \
110 >>$TEST_SSH_LOGFILE 2>&1 &
101SLEEP_PID=$! 111SLEEP_PID=$!
102${SSH} -F $OBJ/ssh_config -S $CTL -Ostop otherhost >>$TEST_SSH_LOGFILE 2>&1 \ 112${SSH} -F $OBJ/ssh_config -S $CTL -Ostop otherhost >>$TEST_SSH_LOGFILE 2>&1 \
103 || fail "send stop command failed" 113 || fail "send stop command failed"
104sleep 12 # Wait for master to exit 114
115# wait until both long-running command and master have exited.
105wait $SLEEP_PID 116wait $SLEEP_PID
106[ $! != 0 ] || fail "stop with concurrent command" 117[ $! != 0 ] || fail "waiting for concurrent command"
107ps -p $MASTER_PID >/dev/null && fail "stop command failed" 118wait $MASTER_PID
119[ $! != 0 ] || fail "waiting for master stop"
120kill -0 $MASTER_PID >/dev/null && fail "stop command failed"