Skipping of Code

With two Testwell CTC++ specific pragmas, parts of code can be skipped during instrumentation.

To skip code inside a source file, this pair of Testwell CTC++ specific pragmas can be used:
/*Pair of SKIP pragmas*/
#pragma CTC SKIP
#pragma CTC ENDSKIP

Code between these pragmas is not instrumented by ctc and not recorded in the symbol file.

Example:
/*Embracing SKIP pragmas*/
#include <stdio.h>
#include <bfile.h>
...
int foo1() {
   ...
}
...
#pragma CTC SKIP
int foo2() {
   ...
}
#pragma CTC ENDSKIP
...
int foo3() {
...
}
...
#pragma CTC SKIP
#include "somecode.inc"
#pragma CTC ENDSKIP
...

It is recommended that these pragmas are used outside of functions only. If they are used inside functions, it is required to use them only in such places where an imaginary {…} block could be added without making the program syntax erroneous or changing the program logic.

Inside macro definitions, where the pragmas cannot be used, the constructs "CTC SKIP"; and "CTC ENDSKIP"; can be used as alternative.

Example:

/*Alternative construct CTC SKIP / ENDSKIP*/
#define MY_ASSERT (cond){ "CTC SKIP"; \
   if(!(cond)) { \
      printf("\nMY_ASSERT failure at line %i\n", __LINE__); \
      exit(1); \
   } \
   "CTC ENDSKIP"; }

For the affected functions, all coverage measures do not refer to the whole function any longer.

Statement and line coverage are derived as far as it is possible for the not skipped part of the function, but this derivation can be misleading if the control flow is affected by the skipped part.

When using the pragma variant inside a function, an additional #pragma CTC COUNT name can be used immediately after #pragma CTC ENDSKIP to ensure that statement and line coverage is derived correctly after this point again.

Note: If the pragma or the string alternative is used, a warning is issued by ctc during instrumentation.