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