Пример #1
0
def reboot(dm):
    cwd = os.getcwd()
    deviceName = os.path.basename(cwd)
    errorFile = os.path.join(cwd, '..', 'error.flg')
    proxyIP = getOurIP()
    proxyPort = calculatePort()

    if 'panda' not in deviceName:
        # Attempt to set devicename via env variable 'SUT_NAME'
        sname = os.getenv('SUT_NAME')
        if sname.strip():
            deviceName = sname.strip()
        else:
            log.info("Unable to find a proper devicename, will attempt to "
                     "reboot device")

    if dm is not None:
        try:
            dm.getInfo('process')
            log.info(
                dm._runCmds([{
                    'cmd': 'exec su -c "logcat -d -v time *:W"'
                }],
                            timeout=10))
        except:
            log.info("Failure trying to run logcat on device")
    else:
        log.info("We were unable to connect to device %s, skipping logcat" %
                 deviceName)

    try:
        log.info('forcing device %s reboot' % deviceName)
        status = powermanagement.soft_reboot_and_verify(dm=dm,
                                                        device=deviceName,
                                                        ipAddr=proxyIP,
                                                        port=proxyPort,
                                                        silent=True)
        log.info(status)
    except:
        log.info("Failure while rebooting device")
        setFlag(errorFile,
                "Remote Device Error: Device failed to recover after reboot",
                True)
        return 1

    sys.stdout.flush()
    return 0
Пример #2
0
def reboot(dm):
    cwd = os.getcwd()
    deviceName = os.path.basename(cwd)
    errorFile = os.path.join(cwd, '..', 'error.flg')
    proxyIP = getOurIP()
    proxyPort = calculatePort()

    if 'panda' not in deviceName:
        # Attempt to set devicename via env variable 'SUT_NAME'
        sname = os.getenv('SUT_NAME')
        if sname.strip():
            deviceName = sname.strip()
        else:
            log.info("Unable to find a proper devicename, will attempt to "
                     "reboot device")

    if dm is not None:
        try:
            dm.getInfo('process')
            log.info(dm._runCmds(
                [{'cmd': 'exec su -c "logcat -d -v time *:W"'}], timeout=10))
        except:
            log.info("Failure trying to run logcat on device")
    else:
        log.info("We were unable to connect to device %s, skipping logcat" %
                 deviceName)

    try:
        log.info('forcing device %s reboot' % deviceName)
        status = powermanagement.soft_reboot_and_verify(
            dm=dm,
            device=deviceName,
            ipAddr=proxyIP,
            port=proxyPort,
            silent=True
        )
        log.info(status)
    except:
        log.info("Failure while rebooting device")
        setFlag(errorFile,
                "Remote Device Error: Device failed to recover after reboot",
                True)
        return 1

    sys.stdout.flush()
    return 0
Пример #3
0
    # Moar data!
    dm.debug = 3
    devRoot = dm.getDeviceRoot()

    # checking for /mnt/sdcard/...
    print "devroot %s" % devRoot
    if devRoot is None or devRoot == '/tests':
        setFlag(errorFile, "Remote Device Error: devRoot from devicemanager [%s] is not correct - exiting" % devRoot)
        sys.exit(1)

    width, height = getResolution(dm)
    print("current resolution X:%d Y:%d" % (width, height))

    # adjust resolution up if we are part of a reftest run
    if (testname == 'reftest') and width < refWidth:
        if dm.adjustResolution(width=refWidth, height=refHeight, type='crt'):
            if not powermanagement.soft_reboot_and_verify(dm=dm, device=deviceName, ipAddr=proxyIP, port=proxyPort):
                print("Remote Device Error: Timed out while waiting for device to come back after resolution change.")
                sys.exit(1)

            width, height = getResolution(dm)
            print("current resolution X:%d Y:%d" % (width, height))
            if width != refWidth and height != refHeight:
                setFlag(
                    errorFile,
                    "Remote Device Error: current resolution X:%d Y:%d does "
                    "not match what was set X:%d Y:%d"
                    % (width, height, refWidth, refHeight)
                )
                sys.exit(1)
Пример #4
0
def one_time_setup(ip_addr, major_source):
    ''' One time setup of state

    ip_addr - of the device we want to install app at
    major_source - we've hacked this script to install
            may-also-be-needed tools, but the source we're asked to
            install has the meta data we need

    Side Effects:
        global, needed for error reporting:
            errorFile
    '''

    # set up the flag files, used throughout
    cwd = os.getcwd()
    global errorFile
    errorFile = os.path.join(cwd, '..', 'error.flg')
    deviceName = os.path.basename(cwd)

    proxyIP = getOurIP()
    proxyPort = calculatePort()

    workdir = os.path.dirname(major_source)
    inifile = os.path.join(workdir, 'fennec', 'application.ini')
    remoteappini = os.path.join(workdir, 'talos', 'remoteapp.ini')
    log.info('copying %s to %s' % (inifile, remoteappini))
    runCommand(['cp', inifile, remoteappini])

    log.info("connecting to: %s" % ip_addr)
    dm = devicemanager.DeviceManagerSUT(ip_addr)
    # Moar data!
    dm.debug = 3

    devRoot = checkDeviceRoot(dm)

    if devRoot is None or devRoot == '/tests':
        setFlag(
            errorFile,
            "Remote Device Error: devRoot from devicemanager [%s] is not correct - exiting"
            % devRoot)
        return None, None

    try:
        log.info("%s, %s" % (proxyIP, proxyPort))
        getDeviceTimestamp(dm)
        setDeviceTimestamp(dm)
        getDeviceTimestamp(dm)
        dm.getInfo('process')
        dm.getInfo('memory')
        dm.getInfo('uptime')

        width, height = getResolution(dm)
        # adjust resolution down to allow fennec to install without memory
        # issues
        if (width == 1600 or height == 1200):
            dm.adjustResolution(1024, 768, 'crt')
            log.info('forcing device reboot')
            if not powermanagement.soft_reboot_and_verify(
                    device=deviceName, dm=dm, ipAddr=proxyIP, port=proxyPort):
                return None, None

            width, height = getResolution(dm)
            if width != 1024 and height != 768:
                setFlag(
                    errorFile,
                    "Remote Device Error: Resolution change failed.  Should be %d/%d but is %d/%d"
                    % (1024, 768, width, height))
                return None, None

    except devicemanager.AgentError, err:
        log.error(
            "remoteDeviceError: while doing one time setup for installation: %s"
            % err)
        return None, None
