DHylands updater xpcshell

From MozillaWiki
Jump to: navigation, search

This page documents what I need to do in order to run updater xpcshell tests on my local machine.

Setup

The following makes reference to ${GECKO_DIR} and ${GECKO_OBJDIR}. These refer to the gecko source tree (typically called gecko in the b2g builds) and the gecko object dir, typically called objdir-gecko. Both of these may be overridden in your local .userconfig.

Build the emulator

In order to run locally, you'll need to build an emulator build. You need to make sure that you build with VARIANT=userdebug (you can set this in your .userconfig). VARIANT=user doesn't include marionette and VARIANT=eng doesn't include the updater, so VARIANT=userdebug is the the only VARIANT that will give you both the updater and marionette.

If you change the VARIANT, then you should
rm -rf out ${GECKO_OBJDIR}
otherwise you might not get the updater configured in properly.

Verify that gonk-misc/default-gecko-config has both:

ENABLE_MARIONETTE=1
ENABLE_TESTS=1

enabled. The master branch should have that. Other branches may not.

Verify that the updater was included in your build

Confirm that your build included the updater (i.e. MOZ_UPDATER=1)

grep MOZ_UPDATER ${GECKO_OBJDIR}/config/autoconf.mk

Make sure that the marionette client is up-to-date

cd ${GECKO_DIR}/testing/marionette/client
sudo python setup.py develop

See: Setting up Marionette for more details.

Package the tests

make -C ${GECKO_OBJDIR} package-tests

Install busybox (if testing on a real device)

If you're trying to run xpcshell tests on a real device, then the process will be sped up dramatically by installing busybox on the device. See: installing busybox manually for a link to script which will automate this process for you. You'll need to reinstall busybox each time you reflash your device.

Run the updater tests

I use the following script (which I call run-xpcshell.sh):

#!/bin/bash
# Get full path from where the script was executed, full path is needed to run emulator succesfully
B2G_HOME=$(cd $(dirname $BASH_SOURCE); pwd)

. $B2G_HOME/load-config.sh

export DISPLAY=:0

cd ${GECKO_OBJDIR}/dist/test-package-stage/xpcshell

MANIFEST=tests/toolkit/mozapps/update/test/unit/xpcshell.ini
TESTING_MODULES_DIR=${GECKO_OBJDIR}/dist/test-package-stage/modules
BUSYBOX=${B2G_HOME}/busybox-armv6l

set -x
python runtestsb2g.py --b2gpath ${B2G_HOME} --emulator arm --use-device-libs \
--manifest ${MANIFEST} \
--testing-modules-dir ${TESTING_MODULES_DIR} \
--logcat-dir ${B2G_HOME} \
--busybox=${BUSYBOX} 2>&1 | tee ${B2G_HOME}/run-xpcshell.log

The export DISPLAY=:0 is needed for me, since I typically ssh -X into my development machine and the emulator won't run if the display is directed to the machine where you're running ssh from.

Running on the device instead of in the emulator

I used the following script when running xpcshell updater tests on a real device:

#!/bin/bash

. ./load-config.sh

make -C ${GECKO_OBJDIR} package-tests

# Install busybox if needed

if [ "$(adb shell 'test -f /system/bin/cp; echo -n $?')" == "1" ]; then
  echo "Installing BusyBox ..."
  install-busybox.sh
else
  echo "BusyBox already installed ..."
fi

# Marshall said he used:
#./test.sh xpcshell --test-path toolkit/mozapps/update/test/unit/test_bug833708.js --no-clean

adb shell log "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
adb shell log "%%%%% Starting tests"
adb shell log "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

./test.sh xpcshell --test-path toolkit/mozapps/update/test/unit/test_gonk_general.js --no-clean

# Make a noise
echo -ne \\a

The install-busybox.sh script comes from setup-tools.sh (I renamed it because setup-tools.sh was too generic for me).

Other testing information

See the Running tests page and the XPCShell page.