]> andersk Git - openssh.git/blob - regress/multiplex.sh
- (dtucker) [regress/scp.sh] Make this work on Cygwin too, which doesn't like
[openssh.git] / regress / multiplex.sh
1 #       $OpenBSD: multiplex.sh,v 1.8 2004/06/22 03:12:13 markus Exp $
2 #       Placed in the Public Domain.
3
4 CTL=$OBJ/ctl-sock
5
6 tid="connection multiplexing"
7
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
12 fi
13
14 DATA=/bin/ls${EXEEXT}
15 COPY=$OBJ/ls.copy
16
17 start_sshd
18
19 trace "start master, fork to background"
20 ${SSH} -2 -MS$CTL -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" -f somehost sleep 120
21
22 verbose "test $tid: envpass"
23 trace "env passing over multiplexed connection"
24 _XXX_TEST=blah ${SSH} -oSendEnv="_XXX_TEST" -S$CTL otherhost sh << 'EOF'
25         test X"$_XXX_TEST" = X"blah"
26 EOF
27 if [ $? -ne 0 ]; then
28         fail "environment not found"
29 fi
30
31 verbose "test $tid: transfer"
32 rm -f ${COPY}
33 trace "ssh transfer over multiplexed connection and check result"
34 ${SSH} -S$CTL otherhost cat ${DATA} > ${COPY}
35 test -f ${COPY}                 || fail "ssh -Sctl: failed copy ${DATA}" 
36 cmp ${DATA} ${COPY}             || fail "ssh -Sctl: corrupted copy of ${DATA}"
37
38 rm -f ${COPY}
39 trace "ssh transfer over multiplexed connection and check result"
40 ${SSH} -S $CTL otherhost cat ${DATA} > ${COPY}
41 test -f ${COPY}                 || fail "ssh -S ctl: failed copy ${DATA}" 
42 cmp ${DATA} ${COPY}             || fail "ssh -S ctl: corrupted copy of ${DATA}"
43
44 rm -f ${COPY}
45 trace "sftp transfer over multiplexed connection and check result"
46 echo "get ${DATA} ${COPY}" | \
47         ${SFTP} -S ${SSH} -oControlPath=$CTL otherhost >/dev/null 2>&1
48 test -f ${COPY}                 || fail "sftp: failed copy ${DATA}" 
49 cmp ${DATA} ${COPY}             || fail "sftp: corrupted copy of ${DATA}"
50
51 rm -f ${COPY}
52 trace "scp transfer over multiplexed connection and check result"
53 ${SCP} -S ${SSH} -oControlPath=$CTL otherhost:${DATA} ${COPY} >/dev/null 2>&1
54 test -f ${COPY}                 || fail "scp: failed copy ${DATA}" 
55 cmp ${DATA} ${COPY}             || fail "scp: corrupted copy of ${DATA}"
56
57 rm -f ${COPY}
58
59 for s in 0 1 4 5 44; do
60         trace "exit status $s over multiplexed connection"
61         verbose "test $tid: status $s"
62         ${SSH} -S $CTL otherhost exit $s
63         r=$?
64         if [ $r -ne $s ]; then
65                 fail "exit code mismatch for protocol $p: $r != $s"
66         fi
67
68         # same with early close of stdout/err
69         trace "exit status $s with early close over multiplexed connection"
70         ${SSH} -S $CTL -n otherhost \
71                 exec sh -c \'"sleep 2; exec > /dev/null 2>&1; sleep 3; exit $s"\'
72         r=$?
73         if [ $r -ne $s ]; then
74                 fail "exit code (with sleep) mismatch for protocol $p: $r != $s"
75         fi
76 done
77
78 # kill master, remove control socket.  ssh -MS will exit when sleep exits
79 $SUDO kill `cat $PIDFILE`
80 rm -f $CTL
This page took 0.0891 seconds and 5 git commands to generate.