1
0
mirror of https://github.com/php/php-src.git synced 2026-04-04 14:42:49 +02:00

MFH: - Added --enable-gcov configure option to enable C-level code coverage.

This commit is contained in:
foobar
2005-11-29 23:20:01 +00:00
parent ea80259eb3
commit 30dc899c2e
3 changed files with 137 additions and 2 deletions

66
Makefile.gcov Normal file
View File

@@ -0,0 +1,66 @@
#
# LCOV
#
lcov: lcov-html
lcov-ccache:
@if test -z "$(CCACHE_DISABLE)" || test "$(CCACHE_DISABLE)" != "1"; then \
echo "ccache is not disabled. Set environment variable CCACHE_DISABLE=1 to disable ccache."; \
exit 123; \
fi
lcov-test: all
@echo "Running test suite"
@find . -name \*.gcda | xargs rm -f
-@if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \
NO_INTERACTION=1 \
TEST_PHP_EXECUTABLE=$(PHP_EXECUTABLE) \
TEST_PHP_SRCDIR=$(top_srcdir) \
CC="$(CC)" \
$(PHP_EXECUTABLE) -d 'open_basedir=' -d 'safe_mode=0' -d 'output_buffering=0' -d 'memory_limit=-1' $(top_srcdir)/run-tests.php -d 'extension_dir=modules/' -d `( . $(PHP_MODULES) ; echo extension=$$dlname)` tests/; \
elif test ! -z "$(SAPI_CLI_PATH)" && test -x "$(SAPI_CLI_PATH)"; then \
NO_INTERACTION=1 \
TEST_PHP_EXECUTABLE=$(top_builddir)/$(SAPI_CLI_PATH) \
TEST_PHP_SRCDIR=$(top_srcdir) \
CC="$(CC)" \
$(top_builddir)/$(SAPI_CLI_PATH) -d 'open_basedir=' -d 'safe_mode=0' -d 'output_buffering=0' -d 'memory_limit=-1' $(top_srcdir)/run-tests.php $(TESTS); \
else \
echo "ERROR: Cannot run tests without CLI sapi."; \
fi
php_lcov.info: lcov-test
@echo "Generating data for $@"
@rm -rf lcov_data/
@$(mkinstalldirs) lcov_data/
@echo
-@find . -name \*.gcda -o -name \*.gcno | sed -e 's/^\.\///' | sed -e 's/\.gcda//g' -e 's/\.gcno//g' | uniq | while read x; do \
echo -n . ;\
dir=lcov_data/`dirname $$x`; \
test -d "$$dir" || $(mkinstalldirs) "$$dir"; \
if test -f "$(top_srcdir)/$$x.c"; then \
ln -f -s $(top_srcdir)/$$x.c lcov_data/$$x.c; \
fi; \
if test -f "$(top_srcdir)/$$x.re"; then \
ln -f -s $(top_srcdir)/$$x.re lcov_data/$$x.re; \
fi; \
if test -f "$(top_builddir)/$$x.c"; then \
ln -f -s $(top_builddir)/$$x.c lcov_data/$$x.c; \
fi; \
test -f "$$x.gcno" && cp $$x.gcno lcov_data/ ; \
test -f "$$x.gcda" && cp $$x.gcda lcov_data/ ; \
done
@echo
@echo "Generating $@"
@$(LTP) --directory lcov_data/ --capture --output-file $@ --test-name PHP_LCOV
lcov-html: php_lcov.info
@echo "Generating lcov HTML"
@$(LTP_GENHTML) --no-prefix --output-directory lcov_html/ --title "PHP Code Coverage" --show-details php_lcov.info
lcov-clean:
rm -f php_lcov.info
rm -rf lcov_data/
rm -rf lcov_html/

2
NEWS
View File

@@ -1,6 +1,8 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 200?, PHP 5.1.2
- Added --enable-gcov configure option to enable C-level code coverage.
(John, Jani)
- Added missing support for 'B' format identifier to date() function. (Ilia)
- Improved SPL: (Marcus)
. Added class SplFileInfo as root class for DirectoryIterator and

View File

@@ -378,7 +378,8 @@ unix.h \
utime.h \
sys/utsname.h \
sys/ipc.h \
dlfcn.h
dlfcn.h \
assert.h
],[],[],[
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
@@ -597,6 +598,72 @@ PHP_CONFIGURE_PART(General settings)
PHP_HELP_SEPARATOR([General settings:])
PHP_ARG_ENABLE(gcov, whether to include gcov symbols,
[ --enable-gcov Enable GCOV code coverage (requires LTP) - FOR DEVELOPERS ONLY!!], no, no)
if test "$PHP_GCOV" = "yes"; then
if test "$GCC" != "yes"; then
AC_MSG_ERROR([GCC is required for --enable-gcov])
fi
dnl Check if ccache is being used
dnl FIXME: Need a check for ccache usage, the one below does not work!
PHP_CHECK_GCC_ARG([--ccache-skip], [gcc_ccache=yes])
if test "$gcc_ccache" = "yes"; then
if test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"; then
AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
fi
lcov_target="lcov-ccache"
fi
ltp_version_list="1.4"
AC_CHECK_PROG(LTP, lcov, lcov)
AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
PHP_SUBST(LTP)
PHP_SUBST(LTP_GENHTML)
if test "$LTP"; then
AC_CACHE_CHECK([for ltp version], php_cv_ltp_version, [
php_cv_ltp_version=invalid
ltp_version=`$LTP -v 2>/dev/null | $SED -e 's/^.* //'`
for ltp_check_version in $ltp_version_list; do
if test "$ltp_version" = "$ltp_check_version"; then
php_cv_ltp_version="$ltp_check_version (ok)"
fi
done
])
else
ltp_msg="To enable code coverage reporting you must have one of the following LTP versions installed: $ltp_version_list"
AC_MSG_ERROR([$ltp_msg])
fi
case $php_cv_ltp_version in
""|invalid[)]
ltp_msg="You must have one of the following versions of LTP: $ltp_version_list (found: $ltp_version)."
AC_MSG_ERROR([$ltp_msg])
LTP="exit 0;"
;;
esac
if test -z "$LTP_GENHTML"; then
AC_MSG_ERROR([Could not find genhtml from the LTP package])
fi
AC_DEFINE(HAVE_GCOV, 1, [Whether you have gcov])
PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/Makefile.gcov, $abs_srcdir)
dnl Remove all optimization flags from CFLAGS
changequote({,})
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
changequote([,])
dnl Add the special gcc flags
CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
fi
PHP_ARG_ENABLE(debug, whether to include debugging symbols,
[ --enable-debug Compile with debugging symbols], no, no)
@@ -1180,7 +1247,7 @@ CFLAGS="\$(CFLAGS_CLEAN) $standard_libtool_flag"
INLINE_CFLAGS="$INLINE_CFLAGS $standard_libtool_flag"
CXXFLAGS="$CXXFLAGS $standard_libtool_flag"
all_targets='$(OVERALL_TARGET) $(PHP_MODULES) $(PHP_CLI_TARGET)'
all_targets="$lcov_target \$(OVERALL_TARGET) \$(PHP_MODULES) \$(PHP_CLI_TARGET)"
install_targets="$install_modules install-build install-headers install-programs $install_pear"
case $PHP_SAPI in