xref: /openbsd/regress/usr.sbin/httpd/tests/Makefile (revision e7c2632a)
1#	$OpenBSD: Makefile,v 1.16 2021/12/22 15:54:01 bluhm 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
21# Automatically generate regress targets from test cases in directory.
22
23ARGS !=			cd ${.CURDIR} && ls args-*.pl
24CLEANFILES +=		*.log httpd.conf ktrace.out stamp-*
25CLEANFILES +=		*.pem *.req *.crt *.key *.srl md5-*
26
27HTDOCS_FILES =		512 1048576 1073741824
28HTDOCS_MD5 =		${HTDOCS_FILES:S,^,md5-,}
29HTDOCS_SPARSE =		yes
30CLEANFILES +=		htdocs/*
31
32# Set variables so that make runs with and without obj directory.
33# Only do that if necessary to keep visible output short.
34
35.if ${.CURDIR} == ${.OBJDIR}
36PERLINC =	-I.
37PERLPATH =
38.else
39PERLINC =	-I${.CURDIR}
40PERLPATH =	${.CURDIR}/
41.endif
42
43# The arg tests take a perl hash with arguments controlling the
44# test parameters.  Generally they consist of client, httpd, server.
45
46.for a in ${ARGS}
47REGRESS_TARGETS +=	run-$a
48REGRESS_ROOT_TARGETS +=	run-$a
49run-$a: $a ${HTDOCS_MD5}
50	time SUDO="${SUDO}" KTRACE=${KTRACE} HTTPD=${HTTPD} perl ${PERLINC} ${PERLPATH}httpd.pl ${.OBJDIR} ${PERLPATH}$a
51.endfor
52
53# populate htdocs
54
55.for d in ${HTDOCS_FILES}
56htdocs/$d:
57	mkdir -m 0755 -p ${@:H}
58.if (${HTDOCS_SPARSE} != "yes")
59	dd if=/dev/urandom of=$@ count=$$(($d / 512)) bs=512
60.else
61	dd of=$@ seek=$$(($d / 512)) bs=512 count=0 status=none
62.endif
63
64md5-$d: htdocs/$d
65	md5 -q htdocs/$d >$@
66.endfor
67
68# create certificates for TLS
69
70ca.crt:
71	openssl req -batch -new -subj /L=OpenBSD/O=httpd-regress/OU=ca/CN=root/ -nodes -newkey rsa -keyout ca.key -x509 -out ca.crt
72
73server.req:
74	openssl req -batch -new -subj /L=OpenBSD/O=httpd-regress/OU=server/CN=localhost/ -nodes -newkey rsa -keyout server.key -out server.req
75
76client.req:
77	openssl req -batch -new -subj /L=OpenBSD/O=httpd-regress/OU=client/CN=localhost/ -nodes -newkey rsa -keyout client.key -out $@
78
79server.crt: ca.crt server.req
80	openssl x509 -CAcreateserial -CAkey ca.key -CA ca.crt -req -in server.req -out server.crt
81
82client.crt: ca.crt client.req
83	openssl x509 -CAcreateserial -CAkey ca.key -CA ca.crt -req -in client.req -out $@
84
85${REGRESS_TARGETS:M*tls*} ${REGRESS_TARGETS:M*https*}: server.crt client.crt
86
87# make perl syntax check for all args files
88
89.PHONY: syntax
90
91syntax: stamp-syntax
92
93stamp-syntax: ${ARGS}
94.for a in ${ARGS}
95	@perl -c ${PERLPATH}$a
96.endfor
97	@date >$@
98
99.include <bsd.regress.mk>
100