summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@netsurf-browser.org>2009-02-14 11:12:22 +0000
committerDaniel Silverstone <dsilvers@netsurf-browser.org>2009-02-14 11:12:22 +0000
commit4456645b451300aff4a763e966746e247ec5ae39 (patch)
tree0e2d93b749e073e79336601a0aee6c3306456960
parent472d9ed91f2e43642edd7ae92269b76a293e004e (diff)
downloadlibhubbub-4456645b451300aff4a763e966746e247ec5ae39.tar.gz
libhubbub-4456645b451300aff4a763e966746e247ec5ae39.tar.bz2
Allow TESTTYPE=release to be specified to build the tests with the release CFLAGS.
Add TARGET to the build paths. You should 'make distclean' before updating to this. Add BUILD_SHARED=yes support to the *nix build svn path=/trunk/hubbub/; revision=6478
-rw-r--r--Makefile13
-rw-r--r--Makefile-riscos1
-rw-r--r--Makefile-ronative1
-rw-r--r--build/Makefile.common11
-rw-r--r--test/Makefile17
-rw-r--r--test/parser.c26
-rw-r--r--test/tokeniser.c31
-rw-r--r--test/tree-buf.c4
-rw-r--r--test/tree.c28
-rw-r--r--test/tree2.c2
10 files changed, 68 insertions, 66 deletions
diff --git a/Makefile b/Makefile
index a5db312..72eaeec 100644
--- a/Makefile
+++ b/Makefile
@@ -22,11 +22,11 @@ DOXYGEN := doxygen
WARNFLAGS := -Wall -Wextra -Wundef -Wpointer-arith -Wcast-align \
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
-Wmissing-declarations -Wnested-externs -Werror -pedantic
-CFLAGS = -std=c99 -D_BSD_SOURCE -I$(TOP)/include/ $(WARNFLAGS)
+CFLAGS = -std=c99 -D_BSD_SOURCE -I$(TOP)/include/ $(WARNFLAGS) $(CSHAREDFLAGS)
RELEASECFLAGS = $(CFLAGS) -DNDEBUG -O2
DEBUGCFLAGS = $(CFLAGS) -O0 -g
ARFLAGS := -cru
-LDFLAGS = -L$(TOP)/
+LDFLAGS = -L$(TOP)/ $(LDSHAREDFLAGS)
CPFLAGS :=
RMFLAGS := -f
@@ -42,5 +42,14 @@ EXEEXT :=
# Default installation prefix
PREFIX ?= /usr/local
+TARGET := nix
+
+ifeq ($(BUILD_SHARED),yes)
+
+TARGET := nix-shared
+CSHAREDFLAGS := -fPIC -DPIC
+LDSHAREDFLAGS := -Wl,-shared
+
+endif
include build/Makefile.common
diff --git a/Makefile-riscos b/Makefile-riscos
index 1f05f28..69223c3 100644
--- a/Makefile-riscos
+++ b/Makefile-riscos
@@ -50,4 +50,5 @@ endif
# Default installation prefix
PREFIX ?= $(GCCSDK_INSTALL_ENV)
+TARGET := riscos
include build/Makefile.common
diff --git a/Makefile-ronative b/Makefile-ronative
index 089b876..ba8cd08 100644
--- a/Makefile-ronative
+++ b/Makefile-ronative
@@ -55,4 +55,5 @@ TOP := <Hubbub$$Dir>
# Tell everyone that we're building on RISC OS, so they can work around things.
HOST := riscos
+TARGET := ronative
include build/Makefile.common
diff --git a/build/Makefile.common b/build/Makefile.common
index 65158ad..74948d5 100644
--- a/build/Makefile.common
+++ b/build/Makefile.common
@@ -9,10 +9,11 @@ COMPONENT := libhubbub
# Environment
TOP ?= $(CURDIR)
EXPORT := $(TOP)/dist
-RELEASEDIR := build/Release
-DEBUGDIR := build/Debug
-COVERAGEDIR := build/coverage
-DOCDIR := build/docs
+RELEASEDIR := build/Release-$(TARGET)
+DEBUGDIR := build/Debug-$(TARGET)
+COVERAGEDIR := build/coverage-$(TARGET)
+DOCDIR := build/docs-$(TARGET)
+TESTTYPE ?= debug
# List of items to delete on clean
ITEMS_CLEAN :=
@@ -53,7 +54,7 @@ debug: setup $(addprefix $(DEBUGDIR)/,$(OBJECTS))
@$(AR) $(ARFLAGS) $(COMPONENT)-debug.a \
$(addprefix $(DEBUGDIR)/,$(OBJECTS))
-test: debug $(TARGET_TESTS)
+test: $(TESTTYPE) $(TARGET_TESTS)
coverage: clean
@$(LCOV) --directory . --zerocounters
diff --git a/test/Makefile b/test/Makefile
index caf397d..cb01a62 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -9,6 +9,7 @@
# TOP The location of the source tree root
# RELEASEDIR The place to put release objects
# DEBUGDIR The place to put debug objects
+# TESTTYPE The type of test to build (release/debug)
#
# do_include Canned command sequence to include a child makefile
#
@@ -40,6 +41,14 @@ CFLAGS := $(CFLAGS) -I$(TOP)/src/ -I$(d) \
LDFLAGS := $(LDFLAGS) $(shell $(PKGCONFIG) $(PKGCONFIGFLAGS) --libs json)
endif
+ifeq ($(TESTTYPE),release)
+TESTCFLAGS := $(RELEASECFLAGS)
+TESTLIB := libhubbub.a
+else
+TESTCFLAGS := $(DEBUGCFLAGS)
+TESTLIB := libhubbub-debug.a
+endif
+
ifdef PROFILE
CFLAGS := $(CFLAGS) -pg -fno-omit-frame-pointer
LDFLAGS := $(LDFLAGS) -pg
@@ -75,7 +84,7 @@ define dep_test
DEP_$(d) += $(2)
$(2): $(1)
@$$(RM) $$(RMFLAGS) $(2)
- @$$(CC) $$(DEBUGCFLAGS) -MM -MT '$(2) $(3)' -MF $(2) $(1)
+ @$$(CC) $$(TESTCFLAGS) -MM -MT '$(2) $(3)' -MF $(2) $(1)
endef
@@ -86,11 +95,11 @@ define compile_test
ifeq ($(HOST),riscos)
$(2): $(3)
else
-$(2): $(3) $(TOP)/$(COMPONENT)-debug.a
+$(2): $(3) $(TOP)/$(TESTLIB)
endif
@$$(ECHO) $$(ECHOFLAGS) "==> $(1)"
- @$$(CC) -c -g $$(DEBUGCFLAGS) -o $$@.o $(1)
- @$$(LD) -g -o $$@ $$@.o -lhubbub-debug $$(LDFLAGS) -lgcov
+ @$$(CC) -c -g $$(TESTCFLAGS) -o $$@.o $(1)
+ @$$(LD) -g -o $$@ $$@.o $$(TOP)/$$(TESTLIB) $$(LDFLAGS) -lgcov
@$$(RM) $$(RMFLAGS) $$@.o
endef
diff --git a/test/parser.c b/test/parser.c
index 5531af1..7847a68 100644
--- a/test/parser.c
+++ b/test/parser.c
@@ -50,25 +50,19 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
origlen = len = ftell(fp);
fseek(fp, 0, SEEK_SET);
- while (len >= CHUNK_SIZE) {
- fread(buf, 1, CHUNK_SIZE, fp);
-
+ while (len > 0) {
+ ssize_t bytes_read = fread(buf, 1, CHUNK_SIZE, fp);
+
+ if (bytes_read < 1)
+ break;
+
assert(hubbub_parser_parse_chunk(parser,
- buf, CHUNK_SIZE) == HUBBUB_OK);
-
- len -= CHUNK_SIZE;
- }
-
- if (len > 0) {
- fread(buf, 1, len, fp);
-
- assert(hubbub_parser_parse_chunk(parser,
- buf, len) == HUBBUB_OK);
-
- len = 0;
+ buf, bytes_read) == HUBBUB_OK);
- assert(hubbub_parser_completed(parser) == HUBBUB_OK);
+ len -= bytes_read;
}
+
+ assert(len == 0);
fclose(fp);
diff --git a/test/tokeniser.c b/test/tokeniser.c
index 0614e78..29a2a7e 100644
--- a/test/tokeniser.c
+++ b/test/tokeniser.c
@@ -59,31 +59,22 @@ int main(int argc, char **argv)
origlen = len = ftell(fp);
fseek(fp, 0, SEEK_SET);
- while (len >= CHUNK_SIZE) {
- fread(buf, 1, CHUNK_SIZE, fp);
-
- assert(parserutils_inputstream_append(stream,
- buf, CHUNK_SIZE) == HUBBUB_OK);
-
- len -= CHUNK_SIZE;
-
- assert(hubbub_tokeniser_run(tok) == HUBBUB_OK);
- }
-
- if (len > 0) {
- fread(buf, 1, len, fp);
-
+ while (len > 0) {
+ ssize_t bytes_read = fread(buf, 1, CHUNK_SIZE, fp);
+
+ if (bytes_read < 1)
+ break;
+
assert(parserutils_inputstream_append(stream,
- buf, len) == HUBBUB_OK);
+ buf, bytes_read) == HUBBUB_OK);
- len = 0;
-
- assert(parserutils_inputstream_append(stream, NULL, 0) ==
- HUBBUB_OK);
+ len -= bytes_read;
assert(hubbub_tokeniser_run(tok) == HUBBUB_OK);
}
-
+
+ assert(len == 0);
+
fclose(fp);
hubbub_tokeniser_destroy(tok);
diff --git a/test/tree-buf.c b/test/tree-buf.c
index e406a45..4280a69 100644
--- a/test/tree-buf.c
+++ b/test/tree-buf.c
@@ -241,9 +241,11 @@ int main(int argc, char **argv)
parser = setup_parser();
for (uint32_t i = 0; i < n_chunks; i++) {
+ ssize_t bytes_read;
assert(chunks[i] <= sizeof(buf));
- fread(buf, 1, chunks[i], fp);
+ bytes_read = fread(buf, 1, chunks[i], fp);
+ assert((size_t)(bytes_read) == chunks[i]);
assert(hubbub_parser_parse_chunk(parser, (uint8_t *) buf,
chunks[i]) == HUBBUB_OK);
diff --git a/test/tree.c b/test/tree.c
index 9a5bf8c..8a5a5b1 100644
--- a/test/tree.c
+++ b/test/tree.c
@@ -117,26 +117,20 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
origlen = len = ftell(fp);
fseek(fp, 0, SEEK_SET);
- while (len >= CHUNK_SIZE) {
- fread(buf, 1, CHUNK_SIZE, fp);
-
- assert(hubbub_parser_parse_chunk(parser,
- buf, CHUNK_SIZE) == HUBBUB_OK);
-
- len -= CHUNK_SIZE;
- }
-
- if (len > 0) {
- fread(buf, 1, len, fp);
-
+ while (len > 0) {
+ ssize_t bytes_read = fread(buf, 1, CHUNK_SIZE, fp);
+
+ if (bytes_read < 1)
+ break;
+
assert(hubbub_parser_parse_chunk(parser,
- buf, len) == HUBBUB_OK);
+ buf, bytes_read) == HUBBUB_OK);
- len = 0;
-
- assert(hubbub_parser_completed(parser) == HUBBUB_OK);
+ len -= bytes_read;
}
-
+
+ assert(len == 0);
+
fclose(fp);
charset = hubbub_parser_read_charset(parser, &cssource);
diff --git a/test/tree2.c b/test/tree2.c
index 8fba853..98826ca 100644
--- a/test/tree2.c
+++ b/test/tree2.c
@@ -217,7 +217,7 @@ int main(int argc, char **argv)
bool reprocess = false;
bool passed = true;
- hubbub_parser *parser;
+ hubbub_parser *parser = NULL;
enum reading_state state = EXPECT_DATA;
buf_t expected = { NULL, 0, 0 };