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