Squish Coco

Code Coverage Measurement for Tcl, C# and C/C++

  Squish Coco – A code coverage tool for Tcl, C# and C/C++

Squish Coco is a complete code coverage tool chain for Tcl, C# and C/C++ programs that runs on Apple® Mac OS X, Linux  and Microsoft® Windows. It analyzes the performance of an application being exercised (e.g. by a test suite), to reveal important information that can improve the testing of Tcl, C# and C/C++ applications.

In particular, Squish Coco helps to

Squish Coco can be used at every stage of testing and for all testing methodologies (unit tests, automatic tests, manual white box tests, black box tests, etc.). A test suite can be divided into independent parts: Squish Coco makes it possible to merge multiple execution reports into a single unified report.

The main components of the Squish Coco package are two separate tools and an add-in:

  1. CoverageScanner – a program to analyze and instrument a Tcl, C# and C/C++ application.
  2. CoverageBrowser – a program to display and manage the results of the coverage analysis.
  3. The Microsoft® Visual Studio® Add-In – an optional add-in to configure code coverage for C# or C++ projects that are developed under Microsoft® Visual Studio®.

There are also several helper programs for report generation, coverage data manipulation and license management.

Figure 1: Overview of the code coverage toolchain for Tcl, C# and C/C++

  CoverageScanner – Instrumentation as part of the build process

CoverageScanner instruments the source code that is seen by the compiler, without touching the original code. It generates an instrumented executable, shared library or plugin. The instrumentation keeps track of the code that is executed when the executable is run or when the library or plugin is used (e.g. how many times each line is executed, or whether a line was executed at all). When the instrumented program terminates, it produces an execution report.

In order to get the best quality of code coverage metrics, CoverageScanner not only instruments at the function and statement level, but also records statement coverage and decision coverage information. Optionally, it is also possible to insert the test name and its execution status (“passed” or “failed”) into the report. This can be done by a batch script or directly in the application. That makes it possible to integrate CoverageScanner into a test framework (like CppUnit or CxxTest), where it generates separate coverage information for each test.

CoverageScanner is a command line tool which replaces the compiler that is normally used to build the executable, library, or plugin. Its main functionality is to insert instrumentation instructions into the preprocessed source code and then to compile this modified code instead of the original code, using the normal compiler. CoverageScanner works with almost any standard compiler, including GNU gcc, GNU g++, Microsoft® Visual Studio® 6.0, .NET, Express, and Embedded C++, Intel® C++, etc. A database (the .csmes file) is generated at the same time for later analysis. It contains the list of instrumentations and a copy of the instrumented source code. CoverageScanner can work with most compilers because it can be easily configured for them.

After compilation, the instrumented executable can be run as usual (and an instrumented library or plugin can be used via the program that accesses them), but now, when the program terminates, an execution report is produced (the .csexe file).

Info CoverageScanner has built-in support for Qt Library which makes it possible to inhibit the instrumentation of the moc-generated code.

  CoverageBrowser – Viewing, analyzing and managing code coverage results

The execution report in the .csexe file can be analyzed and managed with the CoverageBrowser tool. This program has a GUI (graphical user interface) by which the user can browse and manage their execution reports. This makes it straightforward to locate untested or unreachable code and inefficient tests.

A summary of CoverageBrowser’s abilities:

Figure 2: CoverageBrowser: Code coverage screen shot
email squish@froglogic.com