예제 #1
0
 def get_devicemanager(self, ip, port, remote_test_root):
     import mozdevice
     dm = None
     if ip:
         dm = mozdevice.DroidADB(ip, port, packageName=None, deviceRoot=remote_test_root)
     else:
         dm = mozdevice.DroidADB(packageName=None, deviceRoot=remote_test_root)
     return dm
예제 #2
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 = mozdevice.DroidADB(options.deviceIP,
                                    options.devicePort,
                                    packageName=None,
                                    deviceRoot=options.remoteTestRoot)
        else:
            dm = mozdevice.DroidADB(packageName=None,
                                    deviceRoot=options.remoteTestRoot)
    else:
        if not options.deviceIP:
            print "Error: you must provide a device IP to connect to via the --device option"
            sys.exit(1)
        dm = mozdevice.DroidSUT(options.deviceIP,
                                options.devicePort,
                                deviceRoot=options.remoteTestRoot)

    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)
예제 #3
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 = parser_remote()
    options = 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 = verifyRemoteOptions(parser, options)
    log = commandline.setup_logging("Remote XPCShell", options,
                                    {"tbpl": sys.stdout})

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

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

    if options.xpcshell is None:
        options.xpcshell = "xpcshell"

    xpcsh = XPCShellRemote(dm, options, log)

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

    if not xpcsh.runTests(testClass=RemoteXPCShellTestThread,
                          mobileArgs=xpcsh.mobileArgs,
                          **vars(options)):
        sys.exit(1)
예제 #4
0
 def get_devicemanager(self, devicemanager, ip, port, remote_test_root):
     import mozdevice
     dm = None
     if devicemanager == "adb":
         if ip:
             dm = mozdevice.DroidADB(ip, port, packageName=None, deviceRoot=remote_test_root)
         else:
             dm = mozdevice.DroidADB(packageName=None, deviceRoot=remote_test_root)
     else:
         if ip:
             dm = mozdevice.DroidSUT(ip, port, deviceRoot=remote_test_root)
         else:
             raise Exception("You must provide a device IP to connect to via the --ip option")
     return dm
예제 #5
0
파일: dmcli.py 프로젝트: tojon/mozbase
    def getDevice(self,
                  dmtype="adb",
                  hwid=None,
                  host=None,
                  port=None,
                  packagename=None,
                  verbose=False):
        '''
        Returns a device with the specified parameters
        '''
        logLevel = mozlog.ERROR
        if verbose:
            logLevel = mozlog.DEBUG

        if hwid:
            return mozdevice.DroidConnectByHWID(hwid, logLevel=logLevel)

        if dmtype == "adb":
            if host and not port:
                port = 5555
            return mozdevice.DroidADB(packageName=packagename,
                                      host=host,
                                      port=port,
                                      logLevel=logLevel)
        elif dmtype == "sut":
            if not host:
                self.parser.error("Must specify host with SUT!")
            if not port:
                port = 20701
            return mozdevice.DroidSUT(host=host, port=port, logLevel=logLevel)
        else:
            self.parser.error("Unknown device manager type: %s" % type)
예제 #6
0
def run_test_harness(log, parser, options):
    device_args = {'deviceRoot': options.remoteTestRoot}
    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
    device_args['packageName'] = options.app
    dm = mozdevice.DroidADB(**device_args)

    runner = GeckoviewTestRunner(log, dm, options)
    result = -1
    try:
        result = runner.run_tests()
    except KeyboardInterrupt:
        log.info("rungeckoview.py | Received keyboard interrupt")
        result = -1
    except:
        traceback.print_exc()
        log.error(
            "rungeckoview.py | Received unexpected exception while running tests"
        )
        result = 1
    finally:
        try:
            crashed = runner.cleanup()
            if not result:
                result = crashed
        except mozdevice.DMError:
            # ignore device error while cleaning up
            pass
    return result
