feat(tests): Add support for coverage report
This patch enables support for coverage report on the
unit tests by using the gcovr tool.
The coverage report is stored in ${RMM_BUILD_DIR}/$<CONFIG>/coverage
Signed-off-by: Javier Almansa Sobrino <javier.almansasobrino@arm.com>
Change-Id: I5b6a2f3ebf13cbc036c0d64f422ea18f337dd8f5
diff --git a/docs/getting_started/build-options.rst b/docs/getting_started/build-options.rst
index d41a145..0db4cdc 100644
--- a/docs/getting_started/build-options.rst
+++ b/docs/getting_started/build-options.rst
@@ -162,7 +162,7 @@
cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
cmake --build ${RMM_BUILD_DIR} -- checkincludes-codebase
-14. Perform unit tests on development host:
+14. Perform unit tests on development host:
Build and run unit tests on host platform. It is recommended to do the Debug
build of RMM.
@@ -172,6 +172,17 @@
cmake -DRMM_CONFIG=host_defcfg -DHOST_VARIANT=host_test -DCMAKE_BUILD_TYPE=Debug -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
cmake --build ${RMM_BUILD_DIR} -- run-unittests
+Run coverage analysis on unit tests.
+
+.. code-block:: bash
+
+ cmake -DRMM_CONFIG=host_defcfg -DHOST_VARIANT=host_test -DRMM_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
+ cmake --build ${RMM_BUILD_DIR} -- run-coverage
+
+The above commands will automatically generate the HTML coverage report in folder
+`build/Debug/coverage` within build directory. The HTML generation can be
+disabled by setting `RMM_HTML_COV_REPORT=OFF`.
+
.. _build_options_table:
###################
@@ -208,9 +219,9 @@
MBEDTLS_ECP_MAX_OPS ,248 - ,1000 ,"Number of max operations per ECC signing iteration"
RMM_FPU_USE_AT_REL2 ,ON | OFF ,OFF(fake_host) ON(aarch64),"Enable FPU/SIMD usage in RMM."
RMM_MAX_GRANULES , ,0 ,"Maximum number of memory granules available to the system"
- HOST_VARIANT ,host_build | host_test ,host_build , "Variant to build for the host platform. Only available when RMM_PLATFORM=host"
-
-
+ HOST_VARIANT ,host_build | host_test ,host_build ,"Variant to build for the host platform. Only available when RMM_PLATFORM=host"
+ RMM_COVERAGE ,ON | OFF ,OFF ,"Enable coverage analysis"
+ RMM_HTML_COV_REPORT ,ON | OFF ,ON ,"Enable HTML output report for coverage analysis"
.. _llvm_build:
diff --git a/docs/getting_started/getting-started.rst b/docs/getting_started/getting-started.rst
index 4e8e07b..88747c9 100644
--- a/docs/getting_started/getting-started.rst
+++ b/docs/getting_started/getting-started.rst
@@ -49,6 +49,7 @@
"Git",, "Firmware, Documentation"
"Graphviz dot",">v2.38.0","Documentation"
"docutils",">v2.38.0","Documentation"
+ "gcovr",">=v4.2","Tools(Coverage analysis)"
.. _getting_started_toolchain:
@@ -143,6 +144,30 @@
cd <rmm source folder>
pip3 install -r docs/requirements.txt
+############################################
+Install coverage tools analysis dependencies
+############################################
+
+.. note::
+
+ This is an optional step only needed if you intend to run coverage
+ analysis on the source code.
+
+On Ubuntu, ``gcovr`` tool can be installed in two different ways:
+
+Using the pagckage manager:
+
+.. code-block:: bash
+
+ sudo apt-get install gcovr
+
+The second (and recommended) way is install it with ``pip3``:
+
+.. code-block:: bash
+
+ pip3 install --upgrade pip
+ pip3 install gcovr
+
.. _getting_started_get_source:
#########################