Call coverage

Code Coverage for C

When analyzing C source code, Code Coverage can provide coverage of function or procedure calls.

Code Coverage defines as many branches as it encounters function calls.

Procedure calls are made during program execution.

This type of coverage ensures that all the call interfaces can be shown to have been exercised for each C function. This may be a pass or failure criterion in software integration test phases.

You can use the -EXCALL option to select C functions whose calls you do not want to instrument, such as C library functions for example.

Example

 

/* Evaluate function */

/* -call */

int evaluate ( NodeTypeP node )

{

  if ( node == (NodeTypeP)0 ) return 0;

  switch ( node->Type )

  {

    int tmp;

    case NUMBER :

      return node->Value;

    case IDENTIFIER :

      return current value ( node->Name );

    case ASSIGN :

      set ( node->Child->Name,

                    tmp = evaluate ( node->Child->Sibling ) );

      return tmp;

    case ADD :

      return evaluate ( node->Child ) +

             evaluate ( node->Child->Sibling );

    case SUBTRACT :

      return evaluate ( node->Child ) -

             evaluate ( node->Child->Sibling );

    case MULTIPLY :

      return evaluate ( node->Child ) *

             evaluate ( node->Child->Sibling );

    case DIVIDE :

      tmp = evaluate ( node->Child->Sibling );

      if ( tmp == 0 ) fatal error ( "Division by zero" );

      else return evaluate ( node->Child ) / tmp;

  }

} /* There are twelve calls in the evaluate function */

 

Related Topics

C Block CoverageC Condition CoverageC Function CoverageC Additional StatementsCode Coverage settings