From f24ec48b27d4cb8dd0555840206dedbb45f1423c Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 24 Oct 2026 01:17:50 +0200 Subject: Add a unit test harness and a first set of tests make check builds tests/runner from the modules that link without the io subsystem and runs it. --- Makefile | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 706b742..8f967f7 100644 --- a/Makefile +++ b/Makefile @@ -99,8 +99,26 @@ proxy.debug: $(OBJECTS_proxy_debug) $(HEADERS) .c.o : $(HEADERS) $(CC) -c -o $@ $(CFLAGS_production) $< +# Unit tests. The modules under test are compiled straight into the test +# binary, so a test may reach a static function by including the source if it +# has to. tests/stubs.c supplies the few symbols those modules reference but +# the tests never reach. +TESTBIN=tests/runner +TEST_SOURCES=tests/runner.c tests/test.c tests/stubs.c tests/t_scan_urlencoded_query.c tests/t_iovec.c tests/t_vector.c +TEST_UNITS=scan_urlencoded_query.c ot_iovec.c ot_vector.c +TEST_HEADERS=tests/test.h $(HEADERS) +CFLAGS_test = $(CFLAGS) -I. -g -O1 $(FEATURES) + +$(TESTBIN): $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) + $(CC) -o $@ $(CFLAGS_test) $(TEST_SOURCES) $(TEST_UNITS) + +check: $(TESTBIN) + ./$(TESTBIN) + +.PHONY: all check clean install + clean: - rm -rf opentracker opentracker.debug *.o *~ + rm -rf opentracker opentracker.debug $(TESTBIN) *.o *~ install: install -m 755 opentracker $(DESTDIR)$(BINDIR) -- cgit v1.3