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