summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2015-02-25 16:58:22 -0800
committerDamien Miller <djm@mindrot.org>2015-02-26 14:55:55 -0800
commitbd58853102cee739f0e115e6d4b5334332ab1442 (patch)
treec214663c1fa4b28cc687faba24183f36085a3141 /regress
parentf43d17269194761eded9e89f17456332f4c83824 (diff)
valgrind support
Diffstat (limited to 'regress')
-rw-r--r--regress/Makefile13
-rw-r--r--regress/integrity.sh2
-rw-r--r--regress/multiplex.sh2
-rw-r--r--regress/reconfigure.sh18
-rw-r--r--regress/sshd-log-wrapper.sh8
-rw-r--r--regress/test-exec.sh59
-rwxr-xr-xregress/valgrind-unit.sh20
7 files changed, 97 insertions, 25 deletions
diff --git a/regress/Makefile b/regress/Makefile
index ecc688cab..7005b410d 100644
--- a/regress/Makefile
+++ b/regress/Makefile
@@ -203,11 +203,14 @@ interop: ${INTEROP_TARGETS}
203# Unit tests, built by top-level Makefile 203# Unit tests, built by top-level Makefile
204unit: 204unit:
205 set -e ; if test -z "${SKIP_UNIT}" ; then \ 205 set -e ; if test -z "${SKIP_UNIT}" ; then \
206 ${.OBJDIR}/unittests/sshbuf/test_sshbuf ; \ 206 V="" ; \
207 ${.OBJDIR}/unittests/sshkey/test_sshkey \ 207 test "x${USE_VALGRIND}" != "x" && \
208 V=${.CURDIR}/valgrind-unit.sh ; \
209 $$V ${.OBJDIR}/unittests/sshbuf/test_sshbuf ; \
210 $$V ${.OBJDIR}/unittests/sshkey/test_sshkey \
208 -d ${.CURDIR}/unittests/sshkey/testdata ; \ 211 -d ${.CURDIR}/unittests/sshkey/testdata ; \
209 ${.OBJDIR}/unittests/bitmap/test_bitmap ; \ 212 $$V ${.OBJDIR}/unittests/bitmap/test_bitmap ; \
210 ${.OBJDIR}/unittests/kex/test_kex ; \ 213 $$V ${.OBJDIR}/unittests/kex/test_kex ; \
211 ${.OBJDIR}/unittests/hostkeys/test_hostkeys \ 214 $$V ${.OBJDIR}/unittests/hostkeys/test_hostkeys \
212 -d ${.CURDIR}/unittests/hostkeys/testdata ; \ 215 -d ${.CURDIR}/unittests/hostkeys/testdata ; \
213 fi 216 fi
diff --git a/regress/integrity.sh b/regress/integrity.sh
index 42cb46422..2ff8b3f17 100644
--- a/regress/integrity.sh
+++ b/regress/integrity.sh
@@ -20,7 +20,7 @@ echo "KexAlgorithms diffie-hellman-group14-sha1,diffie-hellman-group1-sha1" \
20 >> $OBJ/ssh_proxy 20 >> $OBJ/ssh_proxy
21 21
22# sshd-command for proxy (see test-exec.sh) 22# sshd-command for proxy (see test-exec.sh)
23cmd="$SUDO sh ${SRC}/sshd-log-wrapper.sh ${SSHD} ${TEST_SSHD_LOGFILE} -i -f $OBJ/sshd_proxy" 23cmd="$SUDO sh ${SRC}/sshd-log-wrapper.sh ${TEST_SSHD_LOGFILE} ${SSHD} -i -f $OBJ/sshd_proxy"
24 24
25for m in $macs; do 25for m in $macs; do
26 trace "test $tid: mac $m" 26 trace "test $tid: mac $m"
diff --git a/regress/multiplex.sh b/regress/multiplex.sh
index 617615355..acb9234d9 100644
--- a/regress/multiplex.sh
+++ b/regress/multiplex.sh
@@ -90,7 +90,7 @@ $NC -N -Ul $OBJ/unix-1.fwd < ${DATA} > /dev/null &
90netcat_pid=$! 90netcat_pid=$!
91${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -L$OBJ/unix-2.fwd:$OBJ/unix-1.fwd otherhost >>$TEST_SSH_LOGFILE 2>&1 91${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -L$OBJ/unix-2.fwd:$OBJ/unix-1.fwd otherhost >>$TEST_SSH_LOGFILE 2>&1
92${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -R$OBJ/unix-3.fwd:$OBJ/unix-2.fwd otherhost >>$TEST_SSH_LOGFILE 2>&1 92${SSH} -F $OBJ/ssh_config -S $CTL -Oforward -R$OBJ/unix-3.fwd:$OBJ/unix-2.fwd otherhost >>$TEST_SSH_LOGFILE 2>&1
93$NC -U $OBJ/unix-3.fwd < /dev/null > ${COPY} 93$NC -U $OBJ/unix-3.fwd < /dev/null > ${COPY} 2>/dev/null
94cmp ${DATA} ${COPY} || fail "ssh: corrupted copy of ${DATA}" 94cmp ${DATA} ${COPY} || fail "ssh: corrupted copy of ${DATA}"
95kill $netcat_pid 2>/dev/null 95kill $netcat_pid 2>/dev/null
96rm -f ${COPY} $OBJ/unix-[123].fwd 96rm -f ${COPY} $OBJ/unix-[123].fwd
diff --git a/regress/reconfigure.sh b/regress/reconfigure.sh
index 1a42c21b7..e6af9eab1 100644
--- a/regress/reconfigure.sh
+++ b/regress/reconfigure.sh
@@ -4,14 +4,16 @@
4tid="simple connect after reconfigure" 4tid="simple connect after reconfigure"
5 5
6# we need the full path to sshd for -HUP 6# we need the full path to sshd for -HUP
7case $SSHD in 7if test "x$USE_VALGRIND" = "x" ; then
8/*) 8 case $SSHD in
9 # full path is OK 9 /*)
10 ;; 10 # full path is OK
11*) 11 ;;
12 # otherwise make fully qualified 12 *)
13 SSHD=$OBJ/$SSHD 13 # otherwise make fully qualified
14esac 14 SSHD=$OBJ/$SSHD
15 esac
16fi
15 17
16start_sshd 18start_sshd
17 19
diff --git a/regress/sshd-log-wrapper.sh b/regress/sshd-log-wrapper.sh
index a9386be4d..c00934c78 100644
--- a/regress/sshd-log-wrapper.sh
+++ b/regress/sshd-log-wrapper.sh
@@ -3,11 +3,9 @@
3# Placed in the Public Domain. 3# Placed in the Public Domain.
4# 4#
5# simple wrapper for sshd proxy mode to catch stderr output 5# simple wrapper for sshd proxy mode to catch stderr output
6# sh sshd-log-wrapper.sh /path/to/sshd /path/to/logfile 6# sh sshd-log-wrapper.sh /path/to/logfile /path/to/sshd [args...]
7 7
8sshd=$1 8log=$1
9log=$2
10shift
11shift 9shift
12 10
13exec $sshd -E$log $@ 11exec "$@" -E$log
diff --git a/regress/test-exec.sh b/regress/test-exec.sh
index a1bab832f..ff0768a04 100644
--- a/regress/test-exec.sh
+++ b/regress/test-exec.sh
@@ -141,6 +141,55 @@ case "$SSHAGENT" in
141*) SSHAGENT=`which $SSHAGENT` ;; 141*) SSHAGENT=`which $SSHAGENT` ;;
142esac 142esac
143 143
144# Record the actual binaries used.
145SSH_BIN=${SSH}
146SSHD_BIN=${SSHD}
147SSHAGENT_BIN=${SSHAGENT}
148SSHADD_BIN=${SSHADD}
149SSHKEYGEN_BIN=${SSHKEYGEN}
150SSHKEYSCAN_BIN=${SSHKEYSCAN}
151SFTP_BIN=${SFTP}
152SFTPSERVER_BIN=${SFTPSERVER}
153SCP_BIN=${SCP}
154
155if [ "x$USE_VALGRIND" != "x" ]; then
156 mkdir -p $OBJ/valgrind-out
157 VG_TEST=`basename $SCRIPT .sh`
158
159 # Some tests are difficult to fix.
160 case "$VG_TEST" in
161 connect-privsep|reexec)
162 VG_SKIP=1 ;;
163 esac
164
165 if [ x"$VG_SKIP" = "x" ]; then
166 VG_IGNORE="/bin/*,/sbin/*,/usr/*,/var/*"
167 VG_LOG="$OBJ/valgrind-out/${VG_TEST}."
168 VG_OPTS="--track-origins=yes --leak-check=full"
169 VG_OPTS="$VG_OPTS --trace-children=yes"
170 VG_OPTS="$VG_OPTS --trace-children-skip=${VG_IGNORE}"
171 VG_PATH="valgrind"
172 if [ "x$VALGRIND_PATH" != "x" ]; then
173 VG_PATH="$VALGRIND_PATH"
174 fi
175 VG="$VG_PATH $VG_OPTS"
176 SSH="$VG --log-file=${VG_LOG}ssh.%p $SSH"
177 SSHD="$VG --log-file=${VG_LOG}sshd.%p $SSHD"
178 SSHAGENT="$VG --log-file=${VG_LOG}ssh-agent.%p $SSHAGENT"
179 SSHADD="$VG --log-file=${VG_LOG}ssh-add.%p $SSHADD"
180 SSHKEYGEN="$VG --log-file=${VG_LOG}ssh-keygen.%p $SSHKEYGEN"
181 SSHKEYSCAN="$VG --log-file=${VG_LOG}ssh-keyscan.%p $SSHKEYSCAN"
182 SFTP="$VG --log-file=${VG_LOG}sftp.%p ${SFTP}"
183 SCP="$VG --log-file=${VG_LOG}scp.%p $SCP"
184 cat > $OBJ/valgrind-sftp-server.sh << EOF
185#!/bin/sh
186exec $VG --log-file=${VG_LOG}sftp-server.%p $SFTPSERVER "\$@"
187EOF
188 chmod a+rx $OBJ/valgrind-sftp-server.sh
189 SFTPSERVER="$OBJ/valgrind-sftp-server.sh"
190 fi
191fi
192
144# Logfiles. 193# Logfiles.
145# SSH_LOGFILE should be the debug output of ssh(1) only 194# SSH_LOGFILE should be the debug output of ssh(1) only
146# SSHD_LOGFILE should be the debug output of sshd(8) only 195# SSHD_LOGFILE should be the debug output of sshd(8) only
@@ -175,7 +224,7 @@ SSH="$SSHLOGWRAP"
175# [kbytes] to ensure the file is at least that large. 224# [kbytes] to ensure the file is at least that large.
176DATANAME=data 225DATANAME=data
177DATA=$OBJ/${DATANAME} 226DATA=$OBJ/${DATANAME}
178cat ${SSHAGENT} >${DATA} 227cat ${SSHAGENT_BIN} >${DATA}
179chmod u+w ${DATA} 228chmod u+w ${DATA}
180COPY=$OBJ/copy 229COPY=$OBJ/copy
181rm -f ${COPY} 230rm -f ${COPY}
@@ -183,7 +232,7 @@ rm -f ${COPY}
183increase_datafile_size() 232increase_datafile_size()
184{ 233{
185 while [ `du -k ${DATA} | cut -f1` -lt $1 ]; do 234 while [ `du -k ${DATA} | cut -f1` -lt $1 ]; do
186 cat ${SSHAGENT} >>${DATA} 235 cat ${SSHAGENT_BIN} >>${DATA}
187 done 236 done
188} 237}
189 238
@@ -388,7 +437,7 @@ rm -f $OBJ/known_hosts $OBJ/authorized_keys_$USER
388trace "generate keys" 437trace "generate keys"
389for t in rsa rsa1; do 438for t in rsa rsa1; do
390 # generate user key 439 # generate user key
391 if [ ! -f $OBJ/$t ] || [ ${SSHKEYGEN} -nt $OBJ/$t ]; then 440 if [ ! -f $OBJ/$t ] || [ ${SSHKEYGEN_BIN} -nt $OBJ/$t ]; then
392 rm -f $OBJ/$t 441 rm -f $OBJ/$t
393 ${SSHKEYGEN} -q -N '' -t $t -f $OBJ/$t ||\ 442 ${SSHKEYGEN} -q -N '' -t $t -f $OBJ/$t ||\
394 fail "ssh-keygen for $t failed" 443 fail "ssh-keygen for $t failed"
@@ -451,7 +500,7 @@ if test "$REGRESS_INTEROP_PUTTY" = "yes" ; then
451 echo "Hostname=127.0.0.1" >> ${OBJ}/.putty/sessions/localhost_proxy 500 echo "Hostname=127.0.0.1" >> ${OBJ}/.putty/sessions/localhost_proxy
452 echo "PortNumber=$PORT" >> ${OBJ}/.putty/sessions/localhost_proxy 501 echo "PortNumber=$PORT" >> ${OBJ}/.putty/sessions/localhost_proxy
453 echo "ProxyMethod=5" >> ${OBJ}/.putty/sessions/localhost_proxy 502 echo "ProxyMethod=5" >> ${OBJ}/.putty/sessions/localhost_proxy
454 echo "ProxyTelnetCommand=sh ${SRC}/sshd-log-wrapper.sh ${SSHD} ${TEST_SSHD_LOGFILE} -i -f $OBJ/sshd_proxy" >> ${OBJ}/.putty/sessions/localhost_proxy 503 echo "ProxyTelnetCommand=sh ${SRC}/sshd-log-wrapper.sh ${TEST_SSHD_LOGFILE} ${SSHD} -i -f $OBJ/sshd_proxy" >> ${OBJ}/.putty/sessions/localhost_proxy
455 504
456 REGRESS_INTEROP_PUTTY=yes 505 REGRESS_INTEROP_PUTTY=yes
457fi 506fi
@@ -459,7 +508,7 @@ fi
459# create a proxy version of the client config 508# create a proxy version of the client config
460( 509(
461 cat $OBJ/ssh_config 510 cat $OBJ/ssh_config
462 echo proxycommand ${SUDO} sh ${SRC}/sshd-log-wrapper.sh ${SSHD} ${TEST_SSHD_LOGFILE} -i -f $OBJ/sshd_proxy 511 echo proxycommand ${SUDO} sh ${SRC}/sshd-log-wrapper.sh ${TEST_SSHD_LOGFILE} ${SSHD} -i -f $OBJ/sshd_proxy
463) > $OBJ/ssh_proxy 512) > $OBJ/ssh_proxy
464 513
465# check proxy config 514# check proxy config
diff --git a/regress/valgrind-unit.sh b/regress/valgrind-unit.sh
new file mode 100755
index 000000000..433cb069a
--- /dev/null
+++ b/regress/valgrind-unit.sh
@@ -0,0 +1,20 @@
1#!/bin/sh
2
3UNIT_BINARY="$1"
4shift
5UNIT_ARGS="$@"
6
7test "x$OBJ" = "x" && OBJ=$PWD
8
9# This mostly replicates the logic in test-exec.sh for running the
10# regress tests under valgrind.
11VG_TEST=`basename $UNIT_BINARY`
12VG_LOG="$OBJ/valgrind-out/${VG_TEST}.%p"
13VG_OPTS="--track-origins=yes --leak-check=full --log-file=${VG_LOG}"
14VG_OPTS="$VG_OPTS --trace-children=yes"
15VG_PATH="valgrind"
16if [ "x$VALGRIND_PATH" != "x" ]; then
17 VG_PATH="$VALGRIND_PATH"
18fi
19
20exec $VG_PATH $VG_OPTS $UNIT_BINARY $UNIT_ARGS