Bug 1247639 - Fix DMError when running |mach mochitest| on Android, r?gbrown
MozReview-Commit-ID: 1s8x4zIhZSS
--- a/testing/mochitest/mochitest_options.py
+++ b/testing/mochitest/mochitest_options.py
@@ -5,17 +5,17 @@
from abc import ABCMeta, abstractmethod, abstractproperty
from argparse import ArgumentParser, SUPPRESS
from distutils.util import strtobool
from urlparse import urlparse
import json
import os
import tempfile
-from droid import DroidADB, DroidSUT
+from mozdevice import DroidADB, DroidSUT
from mozprofile import DEFAULT_PORTS
import mozinfo
import mozlog
import moznetwork
here = os.path.abspath(os.path.dirname(__file__))
--- a/testing/mochitest/moz.build
+++ b/testing/mochitest/moz.build
@@ -28,23 +28,16 @@ TEST_HARNESS_FILES.testing.mochitest +=
'!automation.py',
'/build/mobile/remoteautomation.py',
'/build/pgo/server-locations.txt',
'/build/sanitizers/lsan_suppressions.txt',
'/build/valgrind/cross-architecture.sup',
'/build/valgrind/i386-redhat-linux-gnu.sup',
'/build/valgrind/x86_64-redhat-linux-gnu.sup',
'/netwerk/test/httpserver/httpd.js',
- '/testing/mozbase/mozdevice/mozdevice/devicemanager.py',
- '/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py',
- '/testing/mozbase/mozdevice/mozdevice/devicemanagerSUT.py',
- '/testing/mozbase/mozdevice/mozdevice/droid.py',
- '/testing/mozbase/mozdevice/mozdevice/version_codes.py',
- '/testing/mozbase/mozdevice/mozdevice/Zeroconf.py',
- '/testing/mozbase/moznetwork/moznetwork/moznetwork.py',
'b2g_start_script.js',
'bisection.py',
'browser-harness.xul',
'browser-test-overlay.xul',
'browser-test.js',
'cc-analyzer.js',
'chrome-harness.js',
'chunkifyTests.js',
--- a/testing/mochitest/runrobocop.py
+++ b/testing/mochitest/runrobocop.py
@@ -16,17 +16,17 @@ sys.path.insert(
from automation import Automation
from remoteautomation import RemoteAutomation, fennecLogcatFilters
from runtests import MochitestDesktop, MessageLogger
from mochitest_options import MochitestArgumentParser
from manifestparser import TestManifest
from manifestparser.filters import chunk_by_slice
-import devicemanager
+import mozdevice
import mozinfo
SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
# TODO inherit from MochitestBase instead
class RobocopTestRunner(MochitestDesktop):
"""
@@ -232,17 +232,17 @@ class RobocopTestRunner(MochitestDesktop
# some files are not needed for robocop; save time by not pushing
shutil.rmtree(os.path.join(self.localProfile, 'webapps'))
desktop_extensions = ['mochikit@mozilla.org', 'worker-test@mozilla.org', 'workerbootstrap-test@mozilla.org']
for ext in desktop_extensions:
shutil.rmtree(os.path.join(self.localProfile, 'extensions', 'staged', ext))
os.remove(os.path.join(self.localProfile, 'userChrome.css'))
try:
self.dm.pushDir(self.localProfile, self.remoteProfileCopy)
- except devicemanager.DMError:
+ except mozdevice.DMError:
self.log.error(
"Automation Error: Unable to copy profile to device.")
raise
return manifest
def setupRemoteProfile(self):
"""
@@ -250,17 +250,17 @@ class RobocopTestRunner(MochitestDesktop
"""
self.log.debug("Updating remote profile at %s" % self.remoteProfile)
self.dm.removeDir(self.remoteProfile)
if self.remoteCopyAvailable:
try:
self.dm.shellCheckOutput(
['cp', '-r', self.remoteProfileCopy, self.remoteProfile],
root=True, timeout=60)
- except devicemanager.DMError:
+ except mozdevice.DMError:
# For instance, cp is not available on some older versions of
# Android.
self.log.info(
"Unable to copy remote profile; falling back to push.")
self.remoteCopyAvailable = False
if not self.remoteCopyAvailable:
self.dm.pushDir(self.localProfile, self.remoteProfile)
@@ -340,17 +340,17 @@ class RobocopTestRunner(MochitestDesktop
for category in devinfo:
if type(devinfo[category]) is list:
self.log.info(" %s:" % category)
for item in devinfo[category]:
self.log.info(" %s" % item)
else:
self.log.info(" %s: %s" % (category, devinfo[category]))
self.log.info("Test root: %s" % self.dm.deviceRoot)
- except devicemanager.DMError:
+ except mozdevice.DMError:
self.log.warning("Error getting device information")
def setupRobotiumConfig(self, browserEnv):
"""
Create robotium.config and push it to the device.
"""
fHandle = tempfile.NamedTemporaryFile(suffix='.config',
prefix='robotium-',
@@ -543,17 +543,17 @@ def run_test_harness(options):
except:
traceback.print_exc()
robocop.log.error(
"runrobocop.py | Received unexpected exception while running tests")
runResult = 1
finally:
try:
robocop.cleanup()
- except devicemanager.DMError:
+ except mozdevice.DMError:
# ignore device error while cleaning up
pass
message_logger.finish()
return runResult
def main(args=sys.argv[1:]):
parser = MochitestArgumentParser(app='android')
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -11,17 +11,17 @@ sys.path.insert(
os.path.realpath(
os.path.dirname(__file__))))
from automation import Automation
from remoteautomation import RemoteAutomation, fennecLogcatFilters
from runtests import MochitestDesktop, MessageLogger
from mochitest_options import MochitestArgumentParser
-import devicemanager
+import mozdevice
import mozinfo
SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
# TODO inherit from MochitestBase instead
class MochiRemote(MochitestDesktop):
_automation = None
@@ -165,34 +165,34 @@ class MochiRemote(MochitestDesktop):
restoreRemotePaths()
def buildProfile(self, options):
restoreRemotePaths = self.switchToLocalPaths(options)
if options.testingModulesDir:
try:
self._dm.pushDir(options.testingModulesDir, self.remoteModulesDir)
self._dm.chmodDir(self.remoteModulesDir)
- except devicemanager.DMError:
+ except mozdevice.DMError:
self.log.error(
"Automation Error: Unable to copy test modules to device.")
raise
savedTestingModulesDir = options.testingModulesDir
options.testingModulesDir = self.remoteModulesDir
else:
savedTestingModulesDir = None
manifest = MochitestDesktop.buildProfile(self, options)
if savedTestingModulesDir:
options.testingModulesDir = savedTestingModulesDir
self.localProfile = options.profilePath
self._dm.removeDir(self.remoteProfile)
try:
self._dm.pushDir(options.profilePath, self.remoteProfile)
self._dm.chmodDir(self.remoteProfile)
- except devicemanager.DMError:
+ except mozdevice.DMError:
self.log.error(
"Automation Error: Unable to copy profile to device.")
raise
restoreRemotePaths()
options.profilePath = self.remoteProfile
return manifest
@@ -203,17 +203,17 @@ class MochiRemote(MochitestDesktop):
options.profilePath = self.localProfile
env["MOZ_HIDE_RESULTS_TABLE"] = "1"
retVal = MochitestDesktop.buildURLOptions(self, options, env)
# we really need testConfig.js (for browser chrome)
try:
self._dm.pushDir(options.profilePath, self.remoteProfile)
self._dm.chmodDir(self.remoteProfile)
- except devicemanager.DMError:
+ except mozdevice.DMError:
self.log.error(
"Automation Error: Unable to copy profile to device.")
raise
options.profilePath = self.remoteProfile
options.logFile = self.localLog
return retVal
@@ -244,17 +244,17 @@ class MochiRemote(MochitestDesktop):
for category in devinfo:
if type(devinfo[category]) is list:
self.log.info(" %s:" % category)
for item in devinfo[category]:
self.log.info(" %s" % item)
else:
self.log.info(" %s: %s" % (category, devinfo[category]))
self.log.info("Test root: %s" % self._dm.deviceRoot)
- except devicemanager.DMError:
+ except mozdevice.DMError:
self.log.warning("Error getting device information")
def getGMPPluginPath(self, options):
# TODO: bug 1149374
return None
def buildBrowserEnv(self, options, debugger=False):
browserEnv = MochitestDesktop.buildBrowserEnv(
@@ -353,17 +353,17 @@ def run_test_harness(options):
dm.recordLogcat()
retVal = mochitest.runTests(options)
except:
log.error("Automation Error: Exception caught while running tests")
traceback.print_exc()
mochitest.stopServers()
try:
mochitest.cleanup(options)
- except devicemanager.DMError:
+ except mozdevice.DMError:
# device error cleaning up... oh well!
pass
retVal = 1
if options.log_mach is None:
mochitest.printDeviceInfo(printLogcat=True)
message_logger.finish()