Mobile/Fennec Xpcshell: Difference between revisions

 
(18 intermediate revisions by the same user not shown)
Line 12: Line 12:


==Porting tests to N800==
==Porting tests to N800==
With changes from {{bug|421611}} we have made this process much simpler. 
If following [[Mobile/Build/Fennec#Running Fennec on Maemo|directions]] for running fennec on N800/N810 devices, you will need to package up the tests from the xulrunner directory and the test harness from the source tree:
If following [[Mobile/Build/Fennec#Running Fennec on Maemo|directions]] for running fennec on N800/N810 devices, you will need to package up the tests from the xulrunner directory and the test harness from the source tree:


<pre>
<pre>
cp $(topsrcdir)/testing/xpcshell/* $(xul_objdir)/_tests/
cd $(xul_objdir)
cd $(xul_objdir)/_tests
make package-tests
tar -chf xpcshell.tar xpcshell/ xpcshell-simple/
cd dist
bunzip2 xulrunner-*tests.tar.bz2
scp xulrunner-*tests.tar root@<deviceip>:/media/mmc1
</pre>
</pre>


Transfer tar file to device via scp and untar it.
On the device, untar the xulrunner-*tests.tar in your test directory alongside the fennec-*.tar:


NOTE: it would be nice if the build script (make) would copy the test harness from the source tree to the xulrunner directory.
<pre>
cd /media/mmc1
mkdir unittests
mv fennec-*.tar unittests
mv xulrunner-*tests.tar unittests
cd unittests
tar -xvf fennec-*.tar
tar -xvf xulrunner-*tests.tar
</pre>


==Getting the Tests==
In addition (for xpcshell only), we need to move some of the test binaries into the fennec tree:
Edit your mozconfig to contain the following lines:


<pre>
<pre>
ac_add_options --enable-tests
cd /media/mmc1/unittest
cp bin/* fennec/xulrunner
cp bin/components/* fennec/components
cp bin/plugins/* fennec/xulrunner/plugins
</pre>
</pre>


Get the source and build according to [[Mobile/Build/Fennec|instructions]].
==Running the tests==


to learn more about the tests, visit the [[https://developer.mozilla.org/en/Writing_xpcshell-based_unit_tests MDC Guide]]
The tests are normally ran via "make check" from the root of the objdir.  In this case, we are running the tests on the device and there is no source tree.  


==Porting tests to N800==
Make check runs [[http://mxr.mozilla.org/mozilla-central/source/testing/xpcshell/runxpcshelltests.py runxpcshelltests.py]].  We can run this on the Maemo platform like this:
If following [[Mobile/Build/Fennec#Running Fennec on Maemo|directions]] for running fennec on N800/N810 devices, you will need to package up the tests from the xulrunner directory and the test harness from the source tree:


<pre>
<pre>
cp $(topsrcdir)/testing/xpcshell/* $(xul_objdir)/_tests/
cd /media/mmc1/unittests
cd $(xul_objdir)/_tests
python -u xpcshell/runxpcshelltests.py --xre-path=/media/mmc1/unittests/fennec/xulrunner --manifest=/media/mmc1/unittests/xpcshell/tests/all-test-dirs.list /media/mmc1/unittests/fennec/xulrunner/xpcshell --keep-going
tar -chf xpcshell.tar xpcshell/ xpcshell-simple/
</pre>
</pre>


Transfer tar file to device via scp and untar it.
We have created a framework to wrap the unittests [[Mobile/Fennec_Automation|maemkit]] which makes this a little bit easier.  Keeping the above example, you need to copy the maemkit files to /media/mmc1/maemkit.  


NOTE: it would be nice if the build script (make) would copy the test harness from the source tree to the xulrunner directory.
Now Edit the /media/mmc1/maemkit/maemkit.cfg file:
<pre>
[general]
xre-path = /media/mmc1/unittests/fennec/xulrunner
appname = /media/mmc1/unittests/fennec/fennec
total-clients = 1
client-number = 1
logdir = logs
ostype = linux


==Running the tests==
[xpcshell]
 
testroot = /media/mmc1/unittests/xpcshell/tests
The tests are normally ran via "make check" from the root of the objdir. In this case, we are running the tests on the device and there is no source tree.  
utility-path = /media/mmc1/unittests/xpcshell
manifest = /media/mmc1/unittests/xpcshell/tests/all-test-dirs.list
log-file = log_xpcshell.txt
</pre>


Inspecting the test_all.sh script in harness/xpcshell, you can run the test from the command line by doing this:


Run the tests from the directory where you unzipped them like so:
Now execute the tests:
<pre>
<pre>
./run-mozilla.sh xpcshell  -f /media/mmc1/unittests/xpcshell/xpcshell/head.js  -f /media/mmc1/unittests/xpcshell/xpcshell-simple/test_update/unit/test_0051_general.js  -f /media/mmc1/unittests/xpcshell/xpcshell/tail.js  -f /media/mmc1/unittests/xpcshell/xpcshell/execute_test.js
cd /media/mmc1/maemkit
python maemkit-chunked.py --testtype=xpcshell
</pre>
</pre>


This is a cumbersome process, and to make this reasonable, we have created [[http://people.mozilla.com/~jmaher/fennec/xpctests.py xpctest.py]] to run the tests.  This script needs to be edited to point to the xpcshell executable as well as the root of the test harness and test directories.  It will iterate the tests and build up a list of test_ files to run tests against, then run the above command for you.
You can view the results in /media/mmc1/maemkit/log_xpcshell.txt


== TODO's ==  
== TODO's ==  


NOTE: this runs 525 tests where there are 548 tests which run on Firefox (in release only, debug core dumps on assertions at test 223).  It appears we are not running on Fennec:
I will start tracking test failures/bugs [[http://people.mozilla.com/~jmaher/mochitest.htm here]]. This doesn't line up with what is below as there is data from fennec desktop and fennec maemo which adds to the mix.
test_privatebrowsing/unit/* (6 tests)
test_browser_places/unit/* (6 tests)
test_browser_feeds/unit/* (1 test)
*need to find the other 10 missing tests still
 
 
Of the 26 failures found, we have these issues:
 
 
* 3 - test_places/autocomplete/
** test_download_embed_bookmarks.js
** test_special_search.js
** test_empty_search.js
* 3 - test_places/unit/
** test_000_frecency.js
** test_adaptive.js
** test_frecency.js
* 1 - test_places/sync/test_database_sync_embed_visits.js
* 1 - test_libjar/unit/test_bug278262.js
* 5 - test_satchel/unit/
** test_db_corrupt.js
** test_db_update_v999a.js
** test_history_api.js
** test_db_update_v1.js
** test_db_update_v999b.js
* 4 test_extensionsmanager/unit/ - possibly path _tests/xpcshell-simple/test_extensionmanager requirement?
** test_bug428341.js
** test_bug299716.js
** test_bug396129.js
** test_bug463819.js
* 1 test_update/unit/test_0040_general.js
* 2 test_necko/test/
** test_request_line_split_in_two_packets.js
** test_sjs_throwing_exceptions.js
* 1 test_places/queries/test_querySerialization.js
* 1 test_intl_locale/unit/test_pluralForm.js
Confirmed users
3,376

edits