coverage: Enable compilation with --coverage

Setting the environment variable `COVERAGE=1` allows us to turn
coverage measurements on. This produces a number of auxiliary gcno and
gcda files which can then be converted into coverage reports.

I know line coverage and branch coverage is not a perfect metric, but
it might get us some more visibility into where more tests might be
needed.
This commit is contained in:
Christian Decker
2017-01-06 18:53:11 +01:00
committed by Rusty Russell
parent af43cc5e2c
commit bd6b9c377e

View File

@@ -19,6 +19,10 @@ VALGRIND=valgrind -q --error-exitcode=7
VALGRIND_TEST_ARGS = --track-origins=yes --leak-check=full --show-reachable=yes
endif
ifeq ($(COVERAGE),1)
COVFLAGS = --coverage
endif
# This is where we add new features as bitcoin adds them.
FEATURES :=
@@ -194,9 +198,9 @@ PROGRAMS := $(TEST_PROGRAMS)
CWARNFLAGS := -Werror -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition
CDEBUGFLAGS := -g -fstack-protector
CFLAGS := $(CWARNFLAGS) $(CDEBUGFLAGS) -I $(CCANDIR) -I secp256k1/include/ -I . $(FEATURES)
CFLAGS := $(CWARNFLAGS) $(CDEBUGFLAGS) -I $(CCANDIR) -I secp256k1/include/ -I . $(FEATURES) $(COVFLAGS)
LDLIBS := -lprotobuf-c -lgmp -lsodium -lsqlite3
LDLIBS := -lprotobuf-c -lgmp -lsodium -lsqlite3 $(COVFLAGS)
$(PROGRAMS): CFLAGS+=-I.
default: $(PROGRAMS) $(MANPAGES) daemon-all