1# $OpenBSD: Makefile,v 1.78 2015/01/26 06:12:18 djm Exp $ 2 3REGRESS_TARGETS= unit t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t-exec 4tests: prep $(REGRESS_TARGETS) 5 6# Interop tests are not run by default 7interop interop-tests: t-exec-interop 8 9prep: 10 test "x${USE_VALGRIND}" = "x" || mkdir -p $(OBJ)/valgrind-out 11 12clean: 13 for F in $(CLEANFILES); do rm -f $(OBJ)$$F; done 14 test -z "${SUDO}" || ${SUDO} rm -f ${SUDO_CLEAN} 15 rm -rf $(OBJ).putty 16 17distclean: clean 18 19LTESTS= connect \ 20 proxy-connect \ 21 connect-privsep \ 22 proto-version \ 23 proto-mismatch \ 24 exit-status \ 25 envpass \ 26 transfer \ 27 banner \ 28 rekey \ 29 stderr-data \ 30 stderr-after-eof \ 31 broken-pipe \ 32 try-ciphers \ 33 yes-head \ 34 login-timeout \ 35 agent \ 36 agent-getpeereid \ 37 agent-timeout \ 38 agent-ptrace \ 39 keyscan \ 40 keygen-change \ 41 keygen-convert \ 42 key-options \ 43 scp \ 44 sftp \ 45 sftp-chroot \ 46 sftp-cmds \ 47 sftp-badcmds \ 48 sftp-batch \ 49 sftp-glob \ 50 sftp-perm \ 51 reconfigure \ 52 dynamic-forward \ 53 forwarding \ 54 multiplex \ 55 reexec \ 56 brokenkeys \ 57 cfgmatch \ 58 addrmatch \ 59 localcommand \ 60 forcecommand \ 61 portnum \ 62 keytype \ 63 kextype \ 64 cert-hostkey \ 65 cert-userkey \ 66 host-expand \ 67 keys-command \ 68 forward-control \ 69 integrity \ 70 krl \ 71 multipubkey \ 72 limit-keytype \ 73 hostkey-agent \ 74 keygen-knownhosts \ 75 hostkey-rotate 76 77 78# dhgex \ 79 80INTEROP_TESTS= putty-transfer putty-ciphers putty-kex conch-ciphers 81#INTEROP_TESTS+=ssh-com ssh-com-client ssh-com-keygen ssh-com-sftp 82 83#LTESTS= cipher-speed 84 85USER!= id -un 86CLEANFILES= t2.out t3.out t6.out1 t6.out2 t7.out t7.out.pub copy.1 copy.2 \ 87 t8.out t8.out.pub t9.out t9.out.pub t10.out t10.out.pub \ 88 t12.out t12.out.pub \ 89 authorized_keys_${USER} known_hosts pidfile testdata \ 90 ssh_config sshd_config.orig ssh_proxy sshd_config sshd_proxy \ 91 rsa.pub rsa rsa1.pub rsa1 host.rsa host.rsa1 \ 92 rsa-agent rsa-agent.pub rsa1-agent rsa1-agent.pub \ 93 ls.copy banner.in banner.out empty.in \ 94 scp-ssh-wrapper.scp ssh_proxy_envpass remote_pid \ 95 sshd_proxy_bak rsa_ssh2_cr.prv rsa_ssh2_crnl.prv \ 96 known_hosts-cert host_ca_key* cert_host_key* cert_user_key* \ 97 putty.rsa2 sshd_proxy_orig ssh_proxy_bak \ 98 key.rsa-* key.dsa-* key.ecdsa-* \ 99 authorized_principals_${USER} expect actual ready \ 100 sshd_proxy.* authorized_keys_${USER}.* modpipe revoked-* krl-* \ 101 ssh.log failed-ssh.log sshd.log failed-sshd.log \ 102 regress.log failed-regress.log ssh-log-wrapper.sh \ 103 sftp-server.sh sftp-server.log sftp.log setuid-allowed \ 104 data ed25519-agent ed25519-agent.pub key.ed25519-512 \ 105 key.ed25519-512.pub netcat host_krl_* host_revoked_* \ 106 kh.* user_*key* agent-key.* known_hosts.* hkr.* 107 108SUDO_CLEAN+= /var/run/testdata_${USER} /var/run/keycommand_${USER} 109 110# Enable all malloc(3) randomisations and checks 111TEST_ENV= "MALLOC_OPTIONS=AFGJPRX" 112 113TEST_SSH_SSHKEYGEN?=ssh-keygen 114 115CPPFLAGS=-I.. 116 117t1: 118 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/rsa_ssh2.prv | diff - ${.CURDIR}/rsa_openssh.prv 119 tr '\n' '\r' <${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_cr.prv 120 ${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_cr.prv | diff - ${.CURDIR}/rsa_openssh.prv 121 awk '{print $$0 "\r"}' ${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_crnl.prv 122 ${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_crnl.prv | diff - ${.CURDIR}/rsa_openssh.prv 123 124t2: 125 cat ${.CURDIR}/rsa_openssh.prv > $(OBJ)/t2.out 126 chmod 600 $(OBJ)/t2.out 127 ${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t2.out | diff - ${.CURDIR}/rsa_openssh.pub 128 129t3: 130 ${TEST_SSH_SSHKEYGEN} -ef ${.CURDIR}/rsa_openssh.pub >$(OBJ)/t3.out 131 ${TEST_SSH_SSHKEYGEN} -if $(OBJ)/t3.out | diff - ${.CURDIR}/rsa_openssh.pub 132 133t4: 134 ${TEST_SSH_SSHKEYGEN} -E md5 -lf ${.CURDIR}/rsa_openssh.pub |\ 135 awk '{print $$2}' | diff - ${.CURDIR}/t4.ok 136 137t5: 138 ${TEST_SSH_SSHKEYGEN} -Bf ${.CURDIR}/rsa_openssh.pub |\ 139 awk '{print $$2}' | diff - ${.CURDIR}/t5.ok 140 141t6: 142 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.prv > $(OBJ)/t6.out1 143 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.pub > $(OBJ)/t6.out2 144 chmod 600 $(OBJ)/t6.out1 145 ${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t6.out1 | diff - $(OBJ)/t6.out2 146 147$(OBJ)/t7.out: 148 ${TEST_SSH_SSHKEYGEN} -q -t rsa -N '' -f $@ 149 150t7: $(OBJ)/t7.out 151 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t7.out > /dev/null 152 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t7.out > /dev/null 153 154$(OBJ)/t8.out: 155 ${TEST_SSH_SSHKEYGEN} -q -t dsa -N '' -f $@ 156 157t8: $(OBJ)/t8.out 158 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t8.out > /dev/null 159 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t8.out > /dev/null 160 161$(OBJ)/t9.out: 162 test "${TEST_SSH_ECC}" != yes || \ 163 ${TEST_SSH_SSHKEYGEN} -q -t ecdsa -N '' -f $@ 164 165t9: $(OBJ)/t9.out 166 test "${TEST_SSH_ECC}" != yes || \ 167 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t9.out > /dev/null 168 test "${TEST_SSH_ECC}" != yes || \ 169 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t9.out > /dev/null 170 171 172$(OBJ)/t10.out: 173 ${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -f $@ 174 175t10: $(OBJ)/t10.out 176 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t10.out > /dev/null 177 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t10.out > /dev/null 178 179t11: 180 ${TEST_SSH_SSHKEYGEN} -E sha256 -lf ${.CURDIR}/rsa_openssh.pub |\ 181 awk '{print $$2}' | diff - ${.CURDIR}/t11.ok 182 183t12.out: 184 ${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -C 'test-comment-1234' -f $(OBJ)/$@ 185 186t12: t12.out 187 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t12.out.pub | grep test-comment-1234 >/dev/null 188 189t-exec: ${LTESTS:=.sh} 190 @if [ "x$?" = "x" ]; then exit 0; fi; \ 191 for TEST in ""$?; do \ 192 echo "run test $${TEST}" ... 1>&2; \ 193 (env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \ 194 done 195 196t-exec-interop: ${INTEROP_TESTS:=.sh} 197 @if [ "x$?" = "x" ]; then exit 0; fi; \ 198 for TEST in ""$?; do \ 199 echo "run test $${TEST}" ... 1>&2; \ 200 (env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \ 201 done 202 203# Not run by default 204interop: ${INTEROP_TARGETS} 205 206# Unit tests, built by top-level Makefile 207unit: 208 set -e ; if test -z "${SKIP_UNIT}" ; then \ 209 V="" ; \ 210 test "x${USE_VALGRIND}" = "x" || \ 211 V=${.CURDIR}/valgrind-unit.sh ; \ 212 $$V ${.OBJDIR}/unittests/sshbuf/test_sshbuf ; \ 213 $$V ${.OBJDIR}/unittests/sshkey/test_sshkey \ 214 -d ${.CURDIR}/unittests/sshkey/testdata ; \ 215 $$V ${.OBJDIR}/unittests/bitmap/test_bitmap ; \ 216 $$V ${.OBJDIR}/unittests/kex/test_kex ; \ 217 $$V ${.OBJDIR}/unittests/hostkeys/test_hostkeys \ 218 -d ${.CURDIR}/unittests/hostkeys/testdata ; \ 219 fi 220