Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Cppunit Tests

This article needs a technical review. How you can help.

Cppunit tests are headless Gecko C++ unit tests. You can run Cppunit tests on B2G; in this article we will look at how to do so. Currently, these are mainly tested on the emulator, but theoretically , it should run on devices as well.

Note: In this article $B2G_HOME refers to the cloned B2G repository.

The Hard Way

There isn't currently much command to run the cpp unit tests, so we're stuck running them the "hard way".

Prerequisites

  • You need to build B2G for the target you're testing (see: Building and installing Firefox OS). Currently, only emulator builds are supported, though other devices may also work.
  • 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 that adb is on your path or specify it with --adbpath (on Linux it is found at $B2G_HOME/out/host/linux-x86/bin/adb.)
  • Have a local copy of Busybox (this isn't strictly necessary but greatly reduces the required setup time).

Running the tests

You can then run xpcshell tests by first starting on an emulator and then executing the following commands:

cd $B2G_HOME/objdir-gecko
make package-tests
cd dist/test-stage/cppunittests
python remotecppunittests.py --xre-path $B2G_HOME/objdir-gecko/dist/bin --adbpath $ADB_PATH --dm_trans=adb --addEnv LD_LIBRARY_PATH=/vendor/lib:/system/lib:/system/b2g <test1> <test2> ...

Document Tags and Contributors

 Contributors to this page: chrisdavidmills, PushpitaPikuDey, dminor
 Last updated by: chrisdavidmills,