Connecting to B2G

In order to run tests on a B2G device, you'll need to have the device connected to your machine via USB.  To verify it's connected properly, you can perform the following steps:

On a device

Please make sure the [Settings > Device Information > More Information >  Developer > Remote debugging] is ON.

Connect your device to your computer and verify it appears in adb devices, then set up adb port forwarding to Marionette's port:

$ adb devices
List of devices attached
full_unagi    device

$ adb forward tcp:2828 tcp:2828

$ telnet localhost 2828
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
66:{
  "from": "root",
  "applicationType", "gecko",
  "traits": []
}

If you see the above output, Marionette is running on your device.

On an emulator

The most common way of running tests on an emulator is to allow Marionette to launch the emulator and manage the connection for you.  However, it's still possible to launch the emulator manually yourself, using the run-emulator.sh script in the B2G repo, and then connect to it using the above directions.

On a B2G desktop build

On a b2g desktop build, you don't need to worry about adb port forwarding.  If you have a Marionette-enabled build, Marionette should be available on port 2828 after launching it.

Debugging the emulator/device

It's a big PITA to debug things on the emulator/device, but you can use log4moz and the Marionette logger to print some statements if you are stuck.

 Cu.import("resource://gre/modules/services-sync/log4moz.js");
 let logger = Log4Moz.repository.getLogger("Marionette");
 logger.info("I'm being logged!");

To view the log, do this, while the instance is running:

 $B2G_HOME/glue/gonk/out/host/linux-x86/bin/adb shell cat /data/b2g/mozilla/<your profile>/marionette.log

Document Tags and Contributors

 Contributors to this page: jgriffin, fscholz, Sheppy
 Last updated by: jgriffin,