183
edits
Mnandigama (talk | contribs) |
Mnandigama (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
<br> | |||
== < | == <font color="GREEN">What is the progress so far!!</font> == | ||
We have completely instrumented Mozilla Firefox , both C/C++ portions and JavaScript portions, twice and generated code coverage results. | We have completely instrumented Mozilla Firefox , both C/C++ portions and JavaScript portions, twice and generated code coverage results. | ||
Results would be discussed in a separate section. | Results would be discussed in a separate section. | ||
Using automated test suites, Mochitest, XPCShell, JSTest, Chrome, Browser-Chrome, RefTest , we got approximately 55% code coverage for C/C++ portion and 50% coverage on the JavaScript portion. | Using automated test suites, Mochitest, XPCShell, JSTest, Chrome, Browser-Chrome, RefTest , we got approximately 55% code coverage for C/C++ portion and 50% coverage on the JavaScript portion. | ||
We have generated a lot of trend diagrams to study the interaction between code coverage data for a given file and the number of bug fixes went into the file; code coverage Vs the number of times the file is modified | We have generated a lot of trend diagrams to study the interaction between code coverage data for a given file and the number of bug fixes went into the file; code coverage Vs the number of times the file is modified and file churn Vs bug fix rate. | ||
Results would be discussed below. | Results would be discussed below. | ||
The plan is to observe the temporal changes in the above trends as we fix more bugs as well as develop new test cases. | The plan is to observe the temporal changes in the above trends as we fix more bugs as well as develop new test cases. | ||
This is what is planned for the immediate future | This is what is planned for the immediate future | ||
* We are going to identify top 3 modules that needs further analysis | *We are going to identify top 3 modules that needs further analysis | ||
* We will identify at least 6 files in each of those modules that have active churn but not good coverage | *We will identify at least 6 files in each of those modules that have active churn but not good coverage | ||
* We will work with DEV and QA to come up with scenarios to improve coverage on those files | *We will work with DEV and QA to come up with scenarios to improve coverage on those files | ||
== < | == <font color="GREEN">Results and Findings </font> == | ||
Code Coverage report generated using '''lcov''' looks like this | |||
For the full report to do your own study, please use the following URL | |||
'''http://people.mozilla.org/~mnandigama/codecoverage_html/''' | |||
For those who just want to have a peek, here are some screen shots. | |||
http://people.mozilla.org/~mnandigama/images/Picture%202.png | |||
If you click on any '''component''' for example '''js''' | |||
http://people.mozilla.org/~mnandigama/images/Picture%204.png | |||
If you want to drill down to a line level coverage | |||
http://people.mozilla.org/~mnandigama/images/Picture%205.png | |||
'''This is important ''': We have done a component/module by component/module code coverage Vs Bugs fix analysis. | <br> '''This is important ''': We have done a component/module by component/module code coverage Vs Bugs fix analysis. | ||
* In a happy path case, all files should have 100% code coverage | *In a happy path case, all files should have 100% code coverage | ||
* In a normal path case, all files that have high rate of bugs fixed in them, should have '''HIGH''' code coverage since there are the most active files in terms of change. | *In a normal path case, all files that have high rate of bugs fixed in them, should have '''HIGH''' code coverage since there are the most active files in terms of change. | ||
* Files that have no change since a long time can have either '''HIGH''' or '''LOW''' coverage in our first iteration since they are not undergoing any change so far. | *Files that have no change since a long time can have either '''HIGH''' or '''LOW''' coverage in our first iteration since they are not undergoing any change so far. | ||
For a sample module, '''JavaScript Engine''' the code coverage Vs Bug fixes looks like this. | For a sample module, '''JavaScript Engine''' the code coverage Vs Bug fixes looks like this. | ||
http://people.mozilla.org/~mnandigama/images/covBugs.png | http://people.mozilla.org/~mnandigama/images/covBugs.png | ||
In a bubble chart format , the same can be visualized as follows | In a bubble chart format , the same can be visualized as follows | ||
http://people.mozilla.org/~mnandigama/images/sample3.png | http://people.mozilla.org/~mnandigama/images/sample3.png | ||
The '''bigger''' the bubble, the higher it should be and all bubbles should ideally bubble up. | The '''bigger''' the bubble, the higher it should be and all bubbles should ideally bubble up. | ||
== < | == <font color="GREEN">How to instrument the Mozilla Firefox Browser </font> == | ||
=== Build config === | === Build config === | ||
This is what you do to instrument the Mozilla Firefox browser. | |||
Create a .mozconfig-gold file in your home directory with the following statements | |||
<br> | |||
export CFLAGS="-fprofile-arcs -ftest-coverage" | export CFLAGS="-fprofile-arcs -ftest-coverage" | ||
Line 80: | Line 82: | ||
For more detailed build options and prerequisites, please visit the following URL | For more detailed build options and prerequisites, please visit the following URL | ||
https://developer.mozilla.org/en/Configuring_Build_Options | https://developer.mozilla.org/en/Configuring_Build_Options | ||
Checkout the source code from the mozilla-central code repository. | Checkout the source code from the mozilla-central code repository. | ||
<br> | |||
rm -rf /home/user/src | rm -rf /home/user/src | ||
Line 93: | Line 96: | ||
cp ../.mozconfig-gold .mozconfig | cp ../.mozconfig-gold .mozconfig | ||
<br> TIP: Save the above commands into a file named ‘startover’ and make it executable. | |||
TIP: | TIP:Change the ‘user’ part to your login account name. | ||
<br> | |||
<br> | |||
The standard build command to build instrumented mozilla firefox is | |||
<br> | |||
make -f client.mk build | |||
=== Execute some Unit tests === | |||
Change Directory to ~/mozcentral-dbg/_tests/testing/mochitest and execute the following command. | |||
Change Directory to ~/mozcentral-dbg/_tests/testing/mochitest and execute the following command. | |||
<br> | |||
python runtests.py to execute mochitest suite. | python runtests.py to execute mochitest suite. | ||
Line 115: | Line 120: | ||
python runtests.py --a11y to run accessibility tests | python runtests.py --a11y to run accessibility tests | ||
<br> Please keep the focus on the Firefox browser , when running your tests, at all times or else your tests will fail. | |||
<br> In order to run jstests, please go to ~/src/js/tests and execute the following commands | |||
In order to run jstests, please go to ~/src/js/tests | |||
<br> | |||
./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 | ||
Line 128: | Line 132: | ||
Getopt-mixed is a required library by that script it needs to be added. | Getopt-mixed is a required library by that script it needs to be added. | ||
<br> | |||
=== Gather the data === | === Gather the data === | ||
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 | <br> Now, come back into your home directory and execute the following command | ||
<br> | |||
lcov -c -d mozcentral-dbg -o app.info | lcov -c -d mozcentral-dbg -o app.info | ||
<br> The lcov tool will go through the entire build directory and generates an app.info file in your home directory | |||
<br> '''TIP''': If you don’t know what is an ‘lcov’ tool, please feel free to ‘google’ the term. | |||
'''TIP''': Please lcov 1.7.x since it provides both line and functional coverage. | |||
Then, execute the following command | |||
Then, execute the following command | |||
<br> | |||
genhtml app.info | genhtml app.info | ||
If by any chance the above command fails to complete, use the following option. | If by any chance the above command fails to complete, use the following option. | ||
genhtml --no-source app.info | genhtml --no-source app.info | ||
<br> The resulting index.html is the landing page for all your code coverage data for the C/C++ code in the Firefox browser. | |||
<br> HINT: Look at the advanced tweaks section on how to modify, geninfo, genhtml scripts in order to generate full code coverage reports. | |||
HINT: Look at the advanced tweaks section on how to modify, geninfo, genhtml scripts in order to generate full | |||
<br> When we run the instrumented Firefox, there is now a "JSCoverage" menu in the "Tools" menu. | |||
<br> Tools -> JSCoverage -> View Coverage loads the jscoverage.html file | |||
Tools - | <br> Tools -> JSCoverage -> Store Coverage saves the coverage data into a directory named "./jscoverage-report. | ||
== < | == <font color="GREEN">Scripts and Works around required </font> == | ||
=== Change to the mozilla code === | === Change to the mozilla code === | ||
As of now, there is a bug https://bugzilla.mozilla.org/show_bug.cgi?id=461270 which prevents the NSPR from getting linked in the code coverage mode. | |||
The work around to address this problem is as follows: | <br> The work around to address this problem is as follows: | ||
<br> | |||
Modify [ in the trunk you checked out ] src/nsprpub/config/rules.mk on line #352 | Modify [ in the trunk you checked out ] src/nsprpub/config/rules.mk on line #352 | ||
Line 184: | Line 185: | ||
to $(MKSHLIB) $(OBJS) $(RES) $(LDFLAGS) $(EXTRA_LIBS) | to $(MKSHLIB) $(OBJS) $(RES) $(LDFLAGS) $(EXTRA_LIBS) | ||
<br> Execute the usual build command 'make -f client.mk build' | |||
<br> Please make sure that you have all the build dependencies installed properly before attempting the build. | |||
=== LCOV === | |||
You'll need [http://ltp.sourceforge.net/coverage/lcov.php lcov]. | |||
on os X the bin/install.sh needs to be modified on the last line there is a install -D remove the -D switch as it's not supported on OS X. | |||
The following needs to be done : | |||
sudo vi /usr/bin/geninfo | sudo vi /usr/bin/geninfo | ||
Press the following key sequence: | Press the following key sequence: | ||
Esc - | Esc -> : -> %s/die/print/g -> Enter | ||
sudo vi /usr/bin/genhtml | sudo vi /usr/bin/genhtml | ||
Press the following key sequence: | Press the following key sequence: | ||
Esc - | Esc -> : -> %s/die/print/g -> Enter | ||
<br> | |||
<br> | |||
=== Jscoverage === | |||
Code coverage for the Javascript part of the Firefox can be done in multiple ways. But using JSCoverage as the tool seemed to be the best way as JSCoverage is an open source tool. | |||
<br> I wish to fully acknowledge the great help Ed Kelly , who maintains the JSCoverage tool , provided in this instrumentation exercise. Ed was very generous in spending cycles to provide enhancements to the JSCoverage tool to meet Firefox instrumentation requirements. | |||
<br> So ... here is how to instrument the javascript portion of Firefox. | |||
<br> Do not download the binary of the JScoverage from http://siliconforks.com/jscoverage/ | |||
You should check out the source code from its public Subversion repository: | |||
svn co http://svn.siliconforks.com/jscoverage/trunk jscoverage | |||
To compile, run bootstrap.sh (requires Automake and Autoconf): | |||
To compile, run bootstrap.sh (requires Automake and Autoconf): | |||
./bootstrap.sh | ./bootstrap.sh | ||
Line 232: | Line 230: | ||
installed in the /usr/local/bin | installed in the /usr/local/bin | ||
<br> Why not use the binary from the site and why to build our own jscoverage !! | |||
<br> The following enhancements are present in our own build with latest revision. | |||
The following enhancements are present in our own build with latest revision. | |||
1. | 1. Instrumenting symbolic links in the case where the destination is a regular file. | ||
For those who are curious, JSCoverage does not instrument javascript files that are symbolically referenced. | For those who are curious, JSCoverage does not instrument javascript files that are symbolically referenced. | ||
2. It copies | 2. It copies file permissions (so that executable files stay executable). | ||
3. It has the | 3. It has the --mozilla option to copy the jscoverage.html file directly into Firefox's chrome. | ||
The --mozilla option automatically sets the JavaScript version to 180,so it is not necessary to use both --mozilla and --js-version at the same time. | The --mozilla option automatically sets the JavaScript version to 180,so it is not necessary to use both --mozilla and --js-version at the same time. | ||
NOTE: --js-version=180 would allow instrumenting the symbolic links | NOTE: --js-version=180 would allow instrumenting the symbolic links | ||
<br> So, starting from the top of the Firefox build (~/mozcentral-dbg )directory , here are the commands to instrument the whole Firefox directory and run the mochitests with the instrumented version: | |||
<br> | |||
cd /dist | cd /dist | ||
Line 262: | Line 258: | ||
bin-original bin | bin-original bin | ||
<br> HINT: If you find a foobar.js file failing in the javascript instrumentation exercise, please add it to the no-instrument list using the following syntax --no-instrument=/path/to/foobar.js | |||
<br> It seems that it is necessary to use --no-instrument on the entire defaults and prefs directories because the preferences .js files should not contain arbitrary JavaScript. | |||
See http://www.xulplanet.com/tutorials/xulqa/q_prefs.html or https://bugzilla.mozilla.org/show_bug.cgi?id=440777 for details. | |||
== <font color="GREEN">How to consolidate / merge results and generate graphs</font> == | |||
'''TO BE ADDED ''' | '''TO BE ADDED ''' |
edits