- dtucker@cvs.openbsd.org 2010/01/08 21:50:49
[openssh-git.git] / regress / multiplex.sh
blob8a98a6e540264939e3d681d59adb69346b91dbc1
1 # $OpenBSD: multiplex.sh,v 1.12 2009/05/05 07:51:36 dtucker Exp $
2 # Placed in the Public Domain.
4 CTL=/tmp/openssh.regress.ctl-sock.$$
6 tid="connection multiplexing"
8 if grep "#define.*DISABLE_FD_PASSING" ${BUILDDIR}/config.h >/dev/null 2>&1
9 then
10 echo "skipped (not supported on this platform)"
11 exit 0
14 DATA=/bin/ls${EXEEXT}
15 COPY=$OBJ/ls.copy
16 LOG=$TEST_SSH_LOGFILE
18 start_sshd
20 trace "start master, fork to background"
21 ${SSH} -Nn2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" somehost &
22 MASTER_PID=$!
24 # Wait for master to start and authenticate
25 sleep 5
27 verbose "test $tid: envpass"
28 trace "env passing over multiplexed connection"
29 _XXX_TEST=blah ${SSH} -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" -S$CTL otherhost sh << 'EOF'
30 test X"$_XXX_TEST" = X"blah"
31 EOF
32 if [ $? -ne 0 ]; then
33 fail "environment not found"
36 verbose "test $tid: transfer"
37 rm -f ${COPY}
38 trace "ssh transfer over multiplexed connection and check result"
39 ${SSH} -F $OBJ/ssh_config -S$CTL otherhost cat ${DATA} > ${COPY}
40 test -f ${COPY} || fail "ssh -Sctl: failed copy ${DATA}"
41 cmp ${DATA} ${COPY} || fail "ssh -Sctl: corrupted copy of ${DATA}"
43 rm -f ${COPY}
44 trace "ssh transfer over multiplexed connection and check result"
45 ${SSH} -F $OBJ/ssh_config -S $CTL otherhost cat ${DATA} > ${COPY}
46 test -f ${COPY} || fail "ssh -S ctl: failed copy ${DATA}"
47 cmp ${DATA} ${COPY} || fail "ssh -S ctl: corrupted copy of ${DATA}"
49 rm -f ${COPY}
50 trace "sftp transfer over multiplexed connection and check result"
51 echo "get ${DATA} ${COPY}" | \
52 ${SFTP} -S ${SSH} -F $OBJ/ssh_config -oControlPath=$CTL otherhost >$LOG 2>&1
53 test -f ${COPY} || fail "sftp: failed copy ${DATA}"
54 cmp ${DATA} ${COPY} || fail "sftp: corrupted copy of ${DATA}"
56 rm -f ${COPY}
57 trace "scp transfer over multiplexed connection and check result"
58 ${SCP} -S ${SSH} -F $OBJ/ssh_config -oControlPath=$CTL otherhost:${DATA} ${COPY} >$LOG 2>&1
59 test -f ${COPY} || fail "scp: failed copy ${DATA}"
60 cmp ${DATA} ${COPY} || fail "scp: corrupted copy of ${DATA}"
62 rm -f ${COPY}
64 for s in 0 1 4 5 44; do
65 trace "exit status $s over multiplexed connection"
66 verbose "test $tid: status $s"
67 ${SSH} -F $OBJ/ssh_config -S $CTL otherhost exit $s
68 r=$?
69 if [ $r -ne $s ]; then
70 fail "exit code mismatch for protocol $p: $r != $s"
73 # same with early close of stdout/err
74 trace "exit status $s with early close over multiplexed connection"
75 ${SSH} -F $OBJ/ssh_config -S $CTL -n otherhost \
76 exec sh -c \'"sleep 2; exec > /dev/null 2>&1; sleep 3; exit $s"\'
77 r=$?
78 if [ $r -ne $s ]; then
79 fail "exit code (with sleep) mismatch for protocol $p: $r != $s"
81 done
83 trace "test check command"
84 ${SSH} -F $OBJ/ssh_config -S $CTL -Ocheck otherhost || fail "check command failed"
86 trace "test exit command"
87 ${SSH} -F $OBJ/ssh_config -S $CTL -Oexit otherhost || fail "send exit command failed"
89 # Wait for master to exit
90 sleep 2
92 kill -0 $MASTER_PID >/dev/null 2>&1 && fail "exit command failed"