source: mod_gnutls/test/Makefile.am @ cbc3477

asyncio
Last change on this file since cbc3477 was cbc3477, checked in by Fiona Klute <fiona.klute@…>, 12 months ago

Skip MSVA test if building without MSVA auth support

Skipping instead of excluding it from the list of tests removes a
special case, and might allow simplifications in test handling later.

  • Property mode set to 100644
File size: 13.5 KB
Line 
1SUBDIRS = tests
2
3VALGRIND_SUPPRESS = suppressions.valgrind
4EXTRA_DIST = $(VALGRIND_SUPPRESS)
5
6if ENABLE_VALGRIND
7valgrind = --valgrind \
8        $(foreach supp,$(VALGRIND_SUPPRESS),--valgrind-suppressions "$(srcdir)/$(supp)")
9else
10valgrind =
11endif
12
13# Generate the test scripts
14test-%.bash: test-template.bash.in | tests/%/
15        testname="$(*)"; \
16        sed -e s/_NUM_/$${testname%%_*}/ -e 's,_VALGRIND_,$(valgrind),' < $< > $@
17        chmod a+x $@
18
19test_scripts = test-00_basic.bash \
20        test-01_priorities_config.bash \
21        test-02_cache_in_vhost.bash \
22        test-03_cachetimeout_in_vhost.bash \
23        test-04_basic_nosni.bash \
24        test-06_verify_sni_a.bash \
25        test-07_verify_sni_b.bash \
26        test-08_verify_no_sni_fallback_to_first_vhost.bash \
27        test-09_verify_no_sni_fails_with_wrong_order.bash \
28        test-10_client_verification.bash \
29        test-12_cgi_variables.bash \
30        test-14_resume_session.bash \
31        test-15_basic_msva.bash \
32        test-16_view-status.bash \
33        test-17_cgi_vars_large_cert.bash \
34        test-19_TLS_reverse_proxy.bash \
35        test-20_TLS_reverse_proxy_client_auth.bash \
36        test-21_TLS_reverse_proxy_wrong_cert.bash \
37        test-22_TLS_reverse_proxy_crl_revoke.bash \
38        test-23_TLS_reverse_proxy_mismatched_priorities.bash \
39        test-24_pkcs11_cert.bash \
40        test-26_redirect_HTTP_to_HTTPS.bash \
41        test-27_OCSP_server.bash \
42        test-28_HTTP2_support.bash \
43        test-29_force_handshake_vhost.bash \
44        test-30_ip_based_vhosts.bash \
45        test-31_vhost_SNI_serveralias_match.bash \
46        test-32_vhost_SNI_serveralias_mismatch.bash \
47        test-33_vhost_SNI_serveralias_missinghost.bash \
48        test-34_TLS_reverse_proxy_h2.bash \
49        test-35_client_reauth.bash \
50        test-36_OCSP_server_nonce.bash \
51        test-37_TLS_reverse_proxy_resume_session.bash
52
53MOSTLYCLEANFILES = $(test_scripts)
54dist_check_SCRIPTS = netns_py.bash test-template.bash.in
55
56TEST_EXTENSIONS = .bash .py
57PY_LOG_COMPILER = $(PYTHON)
58TESTS = doctest-mgstest.py $(test_scripts)
59
60check_PROGRAMS = pgpcrc
61pgpcrc_SOURCES = pgpcrc.c
62
63# build OCSP database tool
64if ENABLE_OCSP_TEST
65check_PROGRAMS += gen_ocsp_index
66gen_ocsp_index_SOURCES = gen_ocsp_index.c cert_helper.c
67gen_ocsp_index_CFLAGS = $(LIBGNUTLS_CFLAGS)
68gen_ocsp_index_LDFLAGS = $(LIBGNUTLS_LIBS)
69noinst_HEADERS = cert_helper.h
70endif
71
72# Python tools for tests
73noinst_PYTHON = https-test-client.py mgstest/http.py mgstest/__init__.py \
74        mgstest/hooks.py mgstest/ocsp.py mgstest/services.py \
75        mgstest/softhsm.py mgstest/tests.py mgstest/valgrind.py runtest.py \
76        softhsm-init.py doctest-mgstest.py required-modules.py data/ocsp.py \
77        check_test_ips.py
78
79# Identities in the miniature CA, server, and client environment for
80# the test suite
81shared_identities = authority authority/client
82pgp_identities = $(shared_identities)
83x509_only_identities = authority/server authority/imposter \
84        authority/subca authority/subca/server \
85        rogueca rogueca/rogueclient
86if ENABLE_OCSP_TEST
87x509_only_identities += authority/ocsp-responder authority/subca/ocsp-responder
88endif
89x509_identities = $(shared_identities) $(x509_only_identities)
90identities = $(shared_identities) $(x509_only_identities)
91# Append strings after ":=" to each identity to generate a list of
92# necessary files
93pgp_tokens = $(pgp_identities:=/cert.pgp) \
94        $(pgp_identities:=/secret.pgp)
95x509_keys = $(x509_identities:=/secret.key)
96x509_certs = $(x509_identities:=/x509.pem)
97x509_tokens = $(x509_certs) $(x509_keys)
98tokens = $(x509_tokens)
99if USE_MSVA
100tokens += $(pgp_tokens)
101endif
102
103if !DISABLE_FLOCK
104# flock command for write access to the authority keyring
105GPG_FLOCK = @FLOCK@ authority/lock
106endif
107
108include $(srcdir)/test_ca.mk
109
110# Test cases trying to create keys and certificates in parallel causes
111# race conditions. Ensure that all keys and certificates are generated
112# before tests get to run.
113#
114# NOTE: Once the support files have been generated, test cases can be
115# run with multiple jobs, but real parallelization would require
116# dynamic port assignments. At the moment, lock files ensure that only
117# one Apache instance (possibly plus a proxy back end instance) is
118# running at any time, so test cases actually have to wait for each
119# other - just not in any particular order.
120check_DATA = $(tokens) authority/server/crl.pem
121
122MOSTLYCLEANFILES += cache/* logs/* outputs/* authority/server/crl.pem
123
124cert_templates = authority/template.in authority/client/template.in \
125        authority/imposter/template.in authority/ocsp-responder/template \
126        authority/server/template.in \
127        authority/subca/template.in authority/subca/server/template.in \
128        authority/subca/ocsp-responder/template \
129        rogueca/template rogueca/rogueclient/template.in
130generated_templates = authority/template authority/client/template \
131        authority/imposter/template rogueca/rogueclient/template \
132        authority/server/template
133
134# Delete X.509 private keys on full clean. Note that unless you need
135# to generate fresh keys, the "mostlyclean" target should be
136# sufficient (see below).
137CLEANFILES = $(x509_keys)
138
139# Delete X.509 certificates and generated templates on "mostlyclean"
140# target. Certificates can be rebuilt without generating new key
141# pairs, and regenerating them makes it possible to change identities
142# (e.g. host names) without wasting time on new keys (which would
143# happen after "clean").
144MOSTLYCLEANFILES += $(x509_certs) $(generated_templates) $(identities:=/uid)
145
146
147# Delete PGP keyrings on "mostlyclean" target. They are created from
148# the X.509 private keys and certificates with an expiration time of
149# one day, so regenerating them is both fast and frequently
150# necessary.
151pgp_patterns = /*.pgp /*.pgp.raw /*.gpg /*.gpg~ /gpg.conf \
152        /*.kbx /*.kbx~ /S.gpg-agent /private-keys-v1.d/*
153MOSTLYCLEANFILES += $(foreach pat,$(pgp_patterns),$(pgp_identities:=$(pat))) \
154        authority/lock authority/tofu.db
155# GnuPG random pool, no need to regenerate on every build
156CLEANFILES += authority/random_seed
157
158# GnuPG 2 starts gpg-agent processes per GNUPGHOME (one for every PGP
159# identity) while creating the PGP certificates. This target is called
160# by both "check-local" and "mostlyclean-local": The former because
161# agent processes are started while preparing for "check" and are no
162# longer needed afterwards, the latter to make sure they are gone
163# along with their certificates.
164stop-gnupg-agent:
165        for id in $(pgp_identities) $(msva_home); do \
166                GNUPGHOME=$$id/ gpgconf --kill gpg-agent || true; \
167        done
168
169check-local: stop-gnupg-agent
170
171# Delete lock files for test servers on "mostlyclean" target.
172MOSTLYCLEANFILES += *.lock
173
174# Build certificate chain files. Note that intermediate tokens must be
175# listed explicitly, or the dependency chain will be broken because
176# the higher level pattern matches, too.
177chain_tokens = authority/server/x509-chain.pem \
178        authority/subca/x509-chain.pem \
179        authority/subca/server/x509-chain.pem
180check_DATA += $(chain_tokens)
181MOSTLYCLEANFILES += $(chain_tokens) authority/x509-chain.pem
182
183# rule to build MSVA trust database
184if USE_MSVA
185msva_home = msva.gnupghome
186check_DATA += $(msva_home)/trustdb.gpg authority/client/uid
187MOSTLYCLEANFILES += $(foreach pat,$(pgp_patterns),$(msva_home)$(pat))
188$(msva_home)/trustdb.gpg: authority/minimal.pgp authority/client/cert.pgp
189        mkdir -p -m 0700 $(dir $@)
190        GNUPGHOME=$(dir $@) gpg --import < $<
191        printf "%s:6:\n" "$$(GNUPGHOME=authority/ gpg --with-colons --list-secret-keys --fingerprint | grep ^fpr: | cut -f 10 -d :)" | GNUPGHOME=$(dir $@) gpg --import-ownertrust
192        GNUPGHOME=$(dir $@) gpg --import < authority/client/cert.pgp
193        printf "keyserver does-not-exist.example\n" > $(msva_home)/gpg.conf
194endif
195
196if ENABLE_OCSP_TEST
197# rules to build OCSP database
198ocsp_index_data = authority/ocsp_index.txt authority/ocsp_index.txt.attr \
199        authority/subca/ocsp_index.txt authority/subca/ocsp_index.txt.attr
200check_DATA += $(ocsp_index_data)
201MOSTLYCLEANFILES += $(ocsp_index_data)
202
203# The "find" command builds a list of all certificates directly below
204# the CA that aren't for the ocsp-responder.
205%/ocsp_index.txt: $(x509_tokens) gen_ocsp_index
206        ./gen_ocsp_index $$(find $(*) -mindepth 2 -maxdepth 2 ! -path '*/ocsp-responder/*' -name x509.pem) > $@
207
208%/ocsp_index.txt.attr:
209        @mkdir -m 0700 -p $(dir $@)
210        echo "unique_subject = no" > $@
211endif
212
213# SoftHSM token, note that the SoftHSM 2 token is a directory
214SOFTHSM2_TOKEN = authority/server/softhsm2.db
215# included in mostlyclean-local below
216clean-softhsm2-db:
217        -rm -rf $(SOFTHSM2_TOKEN)
218
219if HAVE_SOFTHSM
220check_DATA += $(SOFTHSM2_TOKEN)
221endif HAVE_SOFTHSM
222
223check_DATA += make-test-dirs
224extra_dirs = logs cache outputs
225make-test-dirs:
226        mkdir -p $(extra_dirs)
227
228.PHONY: make-test-dirs clean-softhsm2-db stop-gnupg-agent
229
230
231if ENABLE_COVERAGE
232coverage_raw_dir = outputs/coverage
233coverage_out = coverage
234MOSTLYCLEANFILES += $(coverage_raw_dir)/*
235endif
236
237mostlyclean-local: clean-softhsm2-db stop-gnupg-agent
238        -rmdir $(pgp_identities:=/private-keys-v1.d) || true
239if USE_MSVA
240        -rmdir $(msva_home)/private-keys-v1.d || true
241endif
242
243# Delete test data directories, and wait for test services to
244# exit. The reason for the wait is that Apache instances may take some
245# time to exit and delete their PID files. Occasionally some PID files
246# where still around during "distcheck" runs by the time the target
247# checked if the build directory was really empty after "distclean",
248# breaking the build. Delaying "clean-local" until PID files are gone
249# avoids this issue, and the timeout will expose actually unclean
250# stops.
251clean-local:
252if ENABLE_COVERAGE
253        -rmdir $(coverage_raw_dir) || true
254        -rm -rf $(coverage_out) || true
255endif
256        -rmdir $(extra_dirs) || true
257if USE_MSVA
258        -rmdir $(msva_home) || true
259endif
260        wait=0; \
261        while ls *.pid && test "$$wait" -lt "@TEST_LOCK_WAIT@"; do \
262                wait=$$(($$wait + 1)); \
263                echo "waiting for test services to exit ($$wait seconds)"; \
264                sleep 1; \
265        done
266
267# Apache configuration and data files
268apache_data = base_apache.conf cgi_module.conf data/dump.cgi \
269        data/test.txt data/secret/mirror.cgi data/secret/test.txt \
270        mime.types proxy_mods.conf
271
272# Which modules are compiled into the Apache binary varies between
273# distributions. required-modules.py creates additional LoadModule
274# directives if needed.
275check_DATA += apache-conf/required-modules.conf
276MOSTLYCLEANFILES += apache-conf/required-modules.conf
277apache-conf/required-modules.conf: required-modules.py
278        APACHE2=@APACHE2@ AP_LIBEXECDIR=@AP_LIBEXECDIR@ $(PYTHON) $< >$@
279
280# Documentation for the test system
281test_doc = README.md sample_fail.yaml sample_test.yaml
282
283EXTRA_DIST += $(apache_data) $(cert_templates) $(shared_identities:=/uid.in) \
284        authority/server/crl.template $(test_doc)
285
286# Lockfile for the main Apache process
287test_lockfile = ./test.lock
288# Lockfile for the proxy backend Apache process (if any)
289backend_lockfile = ./backend.lock
290# Lockfile for the OCSP server Apache process (if any)
291ocsp_lockfile = ./ocsp.lock
292
293# port for the main Apache server
294TEST_PORT ?= 9932
295# port for MSVA in test cases that use it
296MSVA_PORT ?= 9933
297# port for TLS proxy backend server
298BACKEND_PORT ?= 9934
299# port for plain HTTP server
300TEST_HTTP_PORT ?= 9935
301# port for the OCSP responder
302if ENABLE_OCSP_TEST
303OCSP_PORT ?= 9936
304OCSP_URI_TEMPLATE = ocsp_uri = http://$(TEST_HOST):$(OCSP_PORT)/ocsp/
305endif
306# maximum time to wait for MSVA startup (milliseconds)
307TEST_SERVICE_MAX_WAIT ?= 10000
308# wait loop time for MSVA startup (milliseconds)
309TEST_SERVICE_WAIT ?= 400
310
311AM_TESTS_ENVIRONMENT = export APACHE2=@APACHE2@; \
312        export AP_LIBEXECDIR=@AP_LIBEXECDIR@; \
313        export PYTHON="@PYTHON@"; \
314        export TEST_LOCK_WAIT="@TEST_LOCK_WAIT@"; \
315        export TEST_IP="@TEST_IP@"; \
316        export TEST_HOST="@TEST_HOST@"; \
317        export TEST_PORT="$(TEST_PORT)"; \
318        export TEST_SERVICE_MAX_WAIT="$(TEST_SERVICE_MAX_WAIT)"; \
319        export TEST_SERVICE_WAIT="$(TEST_SERVICE_WAIT)"; \
320        export TEST_QUERY_TIMEOUT="@TEST_QUERY_TIMEOUT@"; \
321        export BACKEND_HOST="@TEST_HOST@"; \
322        export BACKEND_PORT="$(BACKEND_PORT)"; \
323        export TEST_HTTP_PORT="$(TEST_HTTP_PORT)"; \
324        export HTTP_CLI="@HTTP_CLI@";
325
326if USE_MSVA
327AM_TESTS_ENVIRONMENT += export MSVA_PORT="$(MSVA_PORT)";
328endif
329
330if HAVE_SOFTHSM
331AM_TESTS_ENVIRONMENT += export SOFTHSM="@SOFTHSM@"; \
332        export SOFTHSM_LIB="@SOFTHSM_LIB@";
333endif
334
335if ENABLE_OCSP_TEST
336AM_TESTS_ENVIRONMENT += export OPENSSL="@OPENSSL@"; \
337        export OCSP_PORT="$(OCSP_PORT)";
338endif
339
340if ENABLE_VALGRIND
341AM_TESTS_ENVIRONMENT += export VALGRIND="@VALGRIND@";
342endif
343
344if ENABLE_NETNS
345AM_TESTS_ENVIRONMENT += export UNSHARE="@UNSHARE@"; \
346        export USE_TEST_NAMESPACE=1;
347endif
348# Without flock tests must not run in parallel, and PID files are used
349# to prevent conflicts between server instances. Otherwise set lock
350# files for flock.
351if DISABLE_FLOCK
352AM_TESTS_ENVIRONMENT += export TEST_LOCK="apache2.pid"; \
353        export BACKEND_LOCK="backend.pid"; \
354        export OCSP_LOCK="ocsp.pid";
355.NOTPARALLEL:
356else
357AM_TESTS_ENVIRONMENT += export FLOCK="@FLOCK@"; \
358        export TEST_LOCK="$(test_lockfile)"; \
359        export BACKEND_LOCK="$(backend_lockfile)"; \
360        export OCSP_LOCK="$(ocsp_lockfile)";
361endif
362
363if ENABLE_COVERAGE
364AM_TESTS_ENVIRONMENT += export LLVM_PROFILE_FILE="$(coverage_raw_dir)/%p-%3m.profraw";
365
366outputs/coverage.profdata: $(coverage_raw_dir)/*.profraw
367        llvm-profdata merge -sparse $^ -o $@
368
369coverage/index.html: outputs/coverage.profdata
370        llvm-cov show ../src/.libs/mod_gnutls.so -instr-profile=$< -format=html $(srcdir)/../src/*.c $(srcdir)/../src/*.h $(srcdir)/../include/*.h -output-dir=$(dir $@)/
371
372coverage: coverage/index.html
373endif
374
375# Echo AM_TESTS_ENVIRONMENT. This can be useful for debugging, e.g. if
376# you want to manually run an Apache instance with Valgrind using the
377# same configuration as a test case.
378show-test-env: export TEST_ENV=$(AM_TESTS_ENVIRONMENT)
379show-test-env:
380        @echo "$${TEST_ENV}"
381
382# Build the test suite README as HTML if pandoc is available.
383if USE_PANDOC
384noinst_DATA = README.html
385MOSTLYCLEANFILES += $(noinst_DATA)
386%.html: %.md $(srcdir)/../doc/style.css
387        $(PANDOC) --css $(filter %.css,$^) --metadata pagetitle="$(<)" --self-contained -f markdown -o $@ $<
388endif
Note: See TracBrowser for help on using the repository browser.