зеркало из https://github.com/mozilla/gecko-dev.git
Bug 908275 - Use mozlog in mochitest runtestsremote; r=jmaher
This commit is contained in:
Родитель
159520a16f
Коммит
9b5e7ab044
|
@ -23,6 +23,9 @@ from mochitest_options import MochitestOptions
|
|||
import devicemanager
|
||||
import droid
|
||||
import manifestparser
|
||||
import mozlog
|
||||
|
||||
log = mozlog.getLogger('Mochi-Remote')
|
||||
|
||||
class RemoteOptions(MochitestOptions):
|
||||
|
||||
|
@ -130,13 +133,13 @@ class RemoteOptions(MochitestOptions):
|
|||
if os.name != "nt":
|
||||
options.remoteWebServer = automation.getLanIp()
|
||||
else:
|
||||
print "ERROR: you must specify a --remote-webserver=<ip address>\n"
|
||||
log.error("you must specify a --remote-webserver=<ip address>")
|
||||
return None
|
||||
|
||||
options.webServer = options.remoteWebServer
|
||||
|
||||
if (options.deviceIP == None):
|
||||
print "ERROR: you must provide a device IP"
|
||||
log.error("you must provide a device IP")
|
||||
return None
|
||||
|
||||
if (options.remoteLogFile == None):
|
||||
|
@ -147,13 +150,13 @@ class RemoteOptions(MochitestOptions):
|
|||
|
||||
# remoteAppPath or app must be specified to find the product to launch
|
||||
if (options.remoteAppPath and options.app):
|
||||
print "ERROR: You cannot specify both the remoteAppPath and the app setting"
|
||||
log.error("You cannot specify both the remoteAppPath and the app setting")
|
||||
return None
|
||||
elif (options.remoteAppPath):
|
||||
options.app = options.remoteTestRoot + "/" + options.remoteAppPath
|
||||
elif (options.app == None):
|
||||
# Neither remoteAppPath nor app are set -- error
|
||||
print "ERROR: You must specify either appPath or app"
|
||||
log.error("You must specify either appPath or app")
|
||||
return None
|
||||
|
||||
# Only reset the xrePath if it wasn't provided
|
||||
|
@ -171,14 +174,14 @@ class RemoteOptions(MochitestOptions):
|
|||
# Robocop specific deprecated options.
|
||||
if options.robocop:
|
||||
if options.robocopIni:
|
||||
print "ERROR: can not use deprecated --robocop and replacement --robocop-ini together"
|
||||
log.error("can not use deprecated --robocop and replacement --robocop-ini together")
|
||||
return None
|
||||
options.robocopIni = options.robocop
|
||||
del options.robocop
|
||||
|
||||
if options.robocopPath:
|
||||
if options.robocopApk:
|
||||
print "ERROR: can not use deprecated --robocop-path and replacement --robocop-apk together"
|
||||
log.error("can not use deprecated --robocop-path and replacement --robocop-apk together")
|
||||
return None
|
||||
options.robocopApk = os.path.join(options.robocopPath, 'robocop.apk')
|
||||
del options.robocopPath
|
||||
|
@ -186,19 +189,19 @@ class RemoteOptions(MochitestOptions):
|
|||
# Robocop specific options
|
||||
if options.robocopIni != "":
|
||||
if not os.path.exists(options.robocopIni):
|
||||
print "ERROR: Unable to find specified robocop .ini manifest '%s'" % options.robocopIni
|
||||
log.error("Unable to find specified robocop .ini manifest '%s'", options.robocopIni)
|
||||
return None
|
||||
options.robocopIni = os.path.abspath(options.robocopIni)
|
||||
|
||||
if options.robocopApk != "":
|
||||
if not os.path.exists(options.robocopApk):
|
||||
print "ERROR: Unable to find robocop APK '%s'" % options.robocopApk
|
||||
log.error("Unable to find robocop APK '%s'", options.robocopApk)
|
||||
return None
|
||||
options.robocopApk = os.path.abspath(options.robocopApk)
|
||||
|
||||
if options.robocopIds != "":
|
||||
if not os.path.exists(options.robocopIds):
|
||||
print "ERROR: Unable to find specified robocop IDs file '%s'" % options.robocopIds
|
||||
log.error("Unable to find specified robocop IDs file '%s'", options.robocopIds)
|
||||
return None
|
||||
options.robocopIds = os.path.abspath(options.robocopIds)
|
||||
|
||||
|
@ -244,8 +247,8 @@ class MochiRemote(Mochitest):
|
|||
self._dm.getFile(self.remoteLog, self.localLog)
|
||||
self._dm.removeFile(self.remoteLog)
|
||||
else:
|
||||
print "WARNING: Unable to retrieve log file (%s) from remote " \
|
||||
"device" % self.remoteLog
|
||||
log.warn("Unable to retrieve log file (%s) from remote device",
|
||||
self.remoteLog)
|
||||
self._dm.removeDir(self.remoteProfile)
|
||||
|
||||
if (options.pidFile != ""):
|
||||
|
@ -253,7 +256,7 @@ class MochiRemote(Mochitest):
|
|||
os.remove(options.pidFile)
|
||||
os.remove(options.pidFile + ".xpcshell.pid")
|
||||
except:
|
||||
print "Warning: cleaning up pidfile '%s' was unsuccessful from the test harness" % options.pidFile
|
||||
log.warn("cleaning up pidfile '%s' was unsuccessful from the test harness", options.pidFile)
|
||||
|
||||
def findPath(self, paths, filename = None):
|
||||
for path in paths:
|
||||
|
@ -287,7 +290,7 @@ class MochiRemote(Mochitest):
|
|||
paths = [options.xrePath, localAutomation.DIST_BIN, self._automation._product, os.path.join('..', self._automation._product)]
|
||||
options.xrePath = self.findPath(paths)
|
||||
if options.xrePath == None:
|
||||
print "ERROR: unable to find xulrunner path for %s, please specify with --xre-path" % (os.name)
|
||||
log.error("unable to find xulrunner path for %s, please specify with --xre-path", os.name)
|
||||
sys.exit(1)
|
||||
paths.append("bin")
|
||||
paths.append(os.path.join("..", "bin"))
|
||||
|
@ -300,7 +303,7 @@ class MochiRemote(Mochitest):
|
|||
paths.insert(0, options.utilityPath)
|
||||
options.utilityPath = self.findPath(paths, xpcshell)
|
||||
if options.utilityPath == None:
|
||||
print "ERROR: unable to find utility path for %s, please specify with --utility-path" % (os.name)
|
||||
log.error("unable to find utility path for %s, please specify with --utility-path", os.name)
|
||||
sys.exit(1)
|
||||
# httpd-path is specified by standard makefile targets and may be specified
|
||||
# on the command line to select a particular version of httpd.js. If not
|
||||
|
@ -353,7 +356,7 @@ class MochiRemote(Mochitest):
|
|||
try:
|
||||
self._dm.pushDir(options.profilePath, self.remoteProfile)
|
||||
except devicemanager.DMError:
|
||||
print "Automation Error: Unable to copy profile to device."
|
||||
log.error("Automation Error: Unable to copy profile to device.")
|
||||
raise
|
||||
|
||||
options.profilePath = self.remoteProfile
|
||||
|
@ -371,7 +374,7 @@ class MochiRemote(Mochitest):
|
|||
try:
|
||||
self._dm.pushDir(options.profilePath, self.remoteProfile)
|
||||
except devicemanager.DMError:
|
||||
print "Automation Error: Unable to copy profile to device."
|
||||
log.error("Automation Error: Unable to copy profile to device.")
|
||||
raise
|
||||
|
||||
options.profilePath = self.remoteProfile
|
||||
|
@ -387,7 +390,7 @@ class MochiRemote(Mochitest):
|
|||
try:
|
||||
self._dm.pushFile(filename, manifest)
|
||||
except devicemanager.DMError:
|
||||
print "Automation Error: Unable to install Chrome files on device."
|
||||
log.error("Automation Error: Unable to install Chrome files on device.")
|
||||
raise
|
||||
|
||||
return manifest
|
||||
|
@ -424,7 +427,7 @@ class MochiRemote(Mochitest):
|
|||
if fail_found:
|
||||
result = 1
|
||||
if not end_found:
|
||||
print "ERROR: missing end of test marker (process crashed?)"
|
||||
log.error("missing end of test marker (process crashed?)")
|
||||
result = 1
|
||||
return result
|
||||
|
||||
|
@ -467,7 +470,7 @@ class MochiRemote(Mochitest):
|
|||
try:
|
||||
image = self._dm.pullFile("/mnt/sdcard/Robotium-Screenshots/robocop-screenshot.jpg")
|
||||
encoded = base64.b64encode(image)
|
||||
print "SCREENSHOT: data:image/jpg;base64,%s" % encoded
|
||||
log.info("SCREENSHOT: data:image/jpg;base64,%s", encoded)
|
||||
except:
|
||||
# If the test passes, no screenshot will be generated and
|
||||
# pullFile will fail -- continue silently.
|
||||
|
@ -477,11 +480,11 @@ class MochiRemote(Mochitest):
|
|||
try:
|
||||
if printLogcat:
|
||||
logcat = self._dm.getLogcat(filterOutRegexps=fennecLogcatFilters)
|
||||
print ''.join(logcat)
|
||||
print "Device info: %s" % self._dm.getInfo()
|
||||
print "Test root: %s" % self._dm.getDeviceRoot()
|
||||
log.info('\n'+(''.join(logcat)))
|
||||
log.info("Device info: %s", self._dm.getInfo())
|
||||
log.info("Test root: %s", self._dm.getDeviceRoot())
|
||||
except devicemanager.DMError:
|
||||
print "WARNING: Error getting device information"
|
||||
log.warn("Error getting device information")
|
||||
|
||||
def buildRobotiumConfig(self, options, browserEnv):
|
||||
deviceRoot = self._dm.getDeviceRoot()
|
||||
|
@ -500,7 +503,7 @@ class MochiRemote(Mochitest):
|
|||
for key, value in browserEnv.items():
|
||||
try:
|
||||
value.index(',')
|
||||
print "Found: Error an ',' in our value, unable to process value."
|
||||
log.error("Found a ',' in our value, unable to process value.")
|
||||
except ValueError, e:
|
||||
envstr += "%s%s=%s" % (delim, key, value)
|
||||
delim = ","
|
||||
|
@ -533,7 +536,7 @@ def main():
|
|||
auto.setDeviceManager(dm)
|
||||
options = parser.verifyRemoteOptions(options, auto)
|
||||
if (options == None):
|
||||
print "ERROR: Invalid options specified, use --help for a list of valid options"
|
||||
log.error("Invalid options specified, use --help for a list of valid options")
|
||||
sys.exit(1)
|
||||
|
||||
productPieces = options.remoteProductName.split('.')
|
||||
|
@ -578,7 +581,7 @@ def main():
|
|||
if end > len(tests):
|
||||
end = len(tests)
|
||||
my_tests = tests[start:end]
|
||||
print "Running tests %d-%d/%d" % ((start+1), end, len(tests))
|
||||
log.info("Running tests %d-%d/%d", start+1, end, len(tests))
|
||||
|
||||
deviceRoot = dm.getDeviceRoot()
|
||||
dm.removeFile(os.path.join(deviceRoot, "fennec_ids.txt"))
|
||||
|
@ -634,7 +637,7 @@ def main():
|
|||
dm._runCmds([{"cmd": " ".join(delete)}])
|
||||
|
||||
# Insert the bookmarks
|
||||
print "Insert bookmarks in the default android browser database"
|
||||
log.info("Insert bookmarks in the default android browser database")
|
||||
for i in range(20):
|
||||
if ("pandaboard" in devOS):
|
||||
cmd = ['execsu', 'sqlite3', "/data/data/com.android.browser/databases/browser2.db 'insert or replace into bookmarks(_id,title,url,folder,parent,position) values (" + str(30 + i) + ",\"Bookmark"+ str(i) + "\",\"http://www.bookmark" + str(i) + ".com\",0,1," + str(100 + i) + ");'"]
|
||||
|
@ -647,7 +650,7 @@ def main():
|
|||
dm.recordLogcat()
|
||||
result = mochitest.runTests(options)
|
||||
if result != 0:
|
||||
print "ERROR: runTests() exited with code %s" % result
|
||||
log.error("runTests() exited with code %s", result)
|
||||
log_result = mochitest.addLogData()
|
||||
if result != 0 or log_result != 0:
|
||||
mochitest.printDeviceInfo(printLogcat=True)
|
||||
|
@ -656,7 +659,7 @@ def main():
|
|||
if retVal is None or retVal == 0:
|
||||
retVal = result
|
||||
except:
|
||||
print "Automation Error: Exception caught while running tests"
|
||||
log.error("Automation Error: Exception caught while running tests")
|
||||
traceback.print_exc()
|
||||
mochitest.stopWebServer(options)
|
||||
mochitest.stopWebSocketServer(options)
|
||||
|
@ -677,7 +680,7 @@ def main():
|
|||
if (options.dm_trans == "sut"):
|
||||
dm._runCmds([{"cmd": " ".join(cmd_del)}])
|
||||
if retVal is None:
|
||||
print "No tests run. Did you pass an invalid TEST_PATH?"
|
||||
log.warn("No tests run. Did you pass an invalid TEST_PATH?")
|
||||
retVal = 1
|
||||
else:
|
||||
# if we didn't have some kind of error running the tests, make
|
||||
|
@ -692,7 +695,7 @@ def main():
|
|||
dm.recordLogcat()
|
||||
retVal = mochitest.runTests(options)
|
||||
except:
|
||||
print "Automation Error: Exception caught while running tests"
|
||||
log.error("Automation Error: Exception caught while running tests")
|
||||
traceback.print_exc()
|
||||
mochitest.stopWebServer(options)
|
||||
mochitest.stopWebSocketServer(options)
|
||||
|
|
Загрузка…
Ссылка в новой задаче