[Patch] Improve portability of regression tests

kumar kumareshind at gmx.net
Tue Jul 23 13:54:18 EST 2002


Hello All,

I want to test OpenSSH in HP-UX box.Regarding regression tests, do anyone
have the test scripts.

thanks in advance,
Kumaresh.

> Hello All.
> As promised, here is what I needed to do to get the regression tests to
> work on AIX & HPUX. It goes into a bit of detail in the hope that others
> might be able to get them running on their platforms. I've run these
> mods on AIX 4.3.3, HP-UX 11.00, Solaris 8, Redhat 7.3 and OpenBSD 3.0.
>
> The problems I encountered:
> * prereqs (pmake, md5sum)
> * bad directory owner/mode causing auth failures
> * echo -n doesn't always work
> * some "id"'s don't know -n or -u
> * some platforms have no /dev/stdin
> * some tests AIX fails when sshd runs as non-root user
> * path problems
>
> I used Markus' run-tests.sh script as a starting point. This reduced
> the need for pmake. I got md5sum from GNU textutils. Useful pointers:
> md5sum:         http://www.gnu.org/software/textutils/textutils.html
> [bp]make:       http://www.crufty.net/ftp/pub/sjg/
>
> While testing I turned up LogLevel to DEBUG for the sshd under test.
> This showed "bad ownership or modes for directory" in syslog. The
> regress directory and all of its parents must be owned by the testing
> user or root and must be mode 755 or stricter. (Some of mine were owned
> by bin and group writable).
>
> Some tests use "echo -n" for a echoing without newline. This left -n's
> in inconvenient places (eg known_hosts files). I created a "echon"
> function in the test driver "test-exec.sh" that will (hopefully) work
> everywhere.
>
> I replaced "id -nu" with "whoami". (Solaris' "id" doesn't know -u or
> -n).
>
> The sftp test uses /dev/stdin to send commands to sftp via the -b
> (batch) option. Some platforms (eg AIX & HP-UX) don't have /dev/stdin or
> equivalent. I moved the commands to a normal file.
>
> The call to loginrestricted() in auth.c fails when sshd is running as a
> non-root user. I added a "${SUDO}" to ssh_proxy's ProxyCommand. You'll
> need to define SUDO in test-exec.sh on AIX or some tests will fail.
>
> I had problems with paths, so I added more explicit ones. This may not
> be necessary.
>
> One other thing: do authorized_keys_root, copy.1 and copy.2 need to be
> in CVS?
>
> --
> Darren Tucker (dtucker at zip.com.au)
> GPG Fingerprint D9A3 86E9 7EEE AF4B B2D4  37C9 C982 80C7 8FF4 FA69
>     Good judgement comes with experience. Unfortunately, the experience
> usually comes from bad judgement.


----------------------------------------------------------------------------
----


