Part III
CoverageScanner Reference Manual
CoverageScanner is the application which inserts the instrumentation into the
source code.
It performs the following operations:
-
Runs the C preprocessor.
- Instruments the preprocessed source code.
- Compiles the source code using the native C/C++ compiler.
Mainly, during normal usage, it replaces the native compiler.
CoverageScanner does not support precompiled headers.
CoverageScanner automatically deactivates this feature during
compilation.
Chapter 20 C/C++ Compiler Support
Compiler support is carried out through a profile.
A profile contains a set of declarations which makes it possible to adapt
CoverageScanner to C/C++ preprocessors, compilers and linkers.
20.1 Supported Compilers
CoverageScanner executable for a specific compiler is called to cs+’native compiler name’
or alternatively ’native compiler name’+-cs.
(example: cl.exe is the Microsoft® compiler and
the corresponding CoverageScanner executable is cscl.exe or cl-cs.exe).
It is also possible to call ’coveragescanner.exe’ directly when the option
’--cs-compiler=<compiler name>’ is specified.
The native compiler path needs to appear in the PATH variable. This is necessary
to allow code scanner to call the native compiler after insertion of
the instrumentation code.
The following compilers are currently supported by CoverageScanner:
20.1.1 C# compilers
The command line C# compiler of Microsoft® Visual Studio® .NET and Mono C# compiler are supported.
| Native Command | CoverageScanner Command |
| ’mcs’ | ’csmcs’ |
| ’csc’ | ’cscsc’ |
|
20.1.2 Microsoft® Visual C++
The command line compiler and linker of Microsoft® Visual C++ and
Microsoft® Visual C++ Toolkit 2003 are supported.
| Native Command | CoverageScanner Command |
| ’cl’ | ’cscl’ |
| ’lib’ | ’cslib’ |
| ’link’ | ’cslink’ |
|
20.1.3 Intel® C++ Compiler
The C/C++ command line compiler from Intel® is supported.
| Native Command | CoverageScanner Command |
| ’icl’ | ’csicl’ |
| ’icc’ | ’csicc’ |
| ’icpc’ | ’csicpc’ |
|
Only g++ and gcc command line compilers are directly supported.
| Native Command | CoverageScanner Command |
| ’gcc’ | ’csgcc’ |
| ’g++’ | ’csg++’ |
| ’ar’ | ’csar’ |
|
To implement support for GNU cross-compilers proceed as follows:
-
Copy ’coveragescanner’ to the file ’cs+<compiler name>’.
(ex: copy coveragescanner.exe csarm-linux-gcc.exe)
- Copy the profile ’gcc.cspro’ or g++.cspro’ to ’<compiler name>+.cspro’.
(ex: copy gcc.cspro arm-linux-gcc.cspro)
- Edit the new profile and set the parameter TOOL to ’<compiler name>’.
(ex: TOOL=arm-linux-gcc)
- The new GNU cross-compiler ’cs+<compiler name>’ can now be used.
It inserts the instrumentations and calls the ’<compiler name>’ for compilation.
The installation script of TestCocoon creates automatically
the corresponding compiler wrapper of every GNU compiler present. So,
it is normally not necessary to create such compiler configuration
by hand.
20.2 Integrated Development Environment Support
20.2.1 GNU Makefile
Mostly, in makefiles, the C/C++ compiler and the linker are defined
using the environment variable CC, CXX and LINK.
This can be substituted by CoverageScanner by setting CC,
CXX and LINK in the command arguments of make.
Example: make LINK=csg++ CXX=csg++ CC=csgcc
If TestCocoon is installed on the root file
system1,
a compiler wrapper is created for each compiler supported by
Scratchbox. To invoke CoverageScanner,
prepend cs to the name of the cross-compiler.
20.2.3 Qt Library from Nokia
Nokia qmake
The variables QMAKE_CC, QMAKE_CXX and QMAKE_LINK contain the name
of the C compiler, the C++ compiler and the linker command line used
by qmake to generate the makefiles. This variable can be set as a command
line argument of qmake.
Example: qmake QMAKE_LINK=cslink QMAKE_CXX=cscl QMAKE_CC=cscl
An other alternative is to create a configuration called TestCocoon in the .pro file:
TestCocoon {
QMAKE_CXX=cs$$QMAKE_CXX
QMAKE_CC=cs$$QMAKE_CC
QMAKE_LINK=cs$$QMAKE_LINK
}
Calling qmake CONFIG+=TestCocoon will generate the makefiles with code coverage activated.
Nokia Meta-Object Compiler (MOC)
Nokia Meta-Object Compiler add automatically in each classes derived from QObject
new methods. For example, the translation function tr, the source code for all signals,
the cast operator qt_cast, …In order to instrument the code using the Qt Library and not the library itself,
CoverageScanner provides the command line options
--cs-qt4 for Qt4 (resp. --cs-qt3 for Qt3).
In this case:
-
Q_OBJECT macro is no more instrumented.
- All signal are instrumented in order to track their emission.
- The glue code necessary for the signal/slot mechanism is not instrumented.
20.2.4 Microsoft® Visual Studio®
TestCocoon provides a wrapper for link.exe and cl.exe located
on the %TESTCOCOON%\visualstudio directory.
It behaves exactly like the corresponding Microsoft® wrapper except
that the code coverage analysis becomes activated when the option --cs-on
is added to the command arguments.
These wrappers call the Microsoft® tools for compilation or for linkage.
Microsoft® Visual Studio® .NET C# Compiler
To activate the instrumentation of C# source code, it is only necessary to add the define COVERAGESCANNER_COVERAGE_ON in the
properties of the Microsoft® Visual Studio® .NET project. Other defines can be appended to select additional instrumentation options.
The full list can be found on the chapter preprocessor-defines.
Microsoft® Visual Studio® .NET C/C++ Compiler
To use TestCocoon with Microsoft® Visual Studio® .NET proceed as follows:
-
Add the location of the CoverageScanner wrappers to the first position in the VC++ Directories.
-
Start Microsoft® Visual Studio® .NET.
- Open the option dialog: click on "Tools->Preferences…".
- Select the item "Projects->VC++ Directories".
- Add the entry
$(TESTCOCOON)\visualstudio to the first position
in the list of directories. (see figure fig:visual_option_net_fig)
Installation of CoverageScanner on Visual Studio® .NET:
Setting the path of CoverageScanner.
Installation of CoverageScanner on Visual Studio® .NET:
Setting the path of CoverageScanner.
|
- To activate code coverage analysis:
-
Open a Visual C/C++ project.
- Edit the project settings (click on "Project->Properties").
- Add to the option --cs-on to the additional command line arguments
of the C/C++ compiler and linker. (see figure fig:visual_compiler_net_fig)
- In the additional arguments of the linker, add the --cs-libgen which permits to
specify which library should be used for the generation of the CoverageScanner library.
The table tab:librarysettings contains the list of recommended settings.
- For Microsoft® Windows CE applications, append to the linker arguments the command line option --cs-architecture
which permits to specify the target platform.
The table tab:architectures contains the list of available architectures.
| Library | Command line option |
| Single Threaded | --cs-libgen=/ML |
| Static MultiThread | --cs-libgen=/MT |
| Dynamic Link (DLL) | --cs-libgen=/MD |
| Debug Single Threaded | --cs-libgen=/MLd |
| Debug Static MultiThread | --cs-libgen=/MTd |
| Debug Dynamic Link (DLL) | --cs-libgen=/MDd |
CoverageScanner library settings for Microsoft® Visual Studio®
|
| Targeted Architecture | Command line option |
| ARM Microprocessor | --cs-architecture=ARM |
| ARM Microprocessor (Thumb code) | --cs-architecture=THUMB |
| x86 Microprocessor | --cs-architecture=IX86 |
| MIPS16 Microprocessor | --cs-architecture=MIPS16 |
| MIPS Microprocessor | --cs-architecture=MIPS |
| MIPS Microprocessor with FPU | --cs-architecture=MIPSFPU |
| SH3 Microprocessor with FPU | --cs-architecture=SH3 |
| SH4 Microprocessor with FPU | --cs-architecture=SH4 |
List of target architectures
|
Activation of the instrumentation under Visual Studio® .NET.
Activation of the instrumentation under Visual Studio® .NET.
|
Activation of the instrumentation under Visual Studio® .NET.
Activation of the instrumentation under Visual Studio® .NET.
|
TestCocoon Add-In for Microsoft® Visual Studio® 2005, 2008 and 2010
TestCocoon provides for Microsoft® Visual Studio® 2005, 2008 and 2010 an Add-In which does automatically
the steps described in the section visualstudiodotnet.
To use it:
-
Open a C++ project.
- Click on Tools->Code Coverage Build Mode….
- Select the base configuration and the project which should be compiled with code coverage support.
- Click on Enable code coverage to generate a new build mode with code coverage support.
Disable code coverage removes all CoverageScanner command line options.
Microsoft® Visual Studio® 2005 & 2008 Add-In
Microsoft® Visual Studio® 2005 & 2008 Add-In
|
Microsoft® Visual C++ Express
To use TestCocoon with Microsoft® Visual C++ Express proceed as follows:
-
Add the location of the CoverageScanner wrappers to the first position in the VC++ Directories.
-
Start Microsoft® Visual C++ Express.
- Open the option dialog: click on "Tools->Preferences…".
- Select the item "Projects->VC++ Directories".
- Add the entry
$(TESTCOCOON)\visualstudio to the first position
in the list of directories. (see figure fig:visual_option_express_2005_fig)
Installation of CoverageScanner on Visual C++ Express: Setting the path of CoverageScanner.
Installation of CoverageScanner on Visual C++ Express: Setting the path of CoverageScanner.
|
- The activation of the code coverage analysis is similar to
Microsoft® Visual Studio® .NET. (see chap. visualstudiodotnet)
Microsoft® Visual Studio® 6.0
To use TestCocoon with Microsoft® Visual Studio® 6.0 proceed as follows:
-
Add the location of the CoverageScanner wrappers to the first position in the executable directories.
-
Start Microsoft® Visual Studio® 6.0.
- Open the option dialog: click on "Tools->Preferences…".
- Select the item "Directories".
- Select "Executable files" in the combobox "Show directories for:".
- Add the path of the directory
visualstudio of the TestCocoon
installation2
to the first position in the list of directories.
(example: if TestCocoon is installed on c:\programme\TestCocoon,
add the path c:\programme\TestCocoon\visualstudio,
(see figure fig:visual_option_6_fig))
Installation of CoverageScanner on Visual Studio® 6.0: Setting the path of CoverageScanner.
Installation of CoverageScanner on Visual Studio® 6.0: Setting the path of CoverageScanner.
|
- To activate the code coverage analysis:
-
Open a Visual C/C++ project.
- Edit the project settings (click on "Project->Properties").
- Add the option --cs-on to the additional command line arguments
of the C/C++ compiler and linker. (see figure fig:visual_compiler_6_fig)
- In the additional arguments of the linker, add the --cs-libgen which permits to
specify which library should be used for the generation of the CoverageScanner library.
The table tab:librarysettings contains the list of recommanded settings.
Activation of the instrumentation under Visual Studio® 6.0.
Activation of the instrumentation under Visual Studio® 6.0.
|
Activation of the instrumentation under Visual Studio® 6.0.
Activation of the instrumentation under Visual Studio® 6.0.
|
20.2.5 Microsoft® eMbedded Visual C++®
To use TestCocoon with Microsoft® eMbedded Visual C++®proceed as follows:
-
Add the location of the CoverageScanner wrappers to the first position in the executable directories.
-
Start Microsoft® eMbedded Visual C++®.
- Open the option dialog: click on "Tools->Preferences…".
- Select the item "Directories".
- Select "Executable files" in the combobox "Show directories for:".
- Select "Platform" and the targeted "CPUs".
- Add the path of the directory
WinCE of the TestCocoon
installation3
to the first position in the list of directories.
(example: if TestCocoon is installed on c:\programme\TestCocoon,
add the path c:\programme\TestCocoon\WinCE,
(see figure fig:visual_option_embedded_fig))
Installation of CoverageScanner on eMbedded Visual C++®: Setting the path of CoverageScanner.
Installation of CoverageScanner on eMbedded Visual C++®: Setting the path of CoverageScanner.
|
- To activate the code coverage analysis:
-
Open a Visual C/C++ project.
- Edit the project settings (click on "Project->Properties").
- Add the option --cs-on to the additional command line arguments
of the C/C++ compiler and linker. (see figure fig:visual_compiler_embedded_fig)
Activation of the instrumentation under eMbedded Visual C++®.
Activation of the instrumentation under eMbedded Visual C++®.
|
Activation of the instrumentation under eMbedded Visual C++®.
Activation of the instrumentation under eMbedded Visual C++®.
|
20.2.6 Eclipse™ IDE for C/C++
Eclipse™ IDE for C/C++ rely on a GNU-GCC command line compiler. Before trying to compile a project with coverage support, it is necessary to create a compiler wrapper ((see chap. gcc-compiler)).
To compile a project with code coverage support, proceed as follows:
-
Start Eclipse™.
- Load a C/C++ project.
- Open the property window (Project-> Properties)
- Click on "C/C++ Build/Settings"
- Create a new configuration by clicking on "Manage Configurations..." and select it.
- Click on "Tools Settings" tab.
- Click on "GCC C++ Compiler" and prepend cs to the name of the compiler.
- Click on "GCC C Compiler" and prepend cs to the name of the compiler.
- Click on "C++ Linker" and prepend cs to the name of the linker.
20.2.7 Apple® Xcode
To use TestCocoon with Apple® Xcode proceed as follows:
To activate the code coverage analysis:
-
Open a terminal window and set the
CPLUSPLUS, LDPLUSPLUS, LD and CC to CoverageScanner
compiler wrapper. Start Xcode using the open command.
Example: TESTCOCOON=/Applications/TestCocoon/wrapper
export CC=$TESTCOCOON/gcc
export LD=$TESTCOCOON/gcc
export CPLUSPLUS=$TESTCOCOON/g++
export LDPLUSPLUS=$TESTCOCOON/g++
open /Developer/Applications/Xcode.app
- Open a Xcode C/C++ project.
- Edit the project settings (click on "Project->Edit Project Settings").
- Add the option --cs-on to the additional command line arguments
of the C/C++ compiler (fields
Other C Flags and Other C++ Flags) and linker (field Other Linker Flags). (see figure fig:xcode_configuration_fig)
- Disable the usage of the precomiled header: Open the settings of the active target ("Project->Edit Active Target") and remove the contains of
Prefix Header.
Activation of the instrumentation under Apple® Xcode.
Activation of the instrumentation under Apple® Xcode.
|
Chapter 21 Command Line Reference
21.1 Synopsis
| coveragescanner
--cs-compiler=<STRING> | [--cs-exclude-file-regex=<STRING>] | <compiler arguments> |
|
cscl | [--cs-include-file-regex=<STRING>] | |
|
csg++ | [--cs-exclude-file-wildcard=<STRING>] | |
|
csgcc | [--cs-include-file-wildcard=<STRING>] | |
|
cslink | [--cs-compiler=<STRING>] | |
|
csicl | [--cs-on] | |
|
cslib | [--cs-off] | |
| csar | [--cs-hit] | |
| | [--cs-count] | |
| | [--cs-include-path=<STRING>] | |
| | [--cs-exclude-path=<STRING>] | |
| | [--cs-exclude-function-regex=<STRING>] | |
| | [--cs-include-function-regex=<STRING>] | |
| | [--cs-exclude-function-wildcard=<STRING>] | |
| | [--cs-include-function-wildcard=<STRING>] | |
| | [--cs-libgen=<STRING>] | |
| | [--cs-architecture=<STRING>] | |
| | [--cs-qt4] | |
| | [--cs-qt3] | |
| | [--cs-branch] | |
| | [--cs-condition] | |
| | [--cs-decision] | |
| | [--cs-full-instrumentation] | |
| | [--cs-partial-instrumentation] | |
| | [--cs-no-exceptions] | |
| | [--cs-output] | |
| | [--cs-lock-csexe] | |
| | [--cs-nolock-csexe] | |
| | [--cs-keep-instrumentation-files] | |
| | [--cs-pipe] | |
| | [--cs-nopipe] | |
Where:
-
--cs-include-file-wildcard=<STRING>
-
This command line option enables the user to include a file in the
coverage analysis. The file name is specified using a wildcard expression.
Example: --cs-include-file-wildcard=^c:\\include\\*.h includes all
header file names with the extension .h located in c:\include.
- --cs-exclude-file-wildcard=<STRING>
-
This command line option enables the user to exclude a file from the
coverage analysis. The file name is specified using a wildcard expression.
Example: --cs-exclude-file-wildcard=*.h excludes all header file names
with the extension .h.
- --cs-include-file-regex=<STRING>
-
This command line option enables the user to include a file in the
coverage analysis. The file name is specified using a regular expression.
(see chapter sec:regular_expression for the syntax)
Example: --cs-include-file-regex=^c:\\include\\[^\\]*\.h$ includes all
header file names with the extension .h located in c:\include.
- --cs-exclude-file-regex=<STRING>
-
This command line option enables the user to exclude a file from the
coverage analysis. The file name is specified using a regular expression.
(see chapter sec:regular_expression for the syntax)
Example: --cs-exclude-file-regex=^.*\.h$ excludes all header file names
with the extension .h.
- --cs-exclude-path=<STRING>
-
This command line option enables the user to exclude
the files located in a specific path from the code coverage analysis.
Example: --cs-exclude-path=c:\include excludes all files
located in c:\include.
- --cs-include-path=<STRING>
-
This command line option enables the user to include files located in a
specific path in the coverage analysis.
Example: --cs-include-path=c:\include includes all files
located in c:\include.
-
--cs-include-function-wildcard=<STRING>
-
This command line option enables the user to include a function in the
coverage analysis. The function name is specified using a wildcard expression and must include for C++ code the class name and namespace.
Example: --cs-include-function-wildcard=C::* includes all
members of the class C.
- --cs-exclude-function-wildcard=<STRING>
-
This command line option enables the user to exclude a function from the
coverage analysis. The function name is specified using a wildcard expression and must include for C++ code the class name and namespace.
Example: --cs-exclude-function-wildcard=*::Get* excludes all merbers of any classes which starts with Get.
- --cs-include-function-regex=<STRING>
-
This command line option enables the user to include a function in the
coverage analysis. The function name is specified using a regular expression and must include for C++ code the class name and namespace.
(see chapter sec:regular_expression for the syntax)
- --cs-exclude-function-regex=<STRING>
-
This command line option enables the user to exclude a function from the
coverage analysis. The function name is specified using a regular expression and must include for C++ code the class name and namespace.
(see chapter sec:regular_expression for the syntax)
-
--cs-compiler=<STRING>
-
This command option enables the user to select a profile.
This option does not normally need to be specified,
due to the fact that the profile name is usually extracted from
the command line name.
(cscl.exe implicitly selects the profile cl.cspro)
Example: --cs-compiler=cl selects the profile ’cl.cspro’.
- --cs-architecture=<STRING>
-
Permits to specify the target architecture.
- --cs-libgen=<STRING>
-
Adds an additional command line option to the compiler which generates the
code coverage library.
This command can be used more than once.
- --cs-off
-
Disables the code coverage analysis of CoverageScanner.
This is equivalent to calling the native compiler or linker.
- --cs-on
-
Activates the code coverage analysis of CoverageScanner.
This option is set by default.
- --cs-hit
-
Generation of code coverage hit instrumentation.
This option is set by default.
- --cs-count
-
Generation of code coverage count instrumentation.
- --cs-branch
-
Generation of code coverage instrumentation of branches.
- --cs-decision
-
Generation of code coverage instrumentation of branches and decisions.
- --cs-condition
-
Generation of code coverage instrumentation of branches, decisions and conditions. (default)
- --cs-partial-instrumentation
-
Suppression of redundant conditions. (default)
- --cs-full-instrumentation
-
No suppression of redundant conditions.
- --cs-no-exceptions
-
Do not instrument the
catch block of a try…catch statement.
- --cs-qt4
-
Function filter which suppresses the instrumentation of class members
(
Q_OBJECT, qt_metacall, qt_metacast, …)
generated by Nokia Meta-Object Compiler (MOC)
for Qt4 library.
- --cs-qt3
-
Function filter which suppresses the instrumentation of class members
(
Q_OBJECT, className, tr, …)
generated by Nokia Meta-Object Compiler (MOC)
for Qt3 library.
- --cs-output
-
Set the default output file name of the execution report. Per default,
CoverageScanner uses
coverage.csexe. The extension .csexe is
added automatically.
- --cs-lock-csexe
-
Create a lock file which lock the access of the
.csexe file during its generation.
- --cs-nolock-csexe
-
Inverse option to --cs-lock-csexe.
- --cs-pipe
-
The preprocessor output is transmitted to CoverageScannerthrough a pipe.
This option is set by default.
- --cs-nopipe
-
The preprocessor output is transmitted to CoverageScannerthrough a temporary file.
- --cs-keep-instrumentation-files
-
Do not delete temporary source files.
The command line arguments are prioritized by their order in the command line:
the latest entered option has a higher priority than the first one.
Example:
cscl --cs-include=foo.h --cs-exclude=foo.h will exclude the
header foo.h from the coverage analysis.
On windows all file names are converted to lower case.
Parameters specified in the system variable COVERAGESCANNER_ARGS are also parsed by CoverageScanner.
21.2 Instrumenting using preprocessor defines
CoverageScanner activates also the instrumentation if some defines are present in the command line option. This permits to instrument
code with an IDE which does not permits to add custom command line options to the compiler or linker.
Example: Defining COVERAGESCANNER_COVERAGE_ON is equivalent of adding --cs-on to the command line.
| Define | Equivalence |
| COVERAGESCANNER_COVERAGE_ON | --cs-on |
| COVERAGESCANNER_COVERAGE_HIT | --cs-hit |
| COVERAGESCANNER_COVERAGE_COUNT | --cs-count |
| COVERAGESCANNER_COVERAGE_BRANCH | --cs-branch |
| COVERAGESCANNER_COVERAGE_DECISION | --cs-decision |
| COVERAGESCANNER_COVERAGE_CONDITION | --cs-condition |
| COVERAGESCANNER_COVERAGE_LOCK_CSEXE | --cs-lock-csexe |
| COVERAGESCANNER_COVERAGE_NOLOCK_CSEXE | --cs-nolock-csexe |
| COVERAGESCANNER_COVERAGE_PARTIAL_INSTRUMENTATION | --cs-partial-instrumentation |
| COVERAGESCANNER_COVERAGE_FULL_INSTRUMENTATION | --cs-full-instrumentation |
| COVERAGESCANNER_COVERAGE_NO_EXCEPTIONS | --cs-no-exceptions |
21.3 C/C++ Library
CoverageScanner library is generated during the link process and enables the user to:
-
Initialize measurements.
- Generate the execution report.
- Give a name to the executed tests.
- Install a signal handler which saved the execution report on exit.
Additionally CoverageScanner sets the preprocessor define
__COVERAGESCANNER__
which excludes this function from a normal compilation.
21.3.1 __coveragescanner_install
Syntax: void __coveragescanner_install(const char *appname)
__coveragescanner_install performs complete initialization of the CoverageScanner library.
This function is the first function called in the main() function.
The parameter appname contains the executable name. The application name is used
to define the measurement file name (by appending ’.csexe’ to appname).
__coveragescanner_install registers an exit handler via atexit() which stores execution traces using the
__coveragescanner_save procedure. This handler is also called when SIGABRT,
SIGTERM, SIGFPE, SIGILL, SIGINT, SIGSEGV and SIGTERM signal are
received. This makes it possible to save the execution report upon every application termination.
Suggested usage:
1 int main(argc,char *argv[])
2 {
3 #ifdef __COVERAGESCANNER__
4 __coveragescanner_install(argv[0]);
5 #endif
6 ...
7 }
This function is not available if the profile parameter
CUSTOM_SETUP is set to
NONE (see chap.
custom_setup).
With GNU tools or Microsoft compilers, CoverageScanner installs automatically a minimal handler which saves the execution in the file coverage.csmes upon a normal application exit. Calling __coveragescanner_install permits to set the execution report file name and also saves the report upon abnormal exit (crashes or program interruption).
21.3.2 __coveragescanner_testname
Syntax: void __coveragescanner_testname(const char *name)
__coveragescanner_testname sets the name of the test which is currently being executed.
It will be saved to the execution report and is displayed in the "Executions"
window (see chap. execution-management) when the loaded in CoverageBrowser.
21.3.3 __coveragescanner_teststate
Syntax: void __coveragescanner_teststate(const char *state)
__coveragescanner_teststate sets the state of the test which is currently being executed.
The string parameter state can have the following values:
-
"PASSED"
- indicates that the test was successfully executed.
- "FAILED"
- indicates that the test was not successfully passed.
- "CHECK_MANUALLY"
- indicates that it was not possible to determinate if the test was successfully executed.
It will be saved to the execution report and is displayed in the "Executions"
window (see chap. execution-management) when the loaded in CoverageBrowser.
21.3.4 __coveragescanner_save
Syntax: void __coveragescanner_save()
__coveragescanner_save saves the execution report and resets the status of all instrumentations.
21.3.5 __coveragescanner_clear
Syntax: void __coveragescanner_clear()
__coveragescanner_clear resets the status of all instrumentations.
21.3.6 __coveragescanner_filename
Syntax: void __coveragescanner_filename(const char *name)
this function sets the file name of the execution report.
The extension ’.csexe’ is added automatically.
The name must be less than 80 characters.
Setting the execution report file name is necessary if the initialization function
__coveragescanner_install is not used.
21.3.7 __coveragescanner_set_custom_io
Syntax: void __coveragescanner_set_custom_io(
char *(*csfgets)(char *s, int size, void *stream),
int (*csfputs)(const char *s, void *stream),
void *(*csfopenappend)(const char *path),
void *(*csfopenread)(const char *path),
void *(*csfopenwrite)(const char *path),
int (*csfclose)(void *fp),
int (*csremove)(const char *filename) )
Parameters:
-
csfgets
-
csfgets reads in at most one less than size characters from
stream and stores them into the buffer pointed to by s.
Reading stops after an EOF or a newline. If a newline is read, it is
stored into the buffer. A ’\0’ is stored after
the last character in the buffer. - csfputs
-
csfputs writes the string s to stream, without its trailing ’\0’. - csfopenappend
-
csfopenappend open the file path for writing at the end. - csfopenread
-
csfopenread open the file path for reading. - csfopenwrite
-
csfopenwrite open the file path for writing. - csfclose
-
The
csfclose function will flush and close the stream pointed to by fp. - csremove
-
csremove removes filename from the file system.
CoverageScanner writes the execution report (.csexe file) into file using the common C library (fopen, fputs, …).
In some situations, for embedded systems for example, it is necessary to use an other way for recording it.
For this reason, CoverageScanner provides
__coveragescanner_set_custom_io which permits to replace the IO
functions used by __coveragescanner_save.
Default implementation:
1 char *csfgets(char *s, int size, void *stream) { return fgets(s,size,(FILE *)stream); }
2 int csfputs(const char *s, void *stream) { return fputs(s, (FILE *)stream); }
3 void *csfopenappend(const char *path) { return (void*)fopen(path,"a+"); }
4 void *csfopenread(const char *path) { return (void*)fopen(path,"r"); }
5 void *csfopenwrite(const char *path) { return (void*)fopen(path,"w"); }
6 int csremove(const char *filename) { return remove(filename); }
7 int csfclose(void *fp) { return fclose((FILE*)fp); }
Some examples are available in the annex customioexample.
21.4 C# Library
CoverageScanner library is generated during the link process and enables the user to:
-
Generate the execution report.
- Give a name to the executed tests.
- Install a signal handler which saved the execution report on exit.
Additionally CoverageScanner sets the preprocessor define
__COVERAGESCANNER__
which excludes this function from a normal compilation.
21.4.1 CoverageScanner.__coveragescanner_testname
Syntax: void CoverageScanner.__coveragescanner_testname(string name)
CoverageScanner.__coveragescanner_testname sets the name of the test which is currently being executed.
It will be saved to the execution report and is displayed in the "Executions"
window (see chap. execution-management) when the loaded in CoverageBrowser.
21.4.2 CoverageScanner.__coveragescanner_teststate
Syntax: void CoverageScanner.__coveragescanner_teststate(string state)
CoverageScanner.__coveragescanner_teststate sets the state of the test which is currently being executed.
The string parameter state can have the following values:
-
"PASSED"
- indicates that the test was successfully executed.
- "FAILED"
- indicates that the test was not successfully passed.
- "CHECK_MANUALLY"
- indicates that it was not possible to determinate if the test was successfully executed.
It will be saved to the execution report and is displayed in the "Executions"
window (see chap. execution-management) when the loaded in CoverageBrowser.
21.4.3 CoverageScanner.__coveragescanner_save
Syntax: void CoverageScanner.__coveragescanner_save()
CoverageScanner.__coveragescanner_save saves the execution report and resets the status of all instrumentations.
21.4.4 CoverageScanner.__coveragescanner_clear
Syntax: void CoverageScanner.__coveragescanner_clear()
CoverageScanner.__coveragescanner_clear resets the status of all instrumentations.
21.4.5 CoverageScanner.__coveragescanner_filename
Syntax: void CoverageScanner.__coveragescanner_filename(string name)
this function sets the file name of the execution report.
The extension ’.csexe’ is added automatically.
The name must be less than 80 characters.
Setting the execution report file name is necessary if the initialization function
__coveragescanner_install is not used.
21.4.6 CoverageScanner.__coveragescanner_set_custom_io
Syntax: void CoverageScanner.__coveragescanner_set_custom_io(
__cs_fgets_delegate cs_fgets,
__cs_fputs_delegate cs_fputs,
__cs_fopenappend_delegate cs_fopenappend,
__cs_fopenread_delegate cs_fopenread,
__cs_fopenwrite_delegate cs_fopenwrite,
__cs_fclose_delegate cs_fclose,
__cs_remove_delegate cs_remove)
Parameters:
-
csfgets
-
Type:
public delegate string __cs_fgets_delegate(System.IO.Stream stream)
csfgets reads in at most one less than size characters from
stream and stores them into the buffer pointed to by s.
Reading stops after an EOF or a newline. If a newline is read, it is
stored into the buffer. A ’\0’ is stored after
the last character in the buffer. - csfputs
-
Type:
public delegate void __cs_fputs_delegate(string s, System.IO.Stream stream)
csfputs writes the string s to stream, without its trailing ’\0’. - csfopenappend
-
Type:
public delegate System.IO.Stream __cs_fopenappend_delegate(string path)
csfopenappend open the file path for writing at the end. - csfopenread
-
Type:
public delegate System.IO.Stream __cs_fopenread_delegate(string path)
csfopenread open the file path for reading. - csfopenwrite
-
Type:
public delegate System.IO.Stream __cs_fopenwrite_delegate(string path)
csfopenwrite open the file path for writing. - csfclose
-
Type:
public delegate void __cs_fclose_delegate(System.IO.Stream fp)
The csfclose function will flush and close the stream pointed to by fp. - csremove
-
Type:
public delegate void __cs_remove_delegate(string n)
csremove removes filename from the file system.
CoverageScanner writes the execution report (.csexe file) into file using the common C# file IO functions.
In some situations, for embedded systems for example, it is necessary to use an other way for recording it.
For this reason, CoverageScanner provides
CoverageScanner.__coveragescanner_set_custom_io which permits to replace the IO
functions used by CoverageScanner.__coveragescanner_save.
21.5 Controlling the instrumentation during the compilation
CoverageScanner offers the possibility to modify the coverage settings of some source code parts during the compilation.
This permits, for example, to exclude some source code from the coverage analysis.
21.5.1 C/C++ Pragma
CoverageScanner defines C/C++ pragmas which permits to control
during the compilation the generation of the instrumentation. All control commands
are handled in a stack.
The pragmas have the following syntax:
#pragma CoverageScanner ( string )
List of supported pragmas:
-
#pragma CoverageScanner(cov-on)
-
Enables code coverage instrumentation.
- #pragma CoverageScanner(cov-off)
-
Disables code coverage instrumentation.
- #pragma CoverageScanner(cov-hit)
-
Instruments using code coverage hit.
- #pragma CoverageScanner(cov-count)
-
Instruments using code coverage count.
- #pragma CoverageScanner(cov-branch)
-
Select the code coverage branch as instrumentation method.
- #pragma CoverageScanner(cov-decision)
-
Select the code coverage decision as instrumentation method.
- #pragma CoverageScanner(cov-condition)
-
Select the code coverage condition as instrumentation method.
- #pragma CoverageScanner(cov-partial-instrumentation)
-
Partial instrumentation of conditions and decisions.
- #pragma CoverageScanner(cov-full-instrumentation)
-
Full instrumentation of conditions and decisions.
- #pragma CoverageScanner(pop)
-
Restore the instrumentation option before the call of the last CoverageScanner pragma.
CoverageScanner defines C# extensions of the
#region keyword which permits to control
during the compilation the generation of the instrumentation.
The #region extension have the following syntax:
#region CoverageScanner ( string )
The keyword #endregion restores the generation options.
List of supported regions:
-
#region CoverageScanner(cov-on)
-
Enables code coverage instrumentation.
- #region CoverageScanner(cov-off)
-
Disables code coverage instrumentation.
- #region CoverageScanner(cov-hit)
-
Instruments using code coverage hit.
- #region CoverageScanner(cov-count)
-
Instruments using code coverage count.
- #region CoverageScanner(cov-branch)
-
Select the code coverage branch as instrumentation method.
- #region CoverageScanner(cov-decision)
-
Select the code coverage decision as instrumentation method.
- #region CoverageScanner(cov-condition)
-
Select the code coverage condition as instrumentation method.
- #region CoverageScanner(cov-partial-instrumentation)
-
Partial instrumentation of conditions and decisions.
- #region CoverageScanner(cov-full-instrumentation)
-
Full instrumentation of conditions and decisions.
21.6 Regular Expressions
Regular expressions are composed of items (see table tab:regexp_item for
the full list) and combining operators. These can be:
-
[…]: The brackets are used to define a set of characters.
For example, [123] corresponds to the characters
1, 2 or 3. It is possible to define a range
using the minus sign: [a-z] corresponds to all characters
between a and z.
[^…]: The caret defines a set of characters which should not match.
For example, [^0-9] corresponds to any character except a digit.
?: The question mark after a regular expression item makes it optional.
Example: ab? matches the string a or ab.
+: The plus operator makes it possible to repeat the regular expression item.
Example: ab+ matches every strings ab…b.
*: The star operator after a regular expression item signifies that the
item is optional and can be repeated.
Example: ab* matches every string ab…b and a.
|: The pipe operator specifies an alternative.
Example: a|b matches the character a or b.
(…): The parenthesis groups expressions into sub-expressions.
Example: (true)|(false) matches the string true or false.
- Regular Expression Items: The regular expression items are
ASCII or magic characters (See table tab:regexp_item for the complete list).
If a magic character needs to be used as an ASCII character,
it has to be escaped with a backslash (
\).
| Element | Description | Equivalence | Reverse Element |
^ | The caret marks the beginning of the string.
For example, ^c: will only match file names with an absolute path on the drive C:.
If you wish to match a literal ^ you must escape it by writing \^. | | |
$ | The dollar marks the end of the string.
For example \.cpp$ will match every C++ file name.
If you wish to match a literal $ you must escape it by writing \$. | | |
\< | Match the start of a word. | | |
\> | Match the end of a word. | | |
. | Any character | | |
\ | Escape character.
Example: \. corresponds to the character ’.’ and not any character | | |
\m | Alphanumeric character | [0-9a-zA-Z] | \M |
\a | Alphabetic character | [a-zA-Z] | \A |
\b | Blank character | [ \t] | \B |
\c | Control character | | \C |
\d | Digit | [0-9] | \D |
\g | Printable character except space | [] | \G |
\l | Lower-case character | [a-z] | \L |
\p | Printable character | | \P |
\n | Printable character except space or alphanumeric character | | \N |
\s | White-space characters
(space, form-feed , newline , carriage return , horizontal tab and vertical tab) | [ \f\n\r\t\v] | \S |
\u | Uppercase letter | [A-Z] | \U |
\x | Hexadecimal digits | [0-9a-fA-F] | \X |
\w | Alphanumeric character or underscore | [0-9a-zA-Z_] | \W |
Non ASCII Regular Expression Items
|
Chapter 22 Code Coverage of Libraries
22.1 Code Coverage of Static/Shared Libraries and DLL
During the linking operation, CoverageScanner includes all instrumentations
of the shared libraries (if these are compiled with CoverageScanner).
CoverageBrowser displays the code coverage of the complete application
(executable and its libraries) in one view.
To get an analysis of the code coverage of a library only,
it is necessary to compile the main application and exclude its sources from
the code coverage (by adding in the command line
--cs-exclude-regex=.*
for example. (see chap.
exclude-regex))
22.2 Code Coverage of Plugins/Manually Loaded Shared Libraries
CoverageScanner cannot handle the instrumentation of plugins (i.e. shared libraries loaded manually)
during the linking phase. In this case, the library must initialize and store itself the executions.
Therefore, the shared library needs to call __coveragescanner_filename
to set the name of the execution file during its initialization and
__coveragescanner_save to save the instrumentations when its becomes unloaded.
22.2.1 Code Coverage of Plugins Generated with Microsoft® Visual Studio®
The function DllMain is called on the initialization and
the termination of the DLL generated using Microsoft® Visual Studio®.
When the ’reason’ field is equal to DLL_PROCESS_ATTACH the function
__coveragescanner_filename should be called. To save the measures on exit the function
__coveragescanner_save shall be called when ’reason’ is DLL_PROCESS_DETACH.
Example:
1 extern "C"
2 BOOL WINAPI DllMain(HINSTANCE hInstance,
3 DWORD dwReason,
4 LPVOID /*lpReserved*/)
5 {
6 switch( dwReason )
7 {
8 case DLL_PROCESS_ATTACH:
9 #ifdef __COVERAGESCANNER__
10 /* Initialization of the CoverageScanner library. */
11 /* Replace "mylib" with your filename without extension */
12 __coveragescanner_filename("mylib");
13 #endif
14 ...
15 break;
16 case DLL_PROCESS_DETACH:
17 ...
18 #ifdef __COVERAGESCANNER__
19 /* Saves the execution report */
20 __coveragescanner_save();
21 #endif
22 break;
23 }
24 return TRUE;
25 }
22.2.2 Code Coverage of Plugins Generated with GNU gcc
The GNU compiler offers 2 attributes which permits to execute a function when a library becomes loaded or unloaded:
-
__attribute__ ((constructor)) my_init(void);
-
This attribute permits to call a function when the library is loaded.
Call the function
__coveragescanner_filename in the custom
initialization function of the library.
- __attribute__ ((destructor)) my_fini(void);
-
This attribute permits to call a function when the library is unloaded.
Call the function
__coveragescanner_save on the termination
of the library.
Example:
1 static void plugin_load(void) __attribute__ ((constructor)) ;
2 static void plugin_unload(void) __attribute__ ((destructor)) ;
3
4 static void plugin_load(void)
5 {
6 #ifdef __COVERAGESCANNER__
7 /* Initialization of the CoverageScanner library. */
8 /* Replace "mylib" with your filename without extension */
9 __coveragescanner_filename("mylib");
10 #endif
11 ...
12 }
13
14 static void plugin_unload(void)
15 {
16 ...
17 #ifdef __COVERAGESCANNER__
18 /* Saves the execution report */
19 __coveragescanner_save();
20 #endif
21 }
Chapter 23 Test Suite and TestCocoon
23.1 Execution Name And Status
Test suites are able to provide to CoverageBrowser the name of the test and
also the status of their execution (passed or failed).
Two methods are possible:
-
Using the functions
__coveragescanner_testname and
__coveragescanner_teststate can be used to specify the test name and its status.
This is particularly useful for unit tests in which the test framework is compiled
into the application to test.(see chap. executionreportname)
- Writing directly into the .csexe file this information. (see below)
The .csexe file is a simple text file on which is it possible to append additional lines
to extend the information provided to CoverageBrowser.
To set the name of a test simply add before executing it the following line:
§name of the test\n
or
*name of the test\n
The character * or § must be the first character of the line. The name of the test is placed directly after and a is terminated with a carriage return.
To set the status of a test simply add after executing it the following line:
!status\n
The character ! must be the first character of the line. The status of the test is placed directly after and a is terminated with a carriage return. The status can be one of the following strings:
-
"PASSED"
- indicates that the test was successfully executed.
- "FAILED"
- indicates that the test was not successfully passed.
- "CHECK_MANUALLY"
- indicates that it was not possible to determinate if the test was successfully executed.
Example: the following batch file execute the test First Test and set the status of the execution to CHECK_MANUALLY.
echo §First Test >> myapp.csexe
myapp
echo !CHECK_MANUALLY >> myapp.csexe
23.2 Unit Testing
CoverageBrowser import execution results for each object which are part of an application.
This mean that, if an unit test uses the same objects as these for generating the application, CoverageBrowser is able
to import the execution result of the unit test and merge it into the code coverage of the compiled application.
Example:
An application is composed to 3 files:
-
app.cpp
- This file contains the
main() function of the application.
- library.cpp
- This file contains a set of functions called in
app.cpp.
- testlibrary.cpp
- This contains the test code of the functions of the file
library.cpp.
testlibrary.cpp have its own main() function.
To generate the application:
cscl app.cpp /Foapp.obj
cscl library.cpp /Folibrary.obj
cscl library.obj app.obj /Feapp.exe
To generate the unit test:
cscl testlibrary.cpp /Fotestlibrary.obj
cscl library.obj testlibrary.obj /Fetestlibrary.exe
The execution of testlibrary.exe generates the execution report testlibrary.exe.csexe.
This report can be loaded in the measurement database app.exe.csmes. In this case, only the
code coverage analysis of the file library.cpp is loaded. (the coverage analysis of the file
app.cpp indicates that no source line are executed).
23.3 Test Framework Support
CppUnit1 is a unit test framework for C++.
This environment can easily be adapted to get the code coverage from each unit test.
Simply proceed as follows:
-
Call
__coveragebrowser_install() in the main() function.
- Write a CppUnit TestListener class which records the code coverage report upon every unit test
completion. The listener should set the name (using
__coveragescanner_testname())
and clear the instrumentation (using __coveragescanner_clear()) before executing a test item (class member startTest()) to ensure to get only the coverage data
of the concerned test. When an test item is executed, the instrumentation and the execution status
should be saved (using __coveragescanner_teststate() and __coveragescanner_save()) in
the class member endTest().
The class CoverageScannerListener give an implementation example.
- Add this listener in the test manager of CppUnit (class
CPPUNIT_NS::TestResult).
In the example below
CoverageScannerListener coveragescannerlistener;
controller.addListener( &coveragescannerlistener );
- Compile the unit test using CoverageScanner.
QTestLib2 is a unit test framework for the Qt Library.
This environment can easily be adapted to get the code coverage from each unit test.
Simply proceed as follows:
-
Call
__coveragebrowser_install() in the main() function.
- Write a
QObject derived class called TestCoverageObject which records the code coverage report upon every unit test
completion.
- Instead of inheriting from
QObject, make all your test cases inheriting from TestCoverageObject.
TestCoverageObject class provide its own init() and cleanup() slot,
which use the CoverageScanner API to save the code coverage report. If these slots are
also declared in the test case class, it is necessary to rename it in initTest() and cleanupTest().
- Compile your project with code code coverage enabled.
TestCoverageObject header:
TestCoverageObject source:
CxxTest3 is a unit test framework for C++.
This environment can easily be adapted to get the code coverage from each unit test.
Simply proceed as follows:
-
Call
__coveragebrowser_install() in the main() function.
- Create a CxxTest TestListener class called
CoverageScannerListener by subclassing an existing listener (in the
example bellow: ErrorPrinter). It will record the code coverage
report upon every unit test completion. The listener should set the name
(using __coveragescanner_testname())
and clear the instrumentation (using __coveragescanner_clear())
before executing a test item (class member enterTest()) to ensure to
get only the coverage data
of the concerned test. When an test item is executed, the instrumentation and the execution status
should be saved (using __coveragescanner_teststate() and __coveragescanner_save()) in
the class member leaveTest().
Finally, all test failure members of this class need to be reimplemented to record the test failure.
- In the
main() function call the run() function of CoverageScannerListener
instead of CxxTest::ErrorPrinter().run().
- Compile the unit test using CoverageScanner.
Chapter 24 CoverageScanner Adaptation to a Tool Suite
CoverageScanner can be adapted to any compiler using a profile.
This file is called ’<tool name>.cspro’ and must be placed in the
TestCocoon installation directory.
For each profile the CoverageScanner executable should be renamed to ’cs<tool name>’:
in this case CoverageScanner directly loads the profile for ’<tool name>’.
The command line option --cs-compiler
makes it possible to explicitly to select a profile.
It is possible to rename the CoverageScanner executable to the same name as the native compiler1.
In this case CoverageScanner will work exactly like the native tool, and the code coverage analysis will only be activated when command line option --cs-on is used.
In order to call the native tool, its location must be in the PATH
environment variable after the location of CoverageScanner.
The profile permits CoverageScanner:
A profile file can contain:
-
Comments
- comments must start with a # character at the
beginning of a line and ends at the end of the line.
- Global parameters
- parameters are defined with the following syntax:
<item>=<value>
Only one definition per line is allowed.
- Parameters for a specific architecture
- parameters for a specific architecture are defined with the following syntax:
<item>[<architecture>]=<value>
Only one definition per line is allowed and the definition must be placed after the global parameter definition.
| Item | Type | Description |
| ARCHITECTURE | string | List of command line arguments which specify the architecture used during the compilation.
This parameter should be placed in the first lines of the profile. |
| ARCHITECTURE_APPEND | YES/NO/ALLOW | If set, the argument of the command line option, which defines the architecture,
is directly appended
(no space characters are placed between the option and the arguments). |
Profile Parameters for Architecture Settings
|
| Item | Type | Description |
| COVERAGESCANNER_COVERAGE_ON | regular expression | Regular expression which activate the code coverage analysis (equivalent to --cs-on) if this expression match on a command line argument. |
Profile Parameters for Instrumentation Settings
|
| Item | Type | Description |
| PREPROCESSOR_HIDE_OPTION_NO_ARG | string | List of single options (without arguments) which should not
be transmitted to the native preprocessor. |
| PREPROCESSOR_HIDE_OPTION_ONE_ARG | string | List of options with one argument which should not be
transmitted to the native preprocessor. |
| PREPROCESSOR_HIDE_OPTION_ONE_ARG_APPEND | YES/NO/ALLOW | If set, the argument of the options to hide is directly appended
(no space characters are placed between the option and the arguments). |
| PREPROCESSOR_KEEP_OPTION_ONE_ARG | string | List of options with one argument which must be
transmitted to the native preprocessor. |
| PREPROCESSOR_KEEP_OPTION_ONE_ARG_APPEND | YES/NO/ALLOW | If set, the argument of the options which must be transmitted is directly appended
(no space characters are placed between the option and the arguments). |
| PREPROCESSOR_DEFINE_OPTION | string | Preprocessor command line option which permits to
enter C/C++ defines. (ex: -D) |
| PREPROCESSOR_DEFINE_OPTION_APPEND | YES/NO/ALLOW | Allows appending the preprocessor defines just after
its command line option string. (without spaces, ex: -DNDEBUG) |
| PREPROCESSOR_DEFINE_SEPARATOR_OPTION | string | Separator of the define list. For example, if set to ,,
CoverageScanner will detect the defines DEF1 and DEF2 when parsing the string DEF1,DEF2. |
| PREPROCESSOR_CMD | string | Preprocessor command line. CoverageScanner does only analyse
preprocessed files. The command generated the C/C++ file
used for the code coverage analysis.
The following variables are available:
-
$TMP1$…$TMP9$
-
Temporary files names. The temporary files are removed
on exit.
- $OPTIONS$
-
Preprocessing options. The preprocessing option are extracted
from the command line arguments and contains
the list of includes, defines, etc…
- $TOOL$
-
Compiler command (TOOL variable).
- $PROFILE_PATH$
-
Path of the profile file.
- $SOURCE$
-
Source file name.
- $OUTPUT$
-
Destination file. If not present in the command line, the standard output is used.
The preprocessor output is stdout.
If this parameter is omitted in the configuration, the preprocessor step is skipped.
The preprocessor command must set the define __COVERAGESCANNER__ to 1.
(ex: $TOOL$ $OPTIONS$ -D__COVERAGESCANNER__=1 -E $SOURCE$) |
Profile Parameters for Preprocessor Settings
|
| Item | Type | Description |
| LINKER_HIDE_OPTION_NO_ARG | string | List of single options (without arguments) which should not
be transmitted to the native linker. |
| LINKER_HIDE_OPTION_ONE_ARG | string | List of options with one argument which should not be
transmitted to the native linker. |
| LINKER_HIDE_OPTION_ONE_ARG_APPEND | YES/NO/ALLOW | If set, the argument of the options to hide is directly appended
(no space characters are placed between the option and the arguments). |
| OBJ_EXT | string | List of extension for object files separated with a semi-column. (ex: .obj) |
| DYN_LIB_EXT | string | List of extensions for dynamic libraries separated with a semi-column. (ex: .dll) |
| STATIC_LIB_EXT | string | List of extensions for static libraries separated with a semi-column. (ex: .lib) |
| UNIX_LIBRARY_NAME | YES/NO | The library name follows the Unix standard. |
| LINK_LIBRARY_OPTION | string | Link option which permits to select libraries (ex:-l). |
| LINK_LIBRARY_OPTION_APPEND | YES/NO/ALLOW | Append the library directly after the link option string (ex: -lfoo)
if LINK_LIBRARY_OPTION_APPEND is set. |
| LINK_OUTPUT_OPTION | string | Linker output option (ex:-o) |
| LINK_OUTPUT_OPTION_APPEND | YES/NO/ALLOW | Append the linker output file directly after the option string (without spaces, ex: -ofoo.o)
if LINK_OUTPUT_OPTION_APPEND is set. |
| LINK_OUTPUT_DEFAULT | string | Linker output default filename.
The following variable is available:
-
$TMP1$…$TMP9$
-
Temporary files names. The temporary files are removed
on exit.
- $BASENAME_SRC$
-
Base name of the the first source file.
The base name is the filename without extension.
(ex: $BASENAME_SRC$.exe) |
| DEFAULT_LIB_PATH | string | List of directories which contains the shared libraries (ex: /usr/library;/usr/share/library). |
| DLL_OPTION | string | Linker command line option which permits to generate a shared library or a DLL (ex: /DLL). |
| DLL_OUTPUT_STATIC_LIB | string | Static library (associated with the DLL) output file name (ex: /IMPLIB:foo.lib). |
| DLL_OUTPUT_STATIC_LIB_APPEND | YES/NO/ALLOW | Append the static library (associated with the DLL) output file directly after the option string (without spaces, ex: /IMPLIB:foo.lib)
if DLL_OUTPUT_STATIC_LIB_APPEND is set. |
| LIBRARY_PATH_OPTION | string | Link option which permits to add additional directories to the path of directories (ex:-L) |
| LIBRARY_PATH_OPTION_APPEND | YES/NO/ALLOW | Append the directory name directly after the option string (ex: -L/foo)
if LIBRARY_PATH_OPTION_APPEND is set. |
| AR_COMMAND_FORMAT_OPTION | YES/NO | The GNU librarian (ar) has a specific command line syntax which is
supported when this option is set. |
| STDIN_MRI_SCRIPT_OPTION | list | This option indicates that an MRI script is used to generate a library.
The script is provided by the standard input. |
| GENERATE_COVERAGESCANNER_LIBRARY | YES/NO | If set, the CoverageScanner library is generated during the linking operation.
This should be disabled when generating static libraries. |
| SKIP_GENERATE_COVERAGESCANNER_LIBRARY_OPTION | string | Permits to skip the generation of CoverageScanner library if a specific option appears in the command line. |
Profile Parameters for Linker Settings
|
| Item | Type | Description |
| COMPILER_HIDE_OPTION_NO_ARG | string | List of single options (without arguments) which should not
be transmitted to the native compiler. |
| COMPILER_HIDE_OPTION_ONE_ARG | string | List of options with one argument which should not be
transmitted to the native compiler. |
| COMPILER_HIDE_OPTION_ONE_ARG_APPEND | YES/NO/ALLOW | If set, the argument of the options to hide is directly appended
(no space characters are placed between the option and the arguments). |
| TOOL | string | Native compiler/linker command (example: gcc).
The following variables are available:
-
$PROFILE$
- Profile name without extension.
|
| IGNORE_EXT | string | List of file extension, separated with a semi-column, of files to ignore. |
| C#_EXT | string | List of extension for C# files separated with a semi-column. (ex: .cs) |
| C_EXT | string | List of extension for C files separated with a semi-column. (ex: .c) |
| CPP_EXT | string | List of extension for C++ files separated with a semi-column. (ex: .cpp;.cxx) |
| CPP_LANGUAGE_OPTION | string | List of command line options which are switching the compiler in C++ mode. |
| C_LANGUAGE_OPTION | string | List of command line options which are switching the compiler in C mode. |
| LANGUAGE_SELECTION_OPTION | string | List of command line options which permits to select the computing language (C, or C++). |
| LANGUAGE_SELECTION_OPTION_APPEND | YES/NO/ALLOW | Append the selected language directly after the option string. |
| LANGUAGE_SELECTION_OPTION_C_KEYWORD | string | List of arguments of the language selection command line option which force the switching in C mode. |
| LANGUAGE_SELECTION_OPTION_CPP_KEYWORD | string | List of arguments of the language selection command line option which force the switching in C++ mode. |
| COMPILER_CMD | string | Compiler command line.
The compiler command line is used to generate the CoverageScanner library
during the linking phase.
The following variables are available:
-
$TMP1$…$TMP9$
-
Temporary files names. The temporary files are removed
on exit.
- $COMPILER$
- Compiler command (COMPILER variable).
- $SOURCE$
- Source file name.
- $DESTINATION$
- Destination file name.
- $LIBGEN$
- Contains of the command line option --cs-libgen.
(ex: $COMPILER$ -c $SOURCE$ -o $DESTINATION$) |
| COMPILE_OPTION | string | Compile command line option. (ex: -c) |
| COMPILER_OUTPUT_OPTION | string | Compiler output option. (ex: -o) |
| COMPILER_OUTPUT_OPTION_APPEND | YES/NO/ALLOW | Append the compiler output directly after the option string (without spaces, ex: -ofoo.o)
if COMPILER_OUTPUT_OPTION_APPEND is true. |
| COMPILER_OUTPUT_DEFAULT | string | Compiler output default filename.
The following variable is available:
-
$TMP1$…$TMP9$
-
Temporary files names. The temporary files are removed
on exit.
- $BASENAME_SRC$
- Base name of the the first source file.
The base name is the filename without extension.
(ex: $BASENAME_SRC$.obj) |
| FUNCTION_ATTRIBUTE | string | FUNCTION_ATTRIBUTE sets additional compiler attribute to each function
of the CoverageScanner library. |
| DLL_EXPORT | string | DLL_EXPORT contains the compiler attribute
which permits to export a symbol from a DLL/shared library. |
| DLL_IMPORT | string | DLL_IMPORT contains the compiler attribute
which permits to import a symbol from a DLL/shared library. |
| FORCE_DLL_EXPORT | YES/NO | FORCE_DLL_EXPORT permits to force the usage of DLL_EXPORT attribute
during the linking phase instead of DLL_IMPORT attribute. |
| FORCE_DLL_EXPORT_OPTION | string | FORCE_DLL_EXPORT_OPTION permits to force the usage of DLL_EXPORT attribute
when a appears in the command line. |
Profile Parameters for Compiler Settings
|
| Item | Type | Description |
| CSEXE_FOPEN | string | ’fopen function used by the generation of the execution report file. |
| CSEXE_FCLOSE | string | ’fclose function used by the generation of the execution report file. |
| CSEXE_FPUTS | string | fputs function used by the generation of the execution report file. |
| CUSTOM_SETUP | NONE/POSIX/MS/GNU/MSCE/C++ |
-
NONE
-
if set to NONE the function __coveragescanner_install
will not be provided by
CoverageScannerṪhis parameter should be set to NONE on
embedded systems which do not provide the functions
signal() and atexit().
The code coverage information is saved only when __coveragescanner_save() is called.
- POSIX
-
CoverageScanner provides a function
__coveragescanner_install, which
installs a handler which saves the execution report when the application terminates.
The handler is installed using
POSIX functions (signal() and atexit()).
If __coveragescanner_install() is not called, the code coverage information
is only saved when __coveragescanner_save() is called.
- GNU
-
This is similar to the
POSIX setting except that, if __coveragescanner_install
is not called, a default handler is used which saves
the code coverage data in the file coverage.csmes on a normal application exit.
If __coveragescanner_install() is not called, the code coverage information
is not saved on abnormal exit (crash, software interruption, …).
- MS
-
Same as
GNU but for Microsoft® Visual Studio® compiler.
- C++
-
Install a handler written in C++ which saves the code coverage data
in the file
coverage.csmes upon normal application exit.
CoverageScanner provides a function
__coveragescanner_install, which
only changes the name of the destination file.
- MSCE
-
Same as
C++ but for Microsoft® eMbedded Visual C++® compiler.
|
Profile Parameters for Custom IO
|
| Item | Type | Description |
| HIDE_OPTION_NO_ARG | string | List of single options (without arguments) which should not
be transmitted to the native tool (compiler or linker).
(ex: -Yd;/Yd for disabling the precompiled headears on
Microsoft® Visual Studio®) |
| HIDE_OPTION_ONE_ARG | string | List of options with one argument which should not be
transmitted to the native tool (compiler or linker).
(ex: -Yl;-Yc;-Yu;-YX;/Yl;/Yc;/Yu;/YX for disabling the precompiled
headears on Microsoft® Visual Studio®) |
| HIDE_OPTION_ONE_ARG_APPEND | YES/NO/ALLOW | If set, the argument of the options to hide is directly appended
(no space characters are placed between the option and the arguments). |
| PDB_EXT | string | List of extension for debug information files separated with a semi-column. (ex: .pdb) |
| PDB_OUTPUT_OPTION | string | Command line option for specifying the debug information file.
(ex: PDB_OUTPUT_OPTION=/Fd) |
| PDB_OUTPUT_OPTION_APPEND | YES/NO/ALLOW | If set, the command line option for specifying the debug information file is
directly appended to the file name (no space characters are placed
between the option and the arguments). |
| SBR_EXT | string | List of extension for symbol browser files separated with a semi-column. (ex: .sbr) |
| SBR_OUTPUT_OPTION | string | Command line option for specifying the symbol browser information file.
(ex: SBR_OUTPUT_OPTION=/Fr;/FR) |
| SBR_OUTPUT_OPTION_APPEND | YES/NO/ALLOW | If set, the command line option for specifying the symbol browser information file is
directly appended to the file name (no space characters are placed
between the option and the arguments). |
| RESPONSE_FILE_EXT | string | List of file extensions for the response file. |
| RESPONSE_FILE_OPTION | string | Command line option for specifying the response file.
(ex: RESPONSE_FILE_OPTION=@) |
| RESPONSE_FILE_OPTION_APPEND | YES/NO/ALLOW | If set, the command line option for specifying the response file is
directly appended to the file name (no space characters are placed
between the option and the arguments). |
| CODE_STYLE | C++/C# | Language supported. |
| EXIT_FUNCTIONS | string | List of functions which causes an application exit.
(ex: EXIT_FUNCTIONS=abort;exit) |
| DEACTIVATE_COVERAGESCANNER | YES/NO | Disable CoverageScanner globally if set to YES. |
| DEACTIVATE_COVERAGESCANNER_OPTION_NO_ARG | string | List of command line option which deactivates CoverageScanner.
(ex: DEACTIVATE_COVERAGESCANNER_OPTION_NO_ARG=-M;-MM;-MD;-MMD) |
| DEACTIVATE_COVERAGESCANNER_OPTION_ONE_ARG | string | List of command line option with one argument which deactivates CoverageScanner. |
| DEACTIVATE_COVERAGESCANNER_OPTION_ONE_ARG_APPEND | YES/NO/ALLOW | If set, the command line option which disables CoverageScanner is
directly followed by an argument (no space characters are placed
between the option and the arguments). |
| COVERAGESCANNER_LIBRARY_OBJECT | string | Name of the CoverageScanner object containing its library code.
On Unix, its default value is __cs_library.o. On Microsoft® Windows, its default value is __cs_library.obj. |
| ERROR_FORMAT | string | Format of the errors. The following items are parsed:
-
%m
- Error message.
- %f
- File name.
- %l
- Line.
- %c
- Column.
|
| ADDITIONAL_ARGUMENT_SEPARATOR | string | Additional character used as separator for the command line arguments.
(ex: ADDITIONAL_ARGUMENT_SEPARATOR=, for VisualDSP++ compiler) |
Miscellaneous Profile Parameters
|