diff options
author | Damien Miller <djm@mindrot.org> | 2015-02-25 16:58:22 -0800 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2015-02-26 14:55:55 -0800 |
commit | bd58853102cee739f0e115e6d4b5334332ab1442 (patch) | |
tree | c214663c1fa4b28cc687faba24183f36085a3141 | |
parent | f43d17269194761eded9e89f17456332f4c83824 (diff) |
valgrind support
-rw-r--r-- | regress/Makefile | 13 | ||||
-rw-r--r-- | regress/integrity.sh | 2 | ||||
-rw-r--r-- | regress/multiplex.sh | 2 | ||||
-rw-r--r-- | regress/reconfigure.sh | 18 | ||||
-rw-r--r-- | regress/sshd-log-wrapper.sh | 8 | ||||
-rw-r--r-- | regress/test-exec.sh | 59 | ||||
-rwxr-xr-x | regress/valgrind-unit.sh | 20 |
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 |
204 | unit: | 204 | unit: |
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) |
23 | cmd="$SUDO sh ${SRC}/sshd-log-wrapper.sh ${SSHD} ${TEST_SSHD_LOGFILE} -i -f $OBJ/sshd_proxy" | 23 | cmd="$SUDO sh ${SRC}/sshd-log-wrapper.sh ${TEST_SSHD_LOGFILE} ${SSHD} -i -f $OBJ/sshd_proxy" |
24 | 24 | ||
25 | for m in $macs; do | 25 | for 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 & | |||
90 | netcat_pid=$! | 90 | netcat_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 |
94 | cmp ${DATA} ${COPY} || fail "ssh: corrupted copy of ${DATA}" | 94 | cmp ${DATA} ${COPY} || fail "ssh: corrupted copy of ${DATA}" |
95 | kill $netcat_pid 2>/dev/null | 95 | kill $netcat_pid 2>/dev/null |
96 | rm -f ${COPY} $OBJ/unix-[123].fwd | 96 | rm -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 @@ | |||
4 | tid="simple connect after reconfigure" | 4 | tid="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 |
7 | case $SSHD in | 7 | if 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 |
14 | esac | 14 | SSHD=$OBJ/$SSHD |
15 | esac | ||
16 | fi | ||
15 | 17 | ||
16 | start_sshd | 18 | start_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 | ||
8 | sshd=$1 | 8 | log=$1 |
9 | log=$2 | ||
10 | shift | ||
11 | shift | 9 | shift |
12 | 10 | ||
13 | exec $sshd -E$log $@ | 11 | exec "$@" -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` ;; |
142 | esac | 142 | esac |
143 | 143 | ||
144 | # Record the actual binaries used. | ||
145 | SSH_BIN=${SSH} | ||
146 | SSHD_BIN=${SSHD} | ||
147 | SSHAGENT_BIN=${SSHAGENT} | ||
148 | SSHADD_BIN=${SSHADD} | ||
149 | SSHKEYGEN_BIN=${SSHKEYGEN} | ||
150 | SSHKEYSCAN_BIN=${SSHKEYSCAN} | ||
151 | SFTP_BIN=${SFTP} | ||
152 | SFTPSERVER_BIN=${SFTPSERVER} | ||
153 | SCP_BIN=${SCP} | ||
154 | |||
155 | if [ "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 | ||
186 | exec $VG --log-file=${VG_LOG}sftp-server.%p $SFTPSERVER "\$@" | ||
187 | EOF | ||
188 | chmod a+rx $OBJ/valgrind-sftp-server.sh | ||
189 | SFTPSERVER="$OBJ/valgrind-sftp-server.sh" | ||
190 | fi | ||
191 | fi | ||
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. |
176 | DATANAME=data | 225 | DATANAME=data |
177 | DATA=$OBJ/${DATANAME} | 226 | DATA=$OBJ/${DATANAME} |
178 | cat ${SSHAGENT} >${DATA} | 227 | cat ${SSHAGENT_BIN} >${DATA} |
179 | chmod u+w ${DATA} | 228 | chmod u+w ${DATA} |
180 | COPY=$OBJ/copy | 229 | COPY=$OBJ/copy |
181 | rm -f ${COPY} | 230 | rm -f ${COPY} |
@@ -183,7 +232,7 @@ rm -f ${COPY} | |||
183 | increase_datafile_size() | 232 | increase_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 | |||
388 | trace "generate keys" | 437 | trace "generate keys" |
389 | for t in rsa rsa1; do | 438 | for 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 |
457 | fi | 506 | fi |
@@ -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 | |||
3 | UNIT_BINARY="$1" | ||
4 | shift | ||
5 | UNIT_ARGS="$@" | ||
6 | |||
7 | test "x$OBJ" = "x" && OBJ=$PWD | ||
8 | |||
9 | # This mostly replicates the logic in test-exec.sh for running the | ||
10 | # regress tests under valgrind. | ||
11 | VG_TEST=`basename $UNIT_BINARY` | ||
12 | VG_LOG="$OBJ/valgrind-out/${VG_TEST}.%p" | ||
13 | VG_OPTS="--track-origins=yes --leak-check=full --log-file=${VG_LOG}" | ||
14 | VG_OPTS="$VG_OPTS --trace-children=yes" | ||
15 | VG_PATH="valgrind" | ||
16 | if [ "x$VALGRIND_PATH" != "x" ]; then | ||
17 | VG_PATH="$VALGRIND_PATH" | ||
18 | fi | ||
19 | |||
20 | exec $VG_PATH $VG_OPTS $UNIT_BINARY $UNIT_ARGS | ||