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