]> andersk Git - openssh.git/blame - regress/multiplex.sh
- djm@cvs.openbsd.org 2010/01/13 01:40:16
[openssh.git] / regress / multiplex.sh
CommitLineData
cbc2c3e5 1# $OpenBSD: multiplex.sh,v 1.12 2009/05/05 07:51:36 dtucker Exp $
00995aa0 2# Placed in the Public Domain.
3
faf685a9 4CTL=/tmp/openssh.regress.ctl-sock.$$
00995aa0 5
6tid="connection multiplexing"
7
3b4e535d 8if grep "#define.*DISABLE_FD_PASSING" ${BUILDDIR}/config.h >/dev/null 2>&1
9then
10 echo "skipped (not supported on this platform)"
11 exit 0
12fi
13
b066fabe 14DATA=/bin/ls${EXEEXT}
00e612c7 15COPY=$OBJ/ls.copy
83154755 16LOG=$TEST_SSH_LOGFILE
00e612c7 17
00995aa0 18start_sshd
19
20trace "start master, fork to background"
a1c3731b 21${SSH} -Nn2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" somehost &
22MASTER_PID=$!
23
24# Wait for master to start and authenticate
25sleep 5
00995aa0 26
b9a59b74 27verbose "test $tid: envpass"
28trace "env passing over multiplexed connection"
cbc2c3e5 29_XXX_TEST=blah ${SSH} -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" -S$CTL otherhost sh << 'EOF'
cb19b709 30 test X"$_XXX_TEST" = X"blah"
31EOF
b9a59b74 32if [ $? -ne 0 ]; then
33 fail "environment not found"
34fi
35
36verbose "test $tid: transfer"
00e612c7 37rm -f ${COPY}
00995aa0 38trace "ssh transfer over multiplexed connection and check result"
cbc2c3e5 39${SSH} -F $OBJ/ssh_config -S$CTL otherhost cat ${DATA} > ${COPY}
c031f95b 40test -f ${COPY} || fail "ssh -Sctl: failed copy ${DATA}"
41cmp ${DATA} ${COPY} || fail "ssh -Sctl: corrupted copy of ${DATA}"
00995aa0 42
00e612c7 43rm -f ${COPY}
00995aa0 44trace "ssh transfer over multiplexed connection and check result"
cbc2c3e5 45${SSH} -F $OBJ/ssh_config -S $CTL otherhost cat ${DATA} > ${COPY}
c031f95b 46test -f ${COPY} || fail "ssh -S ctl: failed copy ${DATA}"
47cmp ${DATA} ${COPY} || fail "ssh -S ctl: corrupted copy of ${DATA}"
00995aa0 48
00e612c7 49rm -f ${COPY}
00995aa0 50trace "sftp transfer over multiplexed connection and check result"
00e612c7 51echo "get ${DATA} ${COPY}" | \
cbc2c3e5 52 ${SFTP} -S ${SSH} -F $OBJ/ssh_config -oControlPath=$CTL otherhost >$LOG 2>&1
c031f95b 53test -f ${COPY} || fail "sftp: failed copy ${DATA}"
54cmp ${DATA} ${COPY} || fail "sftp: corrupted copy of ${DATA}"
00995aa0 55
00e612c7 56rm -f ${COPY}
00995aa0 57trace "scp transfer over multiplexed connection and check result"
cbc2c3e5 58${SCP} -S ${SSH} -F $OBJ/ssh_config -oControlPath=$CTL otherhost:${DATA} ${COPY} >$LOG 2>&1
c031f95b 59test -f ${COPY} || fail "scp: failed copy ${DATA}"
60cmp ${DATA} ${COPY} || fail "scp: corrupted copy of ${DATA}"
00995aa0 61
00e612c7 62rm -f ${COPY}
58766d34 63
00995aa0 64for s in 0 1 4 5 44; do
65 trace "exit status $s over multiplexed connection"
66 verbose "test $tid: status $s"
cbc2c3e5 67 ${SSH} -F $OBJ/ssh_config -S $CTL otherhost exit $s
00995aa0 68 r=$?
69 if [ $r -ne $s ]; then
70 fail "exit code mismatch for protocol $p: $r != $s"
71 fi
72
73 # same with early close of stdout/err
74 trace "exit status $s with early close over multiplexed connection"
cbc2c3e5 75 ${SSH} -F $OBJ/ssh_config -S $CTL -n otherhost \
00995aa0 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"
80 fi
81done
82
a1c3731b 83trace "test check command"
cbc2c3e5 84${SSH} -F $OBJ/ssh_config -S $CTL -Ocheck otherhost || fail "check command failed"
a1c3731b 85
86trace "test exit command"
cbc2c3e5 87${SSH} -F $OBJ/ssh_config -S $CTL -Oexit otherhost || fail "send exit command failed"
a1c3731b 88
89# Wait for master to exit
90sleep 2
91
a8539f66 92kill -0 $MASTER_PID >/dev/null 2>&1 && fail "exit command failed"
This page took 0.147842 seconds and 5 git commands to generate.