diff options
Diffstat (limited to 'regress/multiplex.sh')
-rw-r--r-- | regress/multiplex.sh | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/regress/multiplex.sh b/regress/multiplex.sh index 93e15088f..1e6cc7606 100644 --- a/regress/multiplex.sh +++ b/regress/multiplex.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: multiplex.sh,v 1.13 2012/06/01 00:47:36 djm Exp $ | 1 | # $OpenBSD: multiplex.sh,v 1.17 2012/10/05 02:05:30 dtucker Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | CTL=/tmp/openssh.regress.ctl-sock.$$ | 4 | CTL=/tmp/openssh.regress.ctl-sock.$$ |
@@ -13,14 +13,22 @@ fi | |||
13 | DATA=/bin/ls${EXEEXT} | 13 | DATA=/bin/ls${EXEEXT} |
14 | COPY=$OBJ/ls.copy | 14 | COPY=$OBJ/ls.copy |
15 | 15 | ||
16 | wait_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 | |||
16 | start_sshd | 26 | start_sshd |
17 | 27 | ||
18 | trace "start master, fork to background" | 28 | trace "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 & |
20 | MASTER_PID=$! | 30 | MASTER_PID=$! |
21 | 31 | wait_for_mux_master_ready | |
22 | # Wait for master to start and authenticate | ||
23 | sleep 5 | ||
24 | 32 | ||
25 | verbose "test $tid: envpass" | 33 | verbose "test $tid: envpass" |
26 | trace "env passing over multiplexed connection" | 34 | trace "env passing over multiplexed connection" |
@@ -78,13 +86,35 @@ for s in 0 1 4 5 44; do | |||
78 | fi | 86 | fi |
79 | done | 87 | done |
80 | 88 | ||
81 | trace "test check command" | 89 | verbose "test $tid: cmd check" |
82 | ${SSH} -F $OBJ/ssh_config -S $CTL -Ocheck otherhost || fail "check command failed" | 90 | ${SSH} -F $OBJ/ssh_config -S $CTL -Ocheck otherhost >>$TEST_SSH_LOGFILE 2>&1 \ |
91 | || fail "check command failed" | ||
83 | 92 | ||
84 | trace "test exit command" | 93 | verbose "test $tid: cmd exit" |
85 | ${SSH} -F $OBJ/ssh_config -S $CTL -Oexit otherhost || fail "send exit command failed" | 94 | ${SSH} -F $OBJ/ssh_config -S $CTL -Oexit otherhost >>$TEST_SSH_LOGFILE 2>&1 \ |
95 | || fail "send exit command failed" | ||
86 | 96 | ||
87 | # Wait for master to exit | 97 | # Wait for master to exit |
88 | sleep 2 | 98 | wait $MASTER_PID |
99 | kill -0 $MASTER_PID >/dev/null 2>&1 && fail "exit command failed" | ||
89 | 100 | ||
90 | kill -0 $MASTER_PID >/dev/null 2>&1 && fail "exit command failed" | 101 | # Restart master and test -O stop command with master using -N |
102 | verbose "test $tid: cmd stop" | ||
103 | trace "restart master, fork to background" | ||
104 | ${SSH} -Nn2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" somehost & | ||
105 | MASTER_PID=$! | ||
106 | wait_for_mux_master_ready | ||
107 | |||
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 & | ||
111 | SLEEP_PID=$! | ||
112 | ${SSH} -F $OBJ/ssh_config -S $CTL -Ostop otherhost >>$TEST_SSH_LOGFILE 2>&1 \ | ||
113 | || fail "send stop command failed" | ||
114 | |||
115 | # wait until both long-running command and master have exited. | ||
116 | wait $SLEEP_PID | ||
117 | [ $! != 0 ] || fail "waiting for concurrent command" | ||
118 | wait $MASTER_PID | ||
119 | [ $! != 0 ] || fail "waiting for master stop" | ||
120 | kill -0 $MASTER_PID >/dev/null 2>&1 && fail "stop command failed" | ||