Ejemplo n.º 1
0
def main():

    if sys.version_info < (2, 7):
        print >> sys.stderr, "Error: You must use python version 2.7 or newer but less than 3.0"
        sys.exit(1)

    parser = RemoteXPCShellOptions()
    options, args = parser.parse_args()
    if not options.localAPK:
        for file in os.listdir(os.path.join(options.objdir, "dist")):
            if (file.endswith(".apk") and file.startswith("fennec")):
                options.localAPK = os.path.join(options.objdir, "dist")
                options.localAPK = os.path.join(options.localAPK, file)
                print >> sys.stderr, "using APK: " + options.localAPK
                break
        else:
            print >> sys.stderr, "Error: please specify an APK"
            sys.exit(1)

    options = parser.verifyRemoteOptions(options)

    if len(args) < 1 and options.manifest is None:
        print >> sys.stderr, """Usage: %s <test dirs>
             or: %s --manifest=test.manifest """ % (sys.argv[0], sys.argv[0])
        sys.exit(1)

    if (options.dm_trans == "adb"):
        if (options.deviceIP):
            dm = devicemanagerADB.DeviceManagerADB(
                options.deviceIP,
                options.devicePort,
                packageName=None,
                deviceRoot=options.remoteTestRoot)
        else:
            dm = devicemanagerADB.DeviceManagerADB(
                packageName=None, deviceRoot=options.remoteTestRoot)
    else:
        dm = devicemanagerSUT.DeviceManagerSUT(
            options.deviceIP,
            options.devicePort,
            deviceRoot=options.remoteTestRoot)
        if (options.deviceIP == None):
            print "Error: you must provide a device IP to connect to via the --device option"
            sys.exit(1)

    if options.interactive and not options.testPath:
        print >> sys.stderr, "Error: You must specify a test filename in interactive mode!"
        sys.exit(1)

    xpcsh = XPCShellRemote(dm, options, args)

    # we don't run concurrent tests on mobile
    options.sequential = True

    if not xpcsh.runTests(xpcshell='xpcshell',
                          testClass=RemoteXPCShellTestThread,
                          testdirs=args[0:],
                          mobileArgs=xpcsh.mobileArgs,
                          **options.__dict__):
        sys.exit(1)
Ejemplo n.º 2
0
def run_tests_remote(tests, prefix, options):
    # Setup device with everything needed to run our tests.
    from mozdevice import devicemanager, devicemanagerADB, devicemanagerSUT

    if options.device_transport == 'adb':
        if options.device_ip:
            dm = devicemanagerADB.DeviceManagerADB(options.device_ip, options.device_port, deviceSerial=options.device_serial, packageName=None, deviceRoot=options.remote_test_root)
        else:
            dm = devicemanagerADB.DeviceManagerADB(deviceSerial=options.device_serial, packageName=None, deviceRoot=options.remote_test_root)
    else:
        dm = devicemanagerSUT.DeviceManagerSUT(options.device_ip, options.device_port, deviceRoot=options.remote_test_root)
        if options.device_ip == None:
            print('Error: you must provide a device IP to connect to via the --device option')
            sys.exit(1)

    # Update the test root to point to our test directory.
    options.remote_test_root = posixpath.join(options.remote_test_root, 'jit-tests')

    # Push js shell and libraries.
    if dm.dirExists(options.remote_test_root):
        dm.removeDir(options.remote_test_root)
    dm.mkDir(options.remote_test_root)
    push_libs(options, dm)
    push_progs(options, dm, [prefix[0]])
    dm.chmodDir(options.remote_test_root)
    dm.pushDir(os.path.dirname(TEST_DIR), options.remote_test_root, timeout=600)
    prefix[0] = os.path.join(options.remote_test_root, 'js')

    # Run all tests.
    gen = get_remote_results(tests, dm, prefix, options)
    ok = process_test_results(gen, len(tests), options)
    return ok
