BullseyeCoverage Up Contents Search

cov_write - Save New Measurements

int cov_write(void);

Description

Function cov_write writes measurements collected in memory for the current process to file, merging with the information already in the file. cov_write only writes measurements which have changed since the previous call to cov_write. (No file i/o occurs if there is no new coverage.) cov_write is automatically called when the instrumented executable terminates. Call cov_write directly when you want to obtain the BullseyeCoverage error status or to manually save coverage data.

Function cov_write looks for coverage files using the following rules.

  1. If environment variable COVFILELIST is set, it specifies a comma-separated list of coverage file paths. For each file in the list, cov_write writes any remaining unwritten coverage data which corresponds to that file. This allows collecting coverage for different sub-projects at the same time without merging the coverage files into a single coverage file.
  2. Otherwise, if environment variable COVFILE is set, it specifies a single coverage file.
  3. Otherwise, cov_write looks for a file named test.cov in the current directory.

If an error occurs, cov_write displays an error message to the screen, or if the COVERR environment variable is set, appends a message to the file named.

If a BullseyeCoverage run-time error occurred prior to calling this function, no action is performed.

This function is automatically declared in source files compiled by covc. In other source files, declare it by including <BullseyeCoverage.h>.

This function is not available with the embedded system small footprint run-time configuration.

Return Value

If successful, cov_write returns 0, otherwise it returns one of the error codes listed in Run-Time Errors.

Examples

#if _BullseyeCoverage
    cov_write();
#endif
#if _BullseyeCoverage
    printf("cov_write %d\n", cov_write());
#endif

Notes

Each dynamic link library (DLL) is considered a separate process. Calling this function from inside a DLL only affects the coverage data in that DLL and does not affect coverage data in programs which call the DLL or other DLLs.

The coverage file does not grow in size when it is updated. To determine whether the coverage file has been updated, view a coverage report.

Updated: 26 Aug 2020