Saving of Counters: Where

By default, for host programs the coverage data is saved as a binary data file at the folder containing the symbol file. This can be changed by several configuration parameters.

Default behavior

Three options determine the location and the name of the data file. Their default setting is:

  • Configuration parameter DATAFILE = %DEFAULT%,
  • Environment variable CTC_DATA_PATH is not set,
  • Environment variable CTC_DATA_NAME is not set.

With that setting, the data files (MON.dat) are written to the directory of the corresponding smybolfile(s) (MON.sym), and they are inheriting their file name (MyMON42.sym leads to MyMON42.dat).

Choosing a different location

At test time there may not be the same directory structure available as it was at instrumentation time. For example, the tests are run in a different machine. There are two options how to determine the location of the data file:

At instrumentation time: With the configuration parameter DATAFILE, a file name and a directory (absolute or relative path) can be set. The file extension .dat is added if not given explicitly. The directory has to exist at testing time on the testing machine. For example, with the instrumentation command

ctc –i m –C DATAFILE=MON5.dat cl –c file.c

the data file will be MON5.dat in the current directory during test execution.

At test time: With the environment variable CTC_DATA_PATH, an existing directory on the test machine can be defined. That directory will contain the data file(s) produced, with the file name determined during instrumentation.

Differentiate data file names

After instrumentation, the executable contains the name of the data file that will be written during test execution. This can be overruled with the environment variable CTC_DATA_NAME.

Example (Windows-oriented):

set CTC_DATA_NAME=UnitTests.dat
… execute unit tests …
set CTC_DATA_NAME=IntegrationTests.dat
… execute integration tests

File extension .dat is added if not given explicitly. No path must be specified with that variable. If the test case concept is used additionally to separate data files, a combination of these two settings is applied.

With HOTA or BITCOV

When you use HOTA, the way the counter data is written is defined in the runtime. See HOTA: Adapting the runtime for details. With BITCOV, the counter data are not written out at all, but have to be dumped from memory.