def start_marionette(self): assert (self.baseurl is not None) if self.bin: if self.address: host, port = self.address.split(':') else: host = 'localhost' port = 2828 self.marionette = Marionette(host=host, port=int(port), app=self.app, bin=self.bin, profile=self.profile, baseurl=self.baseurl, timeout=self.timeout) elif self.address: host, port = self.address.split(':') try: #establish a telnet connection so we can vertify the data come back tlconnection = Telnet(host, port) except: raise Exception( "could not connect to given marionette host/port") if self.emulator: self.marionette = Marionette.getMarionetteOrExit( host=host, port=int(port), connectToRunningEmulator=True, homedir=self.homedir, baseurl=self.baseurl, logcat_dir=self.logcat_dir, gecko_path=self.gecko_path, symbols_path=self.symbols_path, timeout=self.timeout) else: self.marionette = Marionette(host=host, port=int(port), baseurl=self.baseurl, timeout=self.timeout) elif self.emulator: self.marionette = Marionette.getMarionetteOrExit( emulator=self.emulator, emulatorBinary=self.emulatorBinary, emulatorImg=self.emulatorImg, emulator_res=self.emulator_res, homedir=self.homedir, baseurl=self.baseurl, noWindow=self.noWindow, logcat_dir=self.logcat_dir, gecko_path=self.gecko_path, symbols_path=self.symbols_path, timeout=self.timeout) else: raise Exception("must specify binary, address or emulator")
def start_marionette(self): assert(self.baseurl is not None) if self.bin: if self.address: host, port = self.address.split(':') else: host = 'localhost' port = 2828 self.marionette = Marionette(host=host, port=int(port), app=self.app, bin=self.bin, profile=self.profile, baseurl=self.baseurl, timeout=self.timeout) elif self.address: host, port = self.address.split(':') try: #establish a telnet connection so we can vertify the data come back tlconnection = Telnet(host, port) except: raise Exception("could not connect to given marionette host/port") if self.emulator: self.marionette = Marionette.getMarionetteOrExit( host=host, port=int(port), connectToRunningEmulator=True, homedir=self.homedir, baseurl=self.baseurl, logcat_dir=self.logcat_dir, gecko_path=self.gecko_path, symbols_path=self.symbols_path, timeout=self.timeout) else: self.marionette = Marionette(host=host, port=int(port), baseurl=self.baseurl, timeout=self.timeout) elif self.emulator: self.marionette = Marionette.getMarionetteOrExit( emulator=self.emulator, emulatorBinary=self.emulatorBinary, emulatorImg=self.emulatorImg, emulator_res=self.emulator_res, homedir=self.homedir, baseurl=self.baseurl, noWindow=self.noWindow, logcat_dir=self.logcat_dir, gecko_path=self.gecko_path, symbols_path=self.symbols_path, timeout=self.timeout) else: raise Exception("must specify binary, address or emulator")
def run_desktop_mochitests(parser, options): automation = B2GDesktopAutomation() # create our Marionette instance kwargs = {} if options.marionette: host, port = options.marionette.split(':') kwargs['host'] = host kwargs['port'] = int(port) marionette = Marionette.getMarionetteOrExit(**kwargs) automation.marionette = marionette mochitest = B2GDesktopMochitest(automation, options) # b2g desktop builds don't always have a b2g-bin file if options.app[-4:] == '-bin': options.app = options.app[:-4] options = MochitestOptions.verifyOptions(parser, options, mochitest) if options == None: sys.exit(1) if options.desktop and not options.profile: raise Exception("must specify --profile when specifying --desktop") automation.setServerInfo(options.webServer, options.httpPort, options.sslPort, options.webSocketPort) sys.exit(mochitest.runTests(options, onLaunch=mochitest.startTests))
def run_desktop_mochitests(parser, options): automation = B2GDesktopAutomation() # create our Marionette instance kwargs = {} if options.marionette: host, port = options.marionette.split(':') kwargs['host'] = host kwargs['port'] = int(port) marionette = Marionette.getMarionetteOrExit(**kwargs) automation.marionette = marionette mochitest = B2GDesktopMochitest(automation) # b2g desktop builds don't always have a b2g-bin file if options.app[-4:] == '-bin': options.app = options.app[:-4] options = MochitestOptions.verifyOptions(parser, options, mochitest) if options == None: sys.exit(1) if options.desktop and not options.profile: raise Exception("must specify --profile when specifying --desktop") automation.setServerInfo(options.webServer, options.httpPort, options.sslPort, options.webSocketPort) sys.exit(mochitest.runTests(options, onLaunch=mochitest.startTests))
def run_desktop_mochitests(parser, options): # create our Marionette instance kwargs = {} if options.marionette: host, port = options.marionette.split(':') kwargs['host'] = host kwargs['port'] = int(port) marionette = Marionette.getMarionetteOrExit(**kwargs) mochitest = B2GDesktopMochitest(marionette, options.profile_data_dir) # add a -bin suffix if b2g-bin exists, but just b2g was specified if options.app[-4:] != '-bin': if os.path.isfile("%s-bin" % options.app): options.app = "%s-bin" % options.app options = MochitestOptions.verifyOptions(parser, options, mochitest) if options == None: sys.exit(1) if options.desktop and not options.profile: raise Exception("must specify --profile when specifying --desktop") options.browserArgs += ['-marionette'] sys.exit(mochitest.runTests(options, onLaunch=mochitest.startTests))
def start_marionette(self): assert (self.baseurl is not None) if self.bin: if self.address: host, port = self.address.split(':') else: host = 'localhost' port = 2828 self.marionette = Marionette(host=host, port=int(port), app=self.app, bin=self.bin, profile=self.profile, baseurl=self.baseurl) elif self.address: host, port = self.address.split(':') if self.emulator: self.marionette = Marionette.getMarionetteOrExit( host=host, port=int(port), connectToRunningEmulator=True, homedir=self.homedir, baseurl=self.baseurl, logcat_dir=self.logcat_dir, gecko_path=self.gecko_path, symbols_path=self.symbols_path) else: self.marionette = Marionette(host=host, port=int(port), baseurl=self.baseurl) elif self.emulator: self.marionette = Marionette.getMarionetteOrExit( emulator=self.emulator, emulatorBinary=self.emulatorBinary, emulatorImg=self.emulatorImg, emulator_res=self.emulator_res, homedir=self.homedir, baseurl=self.baseurl, noWindow=self.noWindow, logcat_dir=self.logcat_dir, gecko_path=self.gecko_path, symbols_path=self.symbols_path) else: raise Exception("must specify binary, address or emulator")
def start_marionette(self): assert(self.baseurl is not None) if self.bin: if self.address: host, port = self.address.split(':') else: host = 'localhost' port = 2828 self.marionette = Marionette(host=host, port=int(port), app=self.app, bin=self.bin, profile=self.profile, baseurl=self.baseurl) elif self.address: host, port = self.address.split(':') if self.emulator: self.marionette = Marionette.getMarionetteOrExit( host=host, port=int(port), connectToRunningEmulator=True, homedir=self.homedir, baseurl=self.baseurl, logcat_dir=self.logcat_dir, gecko_path=self.gecko_path, symbols_path=self.symbols_path) else: self.marionette = Marionette(host=host, port=int(port), baseurl=self.baseurl) elif self.emulator: self.marionette = Marionette.getMarionetteOrExit( emulator=self.emulator, emulatorBinary=self.emulatorBinary, emulatorImg=self.emulatorImg, emulator_res=self.emulator_res, homedir=self.homedir, baseurl=self.baseurl, noWindow=self.noWindow, logcat_dir=self.logcat_dir, gecko_path=self.gecko_path, symbols_path=self.symbols_path) else: raise Exception("must specify binary, address or emulator")
def start_marionette(self): assert (self.baseurl is not None) if self.bin: if self.address: host, port = self.address.split(':') else: host = 'localhost' port = 2828 self.marionette = Marionette(host=host, port=int(port), app=self.app, app_args=self.app_args, bin=self.bin, profile=self.profile, baseurl=self.baseurl, timeout=self.timeout, device_serial=self.device_serial) elif self.address: host, port = self.address.split(':') try: #establish a socket connection so we can vertify the data come back connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) connection.connect((host, int(port))) connection.close() except Exception, e: raise Exception( "Could not connect to given marionette host:port: %s" % e) if self.emulator: self.marionette = Marionette.getMarionetteOrExit( host=host, port=int(port), connectToRunningEmulator=True, homedir=self.homedir, baseurl=self.baseurl, logcat_dir=self.logcat_dir, gecko_path=self.gecko_path, symbols_path=self.symbols_path, timeout=self.timeout, device_serial=self.device_serial) else: self.marionette = Marionette(host=host, port=int(port), baseurl=self.baseurl, timeout=self.timeout, device_serial=self.device_serial)
def start_marionette(self): assert(self.baseurl is not None) if self.bin: if self.address: host, port = self.address.split(':') else: host = 'localhost' port = 2828 self.marionette = Marionette(host=host, port=int(port), app=self.app, app_args=self.app_args, bin=self.bin, profile=self.profile, baseurl=self.baseurl, timeout=self.timeout, device_serial=self.device_serial) elif self.address: host, port = self.address.split(':') try: #establish a socket connection so we can vertify the data come back connection = socket.socket(socket.AF_INET,socket.SOCK_STREAM) connection.connect((host,int(port))) connection.close() except Exception, e: raise Exception("Could not connect to given marionette host:port: %s" % e) if self.emulator: self.marionette = Marionette.getMarionetteOrExit( host=host, port=int(port), connectToRunningEmulator=True, homedir=self.homedir, baseurl=self.baseurl, logcat_dir=self.logcat_dir, gecko_path=self.gecko_path, symbols_path=self.symbols_path, timeout=self.timeout, device_serial=self.device_serial) else: self.marionette = Marionette(host=host, port=int(port), baseurl=self.baseurl, timeout=self.timeout, device_serial=self.device_serial)
def run_desktop_mochitests(parser, options): # create our Marionette instance kwargs = {} if options.marionette: host, port = options.marionette.split(':') kwargs['host'] = host kwargs['port'] = int(port) marionette = Marionette.getMarionetteOrExit(**kwargs) mochitest = B2GDesktopMochitest(marionette, options.profile_data_dir) # b2g desktop builds don't always have a b2g-bin file if options.app[-4:] == '-bin': options.app = options.app[:-4] options = MochitestOptions.verifyOptions(parser, options, mochitest) if options == None: sys.exit(1) if options.desktop and not options.profile: raise Exception("must specify --profile when specifying --desktop") sys.exit(mochitest.runTests(options, onLaunch=mochitest.startTests))
def run_desktop_reftests(parser, options, args): kwargs = {} if options.marionette: host, port = options.marionette.split(':') kwargs['host'] = host kwargs['port'] = int(port) marionette = Marionette.getMarionetteOrExit(**kwargs) reftest = B2GDesktopReftest(marionette) options = ReftestOptions.verifyCommonOptions(parser, options, reftest) if options == None: sys.exit(1) # add a -bin suffix if b2g-bin exists, but just b2g was specified if options.app[-4:] != '-bin': if os.path.isfile("%s-bin" % options.app): options.app = "%s-bin" % options.app if options.desktop and not options.profile: raise Exception("must specify --profile when specifying --desktop") sys.exit(reftest.run_tests(args[0], options))
def run_desktop_reftests(parser, options, args): kwargs = {} if options.marionette: host, port = options.marionette.split(':') kwargs['host'] = host kwargs['port'] = int(port) marionette = Marionette.getMarionetteOrExit(**kwargs) reftest = B2GDesktopReftest(marionette) options = ReftestOptions.verifyCommonOptions(parser, options, reftest) if options == None: sys.exit(1) # add a -bin suffix if b2g-bin exists, but just b2g was specified if options.app[-4:] != '-bin': if os.path.isfile("%s-bin" % options.app): options.app = "%s-bin" % options.app if options.desktop and not options.profile: raise Exception("must specify --profile when specifying --desktop") sys.exit(reftest.run_tests(args[0], options))
def main(args=sys.argv[1:]): auto = B2GRemoteAutomation(None, "fennec", context_chrome=True) parser = B2GOptions(auto) options, args = parser.parse_args(args) # create our Marionette instance kwargs = {} if options.emulator: kwargs["emulator"] = options.emulator auto.setEmulator(True) if options.noWindow: kwargs["noWindow"] = True if options.geckoPath: kwargs["gecko_path"] = options.geckoPath if options.logcat_dir: kwargs["logcat_dir"] = options.logcat_dir if options.busybox: kwargs["busybox"] = options.busybox if options.emulator_res: kwargs["emulator_res"] = options.emulator_res if options.b2gPath: kwargs["homedir"] = options.b2gPath if options.marionette: host, port = options.marionette.split(":") kwargs["host"] = host kwargs["port"] = int(port) marionette = Marionette.getMarionetteOrExit(**kwargs) auto.marionette = marionette # create the DeviceManager kwargs = {"adbPath": options.adbPath, "deviceRoot": options.remoteTestRoot} if options.deviceIP: kwargs.update({"host": options.deviceIP, "port": options.devicePort}) dm = devicemanagerADB.DeviceManagerADB(**kwargs) auto.setDeviceManager(dm) options = parser.verifyRemoteOptions(options) if options == None: print "ERROR: Invalid options specified, use --help for a list of valid options" sys.exit(1) # TODO fix exception 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 < 1366 or height < 1050: print "ERROR: Invalid screen resolution %sx%s, please adjust to 1366x1050 or higher" % (width, height) return 1 auto.setProduct("b2g") auto.test_script = os.path.join(SCRIPT_DIRECTORY, "b2g_start_script.js") auto.test_script_args = [options.remoteWebServer, options.httpPort] auto.logFinish = "REFTEST TEST-START | Shutdown" reftest = B2GReftest(auto, dm, options, SCRIPT_DIRECTORY) logParent = os.path.dirname(options.remoteLogFile) dm.mkDir(logParent) auto.setRemoteLog(options.remoteLogFile) auto.setServerInfo(options.webServer, options.httpPort, options.sslPort) # 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://%s:%s/%s" % (options.remoteWebServer, options.httpPort, args[0]) elif os.path.exists(args[0]): manifestPath = os.path.abspath(args[0]).split(SCRIPT_DIRECTORY)[1].strip("/") manifest = "http://%s:%s/%s" % (options.remoteWebServer, options.httpPort, manifestPath) else: print "ERROR: Could not find test manifest '%s'" % manifest return 1 # Start the webserver retVal = 1 try: retVal = reftest.startWebServer(options) if retVal: return retVal procName = options.app.split("/")[-1] if dm.processExist(procName): dm.killProcess(procName) cmdlineArgs = ["-reftest", manifest] if getattr(options, "bootstrap", False): cmdlineArgs = [] retVal = reftest.runTests(manifest, options, cmdlineArgs) except: print "Automation Error: Exception caught while running tests" traceback.print_exc() reftest.stopWebServer(options) try: reftest.cleanup(None) except: pass return 1 reftest.stopWebServer(options) return retVal
def run_remote_mochitests(automation, parser, options): # create our Marionette instance kwargs = {} if options.emulator: kwargs['emulator'] = options.emulator automation.setEmulator(True) if options.noWindow: kwargs['noWindow'] = True if options.geckoPath: kwargs['gecko_path'] = options.geckoPath if options.logcat_dir: kwargs['logcat_dir'] = options.logcat_dir if options.busybox: kwargs['busybox'] = options.busybox if options.symbolsPath: kwargs['symbols_path'] = options.symbolsPath # needless to say sdcard is only valid if using an emulator if options.sdcard: kwargs['sdcard'] = options.sdcard if options.b2gPath: kwargs['homedir'] = options.b2gPath if options.marionette: host, port = options.marionette.split(':') kwargs['host'] = host kwargs['port'] = int(port) marionette = Marionette.getMarionetteOrExit(**kwargs) automation.marionette = marionette # create the DeviceManager kwargs = {'adbPath': options.adbPath, 'deviceRoot': options.remoteTestRoot} if options.deviceIP: kwargs.update({'host': options.deviceIP, 'port': options.devicePort}) dm = DeviceManagerADB(**kwargs) automation.setDeviceManager(dm) options = parser.verifyRemoteOptions(options, automation) if (options == None): print "ERROR: Invalid options specified, use --help for a list of valid options" sys.exit(1) automation.setProduct("b2g") mochitest = B2GDeviceMochitest(automation, dm, options) options = parser.verifyOptions(options, mochitest) if (options == None): sys.exit(1) logParent = os.path.dirname(options.remoteLogFile) dm.mkDir(logParent) automation.setRemoteLog(options.remoteLogFile) automation.setServerInfo(options.webServer, options.httpPort, options.sslPort) retVal = 1 try: mochitest.cleanup(None, options) retVal = mochitest.runTests(options) except: print "Automation Error: Exception caught while running tests" traceback.print_exc() mochitest.stopWebServer(options) mochitest.stopWebSocketServer(options) try: mochitest.cleanup(None, options) except: pass retVal = 1 sys.exit(retVal)
def run_remote_mochitests(automation, parser, options): # create our Marionette instance kwargs = {} if options.emulator: kwargs['emulator'] = options.emulator automation.setEmulator(True) if options.noWindow: kwargs['noWindow'] = True if options.geckoPath: kwargs['gecko_path'] = options.geckoPath if options.logcat_dir: kwargs['logcat_dir'] = options.logcat_dir if options.busybox: kwargs['busybox'] = options.busybox # needless to say sdcard is only valid if using an emulator if options.sdcard: kwargs['sdcard'] = options.sdcard if options.b2gPath: kwargs['homedir'] = options.b2gPath if options.marionette: host, port = options.marionette.split(':') kwargs['host'] = host kwargs['port'] = int(port) marionette = Marionette.getMarionetteOrExit(**kwargs) automation.marionette = marionette # create the DeviceManager kwargs = {'adbPath': options.adbPath, 'deviceRoot': options.remoteTestRoot} if options.deviceIP: kwargs.update({'host': options.deviceIP, 'port': options.devicePort}) dm = devicemanagerADB.DeviceManagerADB(**kwargs) automation.setDeviceManager(dm) options = parser.verifyRemoteOptions(options, automation) if (options == None): print "ERROR: Invalid options specified, use --help for a list of valid options" sys.exit(1) automation.setProduct("b2g") mochitest = B2GMochitest(automation, dm, options) options = parser.verifyOptions(options, mochitest) if (options == None): sys.exit(1) logParent = os.path.dirname(options.remoteLogFile) dm.mkDir(logParent) automation.setRemoteLog(options.remoteLogFile) automation.setServerInfo(options.webServer, options.httpPort, options.sslPort) retVal = 1 try: mochitest.cleanup(None, options) retVal = mochitest.runTests(options) except: print "Automation Error: Exception caught while running tests" traceback.print_exc() mochitest.stopWebServer(options) mochitest.stopWebSocketServer(options) try: mochitest.cleanup(None, options) except: pass retVal = 1 sys.exit(retVal)
def run_remote_mochitests(parser, options): # create our Marionette instance kwargs = {} if options.emulator: kwargs['emulator'] = options.emulator if options.noWindow: kwargs['noWindow'] = True if options.geckoPath: kwargs['gecko_path'] = options.geckoPath if options.logcat_dir: kwargs['logcat_dir'] = options.logcat_dir if options.busybox: kwargs['busybox'] = options.busybox if options.symbolsPath: kwargs['symbols_path'] = options.symbolsPath # needless to say sdcard is only valid if using an emulator if options.sdcard: kwargs['sdcard'] = options.sdcard if options.b2gPath: kwargs['homedir'] = options.b2gPath if options.marionette: host, port = options.marionette.split(':') kwargs['host'] = host kwargs['port'] = int(port) marionette = Marionette.getMarionetteOrExit(**kwargs) # create the DeviceManager kwargs = {'adbPath': options.adbPath, 'deviceRoot': options.remoteTestRoot} if options.deviceIP: kwargs.update({'host': options.deviceIP, 'port': options.devicePort}) dm = DeviceManagerADB(**kwargs) options = parser.verifyRemoteOptions(options) if (options == None): print "ERROR: Invalid options specified, use --help for a list of valid options" sys.exit(1) mochitest = B2GDeviceMochitest(marionette, dm, options.profile_data_dir, options.xrePath, remote_test_root=options.remoteTestRoot, remote_log_file=options.remoteLogFile) options = parser.verifyOptions(options, mochitest) if (options == None): sys.exit(1) retVal = 1 try: mochitest.cleanup(None, options) retVal = mochitest.run_tests(options) except: print "Automation Error: Exception caught while running tests" traceback.print_exc() mochitest.stopWebServer(options) mochitest.stopWebSocketServer(options) try: mochitest.cleanup(None, options) except: pass retVal = 1 sys.exit(retVal)
def run_remote_reftests(parser, options, args): auto = B2GRemoteAutomation(None, "fennec", context_chrome=True) # create our Marionette instance kwargs = {} if options.emulator: kwargs['emulator'] = options.emulator auto.setEmulator(True) if options.noWindow: kwargs['noWindow'] = True if options.geckoPath: kwargs['gecko_path'] = options.geckoPath if options.logcat_dir: kwargs['logcat_dir'] = options.logcat_dir if options.busybox: kwargs['busybox'] = options.busybox if options.symbolsPath: kwargs['symbols_path'] = options.symbolsPath if options.emulator_res: kwargs['emulator_res'] = options.emulator_res if options.b2gPath: kwargs['homedir'] = options.b2gPath if options.marionette: host,port = options.marionette.split(':') kwargs['host'] = host kwargs['port'] = int(port) marionette = Marionette.getMarionetteOrExit(**kwargs) auto.marionette = marionette if options.emulator: dm = marionette.emulator.dm else: # create the DeviceManager kwargs = {'adbPath': options.adbPath, 'deviceRoot': options.remoteTestRoot} if options.deviceIP: kwargs.update({'host': options.deviceIP, 'port': options.devicePort}) dm = DeviagerADB(**kwargs) 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) # TODO fix exception 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 < 1366 or height < 1050): print "ERROR: Invalid screen resolution %sx%s, please adjust to 1366x1050 or higher" % (width, height) return 1 auto.setProduct("b2g") auto.test_script = os.path.join(here, 'b2g_start_script.js') auto.test_script_args = [options.remoteWebServer, options.httpPort] auto.logFinish = "REFTEST TEST-START | Shutdown" reftest = B2GRemoteReftest(auto, dm, options, here) options = parser.verifyCommonOptions(options, reftest) logParent = os.path.dirname(options.remoteLogFile) dm.mkDir(logParent); auto.setRemoteLog(options.remoteLogFile) auto.setServerInfo(options.webServer, options.httpPort, options.sslPort) # Hack in a symbolic link for jsreftest os.system("ln -s %s %s" % (os.path.join('..', 'jsreftest'), os.path.join(here, '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(here, args[0])): manifest = "http://%s:%s/%s" % (options.remoteWebServer, options.httpPort, args[0]) elif os.path.exists(args[0]): manifestPath = os.path.abspath(args[0]).split(here)[1].strip('/') manifest = "http://%s:%s/%s" % (options.remoteWebServer, options.httpPort, manifestPath) else: print "ERROR: Could not find test manifest '%s'" % manifest return 1 # Start the webserver retVal = 1 try: retVal = reftest.startWebServer(options) if retVal: return retVal procName = options.app.split('/')[-1] if (dm.processExist(procName)): dm.killProcess(procName) cmdlineArgs = ["-reftest", manifest] if getattr(options, 'bootstrap', False): cmdlineArgs = [] retVal = reftest.runTests(manifest, options, cmdlineArgs) except: print "Automation Error: Exception caught while running tests" traceback.print_exc() reftest.stopWebServer(options) try: reftest.cleanup(None) except: pass return 1 reftest.stopWebServer(options) return retVal
def run_remote_mochitests(parser, options): # create our Marionette instance kwargs = {} if options.emulator: kwargs['emulator'] = options.emulator if options.noWindow: kwargs['noWindow'] = True if options.geckoPath: kwargs['gecko_path'] = options.geckoPath if options.logcat_dir: kwargs['logcat_dir'] = options.logcat_dir if options.busybox: kwargs['busybox'] = options.busybox if options.symbolsPath: kwargs['symbols_path'] = options.symbolsPath # needless to say sdcard is only valid if using an emulator if options.sdcard: kwargs['sdcard'] = options.sdcard if options.b2gPath: kwargs['homedir'] = options.b2gPath if options.marionette: host, port = options.marionette.split(':') kwargs['host'] = host kwargs['port'] = int(port) marionette = Marionette.getMarionetteOrExit(**kwargs) if options.emulator: dm = marionette.emulator.dm else: # create the DeviceManager kwargs = {'adbPath': options.adbPath, 'deviceRoot': options.remoteTestRoot} if options.deviceIP: kwargs.update({'host': options.deviceIP, 'port': options.devicePort}) dm = DeviceManagerADB(**kwargs) options = parser.verifyRemoteOptions(options) if (options == None): print "ERROR: Invalid options specified, use --help for a list of valid options" sys.exit(1) mochitest = B2GDeviceMochitest(marionette, dm, options.profile_data_dir, options.xrePath, remote_test_root=options.remoteTestRoot, remote_log_file=options.remoteLogFile) options = parser.verifyOptions(options, mochitest) if (options == None): sys.exit(1) retVal = 1 try: mochitest.cleanup(None, options) retVal = mochitest.run_tests(options) except: print "Automation Error: Exception caught while running tests" traceback.print_exc() mochitest.stopWebServer(options) mochitest.stopWebSocketServer(options) try: mochitest.cleanup(None, options) except: pass retVal = 1 sys.exit(retVal)
class BaseMarionetteTestRunner(object): textrunnerclass = MarionetteTextTestRunner def __init__(self, address=None, emulator=None, emulatorBinary=None, emulatorImg=None, emulator_res='480x800', homedir=None, app=None, app_args=None, bin=None, profile=None, autolog=False, revision=None, logger=None, testgroup="marionette", noWindow=False, logcat_dir=None, xml_output=None, repeat=0, gecko_path=None, testvars=None, tree=None, type=None, device_serial=None, symbols_path=None, timeout=None, es_servers=None, shuffle=False, sdcard=None, **kwargs): self.address = address self.emulator = emulator self.emulatorBinary = emulatorBinary self.emulatorImg = emulatorImg self.emulator_res = emulator_res self.homedir = homedir self.app = app self.app_args = app_args or [] self.bin = bin self.profile = profile self.autolog = autolog self.testgroup = testgroup self.revision = revision self.logger = logger self.noWindow = noWindow self.httpd = None self.baseurl = None self.marionette = None self.logcat_dir = logcat_dir self.xml_output = xml_output self.repeat = repeat self.gecko_path = gecko_path self.testvars = {} self.test_kwargs = kwargs self.tree = tree self.type = type self.device_serial = device_serial self.symbols_path = symbols_path self.timeout = timeout self._device = None self._capabilities = None self._appName = None self.es_servers = es_servers self.shuffle = shuffle self.sdcard = sdcard self.mixin_run_tests = [] if testvars: if not os.path.exists(testvars): raise Exception('--testvars file does not exist') import json with open(testvars) as f: self.testvars = json.loads(f.read()) # set up test handlers self.test_handlers = [] self.reset_test_stats() if self.logger is None: self.logger = logging.getLogger('Marionette') self.logger.setLevel(logging.INFO) self.logger.addHandler(logging.StreamHandler()) if self.logcat_dir: if not os.access(self.logcat_dir, os.F_OK): os.mkdir(self.logcat_dir) # for XML output self.testvars['xml_output'] = self.xml_output self.results = [] @property def capabilities(self): if self._capabilities: return self._capabilities self.marionette.start_session() self._capabilities = self.marionette.session_capabilities self.marionette.delete_session() return self._capabilities @property def device(self): if self._device: return self._device self._device = self.capabilities.get('device') return self._device @property def appName(self): if self._appName: return self._appName self._appName = self.capabilities.get('browserName') return self._appName def reset_test_stats(self): self.passed = 0 self.failed = 0 self.todo = 0 self.failures = [] def start_httpd(self): host = moznetwork.get_ip() self.httpd = MozHttpd(host=host, port=0, docroot=os.path.join( os.path.dirname(os.path.dirname(__file__)), 'www')) self.httpd.start() self.baseurl = 'http://%s:%d/' % (host, self.httpd.httpd.server_port) self.logger.info('running webserver on %s' % self.baseurl) def start_marionette(self): assert (self.baseurl is not None) if self.bin: if self.address: host, port = self.address.split(':') else: host = 'localhost' port = 2828 self.marionette = Marionette(host=host, port=int(port), app=self.app, app_args=self.app_args, bin=self.bin, profile=self.profile, baseurl=self.baseurl, timeout=self.timeout, device_serial=self.device_serial) elif self.address: host, port = self.address.split(':') try: #establish a socket connection so we can vertify the data come back connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) connection.connect((host, int(port))) connection.close() except Exception, e: raise Exception( "Could not connect to given marionette host:port: %s" % e) if self.emulator: self.marionette = Marionette.getMarionetteOrExit( host=host, port=int(port), connectToRunningEmulator=True, homedir=self.homedir, baseurl=self.baseurl, logcat_dir=self.logcat_dir, gecko_path=self.gecko_path, symbols_path=self.symbols_path, timeout=self.timeout) else: self.marionette = Marionette(host=host, port=int(port), baseurl=self.baseurl, timeout=self.timeout) elif self.emulator: self.marionette = Marionette.getMarionetteOrExit( emulator=self.emulator, emulatorBinary=self.emulatorBinary, emulatorImg=self.emulatorImg, emulator_res=self.emulator_res, homedir=self.homedir, baseurl=self.baseurl, noWindow=self.noWindow, logcat_dir=self.logcat_dir, gecko_path=self.gecko_path, symbols_path=self.symbols_path, timeout=self.timeout, sdcard=self.sdcard)
def run_remote_reftests(parser, options, args): auto = B2GRemoteAutomation(None, "fennec", context_chrome=True) # create our Marionette instance kwargs = {} if options.emulator: kwargs['emulator'] = options.emulator auto.setEmulator(True) if options.noWindow: kwargs['noWindow'] = True if options.geckoPath: kwargs['gecko_path'] = options.geckoPath if options.logcat_dir: kwargs['logcat_dir'] = options.logcat_dir if options.busybox: kwargs['busybox'] = options.busybox if options.symbolsPath: kwargs['symbols_path'] = options.symbolsPath if options.emulator_res: kwargs['emulator_res'] = options.emulator_res if options.b2gPath: kwargs['homedir'] = options.b2gPath if options.marionette: host, port = options.marionette.split(':') kwargs['host'] = host kwargs['port'] = int(port) marionette = Marionette.getMarionetteOrExit(**kwargs) auto.marionette = marionette # create the DeviceManager kwargs = {'adbPath': options.adbPath, 'deviceRoot': options.remoteTestRoot} if options.deviceIP: kwargs.update({'host': options.deviceIP, 'port': options.devicePort}) dm = DeviceManagerADB(**kwargs) auto.setDeviceManager(dm) options = parser.verifyRemoteOptions(options) if (options == None): print "ERROR: Invalid options specified, use --help for a list of valid options" sys.exit(1) # TODO fix exception 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 < 1366 or height < 1050): print "ERROR: Invalid screen resolution %sx%s, please adjust to 1366x1050 or higher" % ( width, height) return 1 auto.setProduct("b2g") auto.test_script = os.path.join(SCRIPT_DIRECTORY, 'b2g_start_script.js') auto.test_script_args = [options.remoteWebServer, options.httpPort] auto.logFinish = "REFTEST TEST-START | Shutdown" reftest = B2GReftest(auto, dm, options, SCRIPT_DIRECTORY) options = parser.verifyCommonOptions(options, reftest) logParent = os.path.dirname(options.remoteLogFile) dm.mkDir(logParent) auto.setRemoteLog(options.remoteLogFile) auto.setServerInfo(options.webServer, options.httpPort, options.sslPort) # Hack in a symbolic link for jsreftest os.system("ln -s %s %s" % (os.path.join( '..', 'jsreftest'), 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://%s:%s/%s" % (options.remoteWebServer, options.httpPort, args[0]) elif os.path.exists(args[0]): manifestPath = os.path.abspath( args[0]).split(SCRIPT_DIRECTORY)[1].strip('/') manifest = "http://%s:%s/%s" % (options.remoteWebServer, options.httpPort, manifestPath) else: print "ERROR: Could not find test manifest '%s'" % manifest return 1 # Start the webserver retVal = 1 try: retVal = reftest.startWebServer(options) if retVal: return retVal procName = options.app.split('/')[-1] if (dm.processExist(procName)): dm.killProcess(procName) cmdlineArgs = ["-reftest", manifest] if getattr(options, 'bootstrap', False): cmdlineArgs = [] retVal = reftest.runTests(manifest, options, cmdlineArgs) except: print "Automation Error: Exception caught while running tests" traceback.print_exc() reftest.stopWebServer(options) try: reftest.cleanup(None) except: pass return 1 reftest.stopWebServer(options) return retVal