It used to be possible to run the testsuite whether coverage was enabled
or not; this is very useful for eg. distros who want to automatically
run the testsuite without having to compile with coverage support.

Most other EFL in the stable branch already allow this (evas, ecore,
edje); update Eina to bring it in line with them.
---
 Makefile.am               |   29 ++++++++++++++++-----
 configure.ac              |   10 +++++++-
 m4/common/efl_coverage.m4 |   62 +++++++++++++++++++++++++++++++++++++++++++++
 m4/common/efl_tests.m4    |   27 +++-----------------
 4 files changed, 97 insertions(+), 31 deletions(-)
 create mode 100644 m4/common/efl_coverage.m4

diff --git a/Makefile.am b/Makefile.am
index 5ff1896..e67c183 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -42,7 +42,8 @@ m4/common/efl_attribute.m4 \
 m4/common/efl_benchmark.m4 \
 m4/common/efl_check_funcs.m4 \
 m4/common/efl_compiler_flag.m4 \
-m4/common/efl_cpu.m4 \
+m4/common/efl_coverage.m4 \
+m4/common/efl_cpu.m4\
 m4/common/efl_doxygen.m4 \
 m4/common/efl_examples.m4 \
 m4/common/efl_path_max.m4 \
@@ -68,6 +69,20 @@ install-doc:
 
 if EFL_ENABLE_TESTS
 
+check-local:
+       @./src/tests/eina_suite
+
+else
+
+check-local:
+       @echo "reconfigure with --enable-tests"
+
+endif
+
+# Coverage report
+
+if EFL_ENABLE_COVERAGE
+
 lcov-reset:
        @rm -rf $(top_builddir)/coverage
        @find $(top_builddir) -name "*.gcda" -delete
@@ -80,21 +95,21 @@ lcov-report:
        genhtml -t "$(PACKAGE_STRING)" -o $(top_builddir)/coverage/html 
$(top_builddir)/coverage/coverage.cleaned.info
        @echo "Coverage Report at $(top_builddir)/coverage/html"
 
-check-local:
+coverage:
        @$(MAKE) lcov-reset
-       @./src/tests/eina_suite
+       @$(MAKE) check
        @$(MAKE) lcov-report
 
 else
 
 lcov-reset:
-       @echo "reconfigure with --enable-tests"
+       @echo "reconfigure with --enable-coverage"
 
 lcov-report:
-       @echo "reconfigure with --enable-tests"
+       @echo "reconfigure with --enable-coverage"
 
-check-local:
-       @echo "reconfigure with --enable-tests"
+coverage:
+       @echo "reconfigure with --enable-tests --enable-coverage"
 
 endif
 
diff --git a/configure.ac b/configure.ac
index d132d15..1775f0e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -553,6 +553,14 @@ EINA_CHECK_MODULE([one-big],        [${enable_one_big}],   
   [one big])
 
 EFL_CHECK_TESTS([eina], [enable_tests="yes"], [enable_tests="no"])
 
+EFL_CHECK_COVERAGE([${enable_tests}], [enable_coverage="yes"], 
[enable_coverage="no"])
+EINA_CFLAGS="${EINA_CFLAGS} ${EFL_COVERAGE_CFLAGS} ${EXOTIC_CFLAGS}"
+EINA_LIBS="${EINA_LIBS} ${EFL_COVERAGE_LIBS} ${EXOTIC_LIBS}"
+if test "x$enable_coverage" = "xyes" ; then
+   EINA_CFLAGS="${EINA_CFLAGS} ${EFL_DEBUG_CFLAGS}"
+fi
+
+
 EFL_CHECK_BENCHMARK([enable_benchmark="yes"], [enable_benchmark="no"])
 EINA_BENCH_MODULE([glib], [${enable_benchmark}], [glib-2.0], 
[enable_benchmark_glib="yes"], [enable_benchmark_glib="no"])
 if test -n "$CXX" && test "x$enable_benchmark" = "xyes" ; then
@@ -628,7 +636,7 @@ echo "  Documentation........: ${build_doc}"
 if test "x${build_doc}" = "xyes" ; then
 echo "    Installation.......: make install-doc"
 fi
-echo "  Tests................: ${enable_tests} (Coverage: 
${efl_enable_coverage})"
+echo "  Tests................: ${enable_tests} (Coverage: ${enable_coverage})"
 echo "  Examples.............: ${enable_build_examples}"
 echo "  Tiler Example........: ${build_tiler_example}"
 echo "  Examples installed...: ${enable_install_examples}"
