Oracle® Solaris Studio 12.4: Overview

Exit Print View

Updated: December 2014
 
 

uncover Tool for Measuring Code Coverage

The uncover utility is a command-line tool for measuring code coverage. The tool shows you which areas of your application code are exercised when the application is run, and which are not exercised and not covered by testing. Uncover produces a report with statistics and metrics to help you determine which functions should be added to the test suite to ensure that more of the code is covered during testing.

uncover works with any binary that is built with an Oracle Solaris Studio compiler, and works best when the binary is built without optimization. Compiling a binary with –g enables uncover to display source code and line-number information while reporting on code coverage.

After compiling the binary, you run the uncover command on the binary. uncover creates a new binary with added instrumentation code and also creates a directory named binary.uc that will contain the code coverage data for your program. Each time you run the instrumented binary, code coverage data is collected and stored in the binary.uc directory.

You can display the experiment data in Performance Analyzer, or generate the uncover report as HTML and display it in your web browser.

The following example shows how to prepare, instrument, and run an executable to generate an uncover report for examining code coverage. The optimized binary is test and is replaced by the instrumented binary also named test.

% cc -g -O2 test.c -o test
% uncover test
% test

The experiment directory is test.uc and contains the data that is generated when the instrumented test runs. The test.uc directory also contains a copy of the uninstrumented test binary.

To view the experiment in Performance Analyzer:

% uncover test.uc

To view the experiment in an HTML page in a browser:

% uncover -H test.html test.uc

For more information, see the uncover(1) man page and the Oracle Solaris Studio 12.4: Discover and Uncover User’s Guide .