Mobile/Fennec Xpcshell: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
 
(33 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)/harness/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:
 
<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>
 
In addition (for xpcshell only), we need to move some of the test binaries into the fennec tree:


==Running the tests==
Run the tests from the directory where you unzipped them like so:
<pre>
<pre>
python mochitest/runtests.py --appname=<absolute path to fennec>
cd /media/mmc1/unittest
cp bin/* fennec/xulrunner
cp bin/components/* fennec/components
cp bin/plugins/* fennec/xulrunner/plugins
</pre>
</pre>


where fennec executable is the absolute path to the fennec executable, /root/fennec/fennec, e.g. Additional arguments like individual test files can be specified, general Mochitest instructions can be found here [http://developer.mozilla.org/en/docs/Mochitest].
==Running the 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.  


note: The tests are sometimes unresponsive on mobile devices, so use the --test-path, --autorun, and --log-file options.
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:


note: In order for the tests to run on the device successfully, we need to run them one directory at a time. We have a script [[http://people.mozilla.com/~jmaher/fennec/maemkit maemkit-chunked.py]] (download the whole maemkit and configure the maemkit.cfg file to point to the correct paths) which will do this and stitch the logs up for you when you are all done.
<pre>
cd /media/mmc1/unittests
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
</pre>


==Adding tests==
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.  
Add a directory named "tests" to the component. In the Makefile.in for the tests directory add a _TEST_FILES section with a list of the files in this directory needed to run the mochitest (the mochitest html file itself and any helper files). Then add this line to the bottom of the Makefile.in:


if test is in central code:
Now Edit the /media/mmc1/maemkit/maemkit.cfg file:
<pre>
<pre>
libs:: $(_TEST_FILES)
[general]
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
xre-path = /media/mmc1/unittests/fennec/xulrunner
appname = /media/mmc1/unittests/fennec/fennec
total-clients = 1
client-number = 1
logdir = logs
ostype = linux
 
[xpcshell]
testroot = /media/mmc1/unittests/xpcshell/tests
utility-path = /media/mmc1/unittests/xpcshell
manifest = /media/mmc1/unittests/xpcshell/tests/all-test-dirs.list
log-file = log_xpcshell.txt
</pre>
</pre>


if test is in mobile:
 
Now execute the tests:
<pre>
<pre>
libs:: $(_TEST_FILES)
cd /media/mmc1/maemkit
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/../xulrunner/_tests/testing/mochitest/tests/$(relativesrcdir)
python maemkit-chunked.py --testtype=xpcshell
</pre>
</pre>


You can view the results in /media/mmc1/maemkit/log_xpcshell.txt
== TODO's ==


When you build, the tests will be added to the xulrunner application's mochitest set.
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.

Latest revision as of 17:41, 27 March 2009

Getting the Tests

Edit your mozconfig to contain the following lines:

ac_add_options --enable-tests

Get the source and build according to instructions.

to learn more about the tests, visit the [MDC Guide]

Porting tests to N800

With changes from bug 421611 we have made this process much simpler.

If following 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:

cd $(xul_objdir)
make package-tests
cd dist
bunzip2 xulrunner-*tests.tar.bz2
scp xulrunner-*tests.tar root@<deviceip>:/media/mmc1

On the device, untar the xulrunner-*tests.tar in your test directory alongside the fennec-*.tar:

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

In addition (for xpcshell only), we need to move some of the test binaries into the fennec tree:

cd /media/mmc1/unittest
cp bin/* fennec/xulrunner
cp bin/components/* fennec/components
cp bin/plugins/* fennec/xulrunner/plugins

Running the 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.

Make check runs [runxpcshelltests.py]. We can run this on the Maemo platform like this:

cd /media/mmc1/unittests
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

We have created a framework to wrap the unittests maemkit which makes this a little bit easier. Keeping the above example, you need to copy the maemkit files to /media/mmc1/maemkit.

Now Edit the /media/mmc1/maemkit/maemkit.cfg file:

[general]
xre-path = /media/mmc1/unittests/fennec/xulrunner
appname = /media/mmc1/unittests/fennec/fennec
total-clients = 1
client-number = 1
logdir = logs
ostype = linux

[xpcshell]
testroot = /media/mmc1/unittests/xpcshell/tests
utility-path = /media/mmc1/unittests/xpcshell
manifest = /media/mmc1/unittests/xpcshell/tests/all-test-dirs.list
log-file = log_xpcshell.txt


Now execute the tests:

cd /media/mmc1/maemkit
python maemkit-chunked.py --testtype=xpcshell

You can view the results in /media/mmc1/maemkit/log_xpcshell.txt

TODO's

I will start tracking test failures/bugs [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.