diff --git a/m4/common/efl_coverage.m4 b/m4/common/efl_coverage.m4
new file mode 100644
index 0000000..85d0321
--- /dev/null
+++ b/m4/common/efl_coverage.m4
@@ -0,0 +1,62 @@
+dnl Copyright (C) 2008 Vincent Torri <vtorri at univ-evry dot fr>
+dnl That code is public domain and can be freely used or copied.
+
+dnl Macro that check if coverage support is wanted and, if yes, if
+dnl lcov is available.
+
+dnl Usage: EFL_CHECK_COVERAGE(tests [, ACTION-IF-FOUND [, 
ACTION-IF-NOT-FOUND]])
+dnl The parameter 'tests' is used if a dependency is needed. If set to "yes",
+dnl the dependency is available.
+dnl Defines EFL_COVERAGE_CFLAGS and EFL_COVERAGE_LIBS variables
+dnl Defines the automake conditionnal EFL_ENABLE_COVERAGE
+
+AC_DEFUN([EFL_CHECK_COVERAGE],
+[
+
+dnl configure option
+
+AC_ARG_ENABLE([coverage],
+   [AC_HELP_STRING([--enable-coverage], [enable coverage profiling 
instrumentation @<:@default=disabled@:>@])],
+   [
+    if test "x${enableval}" = "xyes" ; then
+       _efl_enable_coverage="yes"
+    else
+       _efl_enable_coverage="no"
+    fi
+   ],
+   [_efl_enable_coverage="no"])
+
+AC_MSG_CHECKING([whether to use profiling instrumentation])
+AC_MSG_RESULT([$_efl_enable_coverage])
+
+dnl lcov check
+
+if test "x$_efl_enable_coverage" = "xyes" && test ! "x$1" = "xyes" ; then
+   AC_MSG_WARN([Coverage report requested but tests not being built, disable 
profiling instrumentation.])
+   AC_MSG_WARN([Run configure with --enable-tests])
+   _efl_enable_coverage="no"
+fi
+
+if test "x$_efl_enable_coverage" = "xyes" ; then
+   AC_CHECK_PROG(have_lcov, [lcov], [yes], [no])
+   if test "x$have_lcov" = "xyes" ; then
+      EFL_COVERAGE_CFLAGS="-fprofile-arcs -ftest-coverage"
+      EFL_COVERAGE_LIBS="-lgcov"
+# remove any optimisation flag and force debug symbols
+      EFL_DEBUG_CFLAGS="-g -O0 -DDEBUG"
+   else
+      AC_MSG_WARN([lcov is not found, disable profiling instrumentation])
+      _efl_enable_coverage="no"
+   fi
+fi
+
+dnl Substitution
+AC_SUBST(EFL_COVERAGE_CFLAGS)
+AC_SUBST(EFL_COVERAGE_LIBS)
+
+AM_CONDITIONAL(EFL_ENABLE_COVERAGE, test "x${_efl_enable_coverage}" = "xyes")
+
+AS_IF([test "x$_efl_enable_coverage" = "xyes"], [$2], [$3])
+])
+
+dnl End of efl_coverage.m4
diff --git a/m4/common/efl_tests.m4 b/m4/common/efl_tests.m4
index d8554e1..f044323 100644
--- a/m4/common/efl_tests.m4
+++ b/m4/common/efl_tests.m4
@@ -1,16 +1,14 @@
-dnl Copyright (C) 2008-2012 Vincent Torri <vtorri at univ-evry dot fr>
+dnl Copyright (C) 2008 Vincent Torri <vtorri at univ-evry dot fr>
 dnl That code is public domain and can be freely used or copied.
 
 dnl Macro that check if tests programs are wanted and if yes, if
 dnl the Check library is available.
-dnl the lcov program is available.
 
-dnl Usage: EFL_CHECK_TESTS(EFL[, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+dnl Usage: EFL_CHECK_TESTS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
 dnl Define the automake conditionnal EFL_ENABLE_TESTS
 
 AC_DEFUN([EFL_CHECK_TESTS],
 [
-m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
 
 dnl configure option
 
@@ -36,30 +34,13 @@ if test "x${_efl_enable_tests}" = "xyes" ; then
       [dummy="yes"],
       [_efl_enable_tests="no"])
 fi
-
-efl_enable_coverage="no"
 if test "x${_efl_enable_tests}" = "xyes" ; then
-   AC_CHECK_PROG(have_lcov, [lcov], [yes], [no])
-   if test "x$have_lcov" = "xyes" ; then
-      m4_defn([UPEFL])[]_CFLAGS="${m4_defn([UPEFL])[]_CFLAGS} -fprofile-arcs 
-ftest-coverage"
-      m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} -lgcov"
-# remove any optimisation flag and force debug symbols
-      if test "x${prefer_assert}" = "xno"; then
-         m4_defn([UPEFL])[]_CFLAGS="${m4_defn([UPEFL])[]_CFLAGS} -DNDEBUG"
-      else
-         m4_defn([UPEFL])[]_CFLAGS="${m4_defn([UPEFL])[]_CFLAGS} -g -O0 
-DDEBUG"
-      fi
-      efl_enable_coverage="yes"
-   else
-      AC_MSG_WARN([lcov is not found, disable profiling instrumentation])
-   fi
+   AC_DEFINE(HAVE_TESTS, 1, [Set to 1 if we enabled unit testing.])
 fi
 
 AM_CONDITIONAL(EFL_ENABLE_TESTS, test "x${_efl_enable_tests}" = "xyes")
 
-AS_IF([test "x$_efl_enable_tests" = "xyes"], [$2], [$3])
-
-m4_popdef([UPEFL])
+AS_IF([test "x$_efl_enable_tests" = "xyes"], [$1], [$2])
 ])
 
 dnl End of efl_tests.m4
-- 
1.7.10.4


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122912
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to