xref: /openbsd/regress/usr.sbin/relayd/Makefile (revision 5af055cd)
1#	$OpenBSD: Makefile,v 1.12 2015/10/09 17:51:08 bluhm Exp $
2
3# The following ports must be installed for the regression tests:
4# p5-IO-Socket-INET6	object interface for AF_INET and AF_INET6 domain sockets
5# p5-Socket6		Perl defines relating to AF_INET6 sockets
6# p5-IO-Socket-SSL	perl interface to SSL sockets
7#
8# Check wether all required perl packages are installed.  If some
9# are missing print a warning and skip the tests, but do not fail.
10
11PERL_REQUIRE !=	perl -Mstrict -Mwarnings -e ' \
12    eval { require IO::Socket::INET6 } or print $@; \
13    eval { require Socket6 } or print $@; \
14    eval { require IO::Socket::SSL } or print $@; \
15'
16.if ! empty (PERL_REQUIRE)
17regress:
18	@echo "${PERL_REQUIRE}"
19	@echo install these perl packages for additional tests
20.endif
21
22# Fill out these variables if you want to test relayd with
23# the relayd process running on a remote machine.  You have to specify
24# a local and remote ip address for the tcp connections.  To control
25# the remote machine you need a hostname for ssh to log in.  All the
26# test files must be in the same directory local and remote.
27
28LOCAL_ADDR ?=
29REMOTE_ADDR ?=
30REMOTE_SSH ?=
31
32# Automatically generate regress targets from test cases in directory.
33
34ARGS !=			cd ${.CURDIR} && ls args-*.pl
35TARGETS ?=		${ARGS}
36REGRESS_TARGETS =	${TARGETS:S/^/run-regress-/}
37CLEANFILES +=		*.log relayd.conf ktrace.out stamp-*
38CLEANFILES +=		*.pem *.req *.crt *.key *.srl
39
40# Set variables so that make runs with and without obj directory.
41# Only do that if necessary to keep visible output short.
42
43.if ${.CURDIR} == ${.OBJDIR}
44PERLINC =
45PERLPATH =
46.else
47PERLINC =	-I${.CURDIR}
48PERLPATH =	${.CURDIR}/
49.endif
50
51# The arg tests take a perl hash with arguments controlling the
52# test parameters.  Generally they consist of client, relayd, server.
53
54.for a in ${ARGS}
55run-regress-$a: $a
56	@echo '\n======== $@ ========'
57.if empty (REMOTE_SSH)
58	time SUDO=${SUDO} KTRACE=${KTRACE} RELAYD=${RELAYD} perl ${PERLINC} ${PERLPATH}relayd.pl copy ${PERLPATH}$a
59	time SUDO=${SUDO} KTRACE=${KTRACE} RELAYD=${RELAYD} perl ${PERLINC} ${PERLPATH}relayd.pl splice ${PERLPATH}$a
60.else
61	ssh -t ${REMOTE_SSH} ${SUDO} true
62	time SUDO=${SUDO} KTRACE=${KTRACE} RELAYD=${RELAYD} perl ${PERLINC} ${PERLPATH}remote.pl copy ${LOCAL_ADDR} ${REMOTE_ADDR} ${REMOTE_SSH} ${PERLPATH}$a
63	time SUDO=${SUDO} KTRACE=${KTRACE} RELAYD=${RELAYD} perl ${PERLINC} ${PERLPATH}remote.pl splice ${LOCAL_ADDR} ${REMOTE_ADDR} ${REMOTE_SSH} ${PERLPATH}$a
64.endif
65.endfor
66
67# create certificates for TLS
68
69.for ip in ${REMOTE_ADDR} 127.0.0.1
70${ip}.crt: ca.crt
71	openssl req -batch -new -subj /L=OpenBSD/O=relayd-regress/OU=relayd/CN=${ip}/ -nodes -newkey rsa -keyout ${ip}.key -x509 -out $@
72.if empty (REMOTE_SSH)
73	${SUDO} cp 127.0.0.1.crt /etc/ssl/
74	${SUDO} cp 127.0.0.1.key /etc/ssl/private/
75.else
76	scp ${REMOTE_ADDR}.crt root@${REMOTE_SSH}:/etc/ssl/
77	scp ${REMOTE_ADDR}.key root@${REMOTE_SSH}:/etc/ssl/private/
78	scp ca.crt ca.key ${REMOTE_SSH}:
79.endif
80.endfor
81
82ca.crt:
83	openssl req -batch -new -subj /L=OpenBSD/O=relayd-regress/OU=ca/CN=root/ -nodes -newkey rsa -keyout ca.key -x509 -out ca.crt
84
85server.req:
86	openssl req -batch -new -subj /L=OpenBSD/O=relayd-regress/OU=server/CN=localhost/ -nodes -newkey rsa -keyout server.key -out server.req
87
88server.crt: ca.crt server.req
89	openssl x509 -CAcreateserial -CAkey ca.key -CA ca.crt -req -in server.req -out server.crt
90
91${REGRESS_TARGETS:M*ssl*} ${REGRESS_TARGETS:M*https*}: server.crt
92.if empty (REMOTE_SSH)
93${REGRESS_TARGETS:M*ssl*} ${REGRESS_TARGETS:M*https*}: 127.0.0.1.crt
94.else
95${REGRESS_TARGETS:M*ssl*} ${REGRESS_TARGETS:M*https*}: ${REMOTE_ADDR}.crt
96.endif
97
98# make perl syntax check for all args files
99
100.PHONY: syntax
101
102syntax: stamp-syntax
103
104stamp-syntax: ${ARGS}
105.for a in ${ARGS}
106	@perl -c ${PERLPATH}$a
107.endfor
108	@date >$@
109
110.include <bsd.regress.mk>
111