TestCocoon

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

TestCocoon is no more maintained and every user are invited to use now Squish Coco.

Squish Coco is available for commercial and non-commercial projects. For commercial user froglogic GmbH provides also a professional support.

Many enhancements come with this new product:
  • Better support of C++0x by handling constant and lambda expressions.
  • CoverageBrowser has now a more intuitive analysis of the test quality of software modifications by providing:
    1. the list of protential regressions which are not validated.
    2. the list of tests which impacts the modification.
    3. the code coverage of the difference.
  • A new browsable HTML report which permits:
    1. to browse though the source code.
    2. compare executions together.
    3. to make a code coverage analysis on the difference of two releases.
  • reading execution comments directly from the .csexe file.


Squish Coco is compatible with TestCocoon and does not require that you adapt your build environment.

Part V
Appendix

Appendix A  Additional Tools

A.1  cmreport - Code Coverage Report Generation

Syntax: cmreport -m <csmes_file> -s <selection> ...


Where:

-m <argument> | --csmes=<argument>
CSMes file name
-l <argument> | --level=<argument>
code coverage level
-s <argument> | --select=<argument>
select executions using regular expression
-d <argument> | --deselect=<argument>
deselect executions using regular expression
-h <argument> | --html=<argument>
HTML report output file name
-t <argument> | --text=<argument>
text report output file name
-x <argument> | --xml=<argument>
XML report output file name
--csv-method=<argument>
Generate a CSV report file for each method
--csv-function=<argument>
Generate a CSV report file for each file
--emma=<argument>
Generate an EMMA-XML report

Specific options for HTML/XML output:

--execution-level=<argument>
code coverage level for executions
--method-level=<argument>
code coverage level for methods
--css=<argument>
CSS style sheet
--icon=<argument>
Icon
--title=<argument>
Title
--global=<argument>
Global statistics, values=all, selected or selected_and_first
--method=<argument>
Method statistics, values=all, selected or selected_and_first
--execution=<argument>
Execution statistics, values=all, selected or selected_and_first
--source=<argument>
Source file statistics, values=all, selected or selected_and_first
--method-sort=<argument>
Method sorting, values=name or coverage
--execution-sort=<argument>
Execution sorting, values=name or coverage
--source-sort=<argument>
Source file sorting, values=name or coverage
--global-watermark-low-medium=<argument>
Global watermark setting
--global-watermark-medium-high=<argument>
Global watermark setting
--source-watermark-low-medium=<argument>
Source watermark setting
--source-watermark-medium-high=<argument>
Source watermark setting
--method-watermark-low-medium=<argument>
Method watermark setting
--method-watermark-medium-high=<argument>
Method watermark setting
--execution-watermark-low-medium=<argument>
Execution watermark setting
--execution-watermark-medium-high=<argument>
Execution watermark setting
--source-sublevels=<argument>
Maximum number of intermediate levels for sources
--execution-sublevels=<argument>
Maximum number of intermediate levels for executions
--global-sublevels=<argument>
Maximum number of intermediate levels for global statistics
--method-sublevels=<argument>
Maximum number of intermediate levels for methods
--source-filter-min=<argument>
Filtering out source files according the statistic
--source-filter-max=<argument>
Filtering out source files according the statistic
--method-filter-min=<argument>
Filtering out methods according the statistic
--method-filter-max=<argument>
Filtering out methods according the statistic
--execution-filter-min=<argument>
Filtering out executions according the statistic
--execution-filter-max=<argument>
Filtering out executions according the statistic
-b | --coverage-branch
code coverage on branch level only
-t | --test-coverage
test count mode
-D | --debug
debug flag
--toc
Table of contents
--manually-validated
Manually validated code fragments
--unexecuted
Unexecuted code fragments
--executed
Executed code fragments
--bargraph
Coverage data displayed in a bargraph

Specific options for text output:

--format-executed=<argument>
Line format for the executed for code fragments
--format-unexecuted=<argument>
Line format for the unexecuted for code fragments
Following keywords are substituted:
%f
Source code file name
%l
Line number
%c
Column number
%m
Explanation
It is allowed to to set the output file to an empty string (i.e.: --text=), in this case the standard output of the console is used.

Specific options for CSV output:

--csv-field-separator=<argument>
Field separator for a CSV file
--csv-coma=<argument>
Coma (, or .) used for floats in a CSV file

cmreport is a utility which permits to generate Text, HTML  XML or CSV reports from an instrumentation data base (.csmes file). It generates exactly the same reports as these generated by CoverageBrowser (see chap. export-statistics).

A.2  cmcsexeimport - Command Line Import Utility

Syntax: cmcsexeimport -m <csmes_file> -e <csexe_file> -t <title> [-p <policy>]


Where:

-m <argument>|--csmes=<argument>
CSMes file name
-e <argument>|--csexe=<argument>
CSExe file name
-t <argument>|--title=<argument>
Execution title
-p <argument>|--policy=<argument>
Import policy (ignore_duplicates, import_duplicates_and_empty, import_duplicates or merge)
-P|--passed
Execution marked as passed.
-F|--failed
Execution marked as failed.
-C|--check-manually
Execution marked as to be checked manually.

cmcsexeimport is a utility which permits to import an execution report (.csexe file) into an instrumentation data base (.csmes file). It behaves exactly like CoverageBrowser load of execution report function (see chap. load-execution-report).

A.3  cmmerge - Merging Utility

Syntax: cmmerge -o <output_file> <input_file> ... <input_file>


Where:

-o <argument>|--output=<argument>
CSMes output file
-a|--append
Do not create new output file but merge into an existing CSMes file.
-v|--verbose
Verbose output
-i <argument>|--instrumentation-and-execution=<argument>
Merge only instrumentations and executions present in the reference file (for importing unittests)

