diff options
author | Arthur Jones <arthur.jones@riverbed.com> | 2018-06-14 15:44:38 +0200 |
---|---|---|
committer | Arthur Jones <arthur.jones@riverbed.com> | 2018-07-04 20:06:11 +0200 |
commit | 83284209097c4f0ab0aba415e986df0dee6f9cc4 (patch) | |
tree | 8d4f01f4e7db165f099c9678132fee32e6442534 /configure.ac | |
parent | Merge pull request #2614 from rtrlib/2018-07-02-master-bugfix (diff) | |
download | frr-83284209097c4f0ab0aba415e986df0dee6f9cc4.tar.xz frr-83284209097c4f0ab0aba415e986df0dee6f9cc4.zip |
unit tests: support code coverage instrumentation and reports
Currently, make check runs the unit tests and reports pass/fail,
but we have no way to guage how much of the code is covered by
these tests. gcov provides those statistics on a per source
file basis, but requires special CFLAGS and LDFLAGS. Here, we
add the --enable-gcov configure option to setup those options
correctly. We also add a make target called check-coverage,
which runs the unit tests, runs gcov and uploads the data to
the codecov.io cloud service for display.
Finally, we include a Dockerfile-coverage which creates a
container image in alpine linux to run the tests. To create
the image:
$ docker build \
--build-arg commit=`git rev-parse HEAD` \
--build-arg token=<upload token from codecov.io> \
-t frr-gcov:latest \
-f docker/alpine/Dockerfile-coverage .
and to create and upload the report:
$ docker run -it --rm frr-gcov:latest
Testing done:
Created and uploaded a report from my fork using alpine linux 3.7.
Non-coverage alpine 3.7 build still works.
Issue: https://github.com/FRRouting/frr/issues/2442
Signed-off-by: Arthur Jones <arthur.jones@riverbed.com>
Diffstat (limited to 'configure.ac')
-rwxr-xr-x | configure.ac | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 3ec29cc38..8846fcdf7 100755 --- a/configure.ac +++ b/configure.ac @@ -226,7 +226,14 @@ AC_ARG_ENABLE([memory-sanitizer], AS_HELP_STRING([--enable-memory-sanitizer], \ ]) dnl if the user has specified any CFLAGS, override our settings -if test "x${enable_dev_build}" = "xyes"; then +if test "x${enable_gcov}" = "xyes"; then + if test "z$orig_cflags" = "z"; then + AC_C_FLAG([-coverage]) + AC_C_FLAG([-O0]) + fi + + LDFLAGS="${LDFLAGS} -lgcov" +elif test "x${enable_dev_build}" = "xyes"; then AC_DEFINE(DEV_BUILD,,Build for development) if test "z$orig_cflags" = "z"; then AC_C_FLAG([-g3]) @@ -441,6 +448,8 @@ AC_ARG_ENABLE([clippy-only], AS_HELP_STRING([--enable-clippy-only], [Only build clippy])) AC_ARG_ENABLE([numeric_version], AS_HELP_STRING([--enable-numeric-version], [Only numeric digits allowed in version (for Alpine)])) +AC_ARG_ENABLE([gcov], + AS_HELP_STRING([--enable-gcov], [Add code coverage information])) AS_IF([test "${enable_clippy_only}" != "yes"], [ AC_CHECK_HEADERS(json-c/json.h) @@ -692,6 +701,11 @@ AC_DEFINE_UNQUOTED(MULTIPATH_NUM, $MPATH_NUM, Maximum number of paths for a rout AC_DEFINE_UNQUOTED(VTYSH_PAGER, "$VTYSH_PAGER", [What pager to use]) +dnl -------------------- +dnl Enable code coverage +dnl -------------------- +AM_CONDITIONAL([HAVE_GCOV],[test '!' "$enable_gcov" = no]) + dnl ------------------------------------ dnl Alpine only accepts numeric versions dnl ------------------------------------ |