Compare Revisions

Measuring Code Coverage on Firefox

Change Revisions

Revision 330077:

Revision 330077 by decoder on

Revision 330089:

Revision 330089 by decoder on

Title:
Measuring Code Coverage on Firefox
Measuring Code Coverage on Firefox
Slug:
Measuring_Code_Coverage_on_Firefox
Measuring_Code_Coverage_on_Firefox
Content:

Revision 330077
Revision 330089
n7    <h3>n7    <h3 id="What_is_Code_Coverage.3F">
n13    <h4>n13    <h4 id="What_Code_Coverage_tells_us.2C_and_what_it_doesn't">
n28    <h3>n28    <h3 id="C.2FC.2B.2B_Code_Coverage_on_Firefox">
n34    <h4>n34    <h4 id="Coverage_Reports_for_Automated_Tests">
n57    <h4>n57    <h4 id="Creating_your_own_Coverage_Build">
n61      TBDn61      On Linux and Mac OSX it is straightforward to generate a <e
 >m>gcov</em> build using GCC. Adding the following lines to your <
 >code>.mozconfig</code> file should be sufficient:
tt63    <pre>
64<span class="author-p-975"># Enable code coverage</span>
65<span class="author-p-975">export CFLAGS="-fprofile-arcs -ftest-c
 >overage"</span>
66<span class="author-p-975">export CXXFLAGS="-fprofile-arcs -ftest
 >-coverage"</span>
67<span class="author-p-975">export LDFLAGS="-fprofile-arcs -ftest-
 >coverage -lgcov"</span>
68</pre>
69    <div class="note">
70      <p>
71        <strong>Note:</strong> On Mac OSX, builds are typically d
 >one with Clang which did not support gcov until recently. I have 
 >not yet tested if and how well the Clang gcov support works by no
 >w, so if you are testing this, please update this section with th
 >e results.
72      </p>
73    </div>
63    <h4>74    <p>
75      You can then create your build as usual. Once the build is 
 >complete, you can run any tests/tools you would like to run and t
 >he coverage data is written to special files. In order to view/pr
 >ocess this data, we recommend using the <em>lcov</em> tool, a too
 >l to manage and visualize gcov results:
76    </p>
77    <pre>
78# Change to the objdir of your build
79cd objdir
80 
81# See the Warning box below why this might be required
82find . -name jchuff.gcda -delete
83 
84# This collects (-c) all the coverage information from the curren
 >t directory (-d .) and writes it to <span class="author-p-975">co
 >verage</span>.info
85<span class="author-p-975">lcov -c -d . -o coverage.info</span>
86 
87# This creates HTML data from the <span class="author-p-975">cove
 >rage</span>.info file we just created, and writes HTML files to t
 >he coverage/ subdirectory.
88<span class="author-p-975">genhtml -o </span><span class="author-
 >p-975">coverage</span><span class="author-p-975"> </span><span cl
 >ass="author-p-975">coverage</span><span class="author-p-975">.inf
 >o</span>
89</pre>
90    <p>
91      Once you have created HTML output from the coverage data, y
 >ou can easily view it by pointing your browser to the output dire
 >ctory. The lcov tool also allows you to reset all coverage data t
 >o do multiple runs, combine several coverage files and various ot
 >her tasks. For more information see <code>man lcov</code> and <co
 >de>man genhtml</code>.
92    </p>
93    <div class="warning">
94      <p>
95        <strong>Important:</strong> The lcov tool often seems to 
 >hang when processing coverage information from <code><strong>jchu
 >ff.gcda</strong></code>. I suspect there is some inefficient part
 > of the code exercised heavily just by this file. In order to cre
 >ate coverage information, it might be necessary to delete this fi
 >le and to do without it's coverage data.
96      </p>
97    </div>
98    <h4 id="Obtaining_Coverage_Data_from_a_Try_Push">

Back to History