Leight weight variant of the gcc's gcov-library suitable for stm32.
Normally gcov does use a filesystem do dump out the coverage data. If used on a (embedded) platform without a file system the coverage data can be dumped via a serial interface. This code snippets show how to do so:
- Compile those sourcefiles which shall produce a coverage report with
-fprofile-arcs -ftest-coverage
. This will tell the compiler to blow up your source code with additional code which is needed to gain a coverage report. - Take sure that the coverage initializers (
static_init()
) are called if not done by startup code. - Run your software
- Call
coverage_dump()
which will dump the coverage data as an human readable format to serial console and capture the data on that serial interface. You may usecat /dev/ttyUSB0 > inputFile.txt
for this. - Then call
lwfs.sh inputFile.txt
(see example in lwfs.sh) which creates all *.gcov files on your hard disk. - Much fun.
This method works pretty good for me. I addded some shell scripts to my makefile to do all these steps automatically. It works pretty fine. Much fun with it!
NOTE: Works for me with arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 5.4.1
TIP: Use Gcovr which is parsing and reporting tool for gcov to produce html reports: https://gcovr.com/