summaryrefslogtreecommitdiff
path: root/Makefile.in
diff options
context:
space:
mode:
authorJacob Champion <jchampion@apache.org>2017-05-25 21:18:32 +0000
committerJacob Champion <jchampion@apache.org>2017-05-25 21:18:32 +0000
commitd3289c73ee5f053dc99ccb8546624017e83cca8b (patch)
treeb6bd7bc9e87d1f33c41294a8dbdeb255ad52f569 /Makefile.in
parent1b223229a188d0559b08b2c1fa38bfd0b6b4eed4 (diff)
downloadhttpd-d3289c73ee5f053dc99ccb8546624017e83cca8b.tar.gz
httpdunit: a Check-based unit test suite
Add a unit test suite based on Check: https://libcheck.github.io/check/ The suite depends on the build system to automatically generate the code stubs that call every test case. httpdunit is automatically enabled in the build if configure is able to find Check via pkg-config. At the moment pkg-config is the only official (non-deprecated) way to build and link against Check with an autoconf system, since platforms may distribute Check as a static library. Note that Check is an LGPL'd library, so we can't distribute test objects and binaries. Building and running the suite remains optional and is not required to run the server. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/httpdunit@1796202 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'Makefile.in')
-rw-r--r--Makefile.in38
1 files changed, 37 insertions, 1 deletions
diff --git a/Makefile.in b/Makefile.in
index 4eacffe9c0..f6fac28132 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -28,7 +28,7 @@ DISTCLEAN_TARGETS = include/ap_config_auto.h include/ap_config_layout.h \
build/pkg/pkginfo build/config_vars.sh bsd_converted
EXTRACLEAN_TARGETS = configure include/ap_config_auto.h.in generated_lists \
httpd.spec
-PHONY_TARGETS := check check-conf check-dirs check-include
+PHONY_TARGETS := check check-conf check-dirs check-include unittest-objdir
include $(top_builddir)/build/rules.mk
include $(top_srcdir)/build/program.mk
@@ -431,3 +431,39 @@ check: check-include check-dirs check-conf check/build/config_vars.mk check/apxs
./t/TEST -clean && \
./t/TEST -config && \
./t/TEST
+
+#
+# Unit Test Suite
+#
+
+# Make sure the object subdirectories we use exist in the build directory during
+# VPATH builds.
+unittest-objdir:
+ @mkdir -p test/unit
+
+# Normally I don't like wildcard sources, but for tests, autodiscovery is the
+# way to go.
+testcase_SOURCES := $(patsubst $(top_srcdir)/%,%,$(wildcard $(top_srcdir)/test/unit/*.c))
+testcase_OBJECTS := $(testcase_SOURCES:%.c=%.lo)
+testcase_STUBS := $(testcase_SOURCES:%.c=%.tests)
+
+# Each testcase depends on the source file as well as the autogenerated .tests
+# stub.
+$(testcase_OBJECTS): %.lo: %.c %.tests | unittest-objdir
+
+$(testcase_STUBS): %.tests: %.c
+ $(top_srcdir)/build/httpdunit_gen_stubs.pl < "$<" > "$@"
+
+test/httpdunit.cases: $(testcase_SOURCES) | unittest-objdir
+ for t in $^; do \
+ $(top_srcdir)/build/httpdunit_gen_cases.pl < "$$t"; \
+ done > $@
+
+test/httpdunit.lo: test/httpdunit.c test/httpdunit.cases | unittest-objdir
+
+# httpdunit is only added to $(other_targets) if configure detects a working
+# libcheck on the system.
+httpdunit_OBJECTS := test/httpdunit.lo $(testcase_OBJECTS)
+$(httpdunit_OBJECTS): override LTCFLAGS += $(UNITTEST_CFLAGS)
+test/httpdunit: $(httpdunit_OBJECTS) $(PROGRAM_DEPENDENCIES) $(PROGRAM_OBJECTS)
+ $(LINK) $(httpdunit_OBJECTS) $(PROGRAM_OBJECTS) $(UNITTEST_LIBS) $(PROGRAM_LDADD)