From 6a74967b4d3409cbbb797240bd414d5919c0cfa2 Mon Sep 17 00:00:00 2001 From: hugo303 Date: Wed, 7 Sep 2005 15:10:17 +0000 Subject: [PATCH] Added gcov/lcov support git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@245 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- check/configure.in | 14 ++++++++++++++ check/src/Makefile.am | 35 +++++++++++++++++++++++++++++++++++ check/tests/Makefile.am | 7 +++++-- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/check/configure.in b/check/configure.in index 9da0872..749df98 100644 --- a/check/configure.in +++ b/check/configure.in @@ -13,6 +13,16 @@ AC_SUBST(CHECK_MAJOR_VERSION) AC_SUBST(CHECK_MINOR_VERSION) AC_SUBST(CHECK_MICRO_VERSION) +AC_ARG_ENABLE(gcov, +AC_HELP_STRING([--enable-gcov],[turn on code coverage analysis tools]), +[case "${enableval}" in + yes) enable_gcov=true ;; + no) enable_gcov=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-gcov) ;; +esac], [enable_gcov=false ]) + +AM_CONDITIONAL(ENABLE_GCOV, test x"$enable_gcov" = "xtrue") + AC_ARG_ENABLE(plain_docdir, [ --enable-plain-docdir don't append version information to docdir], [case "${enableval}" in @@ -32,11 +42,15 @@ AC_PROG_RANLIB if test -n "$GCC"; then CFLAGS="$CFLAGS -Wall -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings" fi +AC_CHECK_PROGS(GCOV, gcov, false) +AC_CHECK_PROGS(LCOV, lcov, false) +AC_CHECK_PROGS(GENHTML, genhtml, false) AC_CHECK_PROG(have_docbook2html,docbook2html,yes) if test x"$have_docbook2html" != "xyes" ; then AC_MSG_WARN([required tools not found, not building docs]) fi AM_CONDITIONAL(MAKE_DOC, test x"$have_docbook2html" = "xyes") + dnl Checks for libraries. dnl Checks for header files. diff --git a/check/src/Makefile.am b/check/src/Makefile.am index 18b33c2..929cce5 100644 --- a/check/src/Makefile.am +++ b/check/src/Makefile.am @@ -2,6 +2,10 @@ lib_LIBRARIES=libcheck.a include_HEADERS=check.h +if ENABLE_GCOV +libcheck_a_CFLAGS=-fprofile-arcs -ftest-coverage +endif + libcheck_a_SOURCES=\ check_impl.h \ check.h \ @@ -23,3 +27,34 @@ libcheck_a_SOURCES=\ check_str.c EXTRA_DIST=check.h.in + +CLEANFILES=*~ *.bb *.bbg *.da + +LCOV_OUTPUT = lcov.info +LCOV_HTML = lcov_html +LCOV_LCOV = @LCOV@ +LCOV_GENHTML = @GENHTML@ +TEST_PROG = ../tests/check_check + +lcov: $(LCOV_HTML) + +$(TEST_PROG): force + @$(MAKE) -C ../tests + +$(LCOV_OUTPUT): $(TEST_PROG) + $(TEST_PROG) + $(LCOV_LCOV) --capture --directory . --output-file $(LCOV_OUTPUT) + +$(LCOV_HTML): $(LCOV_OUTPUT) + -$(RM) -r $(LCOV_HTML) + LANG=C $(LCOV_GENHTML) --output-directory $(LCOV_HTML) --title "Check Code Coverage" --show-details $(LCOV_OUTPUT) + @echo "Point a web browser at $(LCOV_HTML)/index.html to see results." + +clean-local: lcov-clean + +.PHONY: lcov-clean +lcov-clean: + -$(RM) -r $(LCOV_HTML) $(LCOV_OUTPUT) + +.PHONY: force +force: diff --git a/check/tests/Makefile.am b/check/tests/Makefile.am index 36115f2..8fb64c2 100644 --- a/check/tests/Makefile.am +++ b/check/tests/Makefile.am @@ -34,8 +34,11 @@ ex_log_output_SOURCES = ex_log_output.c ex_xml_output_SOURCES = ex_xml_output.c - +LIBCHECK_A=../src/libcheck.a INCLUDES = -I$(srcdir)/../src -LDADD = ../src/libcheck.a +LDADD = $(LIBCHECK_A) CLEANFILES = *~ *.log test_logfile + +$(LIBCHECK_A): + $(MAKE) -C ../src -- 2.40.0