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