Project

General

Profile

CodeCoverage » History » Revision 7

Revision 6 (Davide Pesavento, 09/11/2016 11:35 AM) → Revision 7/8 (Davide Pesavento, 10/11/2016 03:35 AM)

Code Coverage 
 ============ 

 This guide has instructions to generate code coverage report on your local machine in HTML or plain text. 

 ## Install required command-line tool (gcovr) and configure the project to generate temporary profiling files: 

 1. Install `gcovr` ``gcovr`` on your machine: `sudo machine. <pre><code>sudo easy_install gcovr` gcovr</code></pre> 

 2. When configuring, add option "--with-coverage" (e.g., (e.g. ``./waf configure --with-tests --with-coverage``). If the build or running unit tests requires other packages, all the packages should be configured with the option "--with-coverage". For example, ``ndn-cpp-dev`` requires ``ndnd-tlv`` to run its unit tests, then when configuring ``ndn-cpp-dev``, we should use "``./waf configure --with-tests --with-coverage``", and when configuring ``ndnd-tlv``, we should use "``./waf configure --with-coverage``". 

 ## To create code coverage report in HTML format, follow these steps: 

 3. After building the project and running unit tests, use `gcovr` ``gcovr`` to generate detailed code coverage report in html format. The following is a one-liner: 
 `mkdir <pre><code>mkdir build/coverage; gcovr -r . --object-directory=build --object-directory=build/ --html --html-details -o build/coverage/coverage.html` build/coverage/coverage.html</code></pre> 

 4. Use any browser to open ``build/coverage/coverage.html`` to see the code coverage report. 

 ## To create code coverage report in plain text format, follow these steps: 

 3. After building the project and running unit tests, use `gcovr` ``gcovr`` to generate detailed code coverage report in plain text. The command is: 
 `gcovr <pre><code>gcovr -r . --object-directory=build --object-directory=build/ --html-details -o build/coverage.txt` build/coverage.txt</code></pre> 

 4. Use any plain text editor/reader to open ``build/coverage.txt`` to see the code coverage report. 

 ## To view the detailed code coverage report on Jenkins for builds triggered by Gerrit 

 1. Click on the build link that Jenkins posted as a comment on Gerrit. 

 2. Click on the label "code-coverage" under "Configurations". 

 3. Click on "Cobertura Coverage Report" to see the detailed code coverage report for the build.