1# $OpenBSD: Makefile,v 1.95 2017/06/24 06:35:24 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 keygen-moduli \ 43 key-options \ 44 scp \ 45 sftp \ 46 sftp-chroot \ 47 sftp-cmds \ 48 sftp-badcmds \ 49 sftp-batch \ 50 sftp-glob \ 51 sftp-perm \ 52 reconfigure \ 53 dynamic-forward \ 54 forwarding \ 55 multiplex \ 56 reexec \ 57 brokenkeys \ 58 sshcfgparse \ 59 cfgparse \ 60 cfgmatch \ 61 addrmatch \ 62 localcommand \ 63 forcecommand \ 64 portnum \ 65 keytype \ 66 kextype \ 67 cert-hostkey \ 68 cert-userkey \ 69 host-expand \ 70 keys-command \ 71 forward-control \ 72 integrity \ 73 krl \ 74 multipubkey \ 75 limit-keytype \ 76 hostkey-agent \ 77 keygen-knownhosts \ 78 hostkey-rotate \ 79 principals-command \ 80 cert-file \ 81 cfginclude \ 82 allow-deny-users \ 83 authinfo 84 85 86# dhgex \ 87 88INTEROP_TESTS= putty-transfer putty-ciphers putty-kex conch-ciphers 89#INTEROP_TESTS+=ssh-com ssh-com-client ssh-com-keygen ssh-com-sftp 90 91#LTESTS= cipher-speed 92 93USERNAME= ${LOGNAME} 94CLEANFILES= *.core actual agent-key.* authorized_keys_${USERNAME} \ 95 authorized_keys_${USERNAME}.* \ 96 authorized_principals_${USERNAME} \ 97 banner.in banner.out cert_host_key* cert_user_key* \ 98 copy.1 copy.2 data ed25519-agent ed25519-agent* \ 99 ed25519-agent.pub ed25519 ed25519.pub empty.in \ 100 expect failed-regress.log failed-ssh.log failed-sshd.log \ 101 hkr.* host.ed25519 host.rsa host.rsa1 host_* \ 102 host_ca_key* host_krl_* host_revoked_* key.* \ 103 key.dsa-* key.ecdsa-* key.ed25519-512 \ 104 key.ed25519-512.pub key.rsa-* keys-command-args kh.* \ 105 known_hosts known_hosts-cert known_hosts.* krl-* ls.copy \ 106 modpipe netcat no_identity_config \ 107 pidfile putty.rsa2 ready regress.log \ 108 remote_pid revoked-* rsa rsa-agent rsa-agent.pub rsa.pub \ 109 rsa1 rsa1-agent rsa1-agent.pub rsa1.pub rsa_ssh2_cr.prv \ 110 rsa_ssh2_crnl.prv scp-ssh-wrapper.exe \ 111 scp-ssh-wrapper.scp setuid-allowed sftp-server.log \ 112 sftp-server.sh sftp.log ssh-log-wrapper.sh ssh.log \ 113 ssh_config ssh_config.* ssh_proxy ssh_proxy_bak \ 114 ssh_proxy_envpass sshd.log sshd_config sshd_config_minimal \ 115 sshd_config.orig sshd_proxy sshd_proxy.* sshd_proxy_bak \ 116 sshd_proxy_orig t10.out t10.out.pub t12.out t12.out.pub \ 117 t2.out t3.out t6.out1 t6.out2 t7.out t7.out.pub \ 118 t8.out t8.out.pub t9.out t9.out.pub testdata \ 119 user_*key* user_ca* user_key* 120 121SUDO_CLEAN+= /var/run/testdata_${USERNAME} /var/run/keycommand_${USERNAME} 122 123# Enable all malloc(3) randomisations and checks 124TEST_ENV= "MALLOC_OPTIONS=CFGJRSUX" 125 126TEST_SSH_SSHKEYGEN?=ssh-keygen 127 128CPPFLAGS=-I.. 129 130t1: 131 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/rsa_ssh2.prv | diff - ${.CURDIR}/rsa_openssh.prv 132 tr '\n' '\r' <${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_cr.prv 133 ${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_cr.prv | diff - ${.CURDIR}/rsa_openssh.prv 134 awk '{print $$0 "\r"}' ${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_crnl.prv 135 ${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_crnl.prv | diff - ${.CURDIR}/rsa_openssh.prv 136 137t2: 138 cat ${.CURDIR}/rsa_openssh.prv > $(OBJ)/t2.out 139 chmod 600 $(OBJ)/t2.out 140 ${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t2.out | diff - ${.CURDIR}/rsa_openssh.pub 141 142t3: 143 ${TEST_SSH_SSHKEYGEN} -ef ${.CURDIR}/rsa_openssh.pub >$(OBJ)/t3.out 144 ${TEST_SSH_SSHKEYGEN} -if $(OBJ)/t3.out | diff - ${.CURDIR}/rsa_openssh.pub 145 146t4: 147 ${TEST_SSH_SSHKEYGEN} -E md5 -lf ${.CURDIR}/rsa_openssh.pub |\ 148 awk '{print $$2}' | diff - ${.CURDIR}/t4.ok 149 150t5: 151 ${TEST_SSH_SSHKEYGEN} -Bf ${.CURDIR}/rsa_openssh.pub |\ 152 awk '{print $$2}' | diff - ${.CURDIR}/t5.ok 153 154t6: 155 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.prv > $(OBJ)/t6.out1 156 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.pub > $(OBJ)/t6.out2 157 chmod 600 $(OBJ)/t6.out1 158 ${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t6.out1 | diff - $(OBJ)/t6.out2 159 160$(OBJ)/t7.out: 161 ${TEST_SSH_SSHKEYGEN} -q -t rsa -N '' -f $@ 162 163t7: $(OBJ)/t7.out 164 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t7.out > /dev/null 165 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t7.out > /dev/null 166 167$(OBJ)/t8.out: 168 ${TEST_SSH_SSHKEYGEN} -q -t dsa -N '' -f $@ 169 170t8: $(OBJ)/t8.out 171 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t8.out > /dev/null 172 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t8.out > /dev/null 173 174$(OBJ)/t9.out: 175 test "${TEST_SSH_ECC}" != yes || \ 176 ${TEST_SSH_SSHKEYGEN} -q -t ecdsa -N '' -f $@ 177 178t9: $(OBJ)/t9.out 179 test "${TEST_SSH_ECC}" != yes || \ 180 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t9.out > /dev/null 181 test "${TEST_SSH_ECC}" != yes || \ 182 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t9.out > /dev/null 183 184 185$(OBJ)/t10.out: 186 ${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -f $@ 187 188t10: $(OBJ)/t10.out 189 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t10.out > /dev/null 190 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t10.out > /dev/null 191 192t11: 193 ${TEST_SSH_SSHKEYGEN} -E sha256 -lf ${.CURDIR}/rsa_openssh.pub |\ 194 awk '{print $$2}' | diff - ${.CURDIR}/t11.ok 195 196$(OBJ)/t12.out: 197 ${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -C 'test-comment-1234' -f $@ 198 199t12: $(OBJ)/t12.out 200 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t12.out.pub | grep test-comment-1234 >/dev/null 201 202t-exec: ${LTESTS:=.sh} 203 @if [ "x$?" = "x" ]; then exit 0; fi; \ 204 for TEST in ""$?; do \ 205 echo "run test $${TEST}" ... 1>&2; \ 206 (env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \ 207 done 208 209t-exec-interop: ${INTEROP_TESTS:=.sh} 210 @if [ "x$?" = "x" ]; then exit 0; fi; \ 211 for TEST in ""$?; do \ 212 echo "run test $${TEST}" ... 1>&2; \ 213 (env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \ 214 done 215 216# Not run by default 217interop: ${INTEROP_TARGETS} 218 219# Unit tests, built by top-level Makefile 220unit: 221 set -e ; if test -z "${SKIP_UNIT}" ; then \ 222 V="" ; \ 223 test "x${USE_VALGRIND}" = "x" || \ 224 V=${.CURDIR}/valgrind-unit.sh ; \ 225 $$V ${.OBJDIR}/unittests/sshbuf/test_sshbuf ; \ 226 $$V ${.OBJDIR}/unittests/sshkey/test_sshkey \ 227 -d ${.CURDIR}/unittests/sshkey/testdata ; \ 228 $$V ${.OBJDIR}/unittests/bitmap/test_bitmap ; \ 229 $$V ${.OBJDIR}/unittests/conversion/test_conversion ; \ 230 $$V ${.OBJDIR}/unittests/kex/test_kex ; \ 231 $$V ${.OBJDIR}/unittests/hostkeys/test_hostkeys \ 232 -d ${.CURDIR}/unittests/hostkeys/testdata ; \ 233 $$V ${.OBJDIR}/unittests/match/test_match ; \ 234 if test "x${TEST_SSH_UTF8}" = "xyes" ; then \ 235 $$V ${.OBJDIR}/unittests/utf8/test_utf8 ; \ 236 fi \ 237 fi 238