Ejemplo n.º 3
0
def main():
    parser = RemoteCPPUnittestOptions()
    mozlog.commandline.add_logging_group(parser)
    options, args = parser.parse_args()
    if not args:
        print >>sys.stderr, """Usage: %s <test binary> [<test binary>...]""" % sys.argv[0]
        sys.exit(1)
    if options.local_lib is not None and not os.path.isdir(options.local_lib):
        print >>sys.stderr, """Error: --localLib directory %s not found""" % options.local_lib
        sys.exit(1)
    if options.local_apk is not None and not os.path.isfile(options.local_apk):
        print >>sys.stderr, """Error: --apk file %s not found""" % options.local_apk
        sys.exit(1)
    if not options.xre_path:
        print >>sys.stderr, """Error: --xre-path is required"""
        sys.exit(1)
    if options.with_b2g_emulator:
        from mozrunner import B2GEmulatorRunner
        runner = B2GEmulatorRunner(b2g_home=options.with_b2g_emulator)
        runner.start()
    if options.dm_trans == "adb":
        if options.with_b2g_emulator:
            # because we just started the emulator, we need more than the
            # default number of retries here.
            retryLimit = 50
        else:
            retryLimit = 5
        try:
            if options.device_ip:
                dm = devicemanagerADB.DeviceManagerADB(options.device_ip, options.device_port, packageName=None, deviceRoot=options.remote_test_root, retryLimit=retryLimit)
            else:
                dm = devicemanagerADB.DeviceManagerADB(packageName=None, deviceRoot=options.remote_test_root, retryLimit=retryLimit)
        except:
            if options.with_b2g_emulator:
                runner.cleanup()
                runner.wait()
            raise
    else:
        dm = devicemanagerSUT.DeviceManagerSUT(options.device_ip, options.device_port, deviceRoot=options.remote_test_root)
        if not options.device_ip:
            print "Error: you must provide a device IP to connect to via the --deviceIP option"
            sys.exit(1)

    log = mozlog.commandline.setup_logging("remotecppunittests", options,
                                           {"tbpl": sys.stdout})

    options.xre_path = os.path.abspath(options.xre_path)
    cppunittests.update_mozinfo()
    progs = cppunittests.extract_unittests_from_args(args,
                                                     mozinfo.info,
                                                     options.manifest_path)
    tester = RemoteCPPUnitTests(dm, options, [item[0] for item in progs])
    try:
        result = tester.run_tests(progs, options.xre_path, options.symbols_path)
    except Exception, e:
        log.error(str(e))
        result = False
Ejemplo n.º 4
0
def run_test_harness(options, args):
    if options.with_b2g_emulator:
        from mozrunner import B2GEmulatorRunner
        runner = B2GEmulatorRunner(arch=options.emulator,
                                   b2g_home=options.with_b2g_emulator)
        runner.start()
    if options.dm_trans == "adb":
        if options.with_b2g_emulator:
            # because we just started the emulator, we need more than the
            # default number of retries here.
            retryLimit = 50
        else:
            retryLimit = 5
        try:
            if options.device_ip:
                dm = devicemanagerADB.DeviceManagerADB(
                    options.device_ip,
                    options.device_port,
                    packageName=None,
                    deviceRoot=options.remote_test_root,
                    retryLimit=retryLimit)
            else:
                dm = devicemanagerADB.DeviceManagerADB(
                    packageName=None,
                    deviceRoot=options.remote_test_root,
                    retryLimit=retryLimit)
        except:
            if options.with_b2g_emulator:
                runner.cleanup()
                runner.wait()
            raise
    else:
        dm = devicemanagerSUT.DeviceManagerSUT(
            options.device_ip,
            options.device_port,
            deviceRoot=options.remote_test_root)
        if not options.device_ip:
            print "Error: you must provide a device IP to connect to via the --deviceIP option"
            sys.exit(1)

    options.xre_path = os.path.abspath(options.xre_path)
    cppunittests.update_mozinfo()
    progs = cppunittests.extract_unittests_from_args(args, mozinfo.info,
                                                     options.manifest_path)
    tester = RemoteCPPUnitTests(dm, options, [item[0] for item in progs])
    try:
        result = tester.run_tests(progs, options.xre_path,
                                  options.symbols_path)
    finally:
        if options.with_b2g_emulator:
            runner.cleanup()
            runner.wait()
    return result
Ejemplo n.º 5
0
 def get_devicemanager(self, devicemanager, ip, port, remote_test_root):
     from mozdevice import devicemanagerADB, devicemanagerSUT
     dm = None
     if devicemanager == "adb":
         if ip:
             dm = devicemanagerADB.DeviceManagerADB(ip, port, packageName=None, deviceRoot=remote_test_root)
         else:
             dm = devicemanagerADB.DeviceManagerADB(packageName=None, deviceRoot=remote_test_root)
     else:
         if ip:
             dm = devicemanagerSUT.DeviceManagerSUT(ip, port, deviceRoot=remote_test_root)
         else:
             raise Exception("You must provide a device IP to connect to via the --ip option")
     return dm
