make
@endcode
+- Code coverage analysis
+
+ By inspecting the code coverage, you can identify potential gaps in your testing
+ and use that information to improve your test scenarios.
+
+ Example usage:
+ @code
+ mkdir build-gcov; cd build-gcov
+ ../configure --enable-gcov [...]
+ make
+ # ... Now execute your test scenarios to collect OpenOCD code coverage ...
+ lcov --capture --directory ./src --output-file openocd-coverage.info
+ genhtml openocd-coverage.info --output-directory coverage_report
+ # ... Open coverage_report/index.html in a web browser ...
+ @endcode
+
Please consider performing these additional checks where appropriate
(especially Clang Static Analyzer for big portions of new code) and
mention the results (e.g. "Valgrind-clean, no new Clang analyzer
m4_define([OPTIONAL_LIBRARIES],
[[[capstone], [Use Capstone disassembly framework], []]])
+m4_define([COVERAGE],
+ [[[gcov], [Collect coverage using gcov], []]])
+
AC_ARG_ENABLE([doxygen-html],
AS_HELP_STRING([--disable-doxygen-html],
[Disable building Doxygen manual as HTML.]),
AS_HELP_STRING([--disable-werror], [Do not treat warnings as errors]),
[gcc_werror=$enableval], [gcc_werror=$gcc_warnings])
+AC_ARG_ENABLE([gcov],
+ AS_HELP_STRING([--enable-gcov], [Enable runtime coverage collection via gcov]),
+ [enable_gcov=$enableval], [enable_gcov=no])
+
+AS_IF([test "x$enable_gcov" = "xyes"], [
+ AC_DEFINE([USE_GCOV], [1], [1 to enable coverage collection using gcov.])
+ dnl When collecting coverage, disable optimizations.
+ dnl This overrides the "-O2" that autoconf uses by default:
+ CFLAGS+=" -O0"
+], [
+ AC_DEFINE([USE_GCOV], [0], [0 to leave coverage collection disabled.])
+])
+
# set default verbose options, overridden by following options
debug_usb_io=no
debug_usb_comms=no
AM_CONDITIONAL([HAVE_JIMTCL_PKG_CONFIG], [test "x$have_jimtcl_pkg_config" = "xyes"])
AM_CONDITIONAL([INTERNAL_LIBJAYLINK], [test "x$use_internal_libjaylink" = "xyes"])
+AM_CONDITIONAL([USE_GCOV], [test "x$enable_gcov" = "xyes"])
+
# Look for environ alternatives. Possibility #1: is environ in unistd.h or stdlib.h?
AC_MSG_CHECKING([for environ in unistd.h and stdlib.h])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
LIBGPIOD_ADAPTERS,
LIBJAYLINK_ADAPTERS, PCIE_ADAPTERS, SERIAL_PORT_ADAPTERS,
DUMMY_ADAPTER,
- OPTIONAL_LIBRARIES],
+ OPTIONAL_LIBRARIES,
+ COVERAGE],
[s=m4_format(["%-40s"], ADAPTER_DESC([adapter]))
AS_CASE([$ADAPTER_VAR([adapter])],
[auto], [