Commit 7ddea052 authored by Niels Möller's avatar Niels Möller

Use bundled tcpconnect and mini-inetd in testsuite.

parent 6fac0e91
2013-03-13 Niels Mller <nisse@lysator.liu.se>
Mostly copied from master branch:
* src/testsuite/functions.sh: Don't use set -e.
(need_tcputils): Deleted function.
(at_connect): Use ./mini-inetd.
* src/testsuite/lshd-random-input-test: Use ./tcpconnect and
./mini-inetd, rather than the possibly installed version from
tcputils. Don't use need_tcputils.
* src/testsuite/lshg-tcpip-local-test: Likewise.
* src/testsuite/rapid7-lsh-test: Likewise.
* src/testsuite/rapid7-lshd-test: Likewise.
* src/testsuite/socks4-test: Likewise.
* src/testsuite/socks5-test: Likewise.
* src/testsuite/tcpip-local-in-use-test: Likewise.
* src/testsuite/tcpip-local-test: Likewise.
* src/testsuite/tcpip-remote-test: Likewise.
2013-03-10 Niels Mller <nisse@lysator.liu.se>
* src/testsuite/Makefile.am: Rules to build tcpconnect and
......
# Helper functions for the test scripts.
# Any error count as failure.
set -e
# echo srcdir = $srcdir
: ${TEST_HOME:=`pwd`/home}
......@@ -20,6 +17,7 @@ export LSH_YARROW_SEED_FILE SEXP_CONV
: ${PIDFILE:="`pwd`/lshd.$$.pid"}
: ${LSH_PIDFILE:="`pwd`/lsh.$$.pid"}
: ${LSHG_PIDFILE:="`pwd`/lshg.$$.pid"}
: ${MINI_INETD_PIDFILE:="`pwd`/mini-inetd.$$.pid"}
: ${INTERFACE:=localhost}
# Ignore any options the tester might have put in the environment.
......@@ -31,7 +29,7 @@ unset LSHGFLAGS || :
unset LSHFLAGS || :
PORT=11147
ATEXIT='set +e'
ATEXIT='true '
# We start with EXIT_FAILURE, and changing it to EXIT_SUCCESS only if
# test_success is invoked.
......@@ -71,16 +69,8 @@ check_x11_support () {
../lsh --help | grep 'x11-forward' >/dev/null || test_skip
}
need_tcputils () {
if type tcpconnect >/dev/null 2>&1 ; then : ; else
test_skip
fi
}
need_tsocks () {
if type tsocks >/dev/null 2>&1 ; then : ; else
test_skip
fi
type tsocks >/dev/null 2>&1 || test_skip
}
at_exit () {
......@@ -155,8 +145,8 @@ spawn_lshg () {
# at_connect local-port max-connections shell-command
at_connect () {
# sleep 1 # Allow some time for earlier processes to die
mini-inetd -m $2 -- localhost:$1 /bin/sh sh -c "$3" &
at_exit "kill $!"
./mini-inetd --background -- localhost:$1 /bin/sh sh -c "$3" > $MINI_INETD_PIDFILE
at_exit "kill `cat $MINI_INETD_PIDFILE`"
}
compare_output() {
......
......@@ -8,8 +8,6 @@ fi
PORT=5555
need_tcputils
werror "Testing lshd with random input"
spawn_lshd
......@@ -17,7 +15,7 @@ spawn_lshd
for seed in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
werror "Trying seed $seed"
../nettle/tools/nettle-lfib-stream $seed \
| tcpconnect $INTERFACE $PORT > /dev/null \
| ./tcpconnect $INTERFACE $PORT > /dev/null \
|| die "Connect failed"
kill -0 `cat $PIDFILE` || die "Server died"
......
......@@ -6,8 +6,6 @@ fi
. $srcdir/functions.sh
need_tcputils
SERVERPORT=`expr $PORT + 1`
PROXYPORT=`expr $PORT + 2`
......@@ -15,7 +13,7 @@ at_connect $SERVERPORT 1 'echo foo' \
&& spawn_lshd \
&& spawn_lsh -G \
&& spawn_lshg -L $PROXYPORT:localhost:$SERVERPORT \
&& tcpconnect -r </dev/null localhost $PROXYPORT | grep foo \
&& ./tcpconnect -r </dev/null localhost $PROXYPORT | grep foo \
&& test_success
test_done
......@@ -6,11 +6,9 @@ fi
. $srcdir/functions.sh
need_tcputils
PORT=5556
mini-inetd -- $PORT /bin/sh /bin/sh -c 'cat current' &
./mini-inetd -- $PORT /bin/sh /bin/sh -c 'cat current' &
pid=$!
at_exit "kill $pid; rm -f current" 0
......
......@@ -6,8 +6,6 @@ fi
. $srcdir/functions.sh
need_tcputils
PORT=5555
werror "Testing lshd"
......@@ -16,7 +14,7 @@ spawn_lshd
for f in $srcdir/rapid7-ssh-pdu/*.pdu ; do
werror "Testing $f"
tcpconnect $INTERFACE $PORT < "$f" > /dev/null \
./tcpconnect $INTERFACE $PORT < "$f" > /dev/null \
|| die "Connect failed"
kill -0 `cat $PIDFILE` || die "Server died"
......
......@@ -6,7 +6,6 @@ fi
. $srcdir/functions.sh
need_tcputils
need_tsocks
SERVERPORT=`expr $PORT + 1`
......
......@@ -6,7 +6,6 @@ fi
. $srcdir/functions.sh
need_tcputils
need_tsocks
SERVERPORT=`expr $PORT + 1`
......@@ -20,7 +19,7 @@ export TSOCKS_CONF_FILE
at_connect $SERVERPORT 1 'grep bar && echo foo' \
&& spawn_lshd \
&& spawn_lsh -D$SOCKSPORT \
&& echo bar | tsocks tcpconnect localhost $SERVERPORT | grep foo \
&& echo bar | tsocks ./tcpconnect localhost $SERVERPORT | grep foo \
&& test_success
test_done
......@@ -6,8 +6,6 @@ fi
. $srcdir/functions.sh
need_tcputils
SERVERPORT=`expr $PORT + 1`
PROXYPORT=`expr $PORT + 2`
......
......@@ -6,15 +6,13 @@ fi
. $srcdir/functions.sh
need_tcputils
SERVERPORT=`expr $PORT + 1`
PROXYPORT=`expr $PORT + 2`
at_connect $SERVERPORT 1 'grep bar && echo foo' \
&& spawn_lshd \
&& spawn_lsh -L $PROXYPORT:localhost:$SERVERPORT \
&& echo bar | tcpconnect localhost $PROXYPORT | grep foo \
&& echo bar | ./tcpconnect localhost $PROXYPORT | grep foo \
&& test_success
test_done
......@@ -6,8 +6,6 @@ fi
. $srcdir/functions.sh
need_tcputils
SERVERPORT=`expr $PORT + 1`
PROXYPORT=`expr $PORT + 2`
......@@ -20,7 +18,7 @@ at_connect $SERVERPORT 1 'echo foo' \
&& spawn_lshd \
&& spawn_lsh -R $PROXYPORT:localhost:$SERVERPORT \
&& sleep 30 \
&& cat /dev/null | tcpconnect localhost $PROXYPORT | grep foo \
&& cat /dev/null | ./tcpconnect localhost $PROXYPORT | grep foo \
&& test_success
test_done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment