Re: PHP 5.1 Release Candidate 1
| From: | John Coggeshall | Date: | Thu, 28 Jul 2005 19:00:24 +0000 |
| Subject: | Re: PHP 5.1 Release Candidate 1 | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-17458@lists.php.net to get a copy of this message | ||
Honestly it's only a patch to the build system to add basically
--enable-gcov to the configure (much like --enable-debug). Basically it
just checks for the proper libraries and utilities during configure as
it should and if everything is okay builds PHP with the proper compile-
time flags and libraries. The libgcov takes care of all the
instrumenting internally (so no changes to internals code). The
difference is that with --enable-gcov PHP produces a ton of .gcda
and .gcno files which contain the code coverage data. Enabling at
configure also provides two new make commands:
make cov
(gather up all the .gcda, .gcno files in the build tree from running php
and put them in one place then run the lcov utility to process them into
a consolidated .phplcov-info.dat file)
make cov-html
Process the .phplcov-info.dat file and generate a pretty HTML report in
the cov_html/ directory
It's really a non-intrusive no-code-change patch. Unfortunately I can't
seem to get at the CVS right now.. Attached is (basically) the patch.
John
On Thu, 2005-07-28 at 11:31 -0700, Andi Gutmans wrote:
> Is this an extension or changes to the core? Do you already have a patch?
> In any case, this would have to wait until earliest after the branch and go
> to HEAD.
> But I suggest to first make a proposal and show what you're planning on
> doing here on internals@
>
> Andi
>
> At 03:02 PM 7/27/2005 -0400, John Coggeshall wrote:
> >I'd also like to get this in to PHP 5.1+ after we branch before Unicode:
> >
>
> >>http://blog.coggeshall.org/archives/204_Code_Coverage_Support_for_PHP_5.html
> >
> >John
>
PHP_ARG_ENABLE(gcov, whether to include gcov symbols, [ --enable-gcov Enable GCOV code coverage (requires LTP)], no, no) if test "$PHP_GCOV" = "yes"; then AC_DEFUN([PHP_PROG_LTP],[ ltp_version_list="1.4" AC_CHECK_PROG(LTP, lcov, lcov) AC_CHECK_PROG(LTP_GENHTML, genhtml, 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 follo wing 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_versi on_list (found: $ltp_version)." AC_MSG_ERROR([$ltp_msg]) LTP="exit 0;" ;; esac if test "$LTP_GENHTML" = ""; then AC_MSG_ERROR([Could not find genhtml from the LTP package]) fi PHP_SUBST(LTP) PHP_SUBST(LTP_GENHTML) ]) PHP_PROG_LTP AC_CHECK_LIB(gcov, __gcov_open, [ PHP_ADD_LIBRARY(gcov) AC_DEFINE(HAVE_GCOV, 1, [Whether you have gcov]) CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage" PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/Makefile.gcov,$abs_srcdir) ], [ AC_MSG_ERROR([Problem with enabling gcov. Please check config.log for detai ls.]) ]) fi ..php_cov_info.ltpdata: @mkdir -p .cov/; \ find . -name \*.gcda -o -name \*.gcno | sed -e 's/^\.\/\.cov\/.*//' | xargs --replace cp {} .cov/; \ find . -name \*.gcda -o -name \*.gcno | sed -e 's/^\.\/\.cov\/.*//' | sed -e 's/^\.\///' | xargs --max-args=1 dirname | sed -e 's/\/.*//' | xargs --replace ln -s `pwd`/{} `pwd`/.cov > /dev/null 2>&1; \ $(LTP) --directory .cov --output-file=.php_cov_info.ltpdata --capture; \ cov: .php_cov_info.ltpdata cov-html: cov @$(LTP_GENHTML) -o cov_html/ .php_cov_info.ltpdata -t "PHP Code Coverage" -s; cov-clean: find . -name \*.gcda -o -name \*.gcno -exec rm -f {} \; rm -f .cov/* # This is done first, since we are symlinked inside.. rm -Rf .cov # Now remove the directory rm -f .php_cov_info.ltpdata rm -Rf cov_html Attachment: [application/x-shellscript] gen_php_cov
PHP_ARG_ENABLE(gcov, whether to include gcov symbols, [ --enable-gcov Enable GCOV code coverage (requires LTP)], no, no) if test "$PHP_GCOV" = "yes"; then AC_DEFUN([PHP_PROG_LTP],[ ltp_version_list="1.4" AC_CHECK_PROG(LTP, lcov, lcov) AC_CHECK_PROG(LTP_GENHTML, genhtml, 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 follo wing 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_versi on_list (found: $ltp_version)." AC_MSG_ERROR([$ltp_msg]) LTP="exit 0;" ;; esac if test "$LTP_GENHTML" = ""; then AC_MSG_ERROR([Could not find genhtml from the LTP package]) fi PHP_SUBST(LTP) PHP_SUBST(LTP_GENHTML) ]) PHP_PROG_LTP AC_CHECK_LIB(gcov, __gcov_open, [ PHP_ADD_LIBRARY(gcov) AC_DEFINE(HAVE_GCOV, 1, [Whether you have gcov]) CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage" PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/Makefile.gcov,$abs_srcdir) ], [ AC_MSG_ERROR([Problem with enabling gcov. Please check config.log for detai ls.]) ]) fi ..php_cov_info.ltpdata: @mkdir -p .cov/; \ find . -name \*.gcda -o -name \*.gcno | sed -e 's/^\.\/\.cov\/.*//' | xargs --replace cp {} .cov/; \ find . -name \*.gcda -o -name \*.gcno | sed -e 's/^\.\/\.cov\/.*//' | sed -e 's/^\.\///' | xargs --max-args=1 dirname | sed -e 's/\/.*//' | xargs --replace ln -s `pwd`/{} `pwd`/.cov > /dev/null 2>&1; \ $(LTP) --directory .cov --output-file=.php_cov_info.ltpdata --capture; \ cov: .php_cov_info.ltpdata cov-html: cov @$(LTP_GENHTML) -o cov_html/ .php_cov_info.ltpdata -t "PHP Code Coverage" -s; cov-clean: find . -name \*.gcda -o -name \*.gcno -exec rm -f {} \; rm -f .cov/* # This is done first, since we are symlinked inside.. rm -Rf .cov # Now remove the directory rm -f .php_cov_info.ltpdata rm -Rf cov_html Attachment: [application/x-shellscript] gen_php_cov