summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJeremy Bettis <jbettis@google.com>2021-03-24 15:54:49 -0600
committerCommit Bot <commit-bot@chromium.org>2021-03-30 18:46:38 +0000
commitb0a76d6b8720fbc2eaa2dee8d45a01adfd8805a4 (patch)
treed366c51031f231e5103296659cef4f1a3734a99c /docs
parentf7fbc629f0655229cc7ffdadfb18c9e13118e3d2 (diff)
downloadchrome-ec-b0a76d6b8720fbc2eaa2dee8d45a01adfd8805a4.tar.gz
zephyr: Generate initial coverage for every board
Create a new ninja target 'all.libraries' which is everything that zephyr.elf depends on, but doesn't actually link the zephyr.elf binary. This allows creating coverage info for boards that run on SOCs that are too small for real coverage runs. Enabled the HAS_COVERAGE_SUPPORT for all boards, so that the all.libraries target will build with coverage enabled. HAS_COVERAGE_SUPPORT can't be set in prj files, as it is not directly user assignable. This is probably somewhat of a misuse of this flag, but nothing depends on it except for CONFIG_COVERAGE. Tweaked the instructions to exclude some more directories that are not useful code, like tests and generate headers. BUG=b:183007888 TEST=Ran commands in code_coverage.md BRANCH=none Change-Id: I6cf1b889b6b3883f7a76d1ae4957805bfa6d7b96 Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2786067 Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'docs')
-rw-r--r--docs/code_coverage.md23
1 files changed, 21 insertions, 2 deletions
diff --git a/docs/code_coverage.md b/docs/code_coverage.md
index 3f87bf7848..790de68f84 100644
--- a/docs/code_coverage.md
+++ b/docs/code_coverage.md
@@ -39,10 +39,29 @@ appear to be caused in part by using relative paths instead of absolute paths.)
This needs some work, but you can generate coverage reports with these commands:
```
+# Get initial (0 lines executed) coverage for as many boards as possible
+for project in $(cd zephyr/projects; find -name zmake.yaml -print)
+do
+ project="$(dirname ${project#./})"
+ echo "Building initial coverage for ${project}"
+ builddir="build/ztest-coverage/projects/$project"
+ infopath="build/ztest-coverage/projects/${project/\//_}.info"
+ zmake configure --coverage -B ${builddir} zephyr/projects/$project
+ for buildsubdir in ${builddir}/build-* ; do ninja -C ${buildsubdir} all.libraries ; done
+ lcov --gcov-tool $HOME/trunk/src/platform/ec/util/llvm-gcov.sh -q -o - -c -d ${builddir} -t "${project/\//_}" \
+ --exclude "*/build-*/zephyr/*/generated/*" --exclude '*/test/*' --exclude '*/testsuite/*' \
+ -i | util/normalize_symlinks.py >${infopath}
+done
+
+# Get unit test coverage
for i in zephyr/test/* ; do
builddir="build/ztest-coverage/$(basename $i)"
zmake configure --coverage --test -B ${builddir} $i
- lcov --gcov-tool $HOME/trunk/src/platform/ec/util/llvm-gcov.sh -q -o - -c -d ${builddir} -t "$(basename $i)" --exclude '*/build-singleimage/zephyr/*/generated/*' | util/normalize_symlinks.py >${builddir}.info
+ lcov --gcov-tool $HOME/trunk/src/platform/ec/util/llvm-gcov.sh -q -o - -c -d ${builddir} -t "$(basename $i)" \
+ --exclude '*/build-singleimage/zephyr/*/generated/*' --exclude '*/test/*' --exclude '*/testsuite/*' \
+ | util/normalize_symlinks.py >${builddir}.info
done
-genhtml -q -o build/ztest-coverage/coverage_rpt -t "Zephyr EC Unittest" -p /mnt/host/source/src -s build/ztest-coverage/*.info
+
+# Merge into a nice html report
+genhtml -q -o build/ztest-coverage/coverage_rpt -t "Zephyr EC Unittest" -p /mnt/host/source/src -s build/ztest-coverage/*.info build/ztest-coverage/projects/*.info
```