I'm using a test-generating tool called KLEE, that creates lots of tests for my C99-Code. Afterwards I run the tests and check line coverage with gcov. Gcov seems to update coverage data at the end of the run upon successful completion.
However, some tests fail (assert statements that are not true), which leads to aborting the program and gcov not counting the lines covered in this run.
Is there any way that gcov flushes information on any exit (not only on successful)?
Call
void __gcov_flush(void)
(from libgcov.a which is linked in by-fprofile-arcs
option of compiler) in your assert code, just before killing and application (e.g. changeabort();
into__gcov_flush();abort();
). This one will call an gcov_exit function (it is statically defined in libgcov). gcov_exit is the main functions to save collected coverage into file. It is registered by __gcov_init withatfork()
; and your assert ignores atfork when kills an application.Another way of solving this is to find why your assert ignores
atfork()
-registered functions.