XPCShell tests are headless tests of Gecko XPCOM APIs. You can run XPCShell tests on B2G; in this article we will look at how to do so. Currently, these are mainly tested on the emulator, but should in theory run on devices as well.
Note: In this article
$B2G_HOME refers to the cloned B2G repository.
- You need to build B2G for the target you're testing (see: Building and installing Firefox OS).
- You need to install some Python packages, either in a virtualenv or otherwise:
cd $GECKO_DIR/testing/mozbase python setup_development.py cd $GECKO_DIR/testing/marionette/client python setup.py develop
- Either make sure
adbis on your path or specify it with
--adbpath(on Linux it is found at
- Have a local copy of Busybox (this isn't strictly necessary but greatly reduces the setup time required.)
Running the tests
You can then run xpcshell tests using one of the following sets of terminal commands:
If you are using an emulator:
cd $B2G_HOME/objdir-gecko make package-tests cd dist/test-stage/xpcshell python runtestsb2g.py --b2gpath $B2G_HOME --adbpath $ADB_PATH --emulator arm --use-device-libs --manifest <path_to_xpcshell_manifest> --testing-modules-dir <path_to_testing_modules_dir> --busybox <path_to_busybox_binary>
If you are using a real device:
cd $B2G_HOME/objdir-gecko make package-tests cd dist/test-stage/xpcshell python runtestsb2g.py --b2gpath $B2G_HOME --adbpath $ADB_PATH --use-device-libs --manifest <path_to_xpcshell_manifest> --testing-modules-dir <path_to_testing_modules_dir>
You can optionally add
--this-chunks arguments as you would with regular desktop xpcshell tests. Use:
python runtestsb2g.py --help
for a full list of supported arguments.
Important: The manifest path you supply must be under the
dist/test-stage/xpcshell directory. Don't use a path to the original source location of the manifest in the tree.
After you invoke
runtestsb2g.py, the test runner will launch the emulator for you (if you're running the tests on an emulator) or reboot your device (if you're running the tests on a device), and start running the tests. Because the emulator is slow, and it is necessary to push a test profile to the emulator and restart B2G, the tests can take a few minutes to start. Before they start, you will just see a black or white screen. After they start, you should see the test log being dumped to the console.
When the tests are done, the emulator is shut down for you, or if you're using a device, the device is rebooted.
Installing busybox manually
When running xpcshell tests on devices there is no
--busybox option, so setting up the test run can take a very long time. Fortunately you can still install it manually prior to running the tests. For an example of how to do this see https://github.com/mozilla/Negatus/blob/master/setup-tools.sh.
Running xpcshell tests with a downloaded emulator
If you've built B2G for another config (like otoro) and want to run the tests on an emulator, you can do so without building an emulator yourself. Just download the latest trunk arm emulator, and use the same instructions as above, replacing the
--b2gpath $B2G_HOME argument for