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