1 # $OpenBSD: multiplex.sh,v 1.1 2004/06/13 15:04:08 djm Exp $
2 # Placed in the Public Domain.
6 tid="connection multiplexing"
10 trace "start master, fork to background"
11 ${SSH} -2 -MS$CTL -F $OBJ/ssh_config -f somehost sleep 60
13 trace "ssh transfer over multiplexed connection and check result"
14 ${SSH} -S$CTL otherhost cat /bin/ls > $OBJ/ls.copy
15 test -f $OBJ/ls.copy || fail "failed copy /bin/ls"
16 cmp /bin/ls $OBJ/ls.copy || fail "corrupted copy of /bin/ls"
18 trace "ssh transfer over multiplexed connection and check result"
19 ${SSH} -S $CTL otherhost cat /bin/ls > $OBJ/ls.copy
20 test -f $OBJ/ls.copy || fail "failed copy /bin/ls"
21 cmp /bin/ls $OBJ/ls.copy || fail "corrupted copy of /bin/ls"
24 trace "sftp transfer over multiplexed connection and check result"
25 echo "get /bin/ls $OBJ/ls.copy" | \
26 ${SFTP} -oControlPath=$CTL otherhost
27 test -f $OBJ/ls.copy || fail "failed copy /bin/ls"
28 cmp /bin/ls $OBJ/ls.copy || fail "corrupted copy of /bin/ls"
31 trace "scp transfer over multiplexed connection and check result"
32 ${SCP} -oControlPath=$CTL otherhost:/bin/ls $OBJ/ls.copy
33 test -f $OBJ/ls.copy || fail "failed copy /bin/ls"
34 cmp /bin/ls $OBJ/ls.copy || fail "corrupted copy of /bin/ls"
36 for s in 0 1 4 5 44; do
37 trace "exit status $s over multiplexed connection"
38 verbose "test $tid: status $s"
39 ${SSH} -S $CTL otherhost exit $s
41 if [ $r -ne $s ]; then
42 fail "exit code mismatch for protocol $p: $r != $s"
45 # same with early close of stdout/err
46 trace "exit status $s with early close over multiplexed connection"
47 ${SSH} -S $CTL -n otherhost \
48 exec sh -c \'"sleep 2; exec > /dev/null 2>&1; sleep 3; exit $s"\'
50 if [ $r -ne $s ]; then
51 fail "exit code (with sleep) mismatch for protocol $p: $r != $s"
55 sleep 30 # early close test sleeps 5 seconds per test