allow to generate code coverage
This commit is contained in:
parent
129ddafb26
commit
1daa2632fb
3 changed files with 43 additions and 5 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -2,7 +2,10 @@
|
||||||
*.d
|
*.d
|
||||||
/iast
|
/iast
|
||||||
/tests/test
|
/tests/test
|
||||||
|
/tests/coverage
|
||||||
*.1.gz
|
*.1.gz
|
||||||
|
*.gcno
|
||||||
|
*.gcda
|
||||||
|
|
||||||
/Makefile
|
/Makefile
|
||||||
/configure
|
/configure
|
||||||
|
|
21
Makefile.in
21
Makefile.in
|
@ -12,11 +12,13 @@ bindir = @bindir@
|
||||||
datarootdir = @datarootdir@
|
datarootdir = @datarootdir@
|
||||||
mandir = @mandir@
|
mandir = @mandir@
|
||||||
|
|
||||||
CFLAGS = -Wall @CFLAGS@
|
USE_GCOV = @USE_GCOV@
|
||||||
|
|
||||||
|
CFLAGS = -Wall @CFLAGS@ @COVERAGE_CFLAGS@
|
||||||
LFLAGS =
|
LFLAGS =
|
||||||
|
|
||||||
TEST_CFLAGS = @CFLAGS@ @CHECK_CFLAGS@
|
TEST_CFLAGS = @CFLAGS@ @CHECK_CFLAGS@
|
||||||
TEST_LFLAGS = @CHECK_LIBS@
|
TEST_LFLAGS = @CHECK_LIBS@ @COVERAGE_LFLAGS@
|
||||||
|
|
||||||
OBJECTS = iast.o iast-czech.o transliteration.o transcription.o utf8.o velthuis.o
|
OBJECTS = iast.o iast-czech.o transliteration.o transcription.o utf8.o velthuis.o
|
||||||
TEST_OBJECTS = tests/main.o tests/translit.o tests/transcript.o tests/velthuis.o
|
TEST_OBJECTS = tests/main.o tests/translit.o tests/transcript.o tests/velthuis.o
|
||||||
|
@ -31,7 +33,7 @@ include $(wildcard *.d tests/*.d)
|
||||||
$(PROGNAME): main.o $(OBJECTS)
|
$(PROGNAME): main.o $(OBJECTS)
|
||||||
$(QUIET_LD) $(CC) $^ -o $@ $(LFLAGS)
|
$(QUIET_LD) $(CC) $^ -o $@ $(LFLAGS)
|
||||||
|
|
||||||
test: all
|
test: tests/test
|
||||||
tests/test
|
tests/test
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
|
@ -41,7 +43,7 @@ tests/%.o: tests/%.c
|
||||||
$(QUIET_CC) $(CC) -MMD -MP -c $< -o $@ $(TEST_CFLAGS)
|
$(QUIET_CC) $(CC) -MMD -MP -c $< -o $@ $(TEST_CFLAGS)
|
||||||
|
|
||||||
tests/test: $(OBJECTS) $(TEST_OBJECTS)
|
tests/test: $(OBJECTS) $(TEST_OBJECTS)
|
||||||
$(QUIET_LD) $(CC) $^ -o $@ $(TEST_CFLAGS) $(TEST_LFLAGS)
|
$(QUIET_LD) $(CC) $^ -o $@ $(TEST_LFLAGS)
|
||||||
|
|
||||||
%.1.gz: %.1
|
%.1.gz: %.1
|
||||||
$(QUIET_GEN) cat $< | gzip -f >$@
|
$(QUIET_GEN) cat $< | gzip -f >$@
|
||||||
|
@ -57,13 +59,22 @@ uninstall:
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(PROGNAME) tests/test $(PROGNAME).1.gz
|
$(RM) $(PROGNAME) tests/test $(PROGNAME).1.gz
|
||||||
$(RM) *.o */*.o */*.d *.d
|
$(RM) -r *.o */*.o */*.d *.d *.gcda *.gcno tests/coverage
|
||||||
|
|
||||||
clean-aux:
|
clean-aux:
|
||||||
$(RM) -r $(AUX_FILES)
|
$(RM) -r $(AUX_FILES)
|
||||||
|
|
||||||
distclean: clean clean-aux
|
distclean: clean clean-aux
|
||||||
|
|
||||||
|
ifeq ($(USE_GCOV),yes)
|
||||||
|
coverage:
|
||||||
|
$(MAKE) test
|
||||||
|
$(MKDIR_P) tests/coverage
|
||||||
|
lcov --no-external -c -d $(shell pwd) -o tests/coverage/coverage.info
|
||||||
|
genhtml -o tests/coverage -t "IAST Test Coverage" \
|
||||||
|
tests/coverage/coverage.info
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
ifndef V
|
ifndef V
|
||||||
QUIET_CC = @echo " CC $@";
|
QUIET_CC = @echo " CC $@";
|
||||||
|
|
24
configure.ac
24
configure.ac
|
@ -29,5 +29,29 @@ AC_FUNC_MALLOC
|
||||||
AC_FUNC_REALLOC
|
AC_FUNC_REALLOC
|
||||||
AC_CHECK_FUNCS([memmove])
|
AC_CHECK_FUNCS([memmove])
|
||||||
|
|
||||||
|
# Enable for gcov if option --enable-gcov is present.
|
||||||
|
USE_GCOV=no
|
||||||
|
AC_MSG_CHECKING([whether gcov should be enabled])
|
||||||
|
AC_ARG_ENABLE(gcov,
|
||||||
|
AS_HELP_STRING([--enable-gcov], [enable gcov code coverage analysis]), [
|
||||||
|
if test "x$enableval" != "xno" ; then
|
||||||
|
if test "$GCC" != "yes"; then
|
||||||
|
AC_MSG_ERROR([gcc is required for --enable-gcov])
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
COVERAGE_CFLAGS="-O0 -g -fno-inline -fprofile-arcs -ftest-coverage"
|
||||||
|
COVERAGE_LFLAGS="-fprofile-arcs -lgcov"
|
||||||
|
USE_GCOV=yes
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
COVERAGE_CFLAGS=""
|
||||||
|
COVERAGE_LFLAGS=""
|
||||||
|
USE_GCOV=no
|
||||||
|
fi
|
||||||
|
], [AC_MSG_RESULT(no)])
|
||||||
|
AC_SUBST(COVERAGE_CFLAGS)
|
||||||
|
AC_SUBST(COVERAGE_LFLAGS)
|
||||||
|
AC_SUBST(USE_GCOV)
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile])
|
AC_CONFIG_FILES([Makefile])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
Loading…
Reference in a new issue