SYNOPSIS

ccovscan.pl code.c > covcode.c

DESCRIPTION

Scans the C/C++ source (before cpp) and inserts a call in each block to record execution. Designed to be as simple as possible.

Detects error prone constructs and forces you to rewrite them in a simpler form. Many of these ideas came from study of the highly regarded perl5 source code. (And as a side-effort makes C/C++ easy to parse.)

This approach to coverage analysis is not close to fullproof! Just because you exercise every code path does not mean that you have exercised all possible states. For example,

char
fetch_char(int xx)
{
  static char *string = "Dr. Zorph Trokien";
  if (xx < 0) {
    return 0;
  } else {
    return string[xx];
  }
}

You still have to be smart about writing your code (and test scripts).

CCOV Source Code Directives

  • /* COVERAGE: on */

    Turns on coverage instrumentation.

  • /* COVERAGE: off */

    Turns off coverage instrumentation.

  • /* COVERAGE: jump myexit croak panic */

    Adds to the list of functions that cause a change in execution flow.

  • ||

    If you use || in an if test, you can avoid the warning by adding an /*OK*/ comment inside the if expression.

  • ?:

    The ?: operator is not checked.

API

  • file_c_CCOV_REPORT()

TODO

Split into a separate distribution.

Persist status between runs.

AUTHOR

Copyright (c) 1997 Joshua Nathaniel Pritikin. All rights reserved.

This package is free software and is provided "as is" without express or implied warranty. It may be used, redistributed and/or modified under the terms of the Perl Artistic License (see http://www.perl.com/perl/misc/Artistic.html)