summaryrefslogtreecommitdiff
path: root/Makefile.am
diff options
context:
space:
mode:
authorArthur Jones <arthur.jones@riverbed.com>2018-06-14 06:44:38 -0700
committerArthur Jones <arthur.jones@riverbed.com>2018-07-04 11:06:11 -0700
commit83284209097c4f0ab0aba415e986df0dee6f9cc4 (patch)
tree8d4f01f4e7db165f099c9678132fee32e6442534 /Makefile.am
parent732c8da3483d4e09fcfe260454092acef3280086 (diff)
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 'Makefile.am')
-rw-r--r--Makefile.am20
1 files changed, 20 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 5dc80b4983..ed22c60e7c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -115,3 +115,23 @@ noinst_HEADERS += defaults.h
indent:
tools/indent.py `find sharpd bgpd eigrpd include isisd lib nhrpd ospf6d ospfd pimd qpb ripd vtysh zebra -name '*.[ch]' | grep -v include/linux`
+
+if HAVE_GCOV
+
+coverage: check
+ @ find . -name '*.o' -exec gcov {} \;
+
+yorn:
+ @ echo "OK to upload coverage to https://coverage.io [y/N]:"
+ @ read yn; test "$$yn" = "y"
+
+upload-check-coverage:
+ @ if [ "x${COMMIT}" = "x" ]; then echo "COMMIT required"; exit 1; fi
+ @ if [ "x${TOKEN}" = "x" ]; then echo "TOKEN required"; exit 1; fi
+ curl -s https://codecov.io/bash | bash -s - -C ${COMMIT} -t ${TOKEN}
+
+force-check-coverage: coverage upload-check-coverage
+
+check-coverage: coverage yorn upload-check-coverage
+
+endif