1 # $OpenBSD: Makefile,v 1.126 2023/09/06 23:36:09 djm Exp $
3 tests: prep file-tests t-exec unit
5 REGRESS_TARGETS= t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
8 file-tests: $(REGRESS_TARGETS)
10 # Interop tests are not run by default
11 interop interop-tests: t-exec-interop
14 test "x${USE_VALGRIND}" = "x" || mkdir -p $(OBJ)/valgrind-out
17 for F in $(CLEANFILES); do rm -f $(OBJ)$$F; done
109 INTEROP_TESTS= putty-transfer putty-ciphers putty-kex conch-ciphers
110 #INTEROP_TESTS+=ssh-com ssh-com-client ssh-com-keygen ssh-com-sftp
112 EXTRA_TESTS= agent-pkcs11
113 #EXTRA_TESTS+= cipher-speed
116 CLEANFILES= *.core actual agent-key.* authorized_keys_${USERNAME} \
117 authorized_keys_${USERNAME}.* \
118 authorized_principals_${USERNAME} \
119 banner.in banner.out cert_host_key* cert_user_key* \
120 copy.1 copy.2 data ed25519-agent ed25519-agent* \
121 ed25519-agent.pub ed25519 ed25519.pub empty.in \
122 expect failed-regress.log failed-ssh.log failed-sshd.log \
123 hkr.* host.ecdsa-sha2-nistp256 host.ecdsa-sha2-nistp384 \
124 host.ecdsa-sha2-nistp521 host.ssh-dss host.ssh-ed25519 \
125 host.ssh-rsa host_ca_key* host_krl_* host_revoked_* key.* \
126 key.dsa-* key.ecdsa-* key.ed25519-512 \
127 key.ed25519-512.pub key.rsa-* keys-command-args kh.* askpass \
128 known_hosts known_hosts-cert known_hosts.* krl-* ls.copy \
129 modpipe netcat no_identity_config \
130 pidfile putty.rsa2 ready regress.log remote_pid \
131 revoked-* rsa rsa-agent rsa-agent.pub rsa.pub rsa_ssh2_cr.prv \
132 rsa_ssh2_crnl.prv scp-ssh-wrapper.exe \
133 scp-ssh-wrapper.scp setuid-allowed sftp-server.log \
134 sftp-server.sh sftp.log ssh-log-wrapper.sh ssh.log \
135 ssh-agent.log ssh-add.log slow-sftp-server.sh \
136 ssh-rsa_oldfmt knownhosts_command \
137 ssh_config ssh_config.* ssh_proxy ssh_proxy_bak \
138 ssh_proxy_* sshd.log sshd_config sshd_config.* \
139 sshd_config.* sshd_proxy sshd_proxy.* sshd_proxy_bak \
140 sshd_proxy_orig t10.out t10.out.pub t12.out t12.out.pub \
141 t2.out t3.out t6.out1 t6.out2 t7.out t7.out.pub \
142 t8.out t8.out.pub t9.out t9.out.pub \
143 timestamp testdata user_*key* user_ca* user_key*
145 # Enable all malloc(3) randomisations and checks
146 TEST_ENV= "MALLOC_OPTIONS=CFGJRSUX"
148 TEST_SSH_SSHKEYGEN?=ssh-keygen
153 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/rsa_ssh2.prv | diff - ${.CURDIR}/rsa_openssh.prv
154 tr '\n' '\r' <${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_cr.prv
155 ${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_cr.prv | diff - ${.CURDIR}/rsa_openssh.prv
156 awk '{print $$0 "\r"}' ${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_crnl.prv
157 ${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_crnl.prv | diff - ${.CURDIR}/rsa_openssh.prv
160 cat ${.CURDIR}/rsa_openssh.prv > $(OBJ)/t2.out
161 chmod 600 $(OBJ)/t2.out
162 ${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t2.out | diff - ${.CURDIR}/rsa_openssh.pub
165 ${TEST_SSH_SSHKEYGEN} -ef ${.CURDIR}/rsa_openssh.pub >$(OBJ)/t3.out
166 ${TEST_SSH_SSHKEYGEN} -if $(OBJ)/t3.out | diff - ${.CURDIR}/rsa_openssh.pub
169 ${TEST_SSH_SSHKEYGEN} -E md5 -lf ${.CURDIR}/rsa_openssh.pub |\
170 awk '{print $$2}' | diff - ${.CURDIR}/t4.ok
173 ${TEST_SSH_SSHKEYGEN} -Bf ${.CURDIR}/rsa_openssh.pub |\
174 awk '{print $$2}' | diff - ${.CURDIR}/t5.ok
177 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.prv > $(OBJ)/t6.out1
178 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.pub > $(OBJ)/t6.out2
179 chmod 600 $(OBJ)/t6.out1
180 ${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t6.out1 | diff - $(OBJ)/t6.out2
183 ${TEST_SSH_SSHKEYGEN} -q -t rsa -N '' -f $@
186 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t7.out > /dev/null
187 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t7.out > /dev/null
190 ${TEST_SSH_SSHKEYGEN} -q -t dsa -N '' -f $@
193 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t8.out > /dev/null
194 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t8.out > /dev/null
197 ! ${TEST_SSH_SSH} -Q key-plain | grep ecdsa >/dev/null || \
198 ${TEST_SSH_SSHKEYGEN} -q -t ecdsa -N '' -f $@
201 ! ${TEST_SSH_SSH} -Q key-plain | grep ecdsa >/dev/null || \
202 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t9.out > /dev/null
203 ! ${TEST_SSH_SSH} -Q key-plain | grep ecdsa >/dev/null || \
204 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t9.out > /dev/null
208 ${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -f $@
211 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t10.out > /dev/null
212 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t10.out > /dev/null
215 ${TEST_SSH_SSHKEYGEN} -E sha256 -lf ${.CURDIR}/rsa_openssh.pub |\
216 awk '{print $$2}' | diff - ${.CURDIR}/t11.ok
219 ${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -C 'test-comment-1234' -f $@
222 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t12.out.pub | grep test-comment-1234 >/dev/null
224 t-exec: ${LTESTS:=.sh}
225 @if [ "x$?" = "x" ]; then exit 0; fi; \
226 _started=""; test -z "${LTESTS_FROM}" && _started=1 ;\
227 for TEST in ""$?; do \
228 if [ -z "$$_started" ] ; then \
229 if [ "x$$TEST" = "x${LTESTS_FROM}.sh" ]; then \
236 for t in ""$${SKIP_LTESTS}; do \
237 if [ "x$${t}.sh" = "x$${TEST}" ]; then skip=yes; fi; \
239 if [ "x$${skip}" = "xno" ]; then \
240 echo "run test $${TEST}" ... 1>&2; \
241 (env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \
243 echo skip test $${TEST} 1>&2; \
247 t-exec-interop: ${INTEROP_TESTS:=.sh}
248 @if [ "x$?" = "x" ]; then exit 0; fi; \
249 for TEST in ""$?; do \
250 echo "run test $${TEST}" ... 1>&2; \
251 (env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \
254 t-extra: ${EXTRA_TESTS:=.sh}
255 @if [ "x$?" = "x" ]; then exit 0; fi; \
256 for TEST in ""$?; do \
257 echo "run test $${TEST}" ... 1>&2; \
258 (env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \
262 interop: ${INTEROP_TARGETS}
264 # Unit tests, built by top-level Makefile
266 set -e ; if test -z "${SKIP_UNIT}" ; then \
268 test "x${USE_VALGRIND}" = "x" || \
269 V=${.CURDIR}/valgrind-unit.sh ; \
270 $$V ${.OBJDIR}/unittests/sshbuf/test_sshbuf ; \
271 $$V ${.OBJDIR}/unittests/sshkey/test_sshkey \
272 -d ${.CURDIR}/unittests/sshkey/testdata ; \
273 $$V ${.OBJDIR}/unittests/sshsig/test_sshsig \
274 -d ${.CURDIR}/unittests/sshsig/testdata ; \
275 $$V ${.OBJDIR}/unittests/authopt/test_authopt \
276 -d ${.CURDIR}/unittests/authopt/testdata ; \
277 $$V ${.OBJDIR}/unittests/bitmap/test_bitmap ; \
278 $$V ${.OBJDIR}/unittests/conversion/test_conversion ; \
279 $$V ${.OBJDIR}/unittests/kex/test_kex ; \
280 $$V ${.OBJDIR}/unittests/hostkeys/test_hostkeys \
281 -d ${.CURDIR}/unittests/hostkeys/testdata ; \
282 $$V ${.OBJDIR}/unittests/match/test_match ; \
283 $$V ${.OBJDIR}/unittests/misc/test_misc ; \
284 if test "x${TEST_SSH_UTF8}" = "xyes" ; then \
285 $$V ${.OBJDIR}/unittests/utf8/test_utf8 ; \