cmmerge is a small utility which permits to merge several instrumentation databases (.csmes file) together. It behaves exactly like CoverageBrowser merge function (see chap. mergedatabase).

Appendix B  Code Coverage Benchmarks

B.1  Test Algorithm

The sorting algorithm used for the tests is quicksort.
Source code:

B.2  Benchmarks

CompilerNormal Execution
(time)
Execution with Instrumentation
(time)
Difference
(%)
GCC without optimization 100 140.3 40.3
GCC with optimization -Os 52.1 61.9 18.8
GCC with optimization -O1 51.6 61.5 19.2
GCC with optimization -O2 55.4 58 4.6
GCC with optimization -O3 55.5 58.1 4.5
Benchmark (sorting algorithm) on VIA Eden 600Mhz
CompilerNormal Execution
(time)
Execution with Instrumentation
(time)
Difference
(%)
GCC without optimization 100 102.2 2.2
GCC with optimization -Os 49.7 54.7 9.9
GCC with optimization -O1 48.9 55.7 13.8
GCC with optimization -O2 48.2 53 9.9
GCC with optimization -O3 48.3 53 9.6
Benchmark (sorting algorithm) on AMD Athlon 1330Mhz
CompilerNormal Execution
(time)
Execution with Instrumentation
(time)
Difference
(%)
GCC without optimization 100 119.6 19.6
GCC with optimization -Os 51.4 76.2 48.1
GCC with optimization -O1 49.4 76.4 54.6
GCC with optimization -O2 48 74 54
GCC with optimization -O3 48 74.3 54.8
Benchmark (sorting algorithm) on Intel Pentium-M 1300Mhz
Compiler Without Instrumentation
(bytes)
With Instrumentation
(bytes)
Difference
(bytes)
GCC without optimization data20256 236
  code12002304 1104
GCC with optimization -Os data20256 236
  code8001840 1040
GCC with optimization -O1 data20256 236
  code8961936 1040
GCC with optimization -O2 data20256 236
  code9761968 992
GCC with optimization -O3 data20256 236
  code9761968 992
Sorting algorithm code size

Appendix C  Building TestCocoon

C.1  Required Tools

For building the documentation LATEX is necessary: on Linux the version provided by the distribution should be fine, on Microsoft® Windows MiKTeX1 can be used and on Apple® Mac OS X Tex Live2 can be installed.



Following tools needs to be installed to compile the project:

LinuxMicrosoft® WindowsApple® Mac OS X
flex version 2.5.35  
bison version 2.4.1  
 7-Zip 
GNU g++ compilerMicrosoft® Visual Studio® .NET 2005Apple® Xcode
Qt Library version 4.6.3 or above
Kitware CMake version 2.8



To generate the installer, following software are necessary:

LinuxMicrosoft® WindowsApple® Mac OS X
makeselfNSIS3IceBerg4

C.2  Build Installer

To build Qt:

LinuxMicrosoft® WindowsApple® Mac OS X
In a shell, execute:
cd gen/linux
./buildqt.sh install 
Create the directory \qt\x86. Copy the windows source files of Qt version 4.6.3 on it.
In a DOS console, execute:
  cd gen\windows
  buildqt_x86.bat
In a shell, execute:
  cd gen/macos
  ./buildqt.sh



To build TestCocoon installer:

LinuxMicrosoft® WindowsApple® Mac OS X
  gen/linux/build.sh 
  cd gen\windows
  build.bat
  gen/macos/build.sh

C.3  Build Steps

To build the sources follows this steps:

  1. Create an empty directory which will contains the result of the build (object and executables).
  2. In a shell/DOS prompt go into this directory and execute:
        cmake -DCMAKE_BUILD_TYPE=<build_type> <path_of_sources>
        
    Following values of <build_type> are possible:
    <build_type>Description
    debugdebug mode build
    releaserelease mode build
    logrelease mode build with verbose log output
    -G can be used to generate Microsoft® Visual Studio® .NET or Apple® Xcode projects.
  3. Execute make or nmake to generate the project.
  4. On Unix, ’make install’ (resp. ’make uninstall’) installs TestCocoon (resp. unistalls). Setting the CMake variable CMAKE_INSTALL_PREFIX permits to set the installation path (ex: cmake -DCMAKE_INSTALL_PREFIX=/tmp/InstallTest ...)

Appendix D  Customizing I/O of CoverageScanner library

D.1  Custom I/O using C file access

The following example shows how to generate the execution report using the standard C file API.


To compile the example on Microsoft® Windows:

cscl customiofile.c

To compile the example on Linux or Apple® Mac OS X:

csgcc customiofile.c -o customiofile

Source code:

D.2  Custom I/O using SFTP protocol

The following example shows how to generate the execution report directly on a SFTP server. The SFTP server is part of SSH v2 and is available on most of the Unix platforms. On Microsoft® Windows, a free SSH server can be downloaded from http://www.freesshd.com.


To compile the example on Microsoft® Windows:

  1. Download libSSH2 from http://www.libssh2.org. Generate the library and set the environment variable LIBSSH2 to the location of the libSSH2 source code.
  2. To compile the example:
    cscl %LIBSSH2%\win32\debug_dll\libssh2.lib -DWIN32 --cs-libgen=/MTd 
         /MTd -I %LIBSSH2%\include ws2_32.lib customiosftp.c 
    
  3. Execute custom_io_sftp.exe.

To compile the example on Linux:

  1. Install the development package of libssh2.
  2. To compile the example:
    csgcc -lssh2 customiosftp.c -o customiosftp
    
  3. Execute custom_io_sftp.

Source code: