Running code coverage in headless mode

Headless mode runs code coverage without having a UI open. Headless mode is ideal for environments in which a UI workbench is not installed or from the command line or as part of a script.

About this task

You can run code coverage for any compiled language application that you can debug from the command line or as part of a script. There are two modes in which you can run headless code coverage:

  1. Running as a daemon that is listening for a connection (use with a remote debugging engine that is using the specified port). For more information, see "Running code coverage in headless mode by using a daemon."
  2. Operating directly on a program that is compiled with debugging information that is specified as an argument (One Shot mode).
    Note: One Shot mode is available only for AIX® and Linux, not on z Series.
    $ codecov testProg
Note: The results are stored by date in the root of the user's home directory under the CC folder.
The syntax diagram for the codecov command is shown below:
>>-codecov--+----------------------------------------------------------------------------------------------------------------+--><
            |                                                                                                                |
            + -stopdaemon=<PORT_NUMBER> -------------------------------------------------------------------------------------+
            |                                                                                                                |
            + <PROGRAM_NAME>  <PROGRAM_PARAMETERS>  -optionsfile=<PATH> --+                                                  |
            |                                                             |                                                  |
            |                                     .------------------.    |                                                  |
            |                                     v                  |    v                                                  |
            + -startdaemon  -optionsfile=<PATH> --+--------------------------+--------------------------------------------+--+
            |                                     |                  |       |                                            |  |
            |                                     + -singleconnect --+       + -output=<PATH> ----------------------------+  |
            |                                     |           	     |       |                                            |  |
            |                                     + -localonly ------+       + -cclevel=<"LINE" | "FUNCTION" | "LEVEL"> --+  |
            |                                                                |                                            |  |
            |                                                                + -prevresultpath=<"NONE" | "PREV" | PATH> --+  |
            |                                                                |                                            |  |
            |                                                                + -reportformat=<"HTML" | "NONE"> -----------+  |
            |                                                                |                                            |  |
            |                                                                + -savesource -------------------------------+  |
            |                                                                |                                            |  |
            |                                                                + -startupcommandlist=<PATH> ----------------+  |
            |                                                                |                                            |  |
            |                                                                + -zipresult --------------------------------+  |
            |                                                                |                                            |  |
            |                                                                + -port=<PORT_LIST> -------------------------+  |
            |                                                                                                                |  
            + -help ---------------------------------------------------------------------------------------------------------+  
                                           
Options list
Format: codecov [options] [program_name] [program_parameters]
program_name
The full path of the program to run code coverage on.
Note: One Shot mode is only available on AIX and Linux, not on Z Series.
program_parameters
The parameters for the program.
Note: One Shot mode is available only on AIX and Linux, not on Z Series.
-startdaemon
Start in daemon mode and wait for connections.
-stopdaemon=port
Stop the daemon that is listening on the port.
-cclevel=cc_level
Specify the code coverage level (either "LINE", "FUNCTION" or "MODULE").
-prevresultpath="NONE" | "PREV" | path
Specify the path of the previous result file.
-reportformat="HTML" | "NONE"
Generate an HTML report if the report format is HTML.
-singleconnect
Exit after a single daemon connection (must use with -startDaemon).
-localonly
The daemon accepts only connections from the localhost.
startupcommandlist=path
Specifies a file that contains commands that are sent to the debugger engine at startup.
-savesource
Saves the source with the results.
-optionsfile=path
Read command arguments from the specified options file.
-tag="text"
Specify a tag, for example, a test-case ID, to be associated with the code coverage results.
-zipresult
The results directory is compressed into a compressed file with the same base name as the results directory.
-port=port_list
The port number, port list (port,port) or port range (port-port) used by the debug daemon.
-help
Print the help screen.

Feedback