summaryrefslogtreecommitdiff
path: root/docs/code_coverage.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/code_coverage.md')
-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`.