From 8e16712145eb716d9b20ce95a50c3b3f4ce5d1d7 Mon Sep 17 00:00:00 2001 From: Markus Friedl Date: Sat, 23 Mar 2002 16:38:10 +0000 Subject: some tests for stderr handling --- regress/usr.bin/ssh/Makefile | 4 +++- regress/usr.bin/ssh/stderr-after-eof.sh | 28 ++++++++++++++++++++++++++++ regress/usr.bin/ssh/stderr-data.sh | 33 +++++++++++++++++++++++++++++++++ regress/usr.bin/ssh/test-exec.sh | 4 +++- 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 regress/usr.bin/ssh/stderr-after-eof.sh create mode 100644 regress/usr.bin/ssh/stderr-data.sh (limited to 'regress/usr.bin/ssh') diff --git a/regress/usr.bin/ssh/Makefile b/regress/usr.bin/ssh/Makefile index b3ac6fb45f1..7aa106875a4 100644 --- a/regress/usr.bin/ssh/Makefile +++ b/regress/usr.bin/ssh/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.8 2002/03/21 22:27:00 markus Exp $ +# $OpenBSD: Makefile,v 1.9 2002/03/23 16:38:08 markus Exp $ REGRESSTARGETS= t1 t2 t3 t4 t5 t6 t7 @@ -10,6 +10,8 @@ LTESTS= connect \ proto-version \ proto-mismatch \ exit-status \ + stderr-data \ + stderr-after-eof \ broken-pipe \ try-ciphers \ yes-head \ diff --git a/regress/usr.bin/ssh/stderr-after-eof.sh b/regress/usr.bin/ssh/stderr-after-eof.sh new file mode 100644 index 00000000000..cd1e66d571b --- /dev/null +++ b/regress/usr.bin/ssh/stderr-after-eof.sh @@ -0,0 +1,28 @@ +# $OpenBSD: stderr-after-eof.sh,v 1.1 2002/03/23 16:38:09 markus Exp $ +# Placed in the Public Domain. + +tid="stderr data after eof" + +DATA=/etc/motd +DATA=${OBJ}/data +COPY=${OBJ}/copy + +# setup data +rm -f ${DATA} ${COPY} +cp /dev/null ${DATA} +for i in 1 2 3 4 5 6; do + (date;echo $i) | md5 >> ${DATA} +done + +${SSH} -2 -F $OBJ/ssh_proxy otherhost \ + exec sh -c \'"exec > /dev/null; sleep 2; cat ${DATA} 1>&2 $s"\' \ + 2> ${COPY} +r=$? +if [ $r -ne 0 ]; then + fail "ssh failed with exit code $r" +fi +egrep 'Disconnecting: Received extended_data after EOF' ${COPY} && + fail "ext data received after eof" +cmp ${DATA} ${COPY} || fail "stderr corrupt" + +rm -f ${DATA} ${COPY} diff --git a/regress/usr.bin/ssh/stderr-data.sh b/regress/usr.bin/ssh/stderr-data.sh new file mode 100644 index 00000000000..4c46c3a1c66 --- /dev/null +++ b/regress/usr.bin/ssh/stderr-data.sh @@ -0,0 +1,33 @@ +# $OpenBSD: stderr-data.sh,v 1.1 2002/03/23 16:38:09 markus Exp $ +# Placed in the Public Domain. + +tid="stderr data transfer" + +DATA=/bin/ls +COPY=${OBJ}/copy +rm -f ${COPY} + +for n in '' -n; do +for p in 1 2; do + verbose "test $tid: proto $p ($n)" + ${SSH} $n -$p -F $OBJ/ssh_proxy otherhost \ + exec sh -c \'"exec > /dev/null; sleep 3; cat ${DATA} 1>&2 $s"\' \ + 2> ${COPY} + r=$? + if [ $r -ne 0 ]; then + fail "ssh failed with exit code $r" + fi + cmp ${DATA} ${COPY} || fail "stderr corrupt" + rm -f ${COPY} + + ${SSH} $n -$p -F $OBJ/ssh_proxy otherhost \ + exec sh -c \'"echo a; exec > /dev/null; sleep 3; cat ${DATA} 1>&2 $s"\' \ + >- 2> ${COPY} + r=$? + if [ $r -ne 0 ]; then + fail "ssh failed with exit code $r" + fi + cmp ${DATA} ${COPY} || fail "stderr corrupt" + rm -f ${COPY} +done +done diff --git a/regress/usr.bin/ssh/test-exec.sh b/regress/usr.bin/ssh/test-exec.sh index d7194fd075c..a740b261929 100644 --- a/regress/usr.bin/ssh/test-exec.sh +++ b/regress/usr.bin/ssh/test-exec.sh @@ -1,4 +1,4 @@ -# $OpenBSD: test-exec.sh,v 1.11 2002/03/21 22:27:00 markus Exp $ +# $OpenBSD: test-exec.sh,v 1.12 2002/03/23 16:38:09 markus Exp $ # Placed in the Public Domain. PORT=4242 @@ -158,6 +158,8 @@ Host * StrictHostKeyChecking yes EOF +rm -f $OBJ/known_hosts + trace "generate keys" for t in rsa rsa1; do # generate user key -- cgit v1.2.3