Ejemplo n.º 6
0
def main():

    parser = RemoteXPCShellOptions()
    options, args = parser.parse_args()
    options = parser.verifyRemoteOptions(options)

    if len(args) < 1 and options.manifest is None:
      print >>sys.stderr, """Usage: %s <test dirs>
           or: %s --manifest=test.manifest """ % (sys.argv[0], sys.argv[0])
      sys.exit(1)

    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)
      if (options.deviceIP == None):
        print "Error: you must provide a device IP to connect to via the --device option"
        sys.exit(1)

    if options.interactive and not options.testPath:
      print >>sys.stderr, "Error: You must specify a test filename in interactive mode!"
      sys.exit(1)

    if not options.objdir:
      print >>sys.stderr, "Error: You must specify an objdir"
      sys.exit(1)

    if not options.localAPK:
      for file in os.listdir(os.path.join(options.objdir, "dist")):
        if (file.endswith(".apk") and file.startswith("fennec")):
          options.localAPK = os.path.join(options.objdir, "dist")
          options.localAPK = os.path.join(options.localAPK, file)
          print >>sys.stderr, "using APK: " + options.localAPK
          break

    if not options.localAPK:
      print >>sys.stderr, "Error: please specify an APK"
      sys.exit(1)

    xpcsh = XPCShellRemote(dm, options, args)

    if not xpcsh.runTests(xpcshell='xpcshell',
                          testdirs=args[0:],
                          **options.__dict__):
      sys.exit(1)
Ejemplo n.º 7
0
def testAgent(host, port):
  if port == -1:
    from mozdevice import devicemanagerADB
    return devicemanagerADB.DeviceManagerADB(host, port)
  else:
    from mozdevice import devicemanagerSUT
    return devicemanagerSUT.DeviceManagerSUT(host, port)
Ejemplo n.º 8
0
def main():
    parser = RemoteCPPUnittestOptions()
    options, args = parser.parse_args()
    if not args:
        print >> sys.stderr, """Usage: %s <test binary> [<test binary>...]""" % sys.argv[
            0]
        sys.exit(1)
    if options.local_lib is None and options.local_apk is None:
        print >> sys.stderr, """Error: --localLib or --apk is required"""
        sys.exit(1)
    if options.local_lib is not None and not os.path.isdir(options.local_lib):
        print >> sys.stderr, """Error: --localLib directory %s not found""" % options.local_lib
        sys.exit(1)
    if options.local_apk is not None and not os.path.isfile(options.local_apk):
        print >> sys.stderr, """Error: --apk file %s not found""" % options.local_apk
        sys.exit(1)
    if not options.xre_path:
        print >> sys.stderr, """Error: --xre-path is required"""
        sys.exit(1)
    if options.dm_trans == "adb":
        if options.device_ip:
            dm = devicemanagerADB.DeviceManagerADB(
                options.device_ip,
                options.device_port,
                packageName=None,
                deviceRoot=options.remote_test_root)
        else:
            dm = devicemanagerADB.DeviceManagerADB(
                packageName=None, deviceRoot=options.remote_test_root)
    else:
        dm = devicemanagerSUT.DeviceManagerSUT(
            options.device_ip,
            options.device_port,
            deviceRoot=options.remote_test_root)
        if not options.device_ip:
            print "Error: you must provide a device IP to connect to via the --deviceIP option"
            sys.exit(1)
    options.xre_path = os.path.abspath(options.xre_path)
    progs = cppunittests.extract_unittests_from_args(args,
                                                     options.manifest_file)
    tester = RemoteCPPUnitTests(dm, options, progs)
    try:
        result = tester.run_tests(progs, options.xre_path,
                                  options.symbols_path)
    except Exception, e:
        log.error(str(e))
        result = False
Ejemplo n.º 9
0
def main():
    parser = B2GOptions()
    options, args = parser.parse_args()
    options = parser.verifyRemoteOptions(options)

    # Create the Marionette instance
    kwargs = {}
    if options.emulator:
        kwargs['emulator'] = options.emulator
        if options.no_window:
            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.b2g_path:
        kwargs['homedir'] = options.emu_path or options.b2g_path
    if options.address:
        host, port = options.address.split(':')
        kwargs['host'] = host
        kwargs['port'] = int(port)
        kwargs['baseurl'] = 'http://%s:%d/' % (host, int(port))
        if options.emulator:
            kwargs['connectToRunningEmulator'] = True
    marionette = Marionette(**kwargs)

    if options.emulator:
        dm = marionette.emulator.dm
    else:
        # Create the DeviceManager instance
        kwargs = {'adbPath': options.adb_path}
        if options.deviceIP:
            kwargs['host'] = options.deviceIP
            kwargs['port'] = options.devicePort
        kwargs['deviceRoot'] = options.remoteTestRoot
        dm = devicemanagerADB.DeviceManagerADB(**kwargs)

    if not options.remoteTestRoot:
        options.remoteTestRoot = dm.getDeviceRoot()
    xpcsh = B2GXPCShellRemote(dm, options, args)

    # we don't run concurrent tests on mobile
    options.sequential = True

    try:
        if not xpcsh.runTests(xpcshell='xpcshell',
                              testdirs=args[0:],
                              testClass=B2GXPCShellTestThread,
                              mobileArgs=xpcsh.mobileArgs,
                              **options.__dict__):
            sys.exit(1)
    except:
        print "Automation Error: Exception caught while running tests"
        traceback.print_exc()
        sys.exit(1)
