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