本文整理汇总了Python中remoteautomation.RemoteAutomation类的典型用法代码示例。如果您正苦于以下问题:Python RemoteAutomation类的具体用法?Python RemoteAutomation怎么用?Python RemoteAutomation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RemoteAutomation类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run_test_harness
def run_test_harness(options):
if options is None:
raise ValueError(
"Invalid options specified, use --help for a list of valid options")
message_logger = MessageLogger(logger=None)
process_args = {'messageLogger': message_logger}
auto = RemoteAutomation(None, "fennec", processArgs=process_args)
auto.setDeviceManager(options.dm)
runResult = -1
robocop = RobocopTestRunner(auto, options.dm, options)
try:
message_logger.logger = robocop.log
message_logger.buffering = False
robocop.message_logger = message_logger
robocop.log.debug("options=%s" % vars(options))
runResult = robocop.runTests()
except KeyboardInterrupt:
robocop.log.info("runrobocop.py | Received keyboard interrupt")
runResult = -1
except:
traceback.print_exc()
robocop.log.error(
"runrobocop.py | Received unexpected exception while running tests")
runResult = 1
finally:
try:
robocop.cleanup()
except devicemanager.DMError:
# ignore device error while cleaning up
pass
message_logger.finish()
return runResult
开发者ID:paulmadore,项目名称:luckyde,代码行数:32,代码来源:runrobocop.py
示例2: main
def main():
dm = DeviceManager(None, None)
automation = RemoteAutomation(dm)
parser = RemoteOptions(automation)
options, args = parser.parse_args()
if options.deviceIP == None:
print "Error: you must provide a device IP to connect to via the --device option"
sys.exit(1)
dm = DeviceManager(options.deviceIP, options.devicePort)
automation.setDeviceManager(dm)
if options.remoteProductName != None:
automation.setProduct(options.remoteProductName)
# Set up the defaults and ensure options are set
options = parser.verifyRemoteOptions(options)
if options == None:
print "ERROR: Invalid options specified, use --help for a list of valid options"
sys.exit(1)
automation.setAppName(options.app)
automation.setRemoteProfile(options.remoteProfile)
reftest = RemoteReftest(automation, dm, options, SCRIPT_DIRECTORY)
# Start the webserver
reftest.startWebServer(options)
# an example manifest name to use on the cli
# manifest = "http://" + options.remoteWebServer + "/reftests/layout/reftests/reftest-sanity/reftest.list"
reftest.runTests(args[0], options)
reftest.stopWebServer(options)
开发者ID:lofter2011,项目名称:Icefox,代码行数:32,代码来源:remotereftest.py
示例3: main
def main():
scriptdir = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
dm = devicemanager.DeviceManager(None, None)
auto = RemoteAutomation(dm, "fennec")
parser = RemoteOptions(auto, scriptdir)
options, args = parser.parse_args()
dm = devicemanager.DeviceManager(options.deviceIP, options.devicePort)
auto.setDeviceManager(dm)
options = parser.verifyRemoteOptions(options, auto)
if (options == None):
print "ERROR: Invalid options specified, use --help for a list of valid options"
sys.exit(1)
productPieces = options.remoteProductName.split('.')
if (productPieces != None):
auto.setProduct(productPieces[0])
else:
auto.setProduct(options.remoteProductName)
mochitest = MochiRemote(auto, dm, options)
options = parser.verifyOptions(options, mochitest)
if (options == None):
sys.exit(1)
auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
sys.exit(mochitest.runTests(options))
开发者ID:lofter2011,项目名称:Icefox,代码行数:28,代码来源:runtestsremote.py
示例4: run_test_harness
def run_test_harness(parser, options):
parser.validate(options)
if options is None:
raise ValueError(
"Invalid options specified, use --help for a list of valid options")
message_logger = MessageLogger(logger=None)
process_args = {'messageLogger': message_logger}
auto = RemoteAutomation(None, "fennec", processArgs=process_args)
auto.setDeviceManager(options.dm)
runResult = -1
robocop = RobocopTestRunner(auto, options.dm, options)
# Check that Firefox is installed
expected = options.app.split('/')[-1]
installed = options.dm.shellCheckOutput(['pm', 'list', 'packages', expected])
if expected not in installed:
robocop.log.error("%s is not installed on this device" % expected)
return 1
try:
message_logger.logger = robocop.log
message_logger.buffering = False
robocop.message_logger = message_logger
robocop.log.debug("options=%s" % vars(options))
runResult = robocop.runTests()
except KeyboardInterrupt:
robocop.log.info("runrobocop.py | Received keyboard interrupt")
runResult = -1
except:
traceback.print_exc()
robocop.log.error(
"runrobocop.py | Received unexpected exception while running tests")
runResult = 1
finally:
try:
robocop.cleanup()
except mozdevice.DMError:
# ignore device error while cleaning up
pass
message_logger.finish()
return runResult
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:42,代码来源:runrobocop.py
示例5: main
def main():
scriptdir = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
auto = RemoteAutomation(None, "fennec")
parser = RemoteOptions(auto, scriptdir)
options, args = parser.parse_args()
if (options.dm_trans == "adb"):
if (options.deviceIP):
dm = devicemanagerADB.DeviceManagerADB(options.deviceIP, options.devicePort)
else:
dm = devicemanagerADB.DeviceManagerADB()
else:
dm = devicemanagerSUT.DeviceManagerSUT(options.deviceIP, options.devicePort)
auto.setDeviceManager(dm)
options = parser.verifyRemoteOptions(options, auto)
if (options == None):
print "ERROR: Invalid options specified, use --help for a list of valid options"
sys.exit(1)
productPieces = options.remoteProductName.split('.')
if (productPieces != None):
auto.setProduct(productPieces[0])
else:
auto.setProduct(options.remoteProductName)
mochitest = MochiRemote(auto, dm, options)
options = parser.verifyOptions(options, mochitest)
if (options == None):
sys.exit(1)
logParent = os.path.dirname(options.remoteLogFile)
dm.mkDir(logParent);
auto.setRemoteLog(options.remoteLogFile)
auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
print dm.getInfo()
procName = options.app.split('/')[-1]
if (dm.processExist(procName)):
dm.killProcess(procName)
if options.robocop != "":
mp = manifestparser.TestManifest(strict=False)
# TODO: pull this in dynamically
mp.read(options.robocop)
robocop_tests = mp.active_tests(exists=False)
deviceRoot = dm.getDeviceRoot()
dm.removeFile(os.path.join(deviceRoot, "fennec_ids.txt"))
fennec_ids = os.path.abspath("fennec_ids.txt")
if not os.path.exists(fennec_ids) and options.robocopIds:
fennec_ids = options.robocopIds
dm.pushFile(fennec_ids, os.path.join(deviceRoot, "fennec_ids.txt"))
options.extraPrefs.append('robocop.logfile="%s/robocop.log"' % deviceRoot)
options.extraPrefs.append('browser.search.suggest.enabled=true')
options.extraPrefs.append('browser.search.suggest.prompted=true')
if (options.dm_trans == 'adb' and options.robocopPath):
dm._checkCmd(["install", "-r", os.path.join(options.robocopPath, "robocop.apk")])
appname = options.app
retVal = None
for test in robocop_tests:
if options.testPath and options.testPath != test['name']:
continue
options.app = "am"
options.browserArgs = ["instrument", "-w", "-e", "deviceroot", deviceRoot, "-e", "class"]
options.browserArgs.append("%s.tests.%s" % (appname, test['name']))
options.browserArgs.append("org.mozilla.roboexample.test/%s.FennecInstrumentationTestRunner" % appname)
try:
dm.recordLogcat()
retVal = mochitest.runTests(options)
mochitest.addLogData()
except:
print "TEST-UNEXPECTED-FAIL | %s | Exception caught while running robocop tests." % sys.exc_info()[1]
mochitest.stopWebServer(options)
mochitest.stopWebSocketServer(options)
try:
mochitest.cleanup(None, options)
except devicemanager.DMError:
# device error cleaning up... oh well!
pass
retVal = 1
break
if retVal is None:
print "No tests run. Did you pass an invalid TEST_PATH?"
retVal = 1
if retVal == 0:
# if we didn't have some kind of error running the tests, make
# sure the tests actually passed
retVal = mochitest.printLog()
else:
try:
dm.recordLogcat()
retVal = mochitest.runTests(options)
except:
print "TEST-UNEXPECTED-FAIL | %s | Exception caught while running tests." % sys.exc_info()[1]
#.........这里部分代码省略.........
开发者ID:mihaisucan,项目名称:devtools-window,代码行数:101,代码来源:runtestsremote.py
示例6: run_test_harness
def run_test_harness(parser, options):
parser.validate(options)
message_logger = MessageLogger(logger=None)
process_args = {"messageLogger": message_logger}
auto = RemoteAutomation(None, "fennec", processArgs=process_args)
if options is None:
raise ValueError("Invalid options specified, use --help for a list of valid options")
options.runByDir = False
# roboextender is used by mochitest-chrome tests like test_java_addons.html,
# but not by any plain mochitests
if options.flavor != "chrome":
options.extensionsToExclude.append("[email protected]")
dm = options.dm
auto.setDeviceManager(dm)
mochitest = MochiRemote(auto, dm, options)
log = mochitest.log
message_logger.logger = log
mochitest.message_logger = message_logger
# Check that Firefox is installed
expected = options.app.split("/")[-1]
installed = dm.shellCheckOutput(["pm", "list", "packages", expected])
if expected not in installed:
log.error("%s is not installed on this device" % expected)
return 1
productPieces = options.remoteProductName.split(".")
if productPieces is not None:
auto.setProduct(productPieces[0])
else:
auto.setProduct(options.remoteProductName)
auto.setAppName(options.remoteappname)
logParent = os.path.dirname(options.remoteLogFile)
dm.mkDir(logParent)
auto.setRemoteLog(options.remoteLogFile)
auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
if options.log_mach is None:
mochitest.printDeviceInfo()
# Add Android version (SDK level) to mozinfo so that manifest entries
# can be conditional on android_version.
androidVersion = dm.shellCheckOutput(["getprop", "ro.build.version.sdk"])
log.info("Android sdk version '%s'; will use this to filter manifests" % str(androidVersion))
mozinfo.info["android_version"] = androidVersion
deviceRoot = dm.deviceRoot
if options.dmdPath:
dmdLibrary = "libdmd.so"
dmdPathOnDevice = os.path.join(deviceRoot, dmdLibrary)
dm.removeFile(dmdPathOnDevice)
dm.pushFile(os.path.join(options.dmdPath, dmdLibrary), dmdPathOnDevice)
options.dmdPath = deviceRoot
options.dumpOutputDirectory = deviceRoot
procName = options.app.split("/")[-1]
dm.killProcess(procName)
mochitest.mozLogName = "moz.log"
try:
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 mozdevice.DMError:
# device error cleaning up... oh well!
pass
retVal = 1
if options.log_mach is None:
mochitest.printDeviceInfo(printLogcat=True)
message_logger.finish()
return retVal
开发者ID:frap129,项目名称:hyperfox,代码行数:86,代码来源:runtestsremote.py
示例7: main
def main():
dm_none = devicemanagerADB.DeviceManagerADB(None, None)
automation = RemoteAutomation(dm_none)
parser = RemoteOptions(automation)
options, args = parser.parse_args()
if (options.deviceIP == None):
print "Error: you must provide a device IP to connect to via the --device option"
sys.exit(1)
if (options.dm_trans == "adb"):
if (options.deviceIP):
dm = devicemanagerADB.DeviceManagerADB(options.deviceIP, options.devicePort)
else:
dm = dm_none
else:
dm = devicemanagerSUT.DeviceManagerSUT(options.deviceIP, options.devicePort)
automation.setDeviceManager(dm)
if (options.remoteProductName != None):
automation.setProduct(options.remoteProductName)
# Set up the defaults and ensure options are set
options = parser.verifyRemoteOptions(options)
if (options == None):
print "ERROR: Invalid options specified, use --help for a list of valid options"
sys.exit(1)
if not options.ignoreWindowSize:
parts = dm.getInfo('screen')['screen'][0].split()
width = int(parts[0].split(':')[1])
height = int(parts[1].split(':')[1])
if (width < 1050 or height < 1050):
print "ERROR: Invalid screen resolution %sx%s, please adjust to 1366x1050 or higher" % (width, height)
sys.exit(1)
automation.setAppName(options.app)
automation.setRemoteProfile(options.remoteProfile)
automation.setRemoteLog(options.remoteLogFile)
reftest = RemoteReftest(automation, dm, options, SCRIPT_DIRECTORY)
# Hack in a symbolic link for jsreftest
os.system("ln -s ../jsreftest " + str(os.path.join(SCRIPT_DIRECTORY, "jsreftest")))
# Dynamically build the reftest URL if possible, beware that args[0] should exist 'inside' the webroot
manifest = args[0]
if os.path.exists(os.path.join(SCRIPT_DIRECTORY, args[0])):
manifest = "http://" + str(options.remoteWebServer) + ":" + str(options.httpPort) + "/" + args[0]
elif os.path.exists(args[0]):
manifestPath = os.path.abspath(args[0]).split(SCRIPT_DIRECTORY)[1].strip('/')
manifest = "http://" + str(options.remoteWebServer) + ":" + str(options.httpPort) + "/" + manifestPath
else:
print "ERROR: Could not find test manifest '%s'" % manifest
sys.exit(1)
# Start the webserver
reftest.startWebServer(options)
procName = options.app.split('/')[-1]
if (dm.processExist(procName)):
dm.killProcess(procName)
#an example manifest name to use on the cli
# manifest = "http://" + options.remoteWebServer + "/reftests/layout/reftests/reftest-sanity/reftest.list"
try:
cmdlineArgs = ["-reftest", manifest]
if options.bootstrap:
cmdlineArgs = []
reftest.runTests(manifest, options, cmdlineArgs)
except:
print "TEST-UNEXPECTED-FAIL | | exception while running reftests"
reftest.stopWebServer(options)
sys.exit(1)
reftest.stopWebServer(options)
开发者ID:ThinkerYzu,项目名称:mozilla-central,代码行数:75,代码来源:remotereftest.py
示例8: run_test_harness
def run_test_harness(options):
message_logger = MessageLogger(logger=None)
process_args = {'messageLogger': message_logger}
auto = RemoteAutomation(None, "fennec", processArgs=process_args)
if options is None:
raise ValueError("Invalid options specified, use --help for a list of valid options")
dm = options.dm
auto.setDeviceManager(dm)
mochitest = MochiRemote(auto, dm, options)
log = mochitest.log
message_logger.logger = log
mochitest.message_logger = message_logger
productPieces = options.remoteProductName.split('.')
if (productPieces is not None):
auto.setProduct(productPieces[0])
else:
auto.setProduct(options.remoteProductName)
auto.setAppName(options.remoteappname)
logParent = os.path.dirname(options.remoteLogFile)
dm.mkDir(logParent)
auto.setRemoteLog(options.remoteLogFile)
auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
mochitest.printDeviceInfo()
# Add Android version (SDK level) to mozinfo so that manifest entries
# can be conditional on android_version.
androidVersion = dm.shellCheckOutput(['getprop', 'ro.build.version.sdk'])
log.info(
"Android sdk version '%s'; will use this to filter manifests" %
str(androidVersion))
mozinfo.info['android_version'] = androidVersion
deviceRoot = dm.deviceRoot
if options.dmdPath:
dmdLibrary = "libdmd.so"
dmdPathOnDevice = os.path.join(deviceRoot, dmdLibrary)
dm.removeFile(dmdPathOnDevice)
dm.pushFile(os.path.join(options.dmdPath, dmdLibrary), dmdPathOnDevice)
options.dmdPath = deviceRoot
options.dumpOutputDirectory = deviceRoot
procName = options.app.split('/')[-1]
dm.killProcess(procName)
if options.robocopIni != "":
# turning buffering off as it's not used in robocop
message_logger.buffering = False
# sut may wait up to 300 s for a robocop am process before returning
dm.default_timeout = 320
if isinstance(options.manifestFile, TestManifest):
mp = options.manifestFile
else:
mp = TestManifest(strict=False)
mp.read(options.robocopIni)
filters = []
if options.totalChunks:
filters.append(
chunk_by_slice(options.thisChunk, options.totalChunks))
robocop_tests = mp.active_tests(exists=False, filters=filters, **mozinfo.info)
options.extraPrefs.append('browser.search.suggest.enabled=true')
options.extraPrefs.append('browser.search.suggest.prompted=true')
options.extraPrefs.append('layout.css.devPixelsPerPx=1.0')
options.extraPrefs.append('browser.chrome.dynamictoolbar=false')
options.extraPrefs.append('browser.snippets.enabled=false')
options.extraPrefs.append('browser.casting.enabled=true')
options.extraPrefs.append('extensions.autoupdate.enabled=false')
if (options.dm_trans == 'adb' and options.robocopApk):
dm._checkCmd(["install", "-r", options.robocopApk])
if not options.autorun:
# Force a single loop iteration. The iteration will start Fennec and
# the httpd server, but not actually run a test.
options.test_paths = [robocop_tests[0]['name']]
retVal = None
# Filtering tests
active_tests = []
for test in robocop_tests:
if options.test_paths and test['name'] not in options.test_paths:
continue
if 'disabled' in test:
log.info(
'TEST-INFO | skipping %s | %s' %
(test['name'], test['disabled']))
continue
active_tests.append(test)
#.........这里部分代码省略.........
开发者ID:nafis-sadik,项目名称:gecko-dev,代码行数:101,代码来源:runtestsremote.py
示例9: run_test_harness
def run_test_harness(options):
message_logger = MessageLogger(logger=None)
process_args = {'messageLogger': message_logger}
auto = RemoteAutomation(None, "fennec", processArgs=process_args)
if options is None:
raise ValueError("Invalid options specified, use --help for a list of valid options")
options.runByDir = False
dm = options.dm
auto.setDeviceManager(dm)
mochitest = MochiRemote(auto, dm, options)
log = mochitest.log
message_logger.logger = log
mochitest.message_logger = message_logger
# Check that Firefox is installed
expected = options.app.split('/')[-1]
installed = dm.shellCheckOutput(['pm', 'list', 'packages', expected])
if expected not in installed:
log.error("%s is not installed on this device" % expected)
return 1
productPieces = options.remoteProductName.split('.')
if (productPieces is not None):
auto.setProduct(productPieces[0])
else:
auto.setProduct(options.remoteProductName)
auto.setAppName(options.remoteappname)
logParent = os.path.dirname(options.remoteLogFile)
dm.mkDir(logParent)
auto.setRemoteLog(options.remoteLogFile)
auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
if options.log_mach is None:
mochitest.printDeviceInfo()
# Add Android version (SDK level) to mozinfo so that manifest entries
# can be conditional on android_version.
androidVersion = dm.shellCheckOutput(['getprop', 'ro.build.version.sdk'])
log.info(
"Android sdk version '%s'; will use this to filter manifests" %
str(androidVersion))
mozinfo.info['android_version'] = androidVersion
deviceRoot = dm.deviceRoot
if options.dmdPath:
dmdLibrary = "libdmd.so"
dmdPathOnDevice = os.path.join(deviceRoot, dmdLibrary)
dm.removeFile(dmdPathOnDevice)
dm.pushFile(os.path.join(options.dmdPath, dmdLibrary), dmdPathOnDevice)
options.dmdPath = deviceRoot
options.dumpOutputDirectory = deviceRoot
procName = options.app.split('/')[-1]
dm.killProcess(procName)
mochitest.nsprLogName = "nspr.log"
try:
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:
# device error cleaning up... oh well!
pass
retVal = 1
if options.log_mach is None:
mochitest.printDeviceInfo(printLogcat=True)
message_logger.finish()
return retVal
开发者ID:kilikkuo,项目名称:gecko-dev,代码行数:82,代码来源:runtestsremote.py
示例10: main
def main():
scriptdir = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
dm_none = devicemanagerADB.DeviceManagerADB()
auto = RemoteAutomation(dm_none, "fennec")
parser = RemoteOptions(auto, scriptdir)
options, args = parser.parse_args()
if (options.dm_trans == "adb" or options.robocop):
if (options.deviceIP):
dm = devicemanagerADB.DeviceManagerADB(options.deviceIP, options.devicePort)
else:
dm = dm_none
else:
dm = devicemanagerSUT.DeviceManagerSUT(options.deviceIP, options.devicePort)
auto.setDeviceManager(dm)
options = parser.verifyRemoteOptions(options, auto)
if (options == None):
print "ERROR: Invalid options specified, use --help for a list of valid options"
sys.exit(1)
productPieces = options.remoteProductName.split('.')
if (productPieces != None):
auto.setProduct(productPieces[0])
else:
auto.setProduct(options.remoteProductName)
mochitest = MochiRemote(auto, dm, options)
options = parser.verifyOptions(options, mochitest)
if (options == None):
sys.exit(1)
logParent = os.path.dirname(options.remoteLogFile)
dm.mkDir(logParent);
auto.setRemoteLog(options.remoteLogFile)
auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
procName = options.app.split('/')[-1]
if (dm.processExist(procName)):
dm.killProcess(procName)
if (options.robocop):
mp = manifestparser.TestManifest(strict=False)
# TODO: pull this in dynamically
mp.read('robocop.ini')
robocop_tests = mp.active_tests(exists=False)
fHandle = open("robotium.config", "w")
fHandle.write("profile=%s\n" % (mochitest.remoteProfile))
fHandle.write("logfile=%s\n" % (options.remoteLogFile))
fHandle.close()
deviceRoot = dm.getDeviceRoot()
# Note, we are pushing to /sdcard since we have this location hard coded in robocop
dm.pushFile("robotium.config", "/sdcard/robotium.config")
dm.pushFile(os.path.abspath(options.robocop + "/fennec_ids.txt"), "/sdcard/fennec_ids.txt")
options.extraPrefs.append('robocop.logfile="%s/robocop.log"' % deviceRoot)
manifest = mochitest.buildProfile(options)
mochitest.startWebServer(options)
if (options.dm_trans == 'adb'):
dm.checkCmd(["install", "-r", os.path.join(options.robocop, "robocop.apk")])
for test in robocop_tests:
cmd = ["shell", "am", "instrument", "-w", "-e", "class"]
cmd.append("%s.tests.%s" % (options.app, test['name']))
cmd.append("org.mozilla.roboexample.test/android.test.InstrumentationTestRunner")
retVal = dm.checkCmd(cmd)
else:
# SUTAgent needs to install robocop and not crash when we launch robocop.
retVal = dm.launchProcess(["am", "instrument", "-w", "org.mozilla.roboexample.test/android.test.InstrumentationTestRunner"])
mochitest.stopWebServer(options)
else:
try:
retVal = mochitest.runTests(options)
except:
print "TEST-UNEXPECTED-ERROR | | Exception caught while running tests."
mochitest.stopWebServer(options)
mochitest.stopWebSocketServer(options)
sys.exit(1)
sys.exit(retVal)
开发者ID:krellian,项目名称:mozilla-central,代码行数:81,代码来源:runtestsremote.py
示例11: main
def main(args):
automation = RemoteAutomation(None)
parser = RemoteOptions(automation)
options, args = parser.parse_args()
if (options.deviceIP == None):
print "Error: you must provide a device IP to connect to via the --device option"
return 1
try:
if (options.dm_trans == "adb"):
if (options.deviceIP):
dm = devicemanagerADB.DeviceManagerADB(options.deviceIP, options.devicePort)
else:
dm = devicemanagerADB.DeviceManagerADB(None, None)
else:
dm = devicemanagerSUT.DeviceManagerSUT(options.deviceIP, options.devicePort)
except devicemanager.DMError:
print "Error: exception while initializing devicemanager. Most likely the device is not in a testable state."
return 1
automation.setDeviceManager(dm)
if (options.remoteProductName != None):
automation.setProduct(options.remoteProductName)
# Set up the defaults and ensure options are set
options = parser.verifyRemoteOptions(options)
if (options == None):
print "ERROR: Invalid options specified, use --help for a list of valid options"
return 1
if not options.ignoreWindowSize:
parts = dm.getInfo('screen')['screen'][0].split()
width = int(parts[0].split(':')[1])
height = int(parts[1].split(':')[1])
if (width < 1050 or height < 1050):
print "ERROR: Invalid screen resolution %sx%s, please adjust to 1366x1050 or higher" % (width, height)
return 1
automation.setAppName(options.app)
automation.setRemoteProfile(options.remoteProfile)
automation.setRemoteLog(options.remoteLogFile)
reftest = RemoteReftest(automation, dm, options, SCRIPT_DIRECTORY)
# Hack in a symbolic link for jsreftest
os.system("ln -s ../jsreftest " + str(os.path.join(SCRIPT_DIRECTORY, "jsreftest")))
# Dynamically build the reftest URL if possible, beware that args[0] should exist 'inside' the webroot
manifest = args[0]
if os.path.exists(os.path.join(SCRIPT_DIRECTORY, args[0])):
manifest = "http://" + str(options.remoteWebServer) + ":" + str(options.httpPort) + "/" + args[0]
elif os.path.exists(args[0]):
manifestPath = os.path.abspath(args[0]).split(SCRIPT_DIRECTORY)[1].strip('/')
manifest = "http://" + str(options.remoteWebServer) + ":" + str(options.httpPort) + "/" + manifestPath
else:
print "ERROR: Could not find test manifest '%s'" % manifest
return 1
# Start the webserver
retVal = reftest.startWebServer(options)
if retVal:
return retVal
procName = options.app.split('/')[-1]
if (dm.processExist(procName)):
dm.killProcess(procName)
print dm.getInfo()
#an example manifest name to use on the cli
# manifest = "http://" + options.remoteWebServer + "/reftests/layout/reftests/reftest-sanity/reftest.list"
retVal = 0
try:
cmdlineArgs = ["-reftest", manifest]
if options.bootstrap:
cmdlineArgs = []
dm.recordLogcat()
reftest.runTests(manifest, options, cmdlineArgs)
except:
print "Automation Error: Exception caught while running tests"
traceback.print_exc()
retVal = 1
reftest.stopWebServer(options)
try:
logcat = dm.getLogcat(filterOutRegexps=fennecLogcatFilters)
print ''.join(logcat)
print dm.getInfo()
except devicemanager.DMError:
print "WARNING: Error getting device information at end of test"
return retVal
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:93,代码来源:remotereftest.py
示例12: run_test_harness
def run_test_harness(parser, options):
parser.validate(options)
message_logger = MessageLogger(logger=None)
process_args = {'messageLogger': message_logger}
auto = RemoteAutomation(None, "fennec", processArgs=process_args)
if options is None:
raise ValueError("Invalid options specified, use --help for a list of valid options")
options.runByManifest = False
# roboextender is used by mochitest-chrome tests like test_java_addons.html,
# but not by any plain mochitests
if options.flavor != 'chrome':
options.extensionsToExclude.append('[email protected]')
dm = options.dm
auto.setDeviceManager(dm)
mochitest = MochiRemote(auto, dm, options)
options.dm = None
log = mochitest.log
message_logger.logger = log
mochitest.message_logger = message_logger
# Check that Firefox is installed
expected = options.app.split('/')[-1]
installed = dm.shellCheckOutput(['pm', 'list', 'packages', expected])
if expected not in installed:
log.error("%s is not installed on this device" % expected)
return 1
productPieces = options.remoteProductName.split('.')
if (productPieces is not None):
auto.setProduct(productPieces[0])
else:
auto.setProduct(options.remoteProductName)
auto.setAppName(options.remoteappname)
logParent = os.path.dirname(options.remoteLogFile)
dm.removeDir(logParent)
dm.mkDir(logParent)
auto.setRemoteLog(options.remoteLogFile)
auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
if options.log_mach is None:
mochitest.printDeviceInfo()
# Add Android version (SDK level) to mozinfo so that manifest entries
# can be conditional on android_version.
androidVersion = dm.shellCheckOutput(['getprop', 'ro.build.version.sdk'])
log.info(
"Android sdk version '%s'; will use this to filter manifests" %
str(androidVersion))
mozinfo.info['android_version'] = androidVersion
deviceRoot = dm.deviceRoot
options.dumpOutputDirectory = deviceRoot
procName = options.app.split('/')[-1]
dm.killProcess(procName)
if dm.processExist(procName):
log.warning("unable to kill %s before running tests!" % procName)
mochitest.mozLogName = "moz.log"
try:
dm.recordLogcat()
if options.verify:
retVal = mochitest.verifyTests(options)
else:
retVal = mochitest.runTests(options)
except Exception:
log.error("Automation Error: Exception caught while running tests")
traceback.print_exc()
mochitest.stopServers()
try:
mochitest.cleanup(options)
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()
return retVal
开发者ID:luke-chang,项目名称:gecko-1,代码行数:88,代码来源:runtestsremote.py
示例13: main
def main():
scriptdir = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
auto = RemoteAutomation(None, "fennec")
parser = RemoteOptions(auto, scriptdir)
options, args = parser.parse_args()
if (options.dm_trans == "adb"):
if (options.deviceIP):
dm = devicemanagerADB.DeviceManagerADB(options.deviceIP, options.devicePort)
else:
dm = devicemanagerADB.DeviceManagerADB()
else:
dm = devicemanagerSUT.DeviceManagerSUT(options.deviceIP, options.devicePort)
auto.setDeviceManager(dm)
options = parser.verifyRemoteOptions(options, auto)
if (options == None):
print "ERROR: Invalid options specified, use --help for a list of valid options"
sys.exit(1)
productPieces = options.remoteProductName.split('.')
if (productPieces != None):
auto.setProduct(productPieces[0])
else:
auto.setProduct(options.remoteProductName)
mochitest = MochiRemote(auto, dm, options)
options = parser.verifyOptions(options, mochitest)
if (options == None):
sys.exit(1)
logParent = os.path.dirname(options.remoteLogFile)
dm.mkDir(logParent);
auto.setRemoteLog(options.remoteLogFile)
auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
print dm.getInfo()
procName = options.app.split('/')[-1]
if (dm.processExist(procName)):
dm.killProcess(procName)
if options.robocop != "":
mp = manifestparser.TestManifest(strict=False)
# TODO: pull this in dynamically
mp.read(options.robocop)
robocop_tests = mp.active_tests(exists=False)
fHandle = open("robotium.config", "w")
fHandle.write("profile=%s\n" % (mochitest.remoteProfile))
fHandle.write("logfile=%s\n" % (options.remoteLogFile))
fHandle.write("host=http://mochi.test:8888/tests\n")
fHandle.write("rawhost=http://%s:%s/tests\n" % (options.remoteWebServer, options.httpPort))
fHandle.close()
deviceRoot = dm.getDeviceRoot()
dm.removeFile(os.path.join(deviceRoot, "fennec_ids.txt"))
dm.removeFile(os.path.join(deviceRoot, "robotium.config"))
dm.pushFile("robotium.config", os.path.join(deviceRoot, "robotium.config"))
fennec_ids = os.path.abspath("fennec_ids.txt")
if not os.path.exists(fennec_ids) and options.robocopIds:
fennec_ids = options.robocopIds
dm.pushFile(fennec_ids, os.path.join(deviceRoot, "fennec_ids.txt"))
options.extraPrefs.append('robocop.logfile="%s/robocop.log"' % deviceRoot)
if (options.dm_trans == 'adb' and options.robocopPath):
dm.checkCmd(["install", "-r", os.path.join(options.robocopPath, "robocop.apk")])
appname = options.app
retVal = None
logcat = []
for test in robocop_tests:
if options.testPath and options.testPath != test['name']:
continue
options.app = "am"
options.browserArgs = ["instrument", "-w", "-e", "deviceroot", deviceRoot, "-e", "class"]
options.browserArgs.append("%s.tests.%s" % (appname, test['name']))
options.browserArgs.append("org.mozilla.roboexample.test/%s.FennecInstrumentationTestRunner" % appname)
try:
dm.recordLogcat()
retVal = mochitest.runTests(options)
logcat = dm.getLogcat()
mochitest.addLogData()
except:
print "TEST-UNEXPECTED-FAIL | %s | Exception caught while running robocop tests." % sys.exc_info()[1]
mochitest.stopWebServer(options)
mochitest.stopWebSocketServer(options)
try:
self.cleanup(None, options)
except:
pass
sys.exit(1)
if retVal is None:
print "No tests run. Did you pass an invalid TEST_PATH?"
retVal = 1
retVal = mochitest.printLog()
else:
try:
#.........这里部分代码省略.........
开发者ID:mikeaich,项目名称:releases-mozilla-central,代码行数:101,代码来源:runtestsremote.py
示例14: main
def main():
message_logger = MessageLogger(logger=None)
process_args = {'messageLogger': message_logger}
auto = RemoteAutomation(None, "fennec", processArgs=process_args)
parser = RemoteOptions(auto)
structured.commandline.add_logging_group(parser)
options, args = parser.parse_args()
if (options.dm_trans == "adb"):
if (options.deviceIP):
dm = droid.DroidADB(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot)
else:
dm = droid.DroidADB(deviceRoot=options.remoteTestRoot)
else:
dm = droid.DroidSUT(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot)
auto.setDeviceManager(dm)
options = parser.verifyRemoteOptions(options, auto)
mochitest = MochiRemote(auto, dm, options)
log = mochitest.log
message_logger.logger = log
mochitest.message_logger = message_logger
if (options == None):
log.error("Invalid options specified, use --help for a list of valid options")
sys.exit(1)
productPieces = options.remoteProductName.split('.')
if (productPieces != None):
auto.setProduct(productPieces[0])
else:
auto.setProduct(options.remoteProductName)
auto.setAppName(options.remoteappname)
options = parser.verifyOptions(options, mochitest)
if (options == None):
sys.exit(1)
logParent = os.path.dirname(options.remoteLogFile)
dm.mkDir(logParent);
auto.setRemoteLog(options.remoteLogFile)
auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
mochitest.printDeviceInfo()
# Add Android version (SDK level) to mozinfo so that manifest entries
# can be conditional on android_version.
androidVersion = dm.shellCheckOutput(['getprop', 'ro.build.version.sdk'])
log.info("Android sdk version '%s'; will use this to filter manifests" % str(androidVersion))
mozinfo.info['android_version'] = androidVersion
deviceRoot = dm.deviceRoot
if options.dmdPath:
dmdLibrary = "libdmd.so"
dmdPathOnDevice = os.path.join(deviceRoot, dmdLibrary)
dm.removeFile(dmdPathOnDevice)
dm.pushFile(os.path.join(options.dmdPath, dmdLibrary), dmdPathOnDevice)
options.dmdPath = deviceRoot
options.dumpOutputDirectory = deviceRoot
procName = options.app.split('/')[-1]
dm.killProcess(procName)
if options.robocopIni != "":
# turning buffering off as it's not used in robocop
message_logger.buffering = False
# sut may wait up to 300 s for a robocop am process before returning
dm.default_timeout = 320
mp = manifestparser.TestManifest(strict=False)
# TODO: pull this in dynamically
mp.read(options.robocopIni)
robocop_tests = mp.active_tests(exists=False, **mozinfo.info)
tests = []
my_tests = tests
for test in robocop_tests:
tests.append(test['name'])
if options.totalChunks:
tests_per_chunk = math.ceil(len(tests) / (options.totalChunks * 1.0))
start = int(round((options.thisChunk-1) * tests_per_chunk))
end = int(round(options.thisChunk * tests_per_chunk))
if end > len(tests):
end = len(tests)
my_tests = tests[start:end]
log.info("Running tests %d-%d/%d" % (start+1, end, len(tests)))
dm.removeFile(os.path.join(deviceRoot, "fennec_ids.txt"))
fennec_ids = os.path.abspath(os.path.join(SCRIPT_DIR, "fennec_ids.txt"))
if not os.path.exists(fennec_ids) and options.robocopIds:
fennec_ids = options.robocopIds
dm.pushFile(fennec_ids, os.path.join(deviceRoot, "fennec_ids.txt"))
options.extraPrefs.append('browser.search.suggest.enabled=true')
options.extraPrefs.append('browser.search.suggest.prompted=true')
options.extraPrefs.append('layout.css.devPixelsPerPx=1.0')
options.extraPrefs.append('browser.chrome.dynamictoolbar=false')
options.extraPrefs.append('browser.snippets.enabled=false')
#.........这里部分代码省略.........
开发者ID:qiuyang001,项目名称:Spidermonkey,代码行数:101,代码来源:runtestsremote.py
示例15: main
def main():
automation = RemoteAutomation(None)
parser = reftestcommandline.RemoteArgumentsParser()
options = parser.parse_args()
if (options.dm_trans == 'sut' and options.deviceIP == None):
print "Error: If --dm_trans = sut, you must provide a device IP to connect to via the --deviceIP option"
return 1
try:
if (options.dm_trans == "adb"):
if (options.deviceIP):
dm = droid.DroidADB(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot)
elif (options.deviceSerial):
dm = droid.DroidADB(None, None, deviceSerial=options.deviceSerial, deviceRoot=options.remoteTestRoot)
else:
dm = droid.DroidADB(None, None, deviceRoot=options.remoteTestRoot)
else:
dm = droid.DroidSUT(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot)
except devicemanager.DMError:
print "Automation Error: exception while initializing devicemanager. Most likely the device is not in a testable state."
return 1
automation.setDeviceManager(dm)
if (options.remoteProductName != None):
automation.setProduct(options.remoteProductName)
# Set up the defaults and ensure options are set
parser.validate_remote(options, automation)
# Check that Firefox is installed
expected = options.app.split('/')[-1]
installed = dm.shellCheckOutput(['pm', 'list', 'packages', expected])
if expected not in installed:
print "%s is not installed on this device" % expected
return 1
automation.setAppName(options.app)
automation.setRemoteProfile(options.remoteProfile)
automation.setRemoteLog(options.remoteLogFile)
reftest = RemoteReftest(automation, dm, options, SCRIPT_DI
|
请发表评论