Example #1
0
def reboot(device_fqdn):
    logger.info('Rebooting device via SUT agent.')
    # This guarantees that the total time will be about 45 seconds or less:
    # up to 15 seconds to connect, up to 15 seconds to get the device root,
    # and up to another 15 seconds to send the reboot command.
    DeviceManagerSUT.default_timeout = 15
    try:
        dm = DeviceManagerSUT(device_fqdn, retryLimit=1)
        dm.reboot()
    except DMError, e:
        logger.error('Reboot failed: %s' % str(e))
        return False
Example #2
0
def reboot(device_fqdn):
    logger.info('Rebooting device via SUT agent.')
    # This guarantees that the total time will be about 45 seconds or less:
    # up to 15 seconds to connect, up to 15 seconds to get the device root,
    # and up to another 15 seconds to send the reboot command.
    DeviceManagerSUT.default_timeout = 15
    try:
        dm = DeviceManagerSUT(device_fqdn, retryLimit=1)
        dm.reboot()
    except DMError, e:
        logger.error('Reboot failed: %s' % str(e))
        return False
Example #3
0
def sut_verify(device_fqdn):
    # This should take no longer than 30 seconds (maximum 15 for connecting
    # and maximum 15 for the built-in call to get the device's test root).
    logger.info('Verifying that SUT agent is running.')
    DeviceManagerSUT.default_timeout = 15
    try:
        DeviceManagerSUT(device_fqdn, retryLimit=1)
    except DMError, e:
        logger.error('Exception initiating DeviceManager!: %s' % str(e))
        return False
Example #4
0
 def __init__(self, **kwargs):
     DeviceManagerSUT.__init__(self, **kwargs)
     B2GMixin.__init__(self, **kwargs)
Example #5
0
def main(ip, port, filename):
    dm = DeviceManagerSUT(ip, port)
    dm.pushFile(filename,
                '/data/data/com.mozilla.SUTAgentAndroid/files/SUTAgent.ini')
Example #6
0
def main(args):
    parser = Options()
    options, args = parser.parse_args()
    kill_port = 20703

    if not options.html_manifest or not options.specialpowers or not options.host1 or not options.host2 or not options.signalling_server:
        parser.print_usage()
        return 2

    package_options = get_package_options(parser, options)
    if not package_options:
        parser.print_usage()
        return 2

    if not os.path.isdir(options.specialpowers):
        parser.error("SpecialPowers directory %s does not exist" %
                     options.specialpowers)
        return 2
    if options.prefs and not os.path.isfile(options.prefs):
        parser.error("Prefs file %s does not exist" % options.prefs)
        return 2
    if options.log_dest and not os.path.isdir(options.log_dest):
        parser.error("Log directory %s does not exist" % options.log_dest)
        return 2

    log = mozlog.unstructured.getLogger('steeplechase')
    log.setLevel(logging.DEBUG)
    if ':' in options.host1:
        host1, port = options.host1.split(':')
        dm1 = DeviceManagerSUT(host1, port)
    else:
        dm1 = DeviceManagerSUT(options.host1)
    if ':' in options.host2:
        host2, port = options.host2.split(':')
        dm2 = DeviceManagerSUT(host2, port)
    else:
        dm2 = DeviceManagerSUT(options.host2)

    if (options.killall is not None) and (options.killall == 1):
        kill_dm1 = DeviceManagerSUT(host1, kill_port)
        kill_dm2 = DeviceManagerSUT(host2, kill_port)
        os_type = GetOStypes(package_options)
        print("OS type of host1 is " + os_type[0] + " and host2 is " +
              os_type[1])
        KillFirefoxesCommand(kill_dm1, os_type[0])
        KillFirefoxesCommand(kill_dm2, os_type[1])

    remote_info = [{
        'dm': dm1,
        'binary': package_options.binary,
        'package': package_options.package,
        'is_initiator': True,
        'name': 'Client1'
    }, {
        'dm': dm2,
        'binary': package_options.binary2,
        'package': package_options.package2,
        'is_initiator': False,
        'name': 'Client2'
    }]
    # first, push app
    for info in remote_info:
        dm = info['dm']

        if info['binary']:
            asset = Binary(path=info['binary'],
                           log=log,
                           dm=info['dm'],
                           name=info['name'])
        else:
            asset = generate_package_asset(path=info['package'],
                                           log=log,
                                           dm=info['dm'],
                                           name=info['name'])

        if options.setup:
            asset.setup_test_root()
        info['test_root'] = asset.test_root()

        if options.setup:
            log.info("Pushing app to %s...", info["name"])
            asset.setup_client()
        info['remote_app_path'] = asset.path_to_launch()
        if not options.setup and not dm.fileExists(info['remote_app_path']):
            log.error("App does not exist on %s, don't use --noSetup",
                      info['name'])
            return 2

    pass_count, fail_count = 0, 0
    if options.html_manifest:
        manifest = TestManifest(strict=False)
        manifest.read(options.html_manifest)
        manifest_data = {
            "tests": [{
                "path": t["relpath"]
            } for t in manifest.active_tests(disabled=False, **mozinfo.info)]
        }

        remote_port = 0
        if options.remote_webserver:
            result = re.search(':(\d+)', options.remote_webserver)
            if result:
                remote_port = int(result.groups()[0])

        @json_response
        def get_manifest(req):
            return (200, manifest_data)

        handlers = [{
            'method': 'GET',
            'path': '/manifest.json',
            'function': get_manifest
        }]
        httpd = MozHttpd(
            host=moznetwork.get_ip(),
            port=remote_port,
            log_requests=True,
            docroot=os.path.join(os.path.dirname(__file__), "..",
                                 "webharness"),
            urlhandlers=handlers,
            path_mappings={"/tests": os.path.dirname(options.html_manifest)})
        httpd.start(block=False)
        test = HTMLTests(httpd, remote_info, log, options)
        html_pass_count, html_fail_count = test.run()
        pass_count += html_pass_count
        fail_count += html_fail_count
        httpd.stop()
    log.info("Result summary:")
    log.info("Passed: %d" % pass_count)
    log.info("Failed: %d" % fail_count)
    return pass_count > 0 and fail_count == 0
 def __init__(self, **kwargs):
     DeviceManagerSUT.__init__(self, **kwargs)
     B2GMixin.__init__(self, **kwargs)
