QA:CodeCoverage

From MozillaWiki
Jump to navigation Jump to search

What is the progress so far!!

Results and Findings

How to instrument the Mozilla Firefox Browser

This is what you do to instrument the Mozilla Firefox browser.

Create a .mozconfig-gold file in your home directory with the following statements


      export CFLAGS="-fprofile-arcs -ftest-coverage"
      export CXXFLAGS="-fprofile-arcs -ftest-coverage"
      export LDFLAGS="-lgcov -static-libgcc"
      export EXTRA_DSO_LDFLAGS="-lgcov -static-libgcc"
      ac_add_options --enable-application=browser
      mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../mozcentral-dbg
      ac_add_options --enable-debug
      ac_add_options --enable-tests
      ac_add_options --enable-mochitest
      ac_add_options --disable-optimize
      mk_add_options MOZ_MAKE_FLAGS="-j3"
      mk_add_options AUTOCONF=autoconf2.13


For more detailed build options and prerequisites, please visit the following URL

https://developer.mozilla.org/en/Configuring_Build_Options

Checkout the source code from the mozilla-central code repository.


        rm -rf /home/user/src
        rm -rf /home/user/mozcentral-dbg
        hg clone http://hg.mozilla.org/mozilla-central/ src
        cd src
        cp ../.mozconfig-gold .mozconfig


TIP: Save the above commands into a file named ‘startover’ and make it executable.

TIP:Change the ‘user’ part to your login account name.



The standard build command to build instrumented mozilla firefox is


     make -f client.mk build



See http://www.xulplanet.com/tutorials/xulqa/q_prefs.html or https://bugzilla.mozilla.org/show_bug.cgi?id=440777 for details.


~/mozcentral-dbg/_tests/testing/mochitest and execute the following command.


   python runtests.py  to execute mochitest suite.
   python runtests.py --chrome --browser-chrome to execute chrome tests.
   python runtests.py --a11y to run accessibility tests


Please keep the focus on the Firefox browser , when running your tests, at all times or else your tests will fail.


In order to run jstests, please go to ~/src/js/tests and execute the following commands


   ./jsDriver.pl -e smdebug -L lc2 -L lc3 -L spidermonkey-n-1.9.1.tests -s ~mozcentral-dbg/dist/bin/js
   ./jsDriver.pl -e smdebug -L lc2 -L lc3 -L spidermonkey-n-1.9.1.tests -s ~mozcentral-dbg/dist/bin/js -o '-j’



After you are done with the test runs, you will end up with a bunch of *.gcda and *.gcno files in your build directory.


Now, come back into your home directory and execute the following command


      lcov -c -i -d mozcentral-dbg -o app.info


The lcov tool will go through the entire build directory and generates an app.info file in your home directory


TIP: If you don’t know what is an ‘lcov’ tool, please feel free to ‘google’ the term.


Then, execute the following command


       genhtml app.info

If by any chance the above command fails to complete, use the following option.

       genhtml --no-source app.info


The resulting index.html is the landing page for all your code coverage data for the C/C++ code in the Firefox browser.


HINT: Look at the advanced tweaks section on how to modify, geninfo, genhtml scripts in order to generate full code coverage reports.


When we run the instrumented Firefox, there is now a "JSCoverage" menu in the "Tools" menu.


Tools -> JSCoverage -> View Coverage loads the jscoverage.html file


Tools -> JSCoverage -> Store Coverage saves the coverage data into a directory named "./jscoverage-report.

Scripts and Works around required

How to consolidate / merge results and generate graphs