Code Coverage for C
When analyzing C source code, Test RealTime can provide the following function coverage:
Procedure Entries
Procedure Entries and Exits
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.
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.
In addition to the terminal instructions provided in the standard definition file, you can define other terminal instructions using the pragma attol exit_instr.
Note The last bracket '}' in a function after a return statement is always displayed in red in the coverage report, even if the function reports 100% coverage.
Related Topics