Ejemplo n.º 10
0
def run_tests_remote(tests, num_tests, prefix, options):
    # Setup device with everything needed to run our tests.
    from mozdevice import devicemanagerADB

    if options.device_ip:
        dm = devicemanagerADB.DeviceManagerADB(
            options.device_ip,
            options.device_port,
            deviceSerial=options.device_serial,
            packageName=None,
            deviceRoot=options.remote_test_root)
    else:
        dm = devicemanagerADB.DeviceManagerADB(
            deviceSerial=options.device_serial,
            packageName=None,
            deviceRoot=options.remote_test_root)

    # Update the test root to point to our test directory.
    jit_tests_dir = posixpath.join(options.remote_test_root, 'jit-tests')
    options.remote_test_root = posixpath.join(jit_tests_dir, 'jit-tests')

    # Push js shell and libraries.
    if dm.dirExists(jit_tests_dir):
        dm.removeDir(jit_tests_dir)
    dm.mkDirs(options.remote_test_root)
    push_libs(options, dm)
    push_progs(options, dm, [prefix[0]])
    dm.chmodDir(options.remote_test_root)

    JitTest.CacheDir = posixpath.join(options.remote_test_root, '.js-cache')
    dm.mkDir(JitTest.CacheDir)

    dm.pushDir(JS_TESTS_DIR,
               posixpath.join(jit_tests_dir, 'tests'),
               timeout=600)

    dm.pushDir(os.path.dirname(TEST_DIR),
               options.remote_test_root,
               timeout=600)
    prefix[0] = os.path.join(options.remote_test_root, 'js')

    # Run all tests.
    pb = create_progressbar(num_tests, options)
    gen = get_remote_results(tests, dm, prefix, options)
    ok = process_test_results(gen, num_tests, pb, options)
    return ok
Ejemplo n.º 11
0
def main():
    parser = B2GOptions()
    options, args = parser.parse_args()

    if options.objdir is None:
        try:
            options.objdir = os.path.join(options.b2g_path, 'objdir-gecko')
        except:
            print >> sys.stderr, "Need to specify a --b2gpath"
            sys.exit(1)

    # Create the Marionette instance
    kwargs = {}
    if options.emulator:
        kwargs['emulator'] = options.emulator
        if options.no_window:
            kwargs['noWindow'] = True
    if options.b2g_path:
        kwargs['homedir'] = options.emu_path or options.b2g_path
    if options.address:
        host, port = options.address.split(':')
        kwargs['host'] = host
        kwargs['port'] = int(port)
        kwargs['baseurl'] = 'http://%s:%d/' % (host, int(port))
        if options.emulator:
            kwargs['connectToRunningEmulator'] = True
    marionette = Marionette(**kwargs)

    # Create the DeviceManager instance
    kwargs = {'adbPath': options.adb_path}
    if options.deviceIP:
        kwargs['host'] = options.deviceIP
        kwargs['port'] = options.devicePort
    kwargs['deviceRoot'] = DEVICE_TEST_ROOT
    dm = devicemanagerADB.DeviceManagerADB(**kwargs)

    options.remoteTestRoot = dm.getDeviceRoot()

    xpcsh = B2GXPCShellRemote(dm, options, args)

    try:
        success = xpcsh.runTests(xpcshell='xpcshell',
                                 testdirs=args[0:],
                                 **options.__dict__)
    except:
        print "Automation Error: Exception caught while running tests"
        traceback.print_exc()
        sys.exit(1)

    sys.exit(int(success))
Ejemplo n.º 12
0
    def connect(self):
        self.adb = B2GInstance.check_adb(self.homedir, emulator=True)
        self.start_adb()

        online, offline = self._get_adb_devices()
        now = datetime.datetime.now()
        while online == set([]):
            time.sleep(1)
            if datetime.datetime.now() - now > datetime.timedelta(seconds=60):
                raise Exception('timed out waiting for emulator to be available')
            online, offline = self._get_adb_devices()
        self.port = int(list(online)[0])

        self.dm = devicemanagerADB.DeviceManagerADB(adbPath=self.adb,
                                                    deviceSerial='emulator-%d' % self.port)
