valgrind support
This commit is contained in:
parent
f43d172691
commit
bd58853102
|
@ -203,11 +203,14 @@ interop: ${INTEROP_TARGETS}
|
|||
# Unit tests, built by top-level Makefile
|
||||
unit:
|
||||
set -e ; if test -z "${SKIP_UNIT}" ; then \
|
||||
${.OBJDIR}/unittests/sshbuf/test_sshbuf ; \
|
||||
${.OBJDIR}/unittests/sshkey/test_sshkey \
|
||||
V="" ; \
|
||||
test "x${USE_VALGRIND}" != "x" && \
|
||||
V=${.CURDIR}/valgrind-unit.sh ; \
|
||||
$$V ${.OBJDIR}/unittests/sshbuf/test_sshbuf ; \
|
||||
$$V ${.OBJDIR}/unittests/sshkey/test_sshkey \
|
||||
-d ${.CURDIR}/unittests/sshkey/testdata ; \
|
||||
${.OBJDIR}/unittests/bitmap/test_bitmap ; \
|
||||
${.OBJDIR}/unittests/kex/test_kex ; \
|
||||
${.OBJDIR}/unittests/hostkeys/test_hostkeys \
|
||||
$$V ${.OBJDIR}/unittests/bitmap/test_bitmap ; \
|
||||
$$V ${.OBJDIR}/unittests/kex/test_kex ; \
|
||||
$$V ${.OBJDIR}/unittests/hostkeys/test_hostkeys \
|
||||
-d ${.CURDIR}/unittests/hostkeys/testdata ; \
|
||||
fi
|
||||
|
|
|
@ -20,7 +20,7 @@ echo "KexAlgorithms diffie-hellman-group14-sha1,diffie-hellman-group1-sha1" \
|
|||
>> $OBJ/ssh_proxy
|
||||
|
||||
# sshd-command for proxy (see test-exec.sh)
|
||||
cmd="$SUDO sh ${SRC}/sshd-log-wrapper.sh ${SSHD} ${TEST_SSHD_LOGFILE} -i -f $OBJ/sshd_proxy"
|
||||
cmd="$SUDO sh ${SRC}/sshd-log-wrapper.sh ${TEST_SSHD_LOGFILE} ${SSHD} -i -f $OBJ/sshd_proxy"
|
||||
|
||||
for m in $macs; do
|
||||
trace "test $tid: mac $m"
|
||||
|
|
|
@ -90,7 +90,7 @@ $NC -N -Ul $OBJ/unix-1.fwd < ${DATA} > /dev/null &
|
|||
netcat_pid=$!
|
||||
${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -L$OBJ/unix-2.fwd:$OBJ/unix-1.fwd otherhost >>$TEST_SSH_LOGFILE 2>&1
|
||||
${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -R$OBJ/unix-3.fwd:$OBJ/unix-2.fwd otherhost >>$TEST_SSH_LOGFILE 2>&1
|
||||
$NC -U $OBJ/unix-3.fwd < /dev/null > ${COPY}
|
||||
$NC -U $OBJ/unix-3.fwd < /dev/null > ${COPY} 2>/dev/null
|
||||
cmp ${DATA} ${COPY} || fail "ssh: corrupted copy of ${DATA}"
|
||||
kill $netcat_pid 2>/dev/null
|
||||
rm -f ${COPY} $OBJ/unix-[123].fwd
|
||||
|
|
|
@ -4,14 +4,16 @@
|
|||
tid="simple connect after reconfigure"
|
||||
|
||||
# we need the full path to sshd for -HUP
|
||||
case $SSHD in
|
||||
/*)
|
||||
# full path is OK
|
||||
;;
|
||||
*)
|
||||
# otherwise make fully qualified
|
||||
SSHD=$OBJ/$SSHD
|
||||
esac
|
||||
if test "x$USE_VALGRIND" = "x" ; then
|
||||
case $SSHD in
|
||||
/*)
|
||||
# full path is OK
|
||||
;;
|
||||
*)
|
||||
# otherwise make fully qualified
|
||||
SSHD=$OBJ/$SSHD
|
||||
esac
|
||||
fi
|
||||
|
||||
start_sshd
|
||||
|
||||
|
|
|
@ -3,11 +3,9 @@
|
|||
# Placed in the Public Domain.
|
||||
#
|
||||
# simple wrapper for sshd proxy mode to catch stderr output
|
||||
# sh sshd-log-wrapper.sh /path/to/sshd /path/to/logfile
|
||||
# sh sshd-log-wrapper.sh /path/to/logfile /path/to/sshd [args...]
|
||||
|
||||
sshd=$1
|
||||
log=$2
|
||||
shift
|
||||
log=$1
|
||||
shift
|
||||
|
||||
exec $sshd -E$log $@
|
||||
exec "$@" -E$log
|
||||
|
|
|
@ -141,6 +141,55 @@ case "$SSHAGENT" in
|
|||
*) SSHAGENT=`which $SSHAGENT` ;;
|
||||
esac
|
||||
|
||||
# Record the actual binaries used.
|
||||
SSH_BIN=${SSH}
|
||||
SSHD_BIN=${SSHD}
|
||||
SSHAGENT_BIN=${SSHAGENT}
|
||||
SSHADD_BIN=${SSHADD}
|
||||
SSHKEYGEN_BIN=${SSHKEYGEN}
|
||||
SSHKEYSCAN_BIN=${SSHKEYSCAN}
|
||||
SFTP_BIN=${SFTP}
|
||||
SFTPSERVER_BIN=${SFTPSERVER}
|
||||
SCP_BIN=${SCP}
|
||||
|
||||
if [ "x$USE_VALGRIND" != "x" ]; then
|
||||
mkdir -p $OBJ/valgrind-out
|
||||
VG_TEST=`basename $SCRIPT .sh`
|
||||
|
||||
# Some tests are difficult to fix.
|
||||
case "$VG_TEST" in
|
||||
connect-privsep|reexec)
|
||||
VG_SKIP=1 ;;
|
||||
esac
|
||||
|
||||
if [ x"$VG_SKIP" = "x" ]; then
|
||||
VG_IGNORE="/bin/*,/sbin/*,/usr/*,/var/*"
|
||||
VG_LOG="$OBJ/valgrind-out/${VG_TEST}."
|
||||
VG_OPTS="--track-origins=yes --leak-check=full"
|
||||
VG_OPTS="$VG_OPTS --trace-children=yes"
|
||||
VG_OPTS="$VG_OPTS --trace-children-skip=${VG_IGNORE}"
|
||||
VG_PATH="valgrind"
|
||||
if [ "x$VALGRIND_PATH" != "x" ]; then
|
||||
VG_PATH="$VALGRIND_PATH"
|
||||
fi
|
||||
VG="$VG_PATH $VG_OPTS"
|
||||
SSH="$VG --log-file=${VG_LOG}ssh.%p $SSH"
|
||||
SSHD="$VG --log-file=${VG_LOG}sshd.%p $SSHD"
|
||||
SSHAGENT="$VG --log-file=${VG_LOG}ssh-agent.%p $SSHAGENT"
|
||||
SSHADD="$VG --log-file=${VG_LOG}ssh-add.%p $SSHADD"
|
||||
SSHKEYGEN="$VG --log-file=${VG_LOG}ssh-keygen.%p $SSHKEYGEN"
|
||||
SSHKEYSCAN="$VG --log-file=${VG_LOG}ssh-keyscan.%p $SSHKEYSCAN"
|
||||
SFTP="$VG --log-file=${VG_LOG}sftp.%p ${SFTP}"
|
||||
SCP="$VG --log-file=${VG_LOG}scp.%p $SCP"
|
||||
cat > $OBJ/valgrind-sftp-server.sh << EOF
|
||||
#!/bin/sh
|
||||
exec $VG --log-file=${VG_LOG}sftp-server.%p $SFTPSERVER "\$@"
|
||||
EOF
|
||||
chmod a+rx $OBJ/valgrind-sftp-server.sh
|
||||
SFTPSERVER="$OBJ/valgrind-sftp-server.sh"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Logfiles.
|
||||
# SSH_LOGFILE should be the debug output of ssh(1) only
|
||||
# SSHD_LOGFILE should be the debug output of sshd(8) only
|
||||
|
@ -175,7 +224,7 @@ SSH="$SSHLOGWRAP"
|
|||
# [kbytes] to ensure the file is at least that large.
|
||||
DATANAME=data
|
||||
DATA=$OBJ/${DATANAME}
|
||||
cat ${SSHAGENT} >${DATA}
|
||||
cat ${SSHAGENT_BIN} >${DATA}
|
||||
chmod u+w ${DATA}
|
||||
COPY=$OBJ/copy
|
||||
rm -f ${COPY}
|
||||
|
@ -183,7 +232,7 @@ rm -f ${COPY}
|
|||
increase_datafile_size()
|
||||
{
|
||||
while [ `du -k ${DATA} | cut -f1` -lt $1 ]; do
|
||||
cat ${SSHAGENT} >>${DATA}
|
||||
cat ${SSHAGENT_BIN} >>${DATA}
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -388,7 +437,7 @@ rm -f $OBJ/known_hosts $OBJ/authorized_keys_$USER
|
|||
trace "generate keys"
|
||||
for t in rsa rsa1; do
|
||||
# generate user key
|
||||
if [ ! -f $OBJ/$t ] || [ ${SSHKEYGEN} -nt $OBJ/$t ]; then
|
||||
if [ ! -f $OBJ/$t ] || [ ${SSHKEYGEN_BIN} -nt $OBJ/$t ]; then
|
||||
rm -f $OBJ/$t
|
||||
${SSHKEYGEN} -q -N '' -t $t -f $OBJ/$t ||\
|
||||
fail "ssh-keygen for $t failed"
|
||||
|
@ -451,7 +500,7 @@ if test "$REGRESS_INTEROP_PUTTY" = "yes" ; then
|
|||
echo "Hostname=127.0.0.1" >> ${OBJ}/.putty/sessions/localhost_proxy
|
||||
echo "PortNumber=$PORT" >> ${OBJ}/.putty/sessions/localhost_proxy
|
||||
echo "ProxyMethod=5" >> ${OBJ}/.putty/sessions/localhost_proxy
|
||||
echo "ProxyTelnetCommand=sh ${SRC}/sshd-log-wrapper.sh ${SSHD} ${TEST_SSHD_LOGFILE} -i -f $OBJ/sshd_proxy" >> ${OBJ}/.putty/sessions/localhost_proxy
|
||||
echo "ProxyTelnetCommand=sh ${SRC}/sshd-log-wrapper.sh ${TEST_SSHD_LOGFILE} ${SSHD} -i -f $OBJ/sshd_proxy" >> ${OBJ}/.putty/sessions/localhost_proxy
|
||||
|
||||
REGRESS_INTEROP_PUTTY=yes
|
||||
fi
|
||||
|
@ -459,7 +508,7 @@ fi
|
|||
# create a proxy version of the client config
|
||||
(
|
||||
cat $OBJ/ssh_config
|
||||
echo proxycommand ${SUDO} sh ${SRC}/sshd-log-wrapper.sh ${SSHD} ${TEST_SSHD_LOGFILE} -i -f $OBJ/sshd_proxy
|
||||
echo proxycommand ${SUDO} sh ${SRC}/sshd-log-wrapper.sh ${TEST_SSHD_LOGFILE} ${SSHD} -i -f $OBJ/sshd_proxy
|
||||
) > $OBJ/ssh_proxy
|
||||
|
||||
# check proxy config
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
UNIT_BINARY="$1"
|
||||
shift
|
||||
UNIT_ARGS="$@"
|
||||
|
||||
test "x$OBJ" = "x" && OBJ=$PWD
|
||||
|
||||
# This mostly replicates the logic in test-exec.sh for running the
|
||||
# regress tests under valgrind.
|
||||
VG_TEST=`basename $UNIT_BINARY`
|
||||
VG_LOG="$OBJ/valgrind-out/${VG_TEST}.%p"
|
||||
VG_OPTS="--track-origins=yes --leak-check=full --log-file=${VG_LOG}"
|
||||
VG_OPTS="$VG_OPTS --trace-children=yes"
|
||||
VG_PATH="valgrind"
|
||||
if [ "x$VALGRIND_PATH" != "x" ]; then
|
||||
VG_PATH="$VALGRIND_PATH"
|
||||
fi
|
||||
|
||||
exec $VG_PATH $VG_OPTS $UNIT_BINARY $UNIT_ARGS
|
Loading…
Reference in New Issue