Enabling coverage reports for device testing with nRF Connect SDK

This may just be more of a Zephyr question but wondering if anyone in the Nordic community has experience with this.

I'd like to generate code coverage reports when running tests using the Zephyr Test Framework (Ztest). This works well when testing on the native_posix platform, but when running on actual hardware e.g.:

twister -T . -j1 --device-testing --device-serial /dev/ttyACM2 --device-serial-baud 115200 -p nrf5340dk_nrf5340_cpuapp --coverage

Coverage is disabled due to unsatisfied dependency HAS_COVERAGE_SUPPORT:

warning: COVERAGE (defined at subsys/testsuite/Kconfig:33) was assigned the value 'y' but got the
value 'n'. Check these unsatisfied dependencies: HAS_COVERAGE_SUPPORT (=n). See
docs.zephyrproject.org/.../kconfig.html and/or look up COVERAGE in the
menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
and Kconfig - Tips and Best Practices sections of the manual might be helpful too.
The description of HAS_COVERAGE_SUPPORT says:
The code coverage report generation is only available on boards
with enough spare RAM to buffer the coverage data, or on boards
based on the POSIX ARCH.
I tested changing HAS_COVERAGE_SUPPORT in Kconfig.board, but this caused the test to timeout. Is it possible to get this working?
Parents Reply
  • Yes, that's right - nothing changed in configuration except enabling coverage. Here are the exact steps using the Zephyr hello_world example:

    (1) Running the Zephyr hello_world example unmodified:

    *** Booting Zephyr OS build v3.0.99-ncs1  ***
    Hello World! nrf5340dk_nrf5340_cpuapp

    (2) Running with coverage support enabled

    - add "select HAS_COVERAGE_SUPPORT" to ncs/zephyr/boards/arm/nrf5340dk_nrf5340/Kconfig.board line 10
    - add CONFIG_COVERAGE=y to prj.conf

    no terminal output

    (3) Based on advice from someone on Zephyr discord, I also tried running with C++ support (related to this issue: https://github.com/zephyrproject-rtos/zephyr/issues/40668)

    - add CONFIG_CPLUSPLUS=y to prj.conf

    *** Booting Zephyr OS build prints repeatedly, looks like CPU is resetting due to a hardfault, but at least get terminal output

Children
Related