Ejemplo n.º 13
0
    def start(self):
        self._check_for_b2g()
        self.start_adb()

        qemu_args = self.args[:]
        if self.copy_userdata:
            # Make a copy of the userdata.img for this instance of the emulator to use.
            self._tmp_userdata = tempfile.mktemp(prefix='marionette')
            shutil.copyfile(self.dataImg, self._tmp_userdata)
            qemu_args[qemu_args.index('-data') + 1] = self._tmp_userdata

        original_online, original_offline = self._get_adb_devices()

        filename = None
        if self.logcat_dir:
            filename = os.path.join(self.logcat_dir, 'qemu.log')
            if os.path.isfile(filename):
                self.rotate_log(filename)

        self.proc = LogOutputProc(qemu_args, filename)
        self.proc.run()

        online, offline = self._get_adb_devices()
        now = datetime.datetime.now()
        while online - original_online == set([]):
            time.sleep(1)
            if datetime.datetime.now() - now > datetime.timedelta(seconds=60):
                raise TimeoutException(
                    'timed out waiting for emulator to start')
            online, offline = self._get_adb_devices()
        self.port = int(list(online - original_online)[0])
        self._emulator_launched = True

        self.dm = devicemanagerADB.DeviceManagerADB(
            adbPath=self.adb, deviceSerial='emulator-%d' % self.port)

        # bug 802877
        time.sleep(10)
        self.geo.set_default_location()
        self.screen.initialize()

        if self.logcat_dir:
            self.save_logcat()

        # setup DNS fix for networking
        self._run_adb(['shell', 'setprop', 'net.dns1', '10.0.2.3'])
Ejemplo n.º 14
0
def run_test_harness(options, args):
    if options.with_b2g_emulator:
        from mozrunner import B2GEmulatorRunner
        runner = B2GEmulatorRunner(arch=options.emulator,
                                   b2g_home=options.with_b2g_emulator)
        runner.start()
        # because we just started the emulator, we need more than the
        # default number of retries here.
        retryLimit = 50
    else:
        retryLimit = 5
    try:
        dm_args = {'deviceRoot': options.remote_test_root}
        dm_args['retryLimit'] = retryLimit
        if options.device_ip:
            dm_args['host'] = options.device_ip
            dm_args['port'] = options.device_port
        if options.adb_path:
            dm_args['adbPath'] = options.adb_path
        if options.log_tbpl_level == 'debug' or options.log_mach_level == 'debug':
            dm_args['logLevel'] = logging.DEBUG  # noqa python 2 / 3
        dm = devicemanagerADB.DeviceManagerADB(**dm_args)
    except:
        if options.with_b2g_emulator:
            runner.cleanup()
            runner.wait()
        raise

    options.xre_path = os.path.abspath(options.xre_path)
    cppunittests.update_mozinfo()
    progs = cppunittests.extract_unittests_from_args(args, mozinfo.info,
                                                     options.manifest_path)
    tester = RemoteCPPUnitTests(dm, options, [item[0] for item in progs])
    try:
        result = tester.run_tests(progs, options.xre_path,
                                  options.symbols_path)
    finally:
        if options.with_b2g_emulator:
            runner.cleanup()
            runner.wait()
    return result
Ejemplo n.º 15
0
    # `os.path.dirname(os.path.abspath(__file__))` for ${talos}
    # https://bugzilla.mozilla.org/show_bug.cgi?id=705809
    browser_config['extensions'] = [
        utils.interpolatePath(i) for i in browser_config['extensions']
    ]
    browser_config['dirs'] = dict([(i, utils.interpolatePath(j))
                                   for i, j in browser_config['dirs'].items()])
    browser_config['bcontroller_config'] = utils.interpolatePath(
        browser_config['bcontroller_config'])

    # get device manager if specified
    dm = None
    if browser_config['remote'] == True:
        if browser_config['port'] == -1:
            from mozdevice import devicemanagerADB
            dm = devicemanagerADB.DeviceManagerADB(browser_config['host'],
                                                   browser_config['port'])
        else:
            from mozdevice import devicemanagerSUT
            dm = devicemanagerSUT.DeviceManagerSUT(browser_config['host'],
                                                   browser_config['port'])

    # normalize browser path to work across platforms
    browser_config['browser_path'] = os.path.normpath(
        browser_config['browser_path'])

    # get test date in seconds since epoch
    if testdate:
        date = int(
            time.mktime(time.strptime(testdate, '%a, %d %b %Y %H:%M:%S GMT')))
    else:
        date = int(time.time())