Пример #5
0
                try:
                    if 'panda' in device:
                        dm.uninstallApp(package_basename)
                        reboot_needed = True
                    else:
                        dm.uninstallAppAndReboot(package_basename)
                        waitForDevice(dm)
                except devicemanager.DMError, err:
                    setFlag(errorFile,
                            "Remote Device Error: Unable to uninstall %s and reboot: %s" % (package_basename, err))
                    return RETCODE_ERROR
                finally:
                    break  # Don't try this proc again, since we already matched

    if reboot_needed:
        if not powermanagement.soft_reboot_and_verify(device, dm):
            # NOTE: powermanagement.soft_reboot_and_verify will setFlag if needed
            return RETCODE_ERROR

    # Now Verify that they are all gone
    packages = dm._runCmds([{'cmd': 'exec pm list packages'}])
    for package in packages.split('\n'):
        for proc in processNames:
            if package == "package:%s" % proc:
                setFlag(errorFile, "Remote Device Error: Unable to properly uninstall %s" % proc)
                return RETCODE_ERROR

    devRoot = checkDeviceRoot(dm)

    if not str(devRoot).startswith("/mnt/sdcard"):
        setFlag(errorFile, "Remote Device Error: devRoot from devicemanager [%s] is not correct" % str(devRoot))
Пример #6
0
def one_time_setup(ip_addr, major_source):
    ''' One time setup of state

    ip_addr - of the device we want to install app at
    major_source - we've hacked this script to install
            may-also-be-needed tools, but the source we're asked to
            install has the meta data we need

    Side Effects:
        global, needed for error reporting:
            errorFile
    '''

    # set up the flag files, used throughout
    cwd = os.getcwd()
    global errorFile
    errorFile = os.path.join(cwd, '..', 'error.flg')
    deviceName = os.path.basename(cwd)

    proxyIP = getOurIP()
    proxyPort = calculatePort()

    workdir = os.path.dirname(major_source)
    inifile = os.path.join(workdir, 'fennec', 'application.ini')
    remoteappini = os.path.join(workdir, 'talos', 'remoteapp.ini')
    log.info('copying %s to %s' % (inifile, remoteappini))
    runCommand(['cp', inifile, remoteappini])

    log.info("connecting to: %s" % ip_addr)
    dm = devicemanager.DeviceManagerSUT(ip_addr)
# Moar data!
    dm.debug = 3

    devRoot = checkDeviceRoot(dm)

    if devRoot is None or devRoot == '/tests':
        setFlag(errorFile, "Remote Device Error: devRoot from devicemanager [%s] is not correct - exiting" % devRoot)
        return None, None

    try:
        log.info("%s, %s" % (proxyIP, proxyPort))
        getDeviceTimestamp(dm)
        setDeviceTimestamp(dm)
        getDeviceTimestamp(dm)
        dm.getInfo('process')
        dm.getInfo('memory')
        dm.getInfo('uptime')

        width, height = getResolution(dm)
        # adjust resolution down to allow fennec to install without memory
        # issues
        if (width == 1600 or height == 1200):
            dm.adjustResolution(1024, 768, 'crt')
            log.info('forcing device reboot')
            if not powermanagement.soft_reboot_and_verify(device=deviceName, dm=dm, ipAddr=proxyIP, port=proxyPort):
                return None, None

            width, height = getResolution(dm)
            if width != 1024 and height != 768:
                setFlag(errorFile, "Remote Device Error: Resolution change failed.  Should be %d/%d but is %d/%d" % (1024, 768, width, height))
                return None, None

    except devicemanager.AgentError, err:
        log.error("remoteDeviceError: while doing one time setup for installation: %s" % err)
        return None, None
Пример #7
0
                        dm.uninstallApp(package_basename)
                        reboot_needed = True
                    else:
                        dm.uninstallAppAndReboot(package_basename)
                        waitForDevice(dm)
                except devicemanager.DMError, err:
                    setFlag(
                        errorFile,
                        "Remote Device Error: Unable to uninstall %s and reboot: %s"
                        % (package_basename, err))
                    return RETCODE_ERROR
                finally:
                    break  # Don't try this proc again, since we already matched

    if reboot_needed:
        if not powermanagement.soft_reboot_and_verify(device, dm):
            # NOTE: powermanagement.soft_reboot_and_verify will setFlag if needed
            return RETCODE_ERROR

    # Now Verify that they are all gone
    packages = dm._runCmds([{'cmd': 'exec pm list packages'}])
    for package in packages.split('\n'):
        for proc in processNames:
            if package == "package:%s" % proc:
                setFlag(
                    errorFile,
                    "Remote Device Error: Unable to properly uninstall %s" %
                    proc)
                return RETCODE_ERROR

    devRoot = checkDeviceRoot(dm)