1 # $OpenBSD: Makefile,v 1.124 2023/03/01 09:29:32 dtucker 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
108 INTEROP_TESTS= putty-transfer putty-ciphers putty-kex conch-ciphers
109 #INTEROP_TESTS+=ssh-com ssh-com-client ssh-com-keygen ssh-com-sftp
111 EXTRA_TESTS= agent-pkcs11
112 #EXTRA_TESTS+= cipher-speed
115 CLEANFILES= *.core actual agent-key.* authorized_keys_${USERNAME} \
116 authorized_keys_${USERNAME}.* \
117 authorized_principals_${USERNAME} \
118 banner.in banner.out cert_host_key* cert_user_key* \
119 copy.1 copy.2 data ed25519-agent ed25519-agent* \
120 ed25519-agent.pub ed25519 ed25519.pub empty.in \
121 expect failed-regress.log failed-ssh.log failed-sshd.log \
122 hkr.* host.ecdsa-sha2-nistp256 host.ecdsa-sha2-nistp384 \
123 host.ecdsa-sha2-nistp521 host.ssh-dss host.ssh-ed25519 \
124 host.ssh-rsa host_ca_key* host_krl_* host_revoked_* key.* \
125 key.dsa-* key.ecdsa-* key.ed25519-512 \
126 key.ed25519-512.pub key.rsa-* keys-command-args kh.* askpass \
127 known_hosts known_hosts-cert known_hosts.* krl-* ls.copy \
128 modpipe netcat no_identity_config \
129 pidfile putty.rsa2 ready regress.log remote_pid \
130 revoked-* rsa rsa-agent rsa-agent.pub rsa.pub rsa_ssh2_cr.prv \
131 rsa_ssh2_crnl.prv scp-ssh-wrapper.exe \
132 scp-ssh-wrapper.scp setuid-allowed sftp-server.log \
133 sftp-server.sh sftp.log ssh-log-wrapper.sh ssh.log \
134 ssh-agent.log ssh-add.log slow-sftp-server.sh \
135 ssh-rsa_oldfmt knownhosts_command \
136 ssh_config ssh_config.* ssh_proxy ssh_proxy_bak \
137 ssh_proxy_* sshd.log sshd_config sshd_config.* \
138 sshd_config.* sshd_proxy sshd_proxy.* sshd_proxy_bak \
139 sshd_proxy_orig t10.out t10.out.pub t12.out t12.out.pub \
140 t2.out t3.out t6.out1 t6.out2 t7.out t7.out.pub \
141 t8.out t8.out.pub t9.out t9.out.pub \
142 timestamp testdata user_*key* user_ca* user_key*
144 # Enable all malloc(3) randomisations and checks
145 TEST_ENV= "MALLOC_OPTIONS=CFGJRSUX"
147 TEST_SSH_SSHKEYGEN?=ssh-keygen
152 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/rsa_ssh2.prv | diff - ${.CURDIR}/rsa_openssh.prv
153 tr '\n' '\r' <${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_cr.prv
154 ${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_cr.prv | diff - ${.CURDIR}/rsa_openssh.prv
155 awk '{print $$0 "\r"}' ${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_crnl.prv
156 ${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_crnl.prv | diff - ${.CURDIR}/rsa_openssh.prv
159 cat ${.CURDIR}/rsa_openssh.prv > $(OBJ)/t2.out
160 chmod 600 $(OBJ)/t2.out
161 ${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t2.out | diff - ${.CURDIR}/rsa_openssh.pub
164 ${TEST_SSH_SSHKEYGEN} -ef ${.CURDIR}/rsa_openssh.pub >$(OBJ)/t3.out
165 ${TEST_SSH_SSHKEYGEN} -if $(OBJ)/t3.out | diff - ${.CURDIR}/rsa_openssh.pub
168 ${TEST_SSH_SSHKEYGEN} -E md5 -lf ${.CURDIR}/rsa_openssh.pub |\
169 awk '{print $$2}' | diff - ${.CURDIR}/t4.ok
172 ${TEST_SSH_SSHKEYGEN} -Bf ${.CURDIR}/rsa_openssh.pub |\
173 awk '{print $$2}' | diff - ${.CURDIR}/t5.ok
176 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.prv > $(OBJ)/t6.out1
177 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.pub > $(OBJ)/t6.out2
178 chmod 600 $(OBJ)/t6.out1
179 ${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t6.out1 | diff - $(OBJ)/t6.out2
182 ${TEST_SSH_SSHKEYGEN} -q -t rsa -N '' -f $@
185 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t7.out > /dev/null
186 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t7.out > /dev/null
189 ${TEST_SSH_SSHKEYGEN} -q -t dsa -N '' -f $@
192 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t8.out > /dev/null
193 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t8.out > /dev/null
196 ! ${TEST_SSH_SSH} -Q key-plain | grep ecdsa >/dev/null || \
197 ${TEST_SSH_SSHKEYGEN} -q -t ecdsa -N '' -f $@
200 ! ${TEST_SSH_SSH} -Q key-plain | grep ecdsa >/dev/null || \
201 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t9.out > /dev/null
202 ! ${TEST_SSH_SSH} -Q key-plain | grep ecdsa >/dev/null || \
203 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t9.out > /dev/null
207 ${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -f $@
210 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t10.out > /dev/null
211 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t10.out > /dev/null
214 ${TEST_SSH_SSHKEYGEN} -E sha256 -lf ${.CURDIR}/rsa_openssh.pub |\
215 awk '{print $$2}' | diff - ${.CURDIR}/t11.ok
218 ${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -C 'test-comment-1234' -f $@
221 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t12.out.pub | grep test-comment-1234 >/dev/null
223 t-exec: ${LTESTS:=.sh}
224 @if [ "x$?" = "x" ]; then exit 0; fi; \
225 for TEST in ""$?; do \
227 for t in ""$${SKIP_LTESTS}; do \
228 if [ "x$${t}.sh" = "x$${TEST}" ]; then skip=yes; fi; \
230 if [ "x$${skip}" = "xno" ]; then \
231 echo "run test $${TEST}" ... 1>&2; \
232 (env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \
234 echo skip test $${TEST} 1>&2; \
238 t-exec-interop: ${INTEROP_TESTS:=.sh}
239 @if [ "x$?" = "x" ]; then exit 0; fi; \
240 for TEST in ""$?; do \
241 echo "run test $${TEST}" ... 1>&2; \
242 (env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \
245 t-extra: ${EXTRA_TESTS:=.sh}
246 @if [ "x$?" = "x" ]; then exit 0; fi; \
247 for TEST in ""$?; do \
248 echo "run test $${TEST}" ... 1>&2; \
249 (env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \
253 interop: ${INTEROP_TARGETS}
255 # Unit tests, built by top-level Makefile
257 set -e ; if test -z "${SKIP_UNIT}" ; then \
259 test "x${USE_VALGRIND}" = "x" || \
260 V=${.CURDIR}/valgrind-unit.sh ; \
261 $$V ${.OBJDIR}/unittests/sshbuf/test_sshbuf ; \
262 $$V ${.OBJDIR}/unittests/sshkey/test_sshkey \
263 -d ${.CURDIR}/unittests/sshkey/testdata ; \
264 $$V ${.OBJDIR}/unittests/sshsig/test_sshsig \
265 -d ${.CURDIR}/unittests/sshsig/testdata ; \
266 $$V ${.OBJDIR}/unittests/authopt/test_authopt \
267 -d ${.CURDIR}/unittests/authopt/testdata ; \
268 $$V ${.OBJDIR}/unittests/bitmap/test_bitmap ; \
269 $$V ${.OBJDIR}/unittests/conversion/test_conversion ; \
270 $$V ${.OBJDIR}/unittests/kex/test_kex ; \
271 $$V ${.OBJDIR}/unittests/hostkeys/test_hostkeys \
272 -d ${.CURDIR}/unittests/hostkeys/testdata ; \
273 $$V ${.OBJDIR}/unittests/match/test_match ; \
274 $$V ${.OBJDIR}/unittests/misc/test_misc ; \
275 if test "x${TEST_SSH_UTF8}" = "xyes" ; then \
276 $$V ${.OBJDIR}/unittests/utf8/test_utf8 ; \