HOTA: Adapting the runtime

For the HOTA approach, Testwell CTC++ provides a runtime as C Code. This code can be adapted to the target's capabilities. It has to be compiled with the cross compiler used in the project.

HOTA Files

The HOTA folder of the Testwell CTC++ directory contains the following source code files:

  • targsend.c: Encapsulates the coverage data write-out function. It contains a default implementation using stdio.h to write the coverage data to a local text file at the target. Typically, this source file has to be modified following the possibilities and restrictions of your target.
  • targcust.c: It may be customized if the standard C system library (e.g. malloc()) is not available at the target.
  • targdata.c: It contains the runtime logic of Testwell CTC++ at the target and does not need to be changed.

and the header files targdata.h, ctctypes.h and transfer.h which does not have to be customized.

When the targcust.c and targsend.c files have been checked and adapted as needed, compile them to with your cross-compiler, for example to object files. Those objects make up the Testwell CTC++ runtime library for the target.

It is also possible to build a static or dynamic library from these files.

Designing the Coverage Data Write-out

The file targsend.c contains the function ctc_send_data(). This is the only spot in HOTA to write-out coverage data. If its default implementation (writing to a file) cannot be used directly, you are able to modify this function.

The basic structure of ctc_send_data() is:

/* Structure of ctc_send_data() in targsend.c */
#include "targdata.h"
 void ctc_send_data(void) {
   int ch;
   while ((ch = ctc_get_character()) > 0) {
       ... /* write ch to "somewhere" */

The Testwell CTC++ runtime for targets (implemented in targdata.c) encodes the coverage data to a stream of printable ASCII characters. The function ctc_send_data() pulls out the chars one by one and writes them to "somewhere" - to the file system of the target, or directly to the host using any communication method available.

The following overview shows the basic possibilities to transfer coverage data from the target to the host:

A (Default Implementation): ctc_send_data() creates the file MON.txt at the local file system of the target and writes the characters there. In one ctc_send_data() call all collected coverage data since program start or a previous call are written out. The file has to be written in append mode. After testing, the file has to be copied to the host machine.

B: If the target can write directly to host disk, this is an even simpler arrangement: The MON.txt file can be written there.

C: In some host-target setups the targets programs can use certain kind of “debug channel”. It is some debug_print() kind of arrangement by which the target program can write messages to the host screen, and these messages can be recorded at the host to a text file. ctc_send_data() can use this way to transfer the coverage data to the host. In ctc_send_data() you just collect the data to small slices, say ~70 chars long. Put prefix "CTCDATA:" at the beginning and write the line (atomic write is assumed!) to the debug channel. At the host the debug log is fed to ctc2dat utility. It extracts the coverage data from the lines that are prefixed by "CTCDATA:" and ignores all other lines.

D: If at the target context there is no printf() kind of outputting possible, but some line communication to the host can be used, you just have to implement what is needed and write the coverage data to the channel. The host side "listener program" then writes the MON.txt file, appending it each time when it gets a complete "write-out burst".

At the host side, in some cases you can use the tool ctc2dat read the channel straight away. In a Linux host it might be done as follows:

nc -l -p 1234 | ctc2dat -o MON.dat

The target can write the chars to the host to port 1234. At some point of time, when you have got enough coverage bursts in (you see them from ctc2dat’s trace to screen), you just stop ctc2dat e.g. by Control-C.