Skip to content

Commit

Permalink
improvement: improve swoole coverage (#3512)
Browse files Browse the repository at this point in the history
  • Loading branch information
huanghantao committed Jul 30, 2020
1 parent 80327b3 commit 1e2525d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
*.so
*.loT
*.pid
*.gcno
*.gcov
*.gcda
*.info
/Debug/*
modules/*
/.deps
Expand Down Expand Up @@ -102,3 +98,10 @@ core-tests/samples/bin/
core-tests/samples/CMakeFiles/
/out
/gcov_result

# coverage
*.gcno
*.gcov
*.gcda
*.info
/html
11 changes: 11 additions & 0 deletions Makefile.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
swoole-build-coverage:
CCACHE_DISABLE=1 EXTRA_CFLAGS="-fprofile-arcs -ftest-coverage" EXTRA_CXXFLAGS="-fprofile-arcs -ftest-coverage" $(MAKE)

swoole-test-coverage:
CCACHE_DISABLE=1 EXTRA_CFLAGS="-fprofile-arcs -ftest-coverage" EXTRA_CXXFLAGS="-fprofile-arcs -ftest-coverage" $(MAKE) && $(MAKE) install && $(top_srcdir)/tests/start.sh $(top_srcdir)/tests

swoole-test-coverage-lcov: swoole-test-coverage
lcov -c --directory $(top_srcdir)/.libs --output-file $(top_srcdir)/coverage.info

swoole-test-coverage-html: swoole-test-coverage-lcov
genhtml $(top_srcdir)/coverage.info --output-directory=$(top_srcdir)/html
19 changes: 11 additions & 8 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ PHP_ARG_WITH(jemalloc_dir, dir of jemalloc,
PHP_ARG_ENABLE(asan, enable asan,
[ --enable-asan Enable asan], no, no)

PHP_ARG_ENABLE(gcov, enable gcov,
[ --enable-gcov Enable gcov], no, no)
PHP_ARG_ENABLE(swoole-coverage, whether to enable swoole coverage support,
[ --enable-swoole-coverage Enable swoole coverage support], no, no)

AC_DEFUN([SWOOLE_HAVE_PHP_EXT], [
extname=$1
Expand Down Expand Up @@ -315,12 +315,6 @@ if test "$PHP_SWOOLE" != "no"; then
CXXFLAGS="$CXXFLAGS -fsanitize=address -fno-omit-frame-pointer"
fi

if test "$PHP_GCOV" != "no"; then
PHP_DEBUG=1
CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage -lgcov"
CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage -lgcov"
fi

if test "$PHP_TRACE_LOG" != "no"; then
AC_DEFINE(SW_LOG_TRACE_OPEN, 1, [enable trace log])
fi
Expand Down Expand Up @@ -625,6 +619,15 @@ if test "$PHP_SWOOLE" != "no"; then
PHP_ADD_INCLUDE([$ext_srcdir/include])
PHP_ADD_INCLUDE([$ext_srcdir/thirdparty/hiredis])

AC_MSG_CHECKING([swoole coverage])
if test "$PHP_SWOOLE_COVERAGE" != "no"; then
AC_MSG_RESULT([enabled])

PHP_ADD_MAKEFILE_FRAGMENT
else
AC_MSG_RESULT([disabled])
fi

PHP_INSTALL_HEADERS([ext/swoole], [*.h config.h include/*.h thirdparty/*.h thirdparty/hiredis/*.h])

PHP_REQUIRE_CXX()
Expand Down

0 comments on commit 1e2525d

Please sign in to comment.