Пример #1
0
 def dm(self):
     if not self._dm:
         self.loggerdeco.info(
             'Connecting to %s:%d...' %
             (self.phone_cfg['ip'], self.phone_cfg['sutcmdport']))
         # Droids and other slow phones can take a while to come back
         # after a SUT crash or spontaneous reboot, so we up the
         # default retrylimit.
         self._dm = DroidSUT(
             self.phone_cfg['ip'],
             self.phone_cfg['sutcmdport'],
             retryLimit=self.user_cfg[DEVICEMANAGER_RETRY_LIMIT],
             logLevel=self.loglevel)
         # Give slow devices chance to mount all devices.
         # Give slow devices chance to mount all devices.
         if self.user_cfg[DEVICEMANAGER_SETTLING_TIME] is not None:
             self._dm.reboot_settling_time = self.user_cfg[
                 DEVICEMANAGER_SETTLING_TIME]
         # Override mozlog.logger
         self._dm._logger = self.loggerdeco
         self.loggerdeco.info('Connected.')
     return self._dm
Пример #2
0
    def validate(self, parser, options, context):
        """Validate android options."""

        if build_obj:
            options.log_mach = '-'

        device_args = {'deviceRoot': options.remoteTestRoot}
        if options.dm_trans == "adb":
            device_args['adbPath'] = options.adbPath
            if options.deviceIP:
                device_args['host'] = options.deviceIP
                device_args['port'] = options.devicePort
            elif options.deviceSerial:
                device_args['deviceSerial'] = options.deviceSerial
            options.dm = DroidADB(**device_args)
        elif options.dm_trans == 'sut':
            if options.deviceIP is None:
                parser.error(
                    "If --dm_trans = sut, you must provide a device IP")
            device_args['host'] = options.deviceIP
            device_args['port'] = options.devicePort
            options.dm = DroidSUT(**device_args)

        if not options.remoteTestRoot:
            options.remoteTestRoot = options.dm.deviceRoot

        if options.remoteWebServer is None:
            if os.name != "nt":
                options.remoteWebServer = moznetwork.get_ip()
            else:
                parser.error(
                    "you must specify a --remote-webserver=<ip address>")

        options.webServer = options.remoteWebServer

        if options.remoteLogFile is None:
            options.remoteLogFile = options.remoteTestRoot + \
                '/logs/mochitest.log'

        if options.remoteLogFile.count('/') < 1:
            options.remoteLogFile = options.remoteTestRoot + \
                '/' + options.remoteLogFile

        if options.remoteAppPath and options.app:
            parser.error(
                "You cannot specify both the remoteAppPath and the app setting")
        elif options.remoteAppPath:
            options.app = options.remoteTestRoot + "/" + options.remoteAppPath
        elif options.app is None:
            if build_obj:
                options.app = build_obj.substs['ANDROID_PACKAGE_NAME']
            else:
                # Neither remoteAppPath nor app are set -- error
                parser.error("You must specify either appPath or app")

        if build_obj and 'MOZ_HOST_BIN' in os.environ:
            options.xrePath = os.environ['MOZ_HOST_BIN']

        # Only reset the xrePath if it wasn't provided
        if options.xrePath is None:
            options.xrePath = options.utilityPath

        if options.pidFile != "":
            f = open(options.pidFile, 'w')
            f.write("%s" % os.getpid())
            f.close()

        # Robocop specific options
        if options.robocopIni != "":
            if not os.path.exists(options.robocopIni):
                parser.error(
                    "Unable to find specified robocop .ini manifest '%s'" %
                    options.robocopIni)
            options.robocopIni = os.path.abspath(options.robocopIni)

            if not options.robocopApk and build_obj:
                options.robocopApk = os.path.join(build_obj.topobjdir, 'mobile', 'android',
                                                  'tests', 'browser',
                                                  'robocop', 'robocop-debug.apk')

        if options.robocopApk != "":
            if not os.path.exists(options.robocopApk):
                parser.error(
                    "Unable to find robocop APK '%s'" %
                    options.robocopApk)
            options.robocopApk = os.path.abspath(options.robocopApk)

        # Disable e10s by default on Android because we don't run Android
        # e10s jobs anywhere yet.
        options.e10s = False
        mozinfo.update({'e10s': options.e10s})

        # allow us to keep original application around for cleanup while
        # running robocop via 'am'
        options.remoteappname = options.app
        return options