Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Bug 960063 - Make sure we don't try to have two concurrent marionette…
Browse files Browse the repository at this point in the history
… sessions;r=davehunt
  • Loading branch information
wlach authored and davehunt committed Jan 21, 2014
1 parent f05f100 commit ffaf504
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 25 deletions.
7 changes: 5 additions & 2 deletions src/eideticker/eideticker/device.py
Expand Up @@ -393,6 +393,7 @@ def setupMarionette(self):
self.marionette = marionette.Marionette()
self._logger.info("Waiting for Marionette...")
self.marionette.wait_for_port()
self._logger.info("Marionette ready, starting session")
self.marionette.start_session()
if 'b2g' not in self.marionette.session:
raise mozdevice.DMError("bad session value %s returned by start_session" %
Expand Down Expand Up @@ -421,9 +422,12 @@ def cleanup(self):
self.removeDir('/'.join(['/sdcard', item]))

def stopB2G(self):
#restart b2g so we start with a clean slate
self._logger.info("Stopping B2G")

if self.marionette and self.marionette.session:
self.marionette.delete_session()
self.marionette = None

self.shellCheckOutput(['stop', 'b2g'])
# Wait for a bit to make sure B2G has completely shut down.
tries = 100
Expand Down Expand Up @@ -477,7 +481,6 @@ class B2GADB(EidetickerB2GMixin, mozdevice.DeviceManagerADB):
def __init__(self, **kwargs):
mozdevice.DeviceManagerADB.__init__(self, **kwargs)
self._init() # custom eideticker init steps
self.setupMarionette()

@property
def type(self):
Expand Down
53 changes: 30 additions & 23 deletions src/eideticker/eideticker/runtest.py
Expand Up @@ -15,24 +15,27 @@ def prepare_test(testkey, device_prefs):
# prepare test logic -- currently only done on b2g
if device_prefs['devicetype'] == 'b2g':
testinfo = get_testinfo(testkey)

device = getDevice(**device_prefs)
# HACK: we need to setup marionette here so we can instantiate a
# b2gpopulate instance inside the device object (even though we
# wind up deleting the same marionette instance in just a moment...
# FIXME: find some less convoluted way of getting the same behaviour)
device.setupMarionette()

test = get_test(testinfo, devicetype = device_prefs['devicetype'],
device=device, appname=testinfo.get('appname'))

# reset B2G device's state for test
logger.info("Resetting B2G and cleaning up...")
logger.info("Stopping B2G and cleaning up...")
device.stopB2G()
device.cleanup()

# even if we're populating the database, we need to restart b2g so
# b2gpopulate has access to a marionette connection

if hasattr(test, 'populate_databases'):
logger.info("Populating database...")
test.populate_databases()

logger.info("Restarting b2g")
logger.info("Starting B2G")
device.startB2G()
device.unlock()
device.killApps()
Expand All @@ -41,6 +44,9 @@ def prepare_test(testkey, device_prefs):
logger.info("Doing initial setup on app for test")
test.prepare_app()

# close down marionette so we can create a new session later
device.marionette.delete_session()

def run_test(testkey, capture_device, appname, capture_name,
device_prefs, extra_prefs={}, test_type=None, profile_file=None,
wifi_settings_file=None, request_log_file=None,
Expand Down Expand Up @@ -70,26 +76,8 @@ def run_test(testkey, capture_device, appname, capture_name,
elif no_capture:
capture_file = None

# Create a device object to interface with the phone
device = getDevice(**device_prefs)

if device_prefs['devicetype'] == 'b2g':

if sync_time:
# if we're synchronizing time, we need to connect to the network
wifi_settings = json.loads(open(wifi_settings_file).read())
device.connectWIFI(wifi_settings)

# unlock device, so it doesn't go to sleep
device.unlock()

# reset orientation to default for this type of device
device.resetOrientation()

# synchronize time unless instructed not to
if sync_time:
device.synchronizeTime()

capture_metadata = {
'name': capture_name,
'testpath': testinfo['relpath'],
Expand Down Expand Up @@ -140,6 +128,25 @@ def run_test(testkey, capture_device, appname, capture_name,
docroot = TEST_DIR,
tempdir = EIDETICKER_TEMP_DIR)

if device_prefs['devicetype'] == 'b2g':

device.setupMarionette()

if sync_time:
# if we're synchronizing time, we need to connect to the network
wifi_settings = json.loads(open(wifi_settings_file).read())
device.connectWIFI(wifi_settings)

# unlock device, so it doesn't go to sleep
device.unlock()

# reset orientation to default for this type of device
device.resetOrientation()

# synchronize time unless instructed not to
if sync_time:
device.synchronizeTime()

test.run()
test.cleanup()

Expand Down

0 comments on commit ffaf504

Please sign in to comment.