예제 #7
0
def main():
    if sys.version_info < (2, 7):
        print(
            "Error: You must use python version 2.7 or newer but less than 3.0",
            file=sys.stderr)
        sys.exit(1)

    parser = parser_remote()
    options = 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("using APK: " + options.localAPK, file=sys.stderr)
                break
        else:
            print("Error: please specify an APK", file=sys.stderr)
            sys.exit(1)

    options = verifyRemoteOptions(parser, options)
    log = commandline.setup_logging("Remote XPCShell", options,
                                    {"tbpl": sys.stdout})

    dm_args = {'deviceRoot': options['remoteTestRoot']}
    if options['deviceIP']:
        dm_args['host'] = options['deviceIP']
        dm_args['port'] = options['devicePort']
    if options['log_tbpl_level'] == 'debug' or options[
            'log_mach_level'] == 'debug':
        dm_args['logLevel'] = logging.DEBUG
    if options['adbPath']:
        dm_args['adbPath'] = options['adbPath']
    dm = mozdevice.DroidADB(**dm_args)

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

    if options['xpcshell'] is None:
        options['xpcshell'] = "xpcshell"

    xpcsh = XPCShellRemote(dm, options, log)

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

    if not xpcsh.runTests(options,
                          testClass=RemoteXPCShellTestThread,
                          mobileArgs=xpcsh.mobileArgs):
        sys.exit(1)
예제 #8
0
    def getDevice(self, hwid=None, host=None, port=None,
                  packagename=None, verbose=False):
        '''
        Returns a device with the specified parameters
        '''
        logLevel = logging.ERROR
        if verbose:
            logLevel = logging.DEBUG

        if host and not port:
            port = 5555
        return mozdevice.DroidADB(packageName=packagename,
                                  host=host, port=port,
                                  logLevel=logLevel)
예제 #9
0
    def getDevice(self, dmtype="adb", hwid=None, host=None, port=None):
        '''
        Returns a device with the specified parameters
        '''
        if self.options.verbose:
            mozdevice.DroidSUT.debug = 4

        if hwid:
            return mozdevice.DroidConnectByHWID(hwid)

        if dmtype == "adb":
            if host and not port:
                port = 5555
            return mozdevice.DroidADB(packageName=self.options.packagename,
                                      host=host,
                                      port=port)
        elif dmtype == "sut":
            if not host:
                self.parser.error("Must specify host with SUT!")
            if not port:
                port = 20701
            return mozdevice.DroidSUT(host=host, port=port)
        else:
            self.parser.error("Unknown device manager type: %s" % type)
예제 #10
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

    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]
    if (dm.processExist(procName)):
        dm.killProcess(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
예제 #11
0
#!/usr/bin/env python

# Reboots device and waits for it to come back with the watcher started

import mozdevice
import sys
import time

WATCHER_TIMEOUT = 120

dm = mozdevice.DroidADB()
dm.reboot(wait=True)

wait_start = time.time()
elapsed = 0
while elapsed < WATCHER_TIMEOUT:
    if dm.processExist('com.mozilla.watcher'):
        print "Watcher running! We are good"
        sys.exit(0)

    remaining = (WATCHER_TIMEOUT - elapsed)
    print "Waiting for watcher... (%s seconds remaining)" % remaining
    time.sleep(5)
    elapsed = time.time() - wait_start

print "ERROR: Timed out waiting for watcher"
sys.exit(1)
예제 #12
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")))

    # 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()
        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
예제 #13
0
def runTests(options, parser):
    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 = mozdevice.DroidADB(options.deviceIP,
                                        options.devicePort,
                                        deviceRoot=options.remoteTestRoot)
            elif (options.deviceSerial):
                dm = mozdevice.DroidADB(None,
                                        None,
                                        deviceSerial=options.deviceSerial,
                                        deviceRoot=options.remoteTestRoot)
            else:
                dm = mozdevice.DroidADB(None,
                                        None,
                                        deviceRoot=options.remoteTestRoot)
        else:
            dm = mozdevice.DroidSUT(options.deviceIP,
                                    options.devicePort,
                                    deviceRoot=options.remoteTestRoot)
    except mozdevice.DMError:
        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 != 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)

    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