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