Bug 809437 - Fix B2G emulator unittest intermittent timeout, r=jgriffin

This commit is contained in:
Andrew Halberstadt 2012-11-13 09:32:34 -05:00
Родитель 6c4fbc534b
Коммит 1291eb0f93
1 изменённых файлов: 34 добавлений и 12 удалений

Просмотреть файл

@ -373,6 +373,32 @@ waitFor(
self.logcat_proc.waitForFinish() self.logcat_proc.waitForFinish()
self.logcat_proc = None self.logcat_proc = None
def _restart_b2g(self, marionette):
self.dm.shellCheckOutput(['stop', 'b2g'])
# ensure the b2g process has fully stopped
for i in range(0, 10):
time.sleep(1)
if self.dm.processExist('b2g') is None:
break
else:
raise TimeoutException("Timeout waiting for the b2g process to terminate")
self.dm.shellCheckOutput(['start', 'b2g'])
# ensure the b2g process has started
for i in range(0, 10):
time.sleep(1)
if self.dm.processExist('b2g') is not None:
break
else:
raise TimeoutException("Timeout waiting for the b2g process to start")
if not self.wait_for_port():
raise TimeoutException("Timeout waiting for marionette on port '%s'" % self.marionette_port)
self.wait_for_system_message(marionette)
def install_gecko(self, gecko_path, marionette): def install_gecko(self, gecko_path, marionette):
""" """
Install gecko into the emulator using adb push. Restart b2g after the Install gecko into the emulator using adb push. Restart b2g after the
@ -383,6 +409,7 @@ waitFor(
# hang indefinitely while copying large files to the system # hang indefinitely while copying large files to the system
# partition. # partition.
push_attempts = 10 push_attempts = 10
restart_attempts = 10
print 'installing gecko binaries...' print 'installing gecko binaries...'
# need to remount so we can write to /system/b2g # need to remount so we can write to /system/b2g
@ -400,20 +427,15 @@ waitFor(
if retry == push_attempts: if retry == push_attempts:
raise raise
print 'restarting B2G' for retry in range(1, restart_attempts+1):
self.dm.shellCheckOutput(['stop', 'b2g']) print 'restarting B2G (attempt %s of %s)' % (retry, restart_attempts)
# ensure the b2g process has fully stopped (bug 809437) try:
for i in range(0, 10): self._restart_b2g(marionette)
time.sleep(1)
if self.dm.processExist('b2g') is None:
break break
else: except MarionetteException, TimeoutException:
raise TimeoutException("Timeout waiting for the b2g process to terminate") if retry == restart_attmempts:
self.dm.shellCheckOutput(['start', 'b2g']) raise
if not self.wait_for_port():
raise TimeoutException("Timeout waiting for marionette on port '%s'" % self.marionette_port)
self.wait_for_system_message(marionette)
def rotate_log(self, srclog, index=1): def rotate_log(self, srclog, index=1):
""" Rotate a logfile, by recursively rotating logs further in the sequence, """ Rotate a logfile, by recursively rotating logs further in the sequence,