summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile58
-rw-r--r--test/Makefile79
-rw-r--r--test/log.c54
-rw-r--r--test/urldbtest.c4
4 files changed, 153 insertions, 42 deletions
diff --git a/Makefile b/Makefile
index fc3225aca..8e1fcc35b 100644
--- a/Makefile
+++ b/Makefile
@@ -22,6 +22,8 @@
# make docs
#
+.PHONY: all
+
all: all-program
# Determine host type
@@ -778,7 +780,7 @@ $(eval $(foreach SOURCE,$(filter %.m,$(SOURCES)), \
#$(eval $(foreach SOURCE,$(filter %.s,$(SOURCES)), \
# $(call dependency_generate_s,$(SOURCE),$(subst /,_,$(SOURCE:.s=.d)),$(subst /,_,$(SOURCE:.s=.o)))))
-ifneq ($(MAKECMDGOALS),clean)
+ifeq ($(filter $(MAKECMDGOALS),clean test),)
-include $(sort $(addprefix $(DEPROOT)/,$(DEPFILES)))
-include $(D_JSAPI_BINDING)
endif
@@ -797,14 +799,54 @@ $(eval $(foreach SOURCE,$(filter %.m,$(SOURCES)), \
$(eval $(foreach SOURCE,$(filter %.s,$(SOURCES)), \
$(call compile_target_s,$(SOURCE),$(subst /,_,$(SOURCE:.s=.o)),$(subst /,_,$(SOURCE:.s=.d)))))
-.PHONY: all clean docs install package-$(TARGET) package install-$(TARGET)
+# ----------------------------------------------------------------------------
+# Test setup
+# ----------------------------------------------------------------------------
+
+include test/Makefile
+
+
+# ----------------------------------------------------------------------------
+# Clean setup
+# ----------------------------------------------------------------------------
+
+.PHONY: clean
clean: $(CLEANS)
-# Target builds a distribution package
+
+# ----------------------------------------------------------------------------
+# build distribution package
+# ----------------------------------------------------------------------------
+
+.PHONY: package-$(TARGET) package
+
package: all-program package-$(TARGET)
+# ----------------------------------------------------------------------------
+# local install on the host system
+# ----------------------------------------------------------------------------
+
+.PHONY: install install-$(TARGET)
+
+install: all-program install-$(TARGET)
+
+
+# ----------------------------------------------------------------------------
+# Documentation build
+# ----------------------------------------------------------------------------
+
+.PHONY: docs
+
+docs:
+ doxygen Docs/Doxyfile
+
+
+# ----------------------------------------------------------------------------
+# Transifex message processing
+# ----------------------------------------------------------------------------
+
.PHONY: messages-split-tfx messages-fetch-tfx messages-import-tfx
# split fat messages into properties files suitable for uploading to transifex
@@ -819,13 +861,3 @@ messages-fetch-tfx:
messages-import-tfx: messages-fetch-tfx
for tfxlang in $(FAT_LANGUAGES);do perl ./utils/import-messages.pl -l $${tfxlang} -p any -f transifex -o resources/FatMessages -i resources/FatMessages -I Messages.any.$${tfxlang}.tfx ; $(RM) Messages.any.$${tfxlang}.tfx; done
-# Target installs executable on the host system
-install: all-program install-$(TARGET)
-
-docs:
- doxygen Docs/Doxyfile
-
-.PHONY:test
-
-test:
- make -C test \ No newline at end of file
diff --git a/test/Makefile b/test/Makefile
index 7327580a9..ce3e2744b 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,55 +1,78 @@
#
# NetSurf unit tests
-CFLAGS := -std=c99 -g -O0 -D_BSD_SOURCE -D_POSIX_C_SOURCE -I. -I.. \
+
+test_CFLAGS := -std=c99 -g -Wall \
+ -D_BSD_SOURCE \
+ -D_POSIX_C_SOURCE=200809L \
+ -D_XOPEN_SOURCE=600 \
+ -Itest -I. -I.. \
$(shell pkg-config --cflags libcurl)
-LDFLAGS := $(shell pkg-config --libs libcurl) -lz
+test_LDFLAGS := $(shell pkg-config --libs libcurl) -lz
-llcache_CFLAGS := $(shell pkg-config --cflags libparserutils libwapcaplet libdom) -O2
-llcache_LDFLAGS := $(shell pkg-config --libs libparserutils libwapcaplet libdom)
+# nsurl sources and flags
+nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c test/log.c test/nsurl.c
+nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libutf8proc) -O0
+nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libutf8proc)
+# low level cache sources and flags
llcache_SRCS := content/fetch.c content/fetchers/curl.c \
content/fetchers/about.c content/fetchers/data.c \
content/fetchers/resource.c content/llcache.c \
content/urldb.c desktop/version.c \
image/image_cache.c \
utils/base64.c utils/corestrings.c utils/hashtable.c \
- utils/log.c utils/nsurl.c utils/messages.c utils/url.c \
+ utils/nsurl.c utils/messages.c utils/url.c \
utils/useragent.c utils/utils.c test/llcache.c
+llcache_CFLAGS := $(shell pkg-config --cflags libparserutils libwapcaplet libdom) -O2
+llcache_LDFLAGS := $(shell pkg-config --libs libparserutils libwapcaplet libdom)
-urldbtest_SRCS := content/urldb.c utils/url.c utils/utils.c utils/log.c \
- utils/messages.c utils/hashtable.c \
+# url database test sources and flags
+urldbtest_SRCS := content/urldb.c utils/url.c utils/utils.c utils/idna.c \
+ utils/messages.c utils/hashtable.c utils/bloom.c utils/nsoption.c \
utils/filename.c utils/nsurl.c utils/corestrings.c \
- test/urldbtest.c
+ test/log.c test/urldbtest.c
+urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libnsutils libutf8proc) -O2
+urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libnsutils libutf8proc)
-urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libnsutils) -O2
-urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libnsutils)
-
-nsurl_SRCS := utils/corestrings.c utils/log.c utils/nsurl.c utils/idna.c desktop/version.c test/nsurl.c
-nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libutf8proc)
-nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libutf8proc)
nsoption_SRCS := utils/log.c utils/nsoption.c test/nsoption.c
nsoption_CFLAGS := -Dnsgtk
-.PHONY: all
+CLEANS += test-clean
+
+TESTS := nsurl urldbtest
+
+TESTROOT := build-$(HOST)-test
+
+
+.PHONY:test
+
+test: $(TESTROOT)/created $(addprefix $(TESTROOT)/,$(TESTS))
+ $(TESTROOT)/nsurl
+ $(TESTROOT)/urldbtest
+
+$(TESTROOT)/created:
+ $(VQ)echo " MKDIR: $(TESTROOT)"
+ $(Q)$(MKDIR) $(TESTROOT)
+ $(Q)$(TOUCH) $@
+
+$(TESTROOT)/nsurl: $(nsurl_SRCS)
+ $(CC) $(test_CFLAGS) $(nsurl_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(nsurl_LDFLAGS)
+
-all: nsurl
- ./nsurl
+$(TESTROOT)/urldbtest: $(urldbtest_SRCS)
+ $(CC) $(test_CFLAGS) $(urldbtest_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(urldbtest_LDFLAGS)
-llcache: $(addprefix ../,$(llcache_SRCS))
- $(CC) $(CFLAGS) $(llcache_CFLAGS) $^ -o $@ $(LDFLAGS) $(llcache_LDFLAGS)
+$(TESTROOT)/llcache: $(llcache_SRCS)
+ $(CC) $(test_CFLAGS) $(llcache_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(llcache_LDFLAGS)
-urldbtest: $(addprefix ../,$(urldbtest_SRCS))
- $(CC) $(CFLAGS) $(urldbtest_CFLAGS) $^ -o $@ $(LDFLAGS) $(urldbtest_LDFLAGS)
-nsurl: $(addprefix ../,$(nsurl_SRCS))
- $(CC) $(CFLAGS) $(nsurl_CFLAGS) $^ -o $@ $(LDFLAGS) $(nsurl_LDFLAGS)
-nsoption: $(addprefix ../,$(nsoption_SRCS))
- $(CC) $(CFLAGS) $(nsoption_CFLAGS) $^ -o $@ $(LDFLAGS) $(nsoption_LDFLAGS)
+$(TESTROOT)/nsoption: $(addprefix ../,$(nsoption_SRCS))
+ $(CC) $(test_CFLAGS) $(nsoption_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(nsoption_LDFLAGS)
-.PHONY: clean
+.PHONY: test-clean
-clean:
- $(RM) llcache urldbtest nsurl nsoption
+test-clean:
+ $(RM) $(addprefix $(TESTROOT)/,$(TESTS))
diff --git a/test/log.c b/test/log.c
new file mode 100644
index 000000000..90b4379e9
--- /dev/null
+++ b/test/log.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2015 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * Minimal unit test log implementation.
+ *
+ * It is necessary to have a logging implementation for the unit tests
+ * so other netsurf modules that assume this functionality work.
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "utils/log.h"
+
+/** flag to enable verbose logging */
+bool verbose_log = false;
+
+nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv)
+{
+ return NSERROR_OK;
+}
+
+
+void nslog_log(const char *file, const char *func, int ln, const char *format, ...)
+{
+ va_list ap;
+
+ fprintf(stderr, "%s:%i %s: ", file, ln, func);
+
+ va_start(ap, format);
+
+ vfprintf(stderr, format, ap);
+
+ va_end(ap);
+
+ fputc('\n', stderr);
+}
diff --git a/test/urldbtest.c b/test/urldbtest.c
index 4536ddd17..f72d77f07 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -46,7 +46,7 @@
#include "utils/utils.h"
int option_expire_url = 0;
-bool verbose_log = true;
+struct netsurf_table *guit = NULL;
static void netsurf_lwc_iterator(lwc_string *str, void *pw)
{
@@ -163,6 +163,8 @@ int main(void)
nsurl *urlr;
char *path_query;
+ verbose_log = true;
+
corestrings_init();
h = urldb_add_host("127.0.0.1");