Example #8
0
def check_sdcard(device_fqdn):
    # This should take a maximum of 13 SUT commands (some DM functions send
    # multiple commands).  Assuming worst-case scenario in which each one
    # takes the maximum timeout, that's 13 * 15 = 195 seconds.
    # Note that most of the time it will take much less.
    logger.info('Checking SD card.')
    success = True
    DeviceManagerSUT.default_timeout = 15
    try:
        dm = DeviceManagerSUT(device_fqdn)
        dev_root = dm.getDeviceRoot()
        if dev_root:
            d = posixpath.join(dev_root, 'sdcardtest')
            dm.removeDir(d)
            dm.mkDir(d)
            if dm.dirExists(d):
                with tempfile.NamedTemporaryFile() as tmp:
                    tmp.write('autophone test\n')
                    tmp.flush()
                    dm.pushFile(tmp.name, posixpath.join(d, 'sdcard_check'))
                    dm.removeDir(d)
                logger.info('Successfully wrote test file to SD card.')
            else:
                logger.error('Failed to create directory under device '
                             'root!')
                success = False
        else:
            logger.error('Invalid device root.')
            success = False
    except DMError, e:
        logger.error('Exception while checking SD card!: %s' % str(e))
        success = False
Example #9
0
def check_sdcard(device_fqdn):
    # This should take a maximum of 13 SUT commands (some DM functions send
    # multiple commands).  Assuming worst-case scenario in which each one
    # takes the maximum timeout, that's 13 * 15 = 195 seconds.
    # Note that most of the time it will take much less.
    logger.info('Checking SD card.')
    success = True
    DeviceManagerSUT.default_timeout = 15
    try:
        dm = DeviceManagerSUT(device_fqdn)
        dev_root = dm.getDeviceRoot()
        if dev_root:
            d = posixpath.join(dev_root, 'sdcardtest')
            dm.removeDir(d)
            dm.mkDir(d)
            if dm.dirExists(d):
                with tempfile.NamedTemporaryFile() as tmp:
                    tmp.write('autophone test\n')
                    tmp.flush()
                    dm.pushFile(tmp.name, posixpath.join(d, 'sdcard_check'))
                    dm.removeDir(d)
                logger.info('Successfully wrote test file to SD card.')
            else:
                logger.error('Failed to create directory under device '
                             'root!')
                success = False
        else:
            logger.error('Invalid device root.')
            success = False
    except DMError, e:
        logger.error('Exception while checking SD card!: %s' % str(e))
        success = False