add unit test and coverage support in configure.in and Makefile.am. Now let's encourage Cedric for writing the unit tests :)

SVN revision: 35254
This commit is contained in:
doursse 2008-07-30 13:58:26 +00:00 committed by doursse
parent 86f58ba639
commit 00911f4df4
2 changed files with 148 additions and 11 deletions

View File

@ -30,3 +30,52 @@ eina.pc
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = eina.pc
# Unit tests
if EINA_ENABLE_TESTS
check-local:
@./src/tests/eina_suite
else
check-local:
@echo "reconfigure with --enable-tests"
endif
# Coverage report
if EINA_ENABLE_COVERAGE
lcov-reset:
@rm -rf coverage
@find . -name "*.gcda" -exec rm {} \;
@lcov --directory . --zerocounters
lcov-report:
@mkdir coverage
@lcov --compat-libtool --directory . --capture --output-file coverage/coverage.info
@lcov -l coverage/coverage.info | grep -v "`cd $(top_srcdir) && pwd`" | cut -d: -f1 > coverage/remove
@lcov -r coverage/coverage.info `cat coverage/remove` > coverage/coverage.cleaned.info
@rm coverage/remove
@mv coverage/coverage.cleaned.info coverage/coverage.info
@genhtml -t "$(PACKAGE_STRING)" -o coverage coverage/coverage.info
coverage:
@make lcov-reset
@make check
@make lcov-report
clean-local:
@rm -rf coverage
else
lcov-reset:
@echo "reconfigure with --enable-coverage"
lcov-report:
@echo "reconfigure with --enable-coverage"
coverage:
@echo "reconfigure with --enable-tests --enable-coverage"
endif

View File

@ -24,30 +24,111 @@ version_info=`expr $VMAJ + $VMIN`":$VMIC:$VMIN"
AC_SUBST(VMAJ)
AC_SUBST(version_info)
# Checks for programs
AC_PROG_CC
### Additional options to configure
# Checks for libraries
# Unit tests
# Checks for header files
AC_ARG_ENABLE([tests],
[AC_HELP_STRING([--enable-tests], [enable tests @<:@default=no@:>@])],
[
if test "x${enableval}" = "xyes" ; then
enable_tests="yes"
else
enable_tests="no"
fi
],
[enable_tests="no"]
)
AC_MSG_CHECKING([whether tests are built])
AC_MSG_RESULT([${enable_tests}])
# Coverage
AC_ARG_ENABLE([coverage],
[AC_HELP_STRING([--enable-coverage], [compile with coverage profiling instrumentation @<:@default=no@:>@])],
[
if test "x${enableval}" = "xyes" ; then
enable_coverage="yes"
else
enable_coverage="no"
fi
],
[enable_coverage="no"]
)
AC_MSG_CHECKING([whether to use profiling instrumentation])
AC_MSG_RESULT([$enable_coverage])
### Checks for libraries
# Check library for unit tests
if test "x${enable_tests}" = "xyes" ; then
PKG_CHECK_MODULES([CHECK],
[check >= 0.9.5],
[dummy="yes"],
[enable_tests="no"]
)
fi
AM_CONDITIONAL(EINA_ENABLE_TESTS, test "x${enable_tests}" = "xyes")
### Checks for header files
AC_HEADER_ASSERT
AC_HEADER_DIRENT
AC_HEADER_TIME
# Checks for types
# Checks for structures
### Checks for programs
AC_PROG_CC
# Checks for compiler characteristics
# lcov program for coverage report
if test "x$enable_tests" = "xno" -a "x$enable_coverage" = "xyes" ; then
AC_MSG_WARN([Coverage report requested but tests not being built. Run configure with --enable-tests])
enable_coverage="no"
fi
if test "x$enable_coverage" = "xyes"; then
AC_CHECK_PROG(have_lcov, [lcov], [yes], [no])
if test "x$have_lcov" = "xyes" ; then
COVERAGE_CFLAGS="-fprofile-arcs -ftest-coverage"
COVERAGE_LIBS="-lgcov"
# remove any optimisation flag and force debug symbols
DEBUG_CFLAGS="-g -O0"
else
AC_MSG_WARN([lcov is not found, disable profiling instrumentation])
enable_coverage="no"
fi
fi
AC_SUBST(COVERAGE_CFLAGS)
AC_SUBST(COVERAGE_LIBS)
AM_CONDITIONAL(EINA_ENABLE_COVERAGE, test "x${enable_coverage}" = "xyes")
### Checks for types
### Checks for structures
### Checks for compiler characteristics
AC_C_CONST
AC_C_BIGENDIAN
AC_PROG_CC_STDC
if test "x$enable_coverage" = "xyes"; then
CFLAGS="${DEBUG_CFLAGS}"
fi
if ! test "${VMIC}" = "x" ; then
CFLAGS="${CFLAGS} -Wall -W -Wextra" # -Werror
fi
# Checks for linker characteristics
### Checks for linker characteristics
lt_enable_auto_import=""
case "$host_os" in
mingw*|cegcc*)
@ -56,9 +137,11 @@ case "$host_os" in
esac
AC_SUBST(lt_enable_auto_import)
# Checks for library functions
## Make the debug preprocessor configurable
### Checks for library functions
### Make the debug preprocessor configurable
AC_CONFIG_FILES([
Makefile
@ -85,7 +168,12 @@ echo
echo
echo "Configuration Options Summary:"
echo
echo "Installation Path.........: $prefix"
echo " Tests................: ${enable_tests}"
echo " Coverage.............: ${enable_coverage}"
echo
echo " Installation.........: make install"
echo
echo " prefix.............: $prefix"
echo
echo "Now type 'make' ('gmake' on some systems) to compile $PACKAGE,"
echo "and then afterwards as root (or the user who will install this), type"