1# $OpenBSD: Makefile,v 1.120 2022/01/06 21:46:56 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 \ 102 knownhosts-command \ 103 agent-restrict \ 104 hostbased 105 106INTEROP_TESTS= putty-transfer putty-ciphers putty-kex conch-ciphers 107#INTEROP_TESTS+=ssh-com ssh-com-client ssh-com-keygen ssh-com-sftp 108 109EXTRA_TESTS= agent-pkcs11 110#EXTRA_TESTS+= cipher-speed 111 112USERNAME= ${LOGNAME} 113CLEANFILES= *.core actual agent-key.* authorized_keys_${USERNAME} \ 114 authorized_keys_${USERNAME}.* \ 115 authorized_principals_${USERNAME} \ 116 banner.in banner.out cert_host_key* cert_user_key* \ 117 copy.1 copy.2 data ed25519-agent ed25519-agent* \ 118 ed25519-agent.pub ed25519 ed25519.pub empty.in \ 119 expect failed-regress.log failed-ssh.log failed-sshd.log \ 120 hkr.* host.ecdsa-sha2-nistp256 host.ecdsa-sha2-nistp384 \ 121 host.ecdsa-sha2-nistp521 host.ssh-dss host.ssh-ed25519 \ 122 host.ssh-rsa host_ca_key* host_krl_* host_revoked_* key.* \ 123 key.dsa-* key.ecdsa-* key.ed25519-512 \ 124 key.ed25519-512.pub key.rsa-* keys-command-args kh.* askpass \ 125 known_hosts known_hosts-cert known_hosts.* krl-* ls.copy \ 126 modpipe netcat no_identity_config \ 127 pidfile putty.rsa2 ready regress.log remote_pid \ 128 revoked-* rsa rsa-agent rsa-agent.pub rsa.pub rsa_ssh2_cr.prv \ 129 rsa_ssh2_crnl.prv scp-ssh-wrapper.exe \ 130 scp-ssh-wrapper.scp setuid-allowed sftp-server.log \ 131 sftp-server.sh sftp.log ssh-log-wrapper.sh ssh.log \ 132 ssh-rsa_oldfmt knownhosts_command \ 133 ssh_config ssh_config.* ssh_proxy ssh_proxy_bak \ 134 ssh_proxy_* sshd.log sshd_config sshd_config.* \ 135 sshd_config.* sshd_proxy sshd_proxy.* sshd_proxy_bak \ 136 sshd_proxy_orig t10.out t10.out.pub t12.out t12.out.pub \ 137 t2.out t3.out t6.out1 t6.out2 t7.out t7.out.pub \ 138 t8.out t8.out.pub t9.out t9.out.pub testdata \ 139 user_*key* user_ca* user_key* 140 141# Enable all malloc(3) randomisations and checks 142TEST_ENV= "MALLOC_OPTIONS=CFGJRSUX" 143 144TEST_SSH_SSHKEYGEN?=ssh-keygen 145 146CPPFLAGS=-I.. 147 148t1: 149 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/rsa_ssh2.prv | diff - ${.CURDIR}/rsa_openssh.prv 150 tr '\n' '\r' <${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_cr.prv 151 ${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_cr.prv | diff - ${.CURDIR}/rsa_openssh.prv 152 awk '{print $$0 "\r"}' ${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_crnl.prv 153 ${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_crnl.prv | diff - ${.CURDIR}/rsa_openssh.prv 154 155t2: 156 cat ${.CURDIR}/rsa_openssh.prv > $(OBJ)/t2.out 157 chmod 600 $(OBJ)/t2.out 158 ${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t2.out | diff - ${.CURDIR}/rsa_openssh.pub 159 160t3: 161 ${TEST_SSH_SSHKEYGEN} -ef ${.CURDIR}/rsa_openssh.pub >$(OBJ)/t3.out 162 ${TEST_SSH_SSHKEYGEN} -if $(OBJ)/t3.out | diff - ${.CURDIR}/rsa_openssh.pub 163 164t4: 165 ${TEST_SSH_SSHKEYGEN} -E md5 -lf ${.CURDIR}/rsa_openssh.pub |\ 166 awk '{print $$2}' | diff - ${.CURDIR}/t4.ok 167 168t5: 169 ${TEST_SSH_SSHKEYGEN} -Bf ${.CURDIR}/rsa_openssh.pub |\ 170 awk '{print $$2}' | diff - ${.CURDIR}/t5.ok 171 172t6: 173 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.prv > $(OBJ)/t6.out1 174 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.pub > $(OBJ)/t6.out2 175 chmod 600 $(OBJ)/t6.out1 176 ${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t6.out1 | diff - $(OBJ)/t6.out2 177 178$(OBJ)/t7.out: 179 ${TEST_SSH_SSHKEYGEN} -q -t rsa -N '' -f $@ 180 181t7: $(OBJ)/t7.out 182 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t7.out > /dev/null 183 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t7.out > /dev/null 184 185$(OBJ)/t8.out: 186 ${TEST_SSH_SSHKEYGEN} -q -t dsa -N '' -f $@ 187 188t8: $(OBJ)/t8.out 189 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t8.out > /dev/null 190 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t8.out > /dev/null 191 192$(OBJ)/t9.out: 193 ! ${TEST_SSH_SSH} -Q key-plain | grep ecdsa >/dev/null || \ 194 ${TEST_SSH_SSHKEYGEN} -q -t ecdsa -N '' -f $@ 195 196t9: $(OBJ)/t9.out 197 ! ${TEST_SSH_SSH} -Q key-plain | grep ecdsa >/dev/null || \ 198 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t9.out > /dev/null 199 ! ${TEST_SSH_SSH} -Q key-plain | grep ecdsa >/dev/null || \ 200 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t9.out > /dev/null 201 202 203$(OBJ)/t10.out: 204 ${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -f $@ 205 206t10: $(OBJ)/t10.out 207 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t10.out > /dev/null 208 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t10.out > /dev/null 209 210t11: 211 ${TEST_SSH_SSHKEYGEN} -E sha256 -lf ${.CURDIR}/rsa_openssh.pub |\ 212 awk '{print $$2}' | diff - ${.CURDIR}/t11.ok 213 214$(OBJ)/t12.out: 215 ${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -C 'test-comment-1234' -f $@ 216 217t12: $(OBJ)/t12.out 218 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t12.out.pub | grep test-comment-1234 >/dev/null 219 220t-exec: ${LTESTS:=.sh} 221 @if [ "x$?" = "x" ]; then exit 0; fi; \ 222 for TEST in ""$?; do \ 223 skip=no; \ 224 for t in ""$${SKIP_LTESTS}; do \ 225 if [ "x$${t}.sh" = "x$${TEST}" ]; then skip=yes; fi; \ 226 done; \ 227 if [ "x$${skip}" = "xno" ]; then \ 228 echo "run test $${TEST}" ... 1>&2; \ 229 (env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \ 230 else \ 231 echo skip test $${TEST} 1>&2; \ 232 fi; \ 233 done 234 235t-exec-interop: ${INTEROP_TESTS:=.sh} 236 @if [ "x$?" = "x" ]; then exit 0; fi; \ 237 for TEST in ""$?; do \ 238 echo "run test $${TEST}" ... 1>&2; \ 239 (env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \ 240 done 241 242t-extra: ${EXTRA_TESTS:=.sh} 243 @if [ "x$?" = "x" ]; then exit 0; fi; \ 244 for TEST in ""$?; do \ 245 echo "run test $${TEST}" ... 1>&2; \ 246 (env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \ 247 done 248 249# Not run by default 250interop: ${INTEROP_TARGETS} 251 252# Unit tests, built by top-level Makefile 253unit: 254 set -e ; if test -z "${SKIP_UNIT}" ; then \ 255 V="" ; \ 256 test "x${USE_VALGRIND}" = "x" || \ 257 V=${.CURDIR}/valgrind-unit.sh ; \ 258 $$V ${.OBJDIR}/unittests/sshbuf/test_sshbuf ; \ 259 $$V ${.OBJDIR}/unittests/sshkey/test_sshkey \ 260 -d ${.CURDIR}/unittests/sshkey/testdata ; \ 261 $$V ${.OBJDIR}/unittests/sshsig/test_sshsig \ 262 -d ${.CURDIR}/unittests/sshsig/testdata ; \ 263 $$V ${.OBJDIR}/unittests/authopt/test_authopt \ 264 -d ${.CURDIR}/unittests/authopt/testdata ; \ 265 $$V ${.OBJDIR}/unittests/bitmap/test_bitmap ; \ 266 $$V ${.OBJDIR}/unittests/conversion/test_conversion ; \ 267 $$V ${.OBJDIR}/unittests/kex/test_kex ; \ 268 $$V ${.OBJDIR}/unittests/hostkeys/test_hostkeys \ 269 -d ${.CURDIR}/unittests/hostkeys/testdata ; \ 270 $$V ${.OBJDIR}/unittests/match/test_match ; \ 271 $$V ${.OBJDIR}/unittests/misc/test_misc ; \ 272 if test "x${TEST_SSH_UTF8}" = "xyes" ; then \ 273 $$V ${.OBJDIR}/unittests/utf8/test_utf8 ; \ 274 fi \ 275 fi 276