summaryrefslogtreecommitdiff
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
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>
-rw-r--r--docs/code_coverage.md23
-rw-r--r--zephyr/CMakeLists.txt10
-rw-r--r--zephyr/projects/kohaku/boards/arm/kohaku/Kconfig.board3
-rw-r--r--zephyr/projects/trogdor/boards/arm/trogdor/Kconfig.board3
-rw-r--r--zephyr/projects/volteer/boards/arm/volteer/Kconfig.board3
5 files changed, 40 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
```
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt
index 01c86e7f10..005c9b8416 100644
--- a/zephyr/CMakeLists.txt
+++ b/zephyr/CMakeLists.txt
@@ -163,6 +163,16 @@ add_subdirectory("app")
add_subdirectory("drivers")
add_subdirectory_ifdef(CONFIG_PLATFORM_EC "shim")
+# Creates a phony target all.libraries in case you only want to build the
+# libraries and not the binaries. For example for creating the initial zero
+# coverage files.
+get_property(ZEPHYR_LIBS_PROPERTY GLOBAL PROPERTY ZEPHYR_LIBS)
+add_custom_target(
+ all.libraries
+ DEPENDS
+ ${ZEPHYR_LIBS_PROPERTY}
+ kernel
+ )
# CONFIG_PLATFORM_EC files that don't relate to something below should be
# included here, sorted by filename. This is common functionality which is
diff --git a/zephyr/projects/kohaku/boards/arm/kohaku/Kconfig.board b/zephyr/projects/kohaku/boards/arm/kohaku/Kconfig.board
index 512e905b13..43cffd68e4 100644
--- a/zephyr/projects/kohaku/boards/arm/kohaku/Kconfig.board
+++ b/zephyr/projects/kohaku/boards/arm/kohaku/Kconfig.board
@@ -5,3 +5,6 @@
config BOARD_KOHAKU
bool "Google Kohaku EC"
depends on SOC_NPCX7M6FB # Actually NPCX7M6FC; C has 512K Flash
+ # NPCX doesn't actually have enough ram for coverage, but this will
+ # allow generating initial 0 line coverage.
+ select HAS_COVERAGE_SUPPORT
diff --git a/zephyr/projects/trogdor/boards/arm/trogdor/Kconfig.board b/zephyr/projects/trogdor/boards/arm/trogdor/Kconfig.board
index 13f6616d08..cb4d368e8d 100644
--- a/zephyr/projects/trogdor/boards/arm/trogdor/Kconfig.board
+++ b/zephyr/projects/trogdor/boards/arm/trogdor/Kconfig.board
@@ -10,3 +10,6 @@
config BOARD_TROGDOR
bool "Google Trogdor Baseboard"
depends on SOC_NPCX7M6FC
+ # NPCX doesn't actually have enough ram for coverage, but this will
+ # allow generating initial 0 line coverage.
+ select HAS_COVERAGE_SUPPORT
diff --git a/zephyr/projects/volteer/boards/arm/volteer/Kconfig.board b/zephyr/projects/volteer/boards/arm/volteer/Kconfig.board
index b38f6e4546..d0d540ddb9 100644
--- a/zephyr/projects/volteer/boards/arm/volteer/Kconfig.board
+++ b/zephyr/projects/volteer/boards/arm/volteer/Kconfig.board
@@ -8,3 +8,6 @@
config BOARD_VOLTEER
bool "Google Volteer Baseboard"
depends on SOC_NPCX7M6FC
+ # NPCX doesn't actually have enough ram for coverage, but this will
+ # allow generating initial 0 line coverage.
+ select HAS_COVERAGE_SUPPORT