Function coverage
Code Coverage for C
When analyzing C source code, Rational® Test RealTime can provide the following function coverage:
-
Procedure Entries
-
Procedure Entries and Exits
Procedure Entries
Inputs identify the C functions that are executed.
/* Factorial function */
/* -proc */
int factorial ( int a )
{
if ( a > 0 ) return a * factorial ( a - 1 );
else return 1;
}
One branch is defined per C function.
Procedure Entries and Exits (Returns and Terminal Statements)
These include the standard output (if coverable), and all return instructions, exits, and other terminal instructions that are instrumented, as well as the input.
/* Factorial function */
/* -proc=ret */
int factorial ( int a )
{
if ( a > 0 ) return a * factorial ( a - 1 );
else return 1;
} /* standard output cannot be covered */
/* Divide function */
void divide ( int a, int b, int *c )
{
if ( b == 0 )
{
fprintf ( stderr, "Division by zero\n" );
exit ( 1 );
};
if ( b == 1 )
{
*c = a;
return;
};
*c = a / b;
}
At least two branches are defined per C function.
The input is always enumerated, as is the output if it can be covered. If it cannot, it is preceded by a terminal instruction involving returns or an exit.
Related Topics
Selecting coverage types | Code Coverage settings