xref: /openbsd/regress/usr.sbin/httpd/tests/Makefile (revision 5af055cd)
1#	$OpenBSD: Makefile,v 1.2 2015/07/16 17:00:41 reyk 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 httpd with
23# the httpd 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 httpd.conf ktrace.out stamp-*
38CLEANFILES +=		*.pem *.req *.crt *.key *.srl md5-*
39
40HTDOCS =		512 1048576 1073741824
41HTDOCS_MD5 =		${HTDOCS:S/^/${.OBJDIR}\/md5-/}
42HTDOCS_SPARSE =		yes
43CLEANFILES +=		${HTDOCS}
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 =
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, httpd, server.
58
59.for a in ${ARGS}
60run-regress-$a: $a ${HTDOCS_MD5}
61	@echo '\n======== $@ ========'
62	time SUDO=${SUDO} KTRACE=${KTRACE} HTTPD=${HTTPD} perl ${PERLINC} ${PERLPATH}httpd.pl ${.OBJDIR} ${PERLPATH}$a
63.endfor
64
65# htdocs
66
67.for d in ${HTDOCS}
68${.OBJDIR}/$d:
69	@echo '\n======== file: $d ========'
70.if (${HTDOCS_SPARSE} != "yes")
71	@dd if=/dev/arandom of=$@ count=$$(($d / 512)) bs=512
72.else
73	@dd of=$@ seek=$$(($d / 512)) bs=512 count=0 status=none
74.endif
75
76${.OBJDIR}/md5-$d: ${.OBJDIR}/$d
77	@md5 -q ${.OBJDIR}/$d > $@
78.endfor
79
80# create certificates for TLS
81
82ca.crt:
83	openssl req -batch -new -subj /L=OpenBSD/O=httpd-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=httpd-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*tls*} ${REGRESS_TARGETS:M*https*}: server.crt
92
93# make perl syntax check for all args files
94
95.PHONY: syntax
96
97syntax: stamp-syntax
98
99stamp-syntax: ${ARGS}
100.for a in ${ARGS}
101	@perl -c ${PERLPATH}$a
102.endfor
103	@date >$@
104
105.include <bsd.regress.mk>
106