summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJeremy Bettis <jbettis@google.com>2021-03-30 14:34:29 -0600
committerCommit Bot <commit-bot@chromium.org>2021-04-02 17:10:20 +0000
commitd7d83e19a725e43301606b26c08c0358fca43833 (patch)
tree2ca8f1c62c8ae92e3796357ac964da02487fa94b /docs
parent4a8979f55db559d402c5f7fe8ecf988042cf43fa (diff)
downloadchrome-ec-d7d83e19a725e43301606b26c08c0358fca43833.tar.gz
zephyr: Add zmake command coverage.
Added a new zmake sub-command `coverage`, which builds all projects with coverage, runs unit tests, and creates a html coverage report. BUG=b:183007888 TEST=sudo emerge zephyr-build-tools && \ zmake coverage build/ztest-coverage BRANCH=none Change-Id: Idb6af59c223ece00d3eb09982778cb1b500d8db4 Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2794925 Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'docs')
-rw-r--r--docs/code_coverage.md41
1 files changed, 12 insertions, 29 deletions
diff --git a/docs/code_coverage.md b/docs/code_coverage.md
index 790de68f84..ec8053ca93 100644
--- a/docs/code_coverage.md
+++ b/docs/code_coverage.md
@@ -36,32 +36,15 @@ appear to be caused in part by using relative paths instead of absolute paths.)
## Zephyr ztest code coverage
-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/*' --exclude '*/test/*' --exclude '*/testsuite/*' \
- | util/normalize_symlinks.py >${builddir}.info
-done
-
-# 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
-```
+To build the Zephyr unit tests for code coverage run:
+
+`zmake coverage build/ztest-coverage`
+
+This target will compile, without linking, all zephyr projects with
+`CONFIG_COVERAGE` Kconfig option enabled, run the tests, and then process the
+profiling data into a code coverage report using the `lcov` and `genhtml`
+tools. This requires the `HAS_COVERAGE_SUPPORT` option, which can only be
+selected in `Kconfig.board`.
+
+The coverage report top-level page is
+`build/ztest-coverage/coverage_rpt/index.html`.