diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2008-09-05 12:11:18 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2008-09-05 12:11:18 +0000 |
commit | 11f53b1063e796dbb766b7ad3fd46e98806bea43 (patch) | |
tree | e77ab3e271f7d464e88e481715997a09bde14e65 /src | |
parent | 579d9a520135078d96eef8335aed399833d33b7e (diff) | |
download | postgresql-11f53b1063e796dbb766b7ad3fd46e98806bea43.tar.gz postgresql-11f53b1063e796dbb766b7ad3fd46e98806bea43.zip |
Code coverage testing with gcov. Documentation is in the regression test
chapter.
Author: Michelle Caisse <Michelle.Caisse@Sun.COM>
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.global.in | 52 | ||||
-rw-r--r-- | src/backend/common.mk | 8 |
2 files changed, 57 insertions, 3 deletions
diff --git a/src/Makefile.global.in b/src/Makefile.global.in index 6212a1467ff..def667a1039 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -1,5 +1,5 @@ # -*-makefile-*- -# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.242 2008/08/29 13:02:32 petere Exp $ +# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.243 2008/09/05 12:11:18 petere Exp $ #------------------------------------------------------------------------------ # All PostgreSQL makefiles include this file and use the variables it sets, @@ -18,7 +18,7 @@ # # Meta configuration -.PHONY: all install install-strip installdirs uninstall clean distclean maintainer-clean distprep check installcheck maintainer-check +.PHONY: all install install-strip installdirs uninstall clean distclean maintainer-clean distprep check installcheck maintainer-check coverage .SILENT: installdirs # make `all' the default target @@ -165,6 +165,7 @@ enable_rpath = @enable_rpath@ enable_nls = @enable_nls@ enable_debug = @enable_debug@ enable_dtrace = @enable_dtrace@ +enable_coverage = @enable_coverage@ enable_thread_safety = @enable_thread_safety@ python_includespec = @python_includespec@ @@ -291,6 +292,17 @@ JADE = @JADE@ NSGMLS = @NSGMLS@ SGMLSPL = @SGMLSPL@ +# Code coverage + +GCOV = @GCOV@ +LCOV = @LCOV@ +GENHTML = @GENHTML@ + +ifeq ($(enable_coverage),yes) +# ccache loses .gcno files +export CCACHE_DISABLE = 1 +endif + # Feature settings DEF_PGPORT = @default_port@ @@ -574,3 +586,39 @@ include $(top_srcdir)/src/nls-global.mk endif # nls.mk endif # enable_nls + + +########################################################################## +# +# Coverage + +ifeq ($(enable_coverage), yes) + +# There is a strange interaction between lcov and existing .gcov +# output files. Hence the rm command and the ordering dependency. + +gcda_files := $(wildcard *.gcda) + +lcov.info: + rm -f *.gcov +ifneq (,$(gcda_files)) + $(LCOV) -d . -c -o $@ $(LCOVFLAGS) +endif + +%.c.gcov: %.gcda | lcov.info + $(GCOV) -b -f -p -o . $(GCOVFLAGS) $*.c >$*.c.gcov.out + + +# hook for clean-up +clean distclean maintainer-clean: clean-coverage + +.PHONY: clean-coverage +clean-coverage: + rm -f *.gcda *.gcno lcov.info *.gcov *.gcov.out + + +# User-callable target to reset counts between test runs +coverage-clean: + rm -f `find . -name '*.gcda' -print` + +endif # enable_coverage diff --git a/src/backend/common.mk b/src/backend/common.mk index 82a9ab6fc10..c617c672765 100644 --- a/src/backend/common.mk +++ b/src/backend/common.mk @@ -1,7 +1,7 @@ # # Common make rules for backend # -# $PostgreSQL: pgsql/src/backend/common.mk,v 1.7 2008/03/17 18:24:56 petere Exp $ +# $PostgreSQL: pgsql/src/backend/common.mk,v 1.8 2008/09/05 12:11:18 petere Exp $ # # When including this file, set OBJS to the object files created in @@ -46,3 +46,9 @@ ifdef SUBDIRS for dir in $(SUBDIRS); do $(MAKE) -C $$dir clean || exit; done endif rm -f $(subsysfilename) $(OBJS) + + +coverage: $(gcda_files:.gcda=.c.gcov) lcov.info +ifdef SUBDIRS + for dir in $(SUBDIRS); do $(MAKE) -C $$dir coverage || exit; done +endif |