> Index: regress/Makefile
> ===================================================================
> RCS file: /cvs/openssh/regress/Makefile,v
> retrieving revision 1.1
> diff -u -r1.1 Makefile
> --- regress/Makefile 1 May 2002 03:17:34 -0000 1.1
> +++ regress/Makefile 22 Jul 2002 12:33:34 -0000
> @@ -39,9 +39,10 @@
>   ssh-keygen -yf t2.out | diff - ${.CURDIR}/rsa_openssh.pub
>
>  t3:
> - ssh-keygen -ef ${.CURDIR}/rsa_openssh.pub |\
> - ssh-keygen -if /dev/stdin |\
> + ssh-keygen -ef ${.CURDIR}/rsa_openssh.pub >${.CURDIR}/rsa_secsh.pub
> + ssh-keygen -if ${.CURDIR}/rsa_secsh.pub | \
>   diff - ${.CURDIR}/rsa_openssh.pub
> + rm -f ${.CURDIR}/rsa_secsh.pub
>
>  t4:
>   ssh-keygen -lf ${.CURDIR}/rsa_openssh.pub |\
> Index: regress/runtests.sh
> ===================================================================
> RCS file: /cvs/openssh/regress/runtests.sh,v
> retrieving revision 1.1
> diff -u -r1.1 runtests.sh
> --- regress/runtests.sh 1 May 2002 03:17:35 -0000 1.1
> +++ regress/runtests.sh 22 Jul 2002 12:33:42 -0000
> @@ -1,13 +1,45 @@
>  #!/bin/sh
>
> -TEST_SSH_SSH=../ssh
> -TEST_SSH_SSHD=../sshd
> -TEST_SSH_SSHAGENT=../ssh-agent
> -TEST_SSH_SSHADD=../ssh-add
> -TEST_SSH_SSHKEYGEN=../ssh-keygen
> -TEST_SSH_SSHKEYSCAN=../ssh-keyscan
> -TEST_SSH_SFTP=../sftp
> -TEST_SSH_SFTPSERVER=../sftp-server
> +pwd=`pwd`
> +bindir=`dirname $pwd`
> +PATH="$bindir:$PATH"
> +export PATH
>
> -pmake
> +TEST_SSH_TRACE=no # Enable for more detail in test
> +TEST_SSH_QUIET=no # Suppress status output
> +export TEST_SSH_TRACE TEST_SSH_QUIET
>
> +# Path to binaries to test
> +TEST_SSH_SSH=$bindir/ssh
> +TEST_SSH_SSHD=$bindir/sshd
> +TEST_SSH_SSHAGENT=$bindir/ssh-agent
> +TEST_SSH_SSHADD=$bindir/ssh-add
> +TEST_SSH_SSHKEYGEN=$bindir/ssh-keygen
> +TEST_SSH_SSHKEYSCAN=$bindir/ssh-keyscan
> +TEST_SSH_SFTP=$bindir/sftp
> +TEST_SSH_SFTPSERVER=$bindir/sftp-server
> +export TEST_SSH_SSH TEST_SSH_SSHD TEST_SSH_SSHAGENT TEST_SSH_SSHADD
> +export TEST_SSH_SSHKEYGEN TEST_SSH_SSHKEYSCAN TEST_SSH_SFTP
TEST_SSH_SFTPSERVER
> +
> +if [ -x `which pmake` ]; then
> + pmake
> +else
> + for test in connect \
> + proxy-connect \
> + connect-privsep \
> + proto-version \
> + proto-mismatch \
> + exit-status \
> + transfer \
> + stderr-data \
> + stderr-after-eof \
> + broken-pipe \
> + try-ciphers \
> + yes-head \
> + agent \
> + keyscan \
> + sftp \
> + forwarding ; do
> + sh test-exec.sh $pwd $pwd/${test}.sh
> + done
> +fi
> Index: regress/sftp.sh
> ===================================================================
> RCS file: /cvs/openssh/regress/sftp.sh,v
> retrieving revision 1.1
> diff -u -r1.1 sftp.sh
> --- regress/sftp.sh 1 May 2002 03:17:35 -0000 1.1
> +++ regress/sftp.sh 22 Jul 2002 12:33:42 -0000
> @@ -6,6 +6,12 @@
>  DATA=/bin/ls
>  COPY=${OBJ}/copy
>
> +cat >`pwd`/batch <<EOF
> +version
> +get $DATA ${COPY}.1
> +put $DATA ${COPY}.2
> +EOF
> +
>  BUFFERSIZE="5 1000 32000 64000"
>  REQUESTS="1 2 10"
>
> @@ -13,12 +19,8 @@
>   for R in ${REQUESTS}; do
>                  verbose "test $tid: buffer_size $B num_requests $R"
>   rm -f ${COPY}.1 ${COPY}.2
> - ${SFTP} -P ${SFTPSERVER} -B $B -R $R -b /dev/stdin \
> - > /dev/null 2>&1 << EOF
> - version
> - get $DATA ${COPY}.1
> - put $DATA ${COPY}.2
> -EOF
> + ${SFTP} -P ${SFTPSERVER} -B $B -R $R -b `pwd`/batch \
> + > /dev/null 2>&1
>   r=$?
>   if [ $r -ne 0 ]; then
>   fail "sftp failed with $r"
> @@ -27,3 +29,5 @@
>   cmp $DATA ${COPY}.2 || fail "corrupted copy after put"
>   done
>  done
> +
> +rm -f `pwd`/batch
> Index: regress/ssh-com.sh
> ===================================================================
> RCS file: /cvs/openssh/regress/ssh-com.sh,v
> retrieving revision 1.1
> diff -u -r1.1 ssh-com.sh
> --- regress/ssh-com.sh 1 May 2002 03:17:35 -0000 1.1
> +++ regress/ssh-com.sh 22 Jul 2002 12:33:42 -0000
> @@ -63,7 +63,7 @@
>
>  # convert and append DSA hostkey
>  (
> - echo -n 'ssh2-localhost-with-alias,127.0.0.1,::1 '
> + echon 'ssh2-localhost-with-alias,127.0.0.1,::1 '
>   ${SSHKEYGEN} -if ${SRC}/dsa_ssh2.pub
>  ) >> $OBJ/known_hosts
>
> Index: regress/test-exec.sh
> ===================================================================
> RCS file: /cvs/openssh/regress/test-exec.sh,v
> retrieving revision 1.1
> diff -u -r1.1 test-exec.sh
> --- regress/test-exec.sh 1 May 2002 03:17:35 -0000 1.1
> +++ regress/test-exec.sh 22 Jul 2002 12:33:42 -0000
> @@ -2,7 +2,7 @@
>  # Placed in the Public Domain.
>
>  PORT=4242
> -USER=`id -un`
> +USER=`whoami`
>  SUDO=
>  #SUDO=sudo
>
> @@ -72,6 +72,18 @@
>  #echo $SSH $SSHD $SSHAGENT $SSHADD $SSHKEYGEN $SSHKEYSCAN $SFTP
$SFTPSERVER
>
>  # helper
> +echon()
> +{
> + if [ "x`echo -n`" = "x" ]; then
> + echo -n "$@"
> + elif [ "x`/bin/echo '\c'`" = "x" ]; then
> + /bin/echo "$@\c"
> + else
> + fatal "Don't know how to echo without newline."
> + fi
> +
> +}
> +
>  cleanup ()
>  {
>   if [ -f $PIDFILE ]; then
> @@ -111,7 +123,7 @@
>
>  fatal ()
>  {
> - echo -n "FATAL: "
> + echon "FATAL: "
>   fail "$@"
>   cleanup
>   exit $RESULT
> @@ -169,7 +181,7 @@
>
>   # known hosts file for client
>   (
> - echo -n 'localhost-with-alias,127.0.0.1,::1 '
> + echon 'localhost-with-alias,127.0.0.1,::1 '
>   cat $OBJ/$t.pub
>   ) >> $OBJ/known_hosts
>
> @@ -189,7 +201,7 @@
>  # create a proxy version of the client config
>  (
>   cat $OBJ/ssh_config
> - echo proxycommand ${SSHD} -i -f $OBJ/sshd_proxy
> + echo proxycommand ${SUDO} ${SSHD} -i -f $OBJ/sshd_proxy
>  ) > $OBJ/ssh_proxy
>
>  # check proxy config
>
>
>




More information about the openssh-unix-dev mailing list