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