2015-07-07 02:05:05 +03:00
|
|
|
#
|
|
|
|
# NetSurf unit tests
|
|
|
|
|
2015-07-09 00:17:20 +03:00
|
|
|
TESTS := nsurl urldbtest nsoption #llcache
|
2010-06-29 11:20:12 +04:00
|
|
|
|
2015-07-07 18:02:54 +03:00
|
|
|
# nsurl sources and flags
|
2015-07-09 00:17:20 +03:00
|
|
|
nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c \
|
|
|
|
test/log.c test/nsurl.c
|
|
|
|
|
|
|
|
# url database test sources and flags
|
|
|
|
urldbtest_SRCS := content/urldb.c \
|
2015-07-09 10:05:06 +03:00
|
|
|
utils/idna.c utils/bloom.c utils/nsoption.c utils/nsurl.c \
|
|
|
|
utils/corestrings.c \
|
2015-07-09 00:17:20 +03:00
|
|
|
test/log.c test/urldbtest.c
|
2010-03-28 16:56:39 +04:00
|
|
|
|
2015-07-07 18:02:54 +03:00
|
|
|
# low level cache sources and flags
|
2011-10-15 01:29:13 +04:00
|
|
|
llcache_SRCS := content/fetch.c content/fetchers/curl.c \
|
|
|
|
content/fetchers/about.c content/fetchers/data.c \
|
|
|
|
content/fetchers/resource.c content/llcache.c \
|
2015-07-09 00:17:20 +03:00
|
|
|
content/urldb.c \
|
2011-10-15 01:29:13 +04:00
|
|
|
image/image_cache.c \
|
2013-04-08 20:50:55 +04:00
|
|
|
utils/base64.c utils/corestrings.c utils/hashtable.c \
|
2015-07-09 00:17:20 +03:00
|
|
|
utils/nsurl.c utils/messages.c utils/url.c utils/useragent.c \
|
|
|
|
utils/utils.c \
|
|
|
|
test/log.c test/llcache.c
|
2010-03-28 16:56:39 +04:00
|
|
|
|
2015-07-09 00:17:20 +03:00
|
|
|
# nsoption test
|
|
|
|
nsoption_SRCS := utils/nsoption.c \
|
|
|
|
test/log.c test/nsoption.c
|
2010-06-29 11:20:12 +04:00
|
|
|
|
2011-10-15 01:29:13 +04:00
|
|
|
|
2013-05-27 12:35:16 +04:00
|
|
|
|
2015-07-09 00:17:20 +03:00
|
|
|
# Coverage builds need additional flags
|
|
|
|
ifeq ($(MAKECMDGOALS),coverage)
|
|
|
|
COVCFLAGS ?= -fprofile-arcs -ftest-coverage -O0
|
|
|
|
COVCXXFLAGS ?= -fprofile-arcs -ftest-coverage -O0
|
|
|
|
COVLDFLAGS ?= -lgcov -fprofile-arcs
|
|
|
|
TESTROOT := build-$(HOST)-coverage
|
|
|
|
else
|
|
|
|
COVCFLAGS ?= -O0
|
|
|
|
COVCXXFLAGS ?= -O0
|
|
|
|
TESTROOT := build-$(HOST)-test
|
|
|
|
endif
|
2015-07-07 18:02:54 +03:00
|
|
|
|
2015-07-09 00:17:20 +03:00
|
|
|
TESTCFLAGS := -std=c99 -g -Wall \
|
|
|
|
-D_BSD_SOURCE \
|
|
|
|
-D_POSIX_C_SOURCE=200809L \
|
|
|
|
-D_XOPEN_SOURCE=600 \
|
|
|
|
-Itest -I. -I.. \
|
|
|
|
-Dnsgtk \
|
2015-07-09 10:00:08 +03:00
|
|
|
$(shell pkg-config --cflags libcurl check libparserutils libwapcaplet libdom libnsutils libutf8proc libidn) \
|
2015-07-09 00:17:20 +03:00
|
|
|
$(COVCFLAGS)
|
2015-07-09 10:00:08 +03:00
|
|
|
TESTLDFLAGS := $(shell pkg-config --libs libcurl check libparserutils libwapcaplet libdom libnsutils libutf8proc libidn) -lz \
|
2015-07-09 00:17:20 +03:00
|
|
|
$(COVLDFLAGS)
|
2015-07-07 18:02:54 +03:00
|
|
|
|
|
|
|
|
2015-07-09 00:17:20 +03:00
|
|
|
# Source files for all tests being compiled
|
|
|
|
TESTSOURCES :=
|
2015-07-07 18:02:54 +03:00
|
|
|
|
2015-07-09 00:17:20 +03:00
|
|
|
GCOV ?= gcov
|
2015-07-07 18:02:54 +03:00
|
|
|
|
2015-07-09 00:17:20 +03:00
|
|
|
define gen_test_target
|
|
|
|
$$(TESTROOT)/$(1): $$(sort $$(addprefix $$(TESTROOT)/,$$(subst /,_,$$(patsubst %.c,%.o,$$(patsubst %.cpp,%.o,$$(patsubst %.m,%.o,$$(patsubst %.s,%.o,$$($(1)_SRCS))))))))
|
|
|
|
$$(VQ)echo "LINKTEST: $$@"
|
|
|
|
$$(Q)$$(CC) $$(TESTCFLAGS) $$^ -o $$@ $$(TESTLDFLAGS)
|
2015-07-07 18:02:54 +03:00
|
|
|
|
2015-07-09 00:17:20 +03:00
|
|
|
.PHONY:$(1)_test
|
|
|
|
|
|
|
|
$(1)_test:$$(TESTROOT)/$(1)
|
|
|
|
$$(VQ)echo "RUN TEST: $(1)"
|
|
|
|
$$(Q)$$(TESTROOT)/$(1)
|
|
|
|
|
|
|
|
TESTSOURCES += $$($(1)_SRCS)
|
|
|
|
|
|
|
|
endef
|
2015-07-07 18:02:54 +03:00
|
|
|
|
2015-07-09 00:17:20 +03:00
|
|
|
define compile_test_target_c
|
|
|
|
$$(TESTROOT)/$(2): $(1) $$(TESTROOT)/created
|
|
|
|
$$(VQ)echo " COMPILE: $(1)"
|
|
|
|
$$(Q)$$(RM) $$(TESTROOT)/$(2)
|
|
|
|
$$(Q)$$(CC) $$(TESTCFLAGS) -o $$(TESTROOT)/$(2) -c $(1)
|
2015-07-07 18:02:54 +03:00
|
|
|
|
2015-07-09 00:17:20 +03:00
|
|
|
endef
|
2010-06-29 11:20:12 +04:00
|
|
|
|
2015-07-09 00:17:20 +03:00
|
|
|
# Generate target for each test program and the list of objects it needs
|
|
|
|
$(eval $(foreach TST,$(TESTS), $(call gen_test_target,$(TST))))
|
2010-06-29 11:20:12 +04:00
|
|
|
|
2015-07-09 00:17:20 +03:00
|
|
|
# generate target rules for test objects
|
|
|
|
$(eval $(foreach SOURCE,$(sort $(filter %.c,$(TESTSOURCES))), \
|
|
|
|
$(call compile_test_target_c,$(SOURCE),$(subst /,_,$(SOURCE:.c=.o)),$(subst /,_,$(SOURCE:.c=.d)))))
|
2010-03-28 16:56:39 +04:00
|
|
|
|
|
|
|
|
2015-07-09 00:17:20 +03:00
|
|
|
.PHONY:test coverage
|
2011-10-15 01:29:13 +04:00
|
|
|
|
2015-07-09 00:17:20 +03:00
|
|
|
test: $(TESTROOT)/created $(addsuffix _test,$(TESTS))
|
|
|
|
|
|
|
|
coverage: test
|
|
|
|
|
|
|
|
$(TESTROOT)/created:
|
|
|
|
$(VQ)echo " MKDIR: $(TESTROOT)"
|
|
|
|
$(Q)$(MKDIR) $(TESTROOT)
|
|
|
|
$(Q)$(TOUCH) $@
|
2013-05-27 12:35:16 +04:00
|
|
|
|
2015-07-07 18:02:54 +03:00
|
|
|
.PHONY: test-clean
|
2010-03-28 16:56:39 +04:00
|
|
|
|
2015-07-07 18:02:54 +03:00
|
|
|
test-clean:
|
2015-07-09 00:17:20 +03:00
|
|
|
$(VQ)echo " CLEAN: $(TESTROOT)"
|
|
|
|
$(VQ)echo " CLEAN: build-$(HOST)-coverage"
|
|
|
|
$(Q)$(RM) -r $(TESTROOT) build-$(HOST)-coverage
|
|
|
|
CLEANS += test-clean
|