Skip to content

Commit

Permalink
Bug 775281 - Add files necessary to run B2G xpcshell tests from test.…
Browse files Browse the repository at this point in the history
…sh, r=jgriffin, DONTBUILD because NPOTB
  • Loading branch information
mihneadb committed Jul 30, 2012
1 parent 0181faa commit 30b93ae
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 10 deletions.
63 changes: 63 additions & 0 deletions testing/xpcshell/b2g_xpcshell_venv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

PYTHON=$1

if [ -z "${PYTHON}" ]
then
echo "No python found"
exit 1
fi

if [ -z "${MARIONETTE_HOME}" ]
then
echo "No MARIONETTE_HOME found"
exit 1
fi

if [ -z "${XPCSHELLTEST_HOME}" ]
then
echo "No XPCSHELLTEST_HOME found"
exit 1
fi

echo "Detected Marionette home in $MARIONETTE_HOME"

# If a GECKO_OBJDIR environemnt variable exists, we will create the Python
# virtual envirnoment there. Otherwise we create it in the PWD.
VENV_DIR="marionette_venv"
if [ -z $GECKO_OBJDIR ]
then
VENV_DIR="$MARIONETTE_HOME/$VENV_DIR"
else
VENV_DIR="$GECKO_OBJDIR/$VENV_DIR"
fi

# Check if environment exists, if not, create a virtualenv:
if [ -d $VENV_DIR ]
then
echo "Using virtual environment in $VENV_DIR"
cd $VENV_DIR
. bin/activate
else
echo "Creating a virtual environment in $VENV_DIR"
curl https://raw.github.com/pypa/virtualenv/develop/virtualenv.py | ${PYTHON} - $VENV_DIR
cd $VENV_DIR
. bin/activate
# set up mozbase
git clone git://github.com/mozilla/mozbase.git
cd mozbase
python setup_development.py
fi

# update the marionette_client
cd $MARIONETTE_HOME
python setup.py develop

cd $XPCSHELLTEST_HOME

# pop off the python parameter
shift
python runtestsb2g.py $@
13 changes: 10 additions & 3 deletions testing/xpcshell/remotexpcshelltests.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ def setupUtilities(self):

self.device.pushFile(self.options.localAPK, self.remoteBinDir)

self.pushLibs()

self.device.chmodDir(self.remoteBinDir)

def pushLibs(self):
if self.options.localAPK:
localLib = os.path.join(self.options.objdir, "dist/fennec")
if not os.path.exists(localLib):
Expand All @@ -126,7 +131,6 @@ def setupUtilities(self):
if (file.endswith(".so")):
self.device.pushFile(os.path.join(root, file), self.remoteBinDir)

self.device.chmodDir(self.remoteBinDir)

def setupTestDir(self):
xpcDir = os.path.join(self.options.objdir, "_tests/xpcshell")
Expand Down Expand Up @@ -197,10 +201,13 @@ def setupProfileDir(self):
self.log.info("TEST-INFO | profile dir is %s" % self.profileDir)
return self.profileDir

def setLD_LIBRARY_PATH(self, env):
env["LD_LIBRARY_PATH"]=self.remoteBinDir

def launchProcess(self, cmd, stdout, stderr, env, cwd):
cmd[0] = self.remoteJoin(self.remoteBinDir, "xpcshell")
env = dict()
env["LD_LIBRARY_PATH"]=self.remoteBinDir
env = {}
self.setLD_LIBRARY_PATH(env)
env["MOZ_LINKER_CACHE"]=self.remoteBinDir
if self.options.localAPK and self.appRoot:
env["GRE_HOME"]=self.appRoot
Expand Down
41 changes: 34 additions & 7 deletions testing/xpcshell/runtestsb2g.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,21 @@ def setupUtilities(self):
XPCShellRemote.setupUtilities(self)

def clean(self):
print >>sys.stderr, "\nCleaning files from previous run.."
self.device.removeDir(DEVICE_TEST_ROOT)

# Overridden
def pushLibs(self):
if not self.options.use_device_libs:
XPCShellRemote.pushLibs(self)

# Overridden
def setLD_LIBRARY_PATH(self, env):
if self.options.use_device_libs:
env['LD_LIBRARY_PATH'] = '/system/b2g'
else:
XPCShellRemote.setLD_LIBRARY_PATH(self, env)

# Overridden
# This returns 1 even when tests pass - this is why it's switched to 0
# https://bugzilla.mozilla.org/show_bug.cgi?id=773703
Expand All @@ -52,10 +65,11 @@ def __init__(self):
help="Path to B2G repo or qemu dir")
defaults['b2g_path'] = None

self.add_option('--marionette', action='store',
type='string', dest='marionette',
help="host:port to use when connecting to Marionette")
defaults['marionette'] = None
self.add_option('--emupath', action='store',
type='string', dest='emu_path',
help="Path to emulator folder (if different "
"from b2gpath")
defaults['emu_path'] = None

self.add_option('--emulator', action='store',
type='string', dest='emulator',
Expand All @@ -72,6 +86,16 @@ def __init__(self):
help="Path to adb")
defaults['adb_path'] = 'adb'

self.add_option('--address', action='store',
type='string', dest='address',
help="host:port of running Gecko instance to connect to")
defaults['address'] = None

self.add_option('--use-device-libs', action='store_true',
dest='use_device_libs',
help="Don't push .so's")
defaults['use_device_libs'] = False

defaults['dm_trans'] = 'adb'
defaults['debugger'] = None
defaults['debuggerArgs'] = None
Expand All @@ -97,11 +121,14 @@ def main():
if options.no_window:
kwargs['noWindow'] = True
if options.b2g_path:
kwargs['homedir'] = options.b2g_path
if options.marionette:
host, port = options.marionette.split(':')
kwargs['homedir'] = options.emu_path or options.b2g_path
if options.address:
host, port = options.address.split(':')
kwargs['host'] = host
kwargs['port'] = int(port)
kwargs['baseurl'] = 'http://%s:%d/' % (host, int(port))
if options.emulator:
kwargs['connectToRunningEmulator'] = True
marionette = Marionette(**kwargs)

# Create the DeviceManager instance
Expand Down

0 comments on commit 30b93ae

Please sign in to comment.