Darren Tucker | e7d0583 | 2004-06-16 20:22:22 +1000 | [diff] [blame^] | 1 | # $OpenBSD: multiplex.sh,v 1.1 2004/06/13 15:04:08 djm Exp $ |
| 2 | # Placed in the Public Domain. |
| 3 | |
| 4 | CTL=$OBJ/ctl-sock |
| 5 | |
| 6 | tid="connection multiplexing" |
| 7 | |
| 8 | start_sshd |
| 9 | |
| 10 | trace "start master, fork to background" |
| 11 | ${SSH} -2 -MS$CTL -F $OBJ/ssh_config -f somehost sleep 60 |
| 12 | |
| 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" |
| 17 | |
| 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" |
| 22 | |
| 23 | rm -f $OBJ/ls.copy |
| 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" |
| 29 | |
| 30 | rm -f $OBJ/ls.copy |
| 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" |
| 35 | |
| 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 |
| 40 | r=$? |
| 41 | if [ $r -ne $s ]; then |
| 42 | fail "exit code mismatch for protocol $p: $r != $s" |
| 43 | fi |
| 44 | |
| 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"\' |
| 49 | r=$? |
| 50 | if [ $r -ne $s ]; then |
| 51 | fail "exit code (with sleep) mismatch for protocol $p: $r != $s" |
| 52 | fi |
| 53 | done |
| 54 | |
| 55 | sleep 30 # early close test sleeps 5 seconds per test |