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