[glom/glom-1-20] gcov: Use lcov instead of my hacky bash script.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/glom-1-20] gcov: Use lcov instead of my hacky bash script.
- Date: Tue, 29 Nov 2011 12:14:01 +0000 (UTC)
commit 02ef37fea6c14ed0bb2233fb5892b61b9add8f36
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Nov 25 12:39:07 2011 +0100
gcov: Use lcov instead of my hacky bash script.
* configure.ac: Check for lcov and genhtml.
* Makefile.am: This generates a nice HTML report.
ChangeLog | 7 +++++++
Makefile.am | 46 +++++++++-------------------------------------
configure.ac | 12 ++++++++++++
3 files changed, 28 insertions(+), 37 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3d8d98c..38e2300 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2011-11-25 Murray Cumming <murrayc murrayc com>
+ gcov: Use lcov instead of my hacky bash script.
+
+ * configure.ac: Check for lcov and genhtml.
+ * Makefile.am: This generates a nice HTML report.
+
+2011-11-25 Murray Cumming <murrayc murrayc com>
+
gcov: Use AC_PATH_PROG().
* configure.ac: Check for the path to gcov.
diff --git a/Makefile.am b/Makefile.am
index 3ef5aed..9eca980 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -83,50 +83,22 @@ MAINTAINERCLEANFILES =
# gcov
if GCOV_ENABLED
-gcov-report.txt: gcov-clean all check
- $(AM_V_GEN)(rm -f $@; \
- echo -e "Test coverage:\n" >> $@; \
- total_covered=0; total_actual=0; \
- for file in $(filter %.cc,$(glom_glom_SOURCES) $(libglom_sources)); do \
- file_basename=$${file##*/}; \
- file_basename_gcda="*-$${file_basename/.cc/.gcda}"; \
- file_o=`find -newer $$file -name $${file_basename_gcda} | sed -e 's/\.gcda/\.o/'`; \
- if [ -z $file_o ]; then \
- echo "Glom: gcov input file (.o) not found."; \
- else \
- $(GCOV) -o $$file_o $$file_basename > /dev/null; \
- file_gcov=$$file_basename.gcov; \
- if test -f $$file_gcov; then \
- actual=`grep -v ' -:' $$file_basename.gcov | wc -l`; \
- uncovered=`grep '#####:' $$file_basename.gcov | wc -l`; \
- covered=$$((actual - uncovered)); \
- total_covered=$$((total_covered + covered)); \
- total_actual=$$((total_actual + actual)); \
- if [ -z $$actual ]; then \
- echo "Glom: gcov failure: actual is 0"; \
- else \
- echo -e "$$file:\t$$covered / $$actual\t($$((($$covered * 100) / $$actual))%)"; \
- fi \
- else \
- echo "generated gcov file not found: $$file_gcov"; \
- fi \
- fi \
- done >> $@; \
- cd $(abs_srcdir); \
- echo -e "\nSource lines: $$total_actual\nCovered statements: $$total_covered\nTotal coverage: $$((($$total_covered * 100) / $$total_actual))%" >> $@)
-
-gcov: gcov-report.txt
- @cat gcov-report.txt
+gcov: gcov-clean all check
+ $(AM_V_GEN)(mkdir -p tests/coverage; \
+ coverage_dir='tests/coverage'; \
+ $(LCOV) --directory . --base-directory . --capture --output-file $$coverage_dir/coverage.info; \
+ $(GENHTML) --output-directory $$coverage_dir $$coverage_dir/coverage.info; \
+ $(LCOV) --directory . --zerocounters; \
+ echo "Code coverage report: file://$(abs_top_builddir)/$$coverage_dir/index.html")
clean: gcov-clean
gcov-clean:
- @find . -name "*.gcda" -o -name "*.gcov" -delete
+ $(LCOV) --directory . --zerocounters
-MAINTAINERCLEANFILES += gcov-report.txt
gcov_phony_files = gcov gcov-clean gcov-report.txt
else
gcov:
- @echo "Need to reconfigure with --enable-gcov"
+ echo "Need to reconfigure with --enable-gcov"
endif
diff --git a/configure.ac b/configure.ac
index 0fdccdf..650480f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -288,6 +288,18 @@ if test "x$enable_gcov" = "xyes"; then
fi
AC_SUBST(GCOV)
+ AC_PATH_PROG(LCOV, [lcov], [no])
+ if test "x$LCOV" = "xno"; then
+ AC_MSG_ERROR([gcov was enabled but lcov was not found.])
+ fi
+ AC_SUBST(LCOV)
+
+ AC_PATH_PROG(GENHTML, [genhtml], [no])
+ if test "x$GENHTML" = "xno"; then
+ AC_MSG_ERROR([gcov was enabled but lcov's genhtml was not found.])
+ fi
+ AC_SUBST(GENHTML)
+
GCOV_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
GCOV_LIBS="-lgcov"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]