tests: Add code coverage
We want to be able to measure code coverage for our test cases. This
patch adds initial support for measuring the coverage of all of the
files in the repo when running the test cases.
Simply run:
`make check-code-coverage`
and an lcov report will be generated
NOTE: This doesn't yet add any filtering to throw out the results for
system headers and tests cases, but the list of results isn't long so it
is easy to see the relevant coverage results and we don't want to add
any false negatives.
Tested:
Sdbuplus plus still builds fine without the code coverage utilities
by default. sdbusplus now builds with `./configure
--enable-code-coverage` and corrects the libs and cflags accordingly
to enable coverage. Make then succeeds to generate a report when run
with `make check-code-coverage`
Change-Id: I7f640b82e771bc9043abf381d14393be54c3e672
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/Makefile.am b/Makefile.am
index 533f423..32fe3ec 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -46,9 +46,10 @@
libsdbusplus_la_SOURCES = \
$(LIBSDBUSPLUS_FILES) \
$(LIBSDBUPLUS_FILES_TRANSACTION)
-libsdbusplus_la_LIBADD = $(SYSTEMD_LIBS)
+libsdbusplus_la_LIBADD = $(SYSTEMD_LIBS) $(CODE_COVERAGE_LIBS)
libsdbusplus_la_LDFLAGS = -version-info 1:0:0 -shared
-libsdbusplus_la_CXXFLAGS = $(SYSTEMD_CFLAGS)
+libsdbusplus_la_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS)
+libsdbusplus_la_CXXFLAGS = $(CODE_COVERAGE_CXXFLAGS) $(SYSTEMD_CFLAGS)
pkgconfiglibdir = ${libdir}/pkgconfig
pkgconfiglib_DATA = sdbusplus.pc