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