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)
def main(): dm_none = DeviceManager(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) 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) 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) # Start the webserver reftest.startWebServer(options) # 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 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" reftest.runTests(manifest, options) reftest.stopWebServer(options)
def main(args): automation = RemoteAutomation(None) parser = RemoteOptions(automation) options, args = 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 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) options = parser.verifyCommonOptions(options, reftest) if mozinfo.info["debug"]: print "changing timeout for remote debug reftests from %s to 600 seconds" % options.timeout options.timeout = 600 # 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) reftest.printDeviceInfo() # 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() retVal = reftest.runTests(manifest, options, cmdlineArgs) except: print "Automation Error: Exception caught while running tests" traceback.print_exc() retVal = 1 reftest.stopWebServer(options) reftest.printDeviceInfo(printLogcat=True) return retVal
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_DIRECTORY) parser.validate(options, reftest) if mozinfo.info['debug']: print "changing timeout for remote debug reftests from %s to 600 seconds" % options.timeout options.timeout = 600 # Hack in a symbolic link for jsreftest os.system("ln -s ../jsreftest " + str(os.path.join(SCRIPT_DIRECTORY, "jsreftest"))) # Start the webserver retVal = reftest.startWebServer(options) if retVal: return retVal procName = options.app.split('/')[-1] if (dm.processExist(procName)): dm.killProcess(procName) reftest.printDeviceInfo() #an example manifest name to use on the cli # manifest = "http://" + options.remoteWebServer + "/reftests/layout/reftests/reftest-sanity/reftest.list" retVal = 0 try: dm.recordLogcat() retVal = reftest.runTests(options.tests, options) except: print "Automation Error: Exception caught while running tests" traceback.print_exc() retVal = 1 reftest.stopWebServer(options) reftest.printDeviceInfo(printLogcat=True) return retVal
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" logcat = [] try: cmdlineArgs = ["-reftest", manifest] if options.bootstrap: cmdlineArgs = [] dm.recordLogcat() reftest.runTests(manifest, options, cmdlineArgs) logcat = dm.getLogcat() except: print "TEST-UNEXPECTED-FAIL | | exception while running reftests" reftest.stopWebServer(options) return 1 reftest.stopWebServer(options) print ''.join(logcat[-500:-1]) print dm.getInfo() return 0
def run_test_harness(parser, options): dm_args = { 'deviceRoot': options.remoteTestRoot, 'host': options.deviceIP, 'port': options.devicePort, } dm_args['adbPath'] = options.adb_path if not dm_args['host']: dm_args['deviceSerial'] = options.deviceSerial if options.log_tbpl_level == 'debug' or options.log_mach_level == 'debug': dm_args['logLevel'] = logging.DEBUG try: dm = mozdevice.DroidADB(**dm_args) except mozdevice.DMError: traceback.print_exc() print ("Automation Error: exception while initializing devicemanager. " "Most likely the device is not in a testable state.") return 1 automation = RemoteAutomation(None) automation.setDeviceManager(dm) if options.remoteProductName: 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_DIRECTORY) parser.validate(options, reftest) if mozinfo.info['debug']: print "changing timeout for remote debug reftests from %s to 600 seconds" % options.timeout options.timeout = 600 # Hack in a symbolic link for jsreftest os.system("ln -s ../jsreftest " + str(os.path.join(SCRIPT_DIRECTORY, "jsreftest"))) # Start the webserver retVal = reftest.startWebServer(options) if retVal: return retVal procName = options.app.split('/')[-1] dm.killProcess(procName) if dm.processExist(procName): print "unable to kill %s before starting tests!" % procName if options.printDeviceInfo: reftest.printDeviceInfo() # an example manifest name to use on the cli # manifest = "http://" + options.remoteWebServer + # "/reftests/layout/reftests/reftest-sanity/reftest.list" retVal = 0 try: dm.recordLogcat() retVal = reftest.runTests(options.tests, options) except: print "Automation Error: Exception caught while running tests" traceback.print_exc() retVal = 1 reftest.stopWebServer(options) if options.printDeviceInfo: reftest.printDeviceInfo(printLogcat=True) return retVal
def run_test_harness(parser, options): dm_args = { 'deviceRoot': options.remoteTestRoot, 'host': options.deviceIP, 'port': options.devicePort, } dm_args['adbPath'] = options.adb_path if not dm_args['host']: dm_args['deviceSerial'] = options.deviceSerial if options.log_tbpl_level == 'debug' or options.log_mach_level == 'debug': dm_args['logLevel'] = logging.DEBUG try: dm = mozdevice.DroidADB(**dm_args) except mozdevice.DMError: traceback.print_exc() print ("Automation Error: exception while initializing devicemanager. " "Most likely the device is not in a testable state.") return 1 automation = RemoteAutomation(None) automation.setDeviceManager(dm) if options.remoteProductName: 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_DIRECTORY) parser.validate(options, reftest) if mozinfo.info['debug']: print "changing timeout for remote debug reftests from %s to 600 seconds" % options.timeout options.timeout = 600 # Hack in a symbolic link for jsreftest os.system("ln -s ../jsreftest " + str(os.path.join(SCRIPT_DIRECTORY, "jsreftest"))) # Despite our efforts to clean up servers started by this script, in practice # we still see infrequent cases where a process is orphaned and interferes # with future tests, typically because the old server is keeping the port in use. # Try to avoid those failures by checking for and killing servers before # trying to start new ones. reftest.killNamedProc('ssltunnel') reftest.killNamedProc('xpcshell') # Start the webserver retVal = reftest.startWebServer(options) if retVal: return retVal procName = options.app.split('/')[-1] dm.killProcess(procName) if dm.processExist(procName): print "unable to kill %s before starting tests!" % procName if options.printDeviceInfo: reftest.printDeviceInfo() # an example manifest name to use on the cli # manifest = "http://" + options.remoteWebServer + # "/reftests/layout/reftests/reftest-sanity/reftest.list" retVal = 0 try: dm.recordLogcat() if options.verify: retVal = reftest.verifyTests(options.tests, options) else: retVal = reftest.runTests(options.tests, options) except Exception: print "Automation Error: Exception caught while running tests" traceback.print_exc() retVal = 1 reftest.stopWebServer(options) if options.printDeviceInfo: reftest.printDeviceInfo(printLogcat=True) return retVal
def main(): 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" sys.exit(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." sys.exit(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" 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)
def main(): dm_none = DeviceManager(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) 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) 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) # Start the webserver reftest.startWebServer(options) # 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 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" reftest.runTests(manifest, options) reftest.stopWebServer(options)