1264377Sdes#	$OpenBSD: Makefile,v 1.68 2014/01/25 04:35:32 dtucker Exp $
298937Sdes
3262566SdesREGRESS_TARGETS=	t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t-exec
4124208Sdestests:		$(REGRESS_TARGETS)
598937Sdes
6180746Sdes# Interop tests are not run by default
7180746Sdesinterop interop-tests: t-exec-interop
8180746Sdes
9124208Sdesclean:
10124208Sdes	for F in $(CLEANFILES); do rm -f $(OBJ)$$F; done
11255670Sdes	test -z "${SUDO}" || ${SUDO} rm -f ${SUDO_CLEAN}
12180746Sdes	rm -rf $(OBJ).putty
13180746Sdes
14124208Sdesdistclean:	clean
1598937Sdes
1698937SdesLTESTS= 	connect \
1798937Sdes		proxy-connect \
1898937Sdes		connect-privsep \
1998937Sdes		proto-version \
2098937Sdes		proto-mismatch \
2198937Sdes		exit-status \
22137015Sdes		envpass \
2398937Sdes		transfer \
24126274Sdes		banner \
25124208Sdes		rekey \
2698937Sdes		stderr-data \
2798937Sdes		stderr-after-eof \
2898937Sdes		broken-pipe \
2998937Sdes		try-ciphers \
3098937Sdes		yes-head \
31128456Sdes		login-timeout \
3298937Sdes		agent \
33113908Sdes		agent-getpeereid \
34113908Sdes		agent-timeout \
35113908Sdes		agent-ptrace \
3698937Sdes		keyscan \
37113908Sdes		keygen-change \
38204861Sdes		keygen-convert \
39180750Sdes		key-options \
40137015Sdes		scp \
4198937Sdes		sftp \
42255670Sdes		sftp-chroot \
43113908Sdes		sftp-cmds \
44124208Sdes		sftp-badcmds \
45113908Sdes		sftp-batch \
46146998Sdes		sftp-glob \
47262566Sdes		sftp-perm \
48124208Sdes		reconfigure \
49124208Sdes		dynamic-forward \
50137015Sdes		forwarding \
51137015Sdes		multiplex \
52146998Sdes		reexec \
53162852Sdes		brokenkeys \
54162852Sdes		cfgmatch \
55180750Sdes		addrmatch \
56180746Sdes		localcommand \
57204861Sdes		forcecommand \
58204861Sdes		portnum \
59218767Sdes		keytype \
60218767Sdes		kextype \
61204861Sdes		cert-hostkey \
62218767Sdes		cert-userkey \
63248613Sdes		host-expand \
64248613Sdes		keys-command \
65248613Sdes		forward-control \
66248613Sdes		integrity \
67248613Sdes		krl
68264377Sdes#		dhgex \
6998937Sdes
70180750SdesINTEROP_TESTS=	putty-transfer putty-ciphers putty-kex conch-ciphers
71180746Sdes#INTEROP_TESTS+=ssh-com ssh-com-client ssh-com-keygen ssh-com-sftp
72180746Sdes
73218767Sdes#LTESTS= 	cipher-speed
74218767Sdes
7598937SdesUSER!=		id -un
76218767SdesCLEANFILES=	t2.out t3.out t6.out1 t6.out2 t7.out t7.out.pub copy.1 copy.2 \
77262566Sdes		t8.out t8.out.pub t9.out t9.out.pub t10.out t10.out.pub \
78248613Sdes		authorized_keys_${USER} known_hosts pidfile testdata \
79146998Sdes		ssh_config sshd_config.orig ssh_proxy sshd_config sshd_proxy \
8098937Sdes		rsa.pub rsa rsa1.pub rsa1 host.rsa host.rsa1 \
8198937Sdes		rsa-agent rsa-agent.pub rsa1-agent rsa1-agent.pub \
82137015Sdes		ls.copy banner.in banner.out empty.in \
83162852Sdes		scp-ssh-wrapper.scp ssh_proxy_envpass remote_pid \
84180746Sdes		sshd_proxy_bak rsa_ssh2_cr.prv rsa_ssh2_crnl.prv \
85248613Sdes		known_hosts-cert host_ca_key* cert_host_key* cert_user_key* \
86218767Sdes		putty.rsa2 sshd_proxy_orig ssh_proxy_bak \
87218767Sdes		key.rsa-* key.dsa-* key.ecdsa-* \
88248613Sdes		authorized_principals_${USER} expect actual ready \
89255670Sdes		sshd_proxy.* authorized_keys_${USER}.* modpipe revoked-* krl-* \
90255670Sdes		ssh.log failed-ssh.log sshd.log failed-sshd.log \
91262566Sdes		regress.log failed-regress.log ssh-log-wrapper.sh \
92262566Sdes		sftp-server.sh sftp-server.log sftp.log setuid-allowed \
93262566Sdes		data ed25519-agent ed25519-agent.pub key.ed25519-512 \
94262566Sdes		key.ed25519-512.pub
9598937Sdes
96255670SdesSUDO_CLEAN+=	/var/run/testdata_${USER} /var/run/keycommand_${USER}
97248613Sdes
98204861Sdes# Enable all malloc(3) randomisations and checks
99204861SdesTEST_ENV=      "MALLOC_OPTIONS=AFGJPRX"
100204861Sdes
101218767SdesTEST_SSH_SSHKEYGEN?=ssh-keygen
102218767Sdes
103248613SdesCPPFLAGS=-I..
104248613Sdes
10598937Sdest1:
106218767Sdes	${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/rsa_ssh2.prv | diff - ${.CURDIR}/rsa_openssh.prv
107218767Sdes	tr '\n' '\r' <${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_cr.prv
108218767Sdes	${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_cr.prv | diff - ${.CURDIR}/rsa_openssh.prv
109218767Sdes	awk '{print $$0 "\r"}' ${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_crnl.prv
110218767Sdes	${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_crnl.prv | diff - ${.CURDIR}/rsa_openssh.prv
11198937Sdes
11298937Sdest2:
113124208Sdes	cat ${.CURDIR}/rsa_openssh.prv > $(OBJ)/t2.out
114124208Sdes	chmod 600 $(OBJ)/t2.out
115218767Sdes	${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t2.out | diff - ${.CURDIR}/rsa_openssh.pub
11698937Sdes
11798937Sdest3:
118218767Sdes	${TEST_SSH_SSHKEYGEN} -ef ${.CURDIR}/rsa_openssh.pub >$(OBJ)/t3.out
119218767Sdes	${TEST_SSH_SSHKEYGEN} -if $(OBJ)/t3.out | diff - ${.CURDIR}/rsa_openssh.pub
12098937Sdes
12198937Sdest4:
122218767Sdes	${TEST_SSH_SSHKEYGEN} -lf ${.CURDIR}/rsa_openssh.pub |\
12398937Sdes		awk '{print $$2}' | diff - ${.CURDIR}/t4.ok
12498937Sdes
12598937Sdest5:
126218767Sdes	${TEST_SSH_SSHKEYGEN} -Bf ${.CURDIR}/rsa_openssh.pub |\
12798937Sdes		awk '{print $$2}' | diff - ${.CURDIR}/t5.ok
12898937Sdes
12998937Sdest6:
130218767Sdes	${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.prv > $(OBJ)/t6.out1
131218767Sdes	${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.pub > $(OBJ)/t6.out2
132124208Sdes	chmod 600 $(OBJ)/t6.out1
133218767Sdes	${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t6.out1 | diff - $(OBJ)/t6.out2
13498937Sdes
135124208Sdes$(OBJ)/t7.out:
136218767Sdes	${TEST_SSH_SSHKEYGEN} -q -t rsa -N '' -f $@
13798937Sdes
138124208Sdest7: $(OBJ)/t7.out
139218767Sdes	${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t7.out > /dev/null
140218767Sdes	${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t7.out > /dev/null
14198937Sdes
142218767Sdes$(OBJ)/t8.out:
143218767Sdes	${TEST_SSH_SSHKEYGEN} -q -t dsa -N '' -f $@
144218767Sdes
145218767Sdest8: $(OBJ)/t8.out
146218767Sdes	${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t8.out > /dev/null
147218767Sdes	${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t8.out > /dev/null
148218767Sdes
149218767Sdes$(OBJ)/t9.out:
150218767Sdes	test "${TEST_SSH_ECC}" != yes || \
151218767Sdes	${TEST_SSH_SSHKEYGEN} -q -t ecdsa -N '' -f $@
152218767Sdes
153218767Sdest9: $(OBJ)/t9.out
154218767Sdes	test "${TEST_SSH_ECC}" != yes || \
155218767Sdes	${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t9.out > /dev/null
156218767Sdes	test "${TEST_SSH_ECC}" != yes || \
157218767Sdes	${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t9.out > /dev/null
158218767Sdes
159262566Sdes
160262566Sdes$(OBJ)/t10.out:
161262566Sdes	${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -f $@
162262566Sdes
163262566Sdest10: $(OBJ)/t10.out
164262566Sdes	${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t10.out > /dev/null
165262566Sdes	${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t10.out > /dev/null
166262566Sdes
167124208Sdest-exec:	${LTESTS:=.sh}
168124208Sdes	@if [ "x$?" = "x" ]; then exit 0; fi; \
169124208Sdes	for TEST in ""$?; do \
170124208Sdes		echo "run test $${TEST}" ... 1>&2; \
171255670Sdes		(env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \
172124208Sdes	done
173180746Sdes
174180746Sdest-exec-interop:	${INTEROP_TESTS:=.sh}
175180746Sdes	@if [ "x$?" = "x" ]; then exit 0; fi; \
176180746Sdes	for TEST in ""$?; do \
177180746Sdes		echo "run test $${TEST}" ... 1>&2; \
178255670Sdes		(env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \
179180746Sdes	done
180180746Sdes
181218767Sdes# Not run by default
182218767Sdesinterop: ${INTEROP_TARGETS}
183