diff options
-rw-r--r-- | docs/code_coverage.md | 23 | ||||
-rw-r--r-- | zephyr/CMakeLists.txt | 10 | ||||
-rw-r--r-- | zephyr/projects/kohaku/boards/arm/kohaku/Kconfig.board | 3 | ||||
-rw-r--r-- | zephyr/projects/trogdor/boards/arm/trogdor/Kconfig.board | 3 | ||||
-rw-r--r-- | zephyr/projects/volteer/boards/arm/volteer/Kconfig.board | 3 |
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 |