summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Bettis <jbettis@google.com>2021-04-07 16:26:33 -0600
committerCommit Bot <commit-bot@chromium.org>2021-04-08 22:24:03 +0000
commitd72a916c069d72e4804e7cc04f462727f6497ed5 (patch)
tree3ea99041106d70e4d718ae64a2a4135ffe7bace5
parentce5a951499fe9591054c8fa07df5f5fcf61dec59 (diff)
downloadchrome-ec-d72a916c069d72e4804e7cc04f462727f6497ed5.tar.gz
ec: Improve coverage report.
Exclude the test directories from ec coverage report. Include the test name into the coverage data. Show the test name details in the coverage report. Build several boards with coverage enabled, and use that to make sure all used files are in the coverage report. This lowers the coverage to 38.4% which seems much more realistic than the old value. BRANCH=none BUG=b:156895937 TEST=make -j coverage Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I91fc5bc7ce676943d34e91e16662e680628d1b7e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2811939 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
-rw-r--r--Makefile3
-rw-r--r--Makefile.rules15
2 files changed, 16 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index aa2037e347..fbc59c42df 100644
--- a/Makefile
+++ b/Makefile
@@ -50,6 +50,8 @@ EMPTY=
ifdef CTS_MODULE
# CTS builds need different directories per board per suite.
out?=build/$(BOARD)/cts_$(CTS_MODULE)
+else ifdef TEST_COVERAGE
+out?=build/coverage/initial-$(BOARD)
else
out?=build/$(BOARD)
endif
@@ -377,6 +379,7 @@ def_all_deps+=ro
endif
all_deps?=$(def_all_deps)
all: $(all_deps)
+compile-only: $(ro-objs) $(rw-objs)
ro: override BLD:=RO
ro: $(libsharedobjs_elf-y) $(out)/RO/$(PROJECT).RO.flat
diff --git a/Makefile.rules b/Makefile.rules
index 9916fba5ba..bcddfbbd66 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -389,15 +389,22 @@ $(foreach b, $(cts_boards), \
) \
)
+cov-boards=lazor volteer
cov-test-targets=$(foreach t,$(cov-test-list-host),build/coverage/$(t).info)
+cov-test-targets+=$(foreach t,$(cov-boards),build/coverage/initial-$(t).info)
bldversion=$(shell (./util/getversion.sh ; echo VERSION) | $(CPP) -P -)
# lcov fails when multiple instances run at the same time.
# We need to run them sequentially by using flock
-cmd_lcov=flock /tmp/ec-lcov-lock -c "lcov -q -o $@ -c -d build/coverage/$*"
+cmd_lcov=flock /tmp/ec-lcov-lock -c "lcov --gcov-tool \
+ $(CURDIR)/util/llvm-gcov.sh -q -o $@ -c -d build/coverage/$* -t $* \
+ --exclude '*/ec/test/*' --exclude '*/ec/include/tests/*'"
+cmd_lcov-initial=flock /tmp/ec-lcov-lock -c "lcov --gcov-tool \
+ $(CURDIR)/util/llvm-gcov.sh -q -o $@ -c -d build/coverage/initial-$* \
+ -i -t $* --exclude '*/ec/test/*' --exclude '*/ec/include/tests/*'"
cmd_merge_cov=lcov -o build/coverage/lcov.info $(foreach info,$^,-a ${info})
cmd_report_cov=genhtml -q -o build/coverage/coverage_rpt -t \
- "EC Unittest "$(bldversion) $^
+ "EC Unittest "$(bldversion) -s $^
# Unless V is set to 0 we always want the 'size:' target to report its output,
# there is no point in generating a short form command trace when calculating
@@ -433,6 +440,10 @@ cmd_stats= \
printf "%-10s: %6d\n" $$board $$size; \
done
+.DELETE_ON_ERROR: build/coverage/initial-%.info build/coverage/%.info
+build/coverage/initial-%.info:
+ $(MAKE) TEST_COVERAGE=y BOARD=$* compile-only
+ $(call quiet,lcov-initial,COV )
build/coverage/%.info: run-coverage-%
$(call quiet,lcov,COV )