summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--README16
-rw-r--r--build/Makefile.common19
3 files changed, 35 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index cdac442..74c2b19 100644
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,8 @@ PERL := perl
PKGCONFIG := pkg-config
INSTALL := install
SED := sed
+LCOV := lcov
+GENHTML := genhtml
# Toolchain flags
WARNFLAGS := -Wall -Wextra -Wundef -Wpointer-arith -Wcast-align \
diff --git a/README b/README
index c0e42a4..57ecd10 100644
--- a/README
+++ b/README
@@ -21,8 +21,13 @@ Requirements
Hubbub also requires the following libraries to be installed:
- + An iconv implementation (e.g. libiconv)
- + JSON-C (for the testcases) -- see json/README for further information
+ + An iconv implementation (e.g. libiconv)
+ + JSON-C (for the testcases) -- see json/README for further information
+
+ Hubbub can make use of the following, for debugging and testing purposes:
+
+ + gcov and lcov, for test coverage data
+
Compilation
-----------
@@ -39,6 +44,13 @@ Verification
$ make test
+ If you wish to see test coverage statistics, run:
+
+ $ make coverage
+
+ Then open the build/coverage/index.html file in a web browser.
+
+
API documentation
-----------------
diff --git a/build/Makefile.common b/build/Makefile.common
index bc79ff5..79b81d1 100644
--- a/build/Makefile.common
+++ b/build/Makefile.common
@@ -11,6 +11,7 @@ EXPORT := $(CURDIR)/dist
TOP := $(CURDIR)
RELEASEDIR := build/Release
DEBUGDIR := build/Debug
+COVERAGEDIR := build/coverage
# List of items to delete on clean
ITEMS_CLEAN :=
@@ -48,8 +49,25 @@ debug: setup $(addprefix $(DEBUGDIR)/,$(OBJECTS))
test: debug $(TARGET_TESTS)
+coverage: clean
+ @$(LCOV) --directory . --zerocounters
+ @$(MAKE) test CFLAGS="$(CFLAGS) -fprofile-arcs -ftest-coverage" \
+ LDFLAGS="$(LDFLAGS) -lgcov"
+ @$(LCOV) --directory $(DEBUGDIR) --base-directory $(TOP) \
+ --capture --output-file $(COVERAGEDIR)/$(COMPONENT)_tmp.info
+ @$(LCOV) --extract $(COVERAGEDIR)/$(COMPONENT)_tmp.info "$(TOP)/src*" \
+ -o $(COVERAGEDIR)/$(COMPONENT).info
+ @$(RM) $(RMFLAGS) $(COVERAGEDIR)/$(COMPONENT)_tmp.info
+ @$(GENHTML) -o $(COVERAGEDIR) --num-spaces 2 \
+ $(COVERAGEDIR)/$(COMPONENT).info
+
+profile: clean
+ @$(MAKE) test CFLAGS="$(CFLAGS) -pg" LDFLAGS="-pg $(LDFLAGS)"
+
clean:
-@$(RM) $(RMFLAGS) $(ITEMS_CLEAN)
+ -@$(RM) $(RMFLAGS) gmon.out
+ -@$(RM) $(RMFLAGS) -r $(COVERAGEDIR)
-@$(RM) $(RMFLAGS) -r $(RELEASEDIR)
-@$(RM) $(RMFLAGS) -r $(DEBUGDIR)
-@$(RM) $(RMFLAGS) $(COMPONENT).a
@@ -63,6 +81,7 @@ distclean: clean
setup:
@$(MKDIR) $(MKDIRFLAGS) $(RELEASEDIR)
@$(MKDIR) $(MKDIRFLAGS) $(DEBUGDIR)
+ @$(MKDIR) $(MKDIRFLAGS) $(COVERAGEDIR)
export: release
@$(MKDIR) $(MKDIRFLAGS) $(TOP)/dist/lib