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
  • Thank you - This is not really a Twister issue, and I was able to build with coverage support by selecting HAS_COVERAGE_SUPPORT in Kconfig.board. However, tests do not seem to run properly when COVERAGE is enabled. There is no output on the serial port. Other boards like mps2_an385 support this so it should be possible, if the nRF5340 has enough RAM, but how much RAM is sufficient?
    Having coverage reports is important for my application.

Children
Related