Mobile/Fennec Chrome: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Getting the Tests ==
Edit your mozconfig to contain the following lines:
<pre>
ac_add_options --enable-tests
</pre>
Get the source and build according to [[Mobile/Build/Fennec|instructions]].
to learn more about the tests, visit the [https://developer.mozilla.org/en/Mochitest MDC Guide]]
==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:
<pre>
cd $(xul_objdir)
make package-tests
cd dist
bunzip2 xulrunner-*tests.tar.bz2
scp xulrunner-*tests.tar root@<deviceip>:/media/mmc1
</pre>
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>
== Running Chrome tests on Fennec ==
== Running Chrome tests on Fennec ==


Chrome tests are run just like mochitests except they have the --chrome flag set on the command line when launching.
Chrome tests are run just like mochitests except they have the --chrome flag set on the command line when launching.


Out of the box, these do not run on the device. You can run them on the desktop version of fennec which means that we are running into resource issues on the device.
<pre>
python /media/mmc1/unittests/mochitest/runtests.py --autorun --close-when-done --chrome --utility-path=/media/mmc1/unittests/bin --appname=/media/mmc1/unittests/fennec/fennec --xre-path=/media/mmc1/unittests/fennec/xulrunner --certificate-path=/media/mmc1/unittests/certs --log-file=logs/log_content.txt
</pre>


I have followed the methods of running mochitests and have started running the chrome tests one directory at a time.  This is trickier as you cannot specify a directory via the command line. Instead, I do this:
The Chrome tests will fail when run on a device.  This is because we don't have enough memory available to load the whole set of tests into memory and execute.


To work around this, we run a subset of tests at a time.  We have found that running one subdirectory under the chrome/ folder works out well.  Once we have a --test-path that works for directories in chrome, we can do this easier.  At the moment, we remove all files from the chrome/ directory and move the files over one directory at a time:
<pre>
<pre>
cd _tests/testing/mochitest
cd /media/mmc1/unittests/mochitest
cp -R chrome chrome.bak
cp -R chrome chrome.bak


Line 15: Line 56:
rm -Rf chrome/*
rm -Rf chrome/*
cp -R chrome.bak/content chrome/
cp -R chrome.bak/content chrome/
python runtests.py --appname=../../../../fennec --chrome --log-file=chrome_content.log --autorun --close-when-done
</pre>
</pre>


I have a basic python [[http://people.mozilla.com/~jmaher/fennec/run_chrome_chunked.py script]] which will achieve this.  I still need to clean it up and make it accept command line arguments as well as stitch the chunked log files together.


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.
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
[chrome]
autorun = True
close-when-done = True
utility-path = /media/mmc1/unittests/bin
certificate-path = /media/mmc1/unittests/certs
backupdir = chrome.bak
testroot = /media/mmc1/unittests/mochitest
log-file = log_chrome.txt
</pre>
Now execute the tests:
<pre>
cd /media/mmc1/maemkit
python maemkit-chunked.py --testtype=chrome
</pre>
You can view the results in /media/mmc1/maemkit/log_chrome.txt


== TODO ==
== TODO ==


*HACK: in order to work around bugs {{bug|472334}} and {{bug|472341}}, we need to turn on sessionhistory by setting a user_pref("browser.sessionhistory.max_total_viewers", -1) in automation.py
*HACK: in order to work around bugs {{bug|472334}} and {{bug|472341}}, we need to turn on sessionhistory by setting a user_pref("browser.sessionhistory.max_total_viewers", -1) in automation.py
*HACK: in order to get a [[https://bugzilla.mozilla.org/show_bug.cgi?id=472513 session store test]] running, we need to set dom.storage.default_quota=640 in automation.py and change domstorage_global.js#88 from 32767 to 8191 in the for loop
*NOTE: these two hacks are discussed in {{bug|475098}}

Latest revision as of 19:16, 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

Running Chrome tests on Fennec

Chrome tests are run just like mochitests except they have the --chrome flag set on the command line when launching.

python /media/mmc1/unittests/mochitest/runtests.py --autorun --close-when-done --chrome --utility-path=/media/mmc1/unittests/bin --appname=/media/mmc1/unittests/fennec/fennec --xre-path=/media/mmc1/unittests/fennec/xulrunner --certificate-path=/media/mmc1/unittests/certs --log-file=logs/log_content.txt

The Chrome tests will fail when run on a device. This is because we don't have enough memory available to load the whole set of tests into memory and execute.

To work around this, we run a subset of tests at a time. We have found that running one subdirectory under the chrome/ folder works out well. Once we have a --test-path that works for directories in chrome, we can do this easier. At the moment, we remove all files from the chrome/ directory and move the files over one directory at a time:

cd /media/mmc1/unittests/mochitest
cp -R chrome chrome.bak

## NOTE: you need to do the following steps in a look for each directory
## dirs: [content, docshell, dom, toolkit, widget]
rm -Rf chrome/*
cp -R chrome.bak/content chrome/


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

[chrome]
autorun = True
close-when-done = True
utility-path = /media/mmc1/unittests/bin
certificate-path = /media/mmc1/unittests/certs
backupdir = chrome.bak
testroot = /media/mmc1/unittests/mochitest
log-file = log_chrome.txt


Now execute the tests:

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

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

TODO

  • HACK: in order to work around bugs bug 472334 and bug 472341, we need to turn on sessionhistory by setting a user_pref("browser.sessionhistory.max_total_viewers", -1) in automation.py
  • HACK: in order to get a [session store test] running, we need to set dom.storage.default_quota=640 in automation.py and change domstorage_global.js#88 from 32767 to 8191 in the for loop