xref: /freebsd/crypto/openssh/regress/Makefile (revision b9f654b163bce26de79705e77b872427c9f2afa1)
1#	$OpenBSD: Makefile,v 1.97 2018/06/07 04:46:34 djm Exp $
2
3REGRESS_TARGETS=	unit t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t-exec
4tests:		prep $(REGRESS_TARGETS)
5
6# Interop tests are not run by default
7interop interop-tests: t-exec-interop
8
9prep:
10	test "x${USE_VALGRIND}" = "x" || mkdir -p $(OBJ)/valgrind-out
11
12clean:
13	for F in $(CLEANFILES); do rm -f $(OBJ)$$F; done
14	test -z "${SUDO}" || ${SUDO} rm -f ${SUDO_CLEAN}
15	rm -rf $(OBJ).putty
16
17distclean:	clean
18
19LTESTS= 	connect \
20		proxy-connect \
21		connect-privsep \
22		connect-uri \
23		proto-version \
24		proto-mismatch \
25		exit-status \
26		envpass \
27		transfer \
28		banner \
29		rekey \
30		stderr-data \
31		stderr-after-eof \
32		broken-pipe \
33		try-ciphers \
34		yes-head \
35		login-timeout \
36		agent \
37		agent-getpeereid \
38		agent-timeout \
39		agent-ptrace \
40		keyscan \
41		keygen-change \
42		keygen-convert \
43		keygen-moduli \
44		key-options \
45		scp \
46		scp-uri \
47		sftp \
48		sftp-chroot \
49		sftp-cmds \
50		sftp-badcmds \
51		sftp-batch \
52		sftp-glob \
53		sftp-perm \
54		sftp-uri \
55		reconfigure \
56		dynamic-forward \
57		forwarding \
58		multiplex \
59		reexec \
60		brokenkeys \
61		sshcfgparse \
62		cfgparse \
63		cfgmatch \
64		cfgmatchlisten \
65		addrmatch \
66		localcommand \
67		forcecommand \
68		portnum \
69		keytype \
70		kextype \
71		cert-hostkey \
72		cert-userkey \
73		host-expand \
74		keys-command \
75		forward-control \
76		integrity \
77		krl \
78		multipubkey \
79		limit-keytype \
80		hostkey-agent \
81		keygen-knownhosts \
82		hostkey-rotate \
83		principals-command \
84		cert-file \
85		cfginclude \
86		allow-deny-users \
87		authinfo
88
89
90#		dhgex \
91
92INTEROP_TESTS=	putty-transfer putty-ciphers putty-kex conch-ciphers
93#INTEROP_TESTS+=ssh-com ssh-com-client ssh-com-keygen ssh-com-sftp
94
95#LTESTS= 	cipher-speed
96
97USERNAME=		${LOGNAME}
98CLEANFILES=	*.core actual agent-key.* authorized_keys_${USERNAME} \
99		authorized_keys_${USERNAME}.* \
100		authorized_principals_${USERNAME} \
101		banner.in banner.out cert_host_key* cert_user_key* \
102		copy.1 copy.2 data ed25519-agent ed25519-agent* \
103		ed25519-agent.pub ed25519 ed25519.pub empty.in \
104		expect failed-regress.log failed-ssh.log failed-sshd.log \
105		hkr.* host.ed25519 host.rsa host.rsa1 host_* \
106		host_ca_key* host_krl_* host_revoked_* key.* \
107		key.dsa-* key.ecdsa-* key.ed25519-512 \
108		key.ed25519-512.pub key.rsa-* keys-command-args kh.* \
109		known_hosts known_hosts-cert known_hosts.* krl-* ls.copy \
110		modpipe netcat no_identity_config \
111		pidfile putty.rsa2 ready regress.log \
112		remote_pid revoked-* rsa rsa-agent rsa-agent.pub rsa.pub \
113		rsa1 rsa1-agent rsa1-agent.pub rsa1.pub rsa_ssh2_cr.prv \
114		rsa_ssh2_crnl.prv scp-ssh-wrapper.exe \
115		scp-ssh-wrapper.scp setuid-allowed sftp-server.log \
116		sftp-server.sh sftp.log ssh-log-wrapper.sh ssh.log \
117		ssh_config ssh_config.* ssh_proxy ssh_proxy_bak \
118		ssh_proxy_envpass sshd.log sshd_config sshd_config_minimal \
119		sshd_config.orig sshd_proxy sshd_proxy.* sshd_proxy_bak \
120		sshd_proxy_orig t10.out t10.out.pub t12.out t12.out.pub \
121		t2.out t3.out t6.out1 t6.out2 t7.out t7.out.pub \
122		t8.out t8.out.pub t9.out t9.out.pub testdata \
123		user_*key* user_ca* user_key*
124
125SUDO_CLEAN+=	/var/run/testdata_${USERNAME} /var/run/keycommand_${USERNAME}
126
127# Enable all malloc(3) randomisations and checks
128TEST_ENV=      "MALLOC_OPTIONS=CFGJRSUX"
129
130TEST_SSH_SSHKEYGEN?=ssh-keygen
131
132CPPFLAGS=-I..
133
134t1:
135	${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/rsa_ssh2.prv | diff - ${.CURDIR}/rsa_openssh.prv
136	tr '\n' '\r' <${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_cr.prv
137	${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_cr.prv | diff - ${.CURDIR}/rsa_openssh.prv
138	awk '{print $$0 "\r"}' ${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_crnl.prv
139	${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_crnl.prv | diff - ${.CURDIR}/rsa_openssh.prv
140
141t2:
142	cat ${.CURDIR}/rsa_openssh.prv > $(OBJ)/t2.out
143	chmod 600 $(OBJ)/t2.out
144	${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t2.out | diff - ${.CURDIR}/rsa_openssh.pub
145
146t3:
147	${TEST_SSH_SSHKEYGEN} -ef ${.CURDIR}/rsa_openssh.pub >$(OBJ)/t3.out
148	${TEST_SSH_SSHKEYGEN} -if $(OBJ)/t3.out | diff - ${.CURDIR}/rsa_openssh.pub
149
150t4:
151	${TEST_SSH_SSHKEYGEN} -E md5 -lf ${.CURDIR}/rsa_openssh.pub |\
152		awk '{print $$2}' | diff - ${.CURDIR}/t4.ok
153
154t5:
155	${TEST_SSH_SSHKEYGEN} -Bf ${.CURDIR}/rsa_openssh.pub |\
156		awk '{print $$2}' | diff - ${.CURDIR}/t5.ok
157
158t6:
159	${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.prv > $(OBJ)/t6.out1
160	${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.pub > $(OBJ)/t6.out2
161	chmod 600 $(OBJ)/t6.out1
162	${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t6.out1 | diff - $(OBJ)/t6.out2
163
164$(OBJ)/t7.out:
165	${TEST_SSH_SSHKEYGEN} -q -t rsa -N '' -f $@
166
167t7: $(OBJ)/t7.out
168	${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t7.out > /dev/null
169	${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t7.out > /dev/null
170
171$(OBJ)/t8.out:
172	${TEST_SSH_SSHKEYGEN} -q -t dsa -N '' -f $@
173
174t8: $(OBJ)/t8.out
175	${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t8.out > /dev/null
176	${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t8.out > /dev/null
177
178$(OBJ)/t9.out:
179	test "${TEST_SSH_ECC}" != yes || \
180	${TEST_SSH_SSHKEYGEN} -q -t ecdsa -N '' -f $@
181
182t9: $(OBJ)/t9.out
183	test "${TEST_SSH_ECC}" != yes || \
184	${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t9.out > /dev/null
185	test "${TEST_SSH_ECC}" != yes || \
186	${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t9.out > /dev/null
187
188
189$(OBJ)/t10.out:
190	${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -f $@
191
192t10: $(OBJ)/t10.out
193	${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t10.out > /dev/null
194	${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t10.out > /dev/null
195
196t11:
197	${TEST_SSH_SSHKEYGEN} -E sha256 -lf ${.CURDIR}/rsa_openssh.pub |\
198		awk '{print $$2}' | diff - ${.CURDIR}/t11.ok
199
200$(OBJ)/t12.out:
201	${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -C 'test-comment-1234' -f $@
202
203t12: $(OBJ)/t12.out
204	${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t12.out.pub | grep test-comment-1234 >/dev/null
205
206t-exec:	${LTESTS:=.sh}
207	@if [ "x$?" = "x" ]; then exit 0; fi; \
208	for TEST in ""$?; do \
209		echo "run test $${TEST}" ... 1>&2; \
210		(env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \
211	done
212
213t-exec-interop:	${INTEROP_TESTS:=.sh}
214	@if [ "x$?" = "x" ]; then exit 0; fi; \
215	for TEST in ""$?; do \
216		echo "run test $${TEST}" ... 1>&2; \
217		(env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} ${TEST_SHELL} ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \
218	done
219
220# Not run by default
221interop: ${INTEROP_TARGETS}
222
223# Unit tests, built by top-level Makefile
224unit:
225	set -e ; if test -z "${SKIP_UNIT}" ; then \
226		V="" ; \
227		test "x${USE_VALGRIND}" = "x" || \
228		    V=${.CURDIR}/valgrind-unit.sh ; \
229		$$V ${.OBJDIR}/unittests/sshbuf/test_sshbuf ; \
230		$$V ${.OBJDIR}/unittests/sshkey/test_sshkey \
231			-d ${.CURDIR}/unittests/sshkey/testdata ; \
232		$$V ${.OBJDIR}/unittests/bitmap/test_bitmap ; \
233		$$V ${.OBJDIR}/unittests/conversion/test_conversion ; \
234		$$V ${.OBJDIR}/unittests/kex/test_kex ; \
235		$$V ${.OBJDIR}/unittests/hostkeys/test_hostkeys \
236			-d ${.CURDIR}/unittests/hostkeys/testdata ; \
237		$$V ${.OBJDIR}/unittests/match/test_match ; \
238		if test "x${TEST_SSH_UTF8}" = "xyes"  ; then \
239			$$V ${.OBJDIR}/unittests/utf8/test_utf8 ; \
240		fi \
241	fi
242