Ejemplo n.º 1
0
def checkAndFixScreen(dm, device):
    """ Verify the screen is set as we expect

    If the screen is incorrectly set, this function attempts to fix it,
    which ends up requiring a reboot of the device.

    Returns False if screen is wrong, True if correct
    """
    if not dmAlive(dm):
        return False

    # Verify we have the expected screen resolution
    info = dm.getInfo("screen")
    if not info["screen"][0] == EXPECTED_DEVICE_SCREEN:
        setFlag(
            errorFile,
            "Remote Device Error: Unexpected Screen on device, got '%s' expected '%s'"
            % (info["screen"][0], EXPECTED_DEVICE_SCREEN))
        if not dm.adjustResolution(**EXPECTED_DEVICE_SCREEN_ARGS):
            setFlag(errorFile, "Command to update resolution returned failure")
        else:
            soft_reboot(dm=dm, device=device)
            # Reboot sooner than cp would trigger a hard Reset
        return False
    log.info("INFO: Got expected screen size '%s'" % EXPECTED_DEVICE_SCREEN)
    return True
Ejemplo n.º 2
0
def verifyDevice(device,
                 checksut=True,
                 doCheckStalled=True,
                 skipWhenMozpoolReady=False):
    # Returns False on failure, True on Success
    global dm, errorFile
    devicePath = os.path.join('/builds', device)
    errorFile = os.path.join(devicePath, 'error.flg')

    if doCheckStalled:
        if not cleanupFoopy(device):
            log.info("verifyDevice: failing to cleanup foopy")
            return False

    mozpool_state = isMozpoolReady(device)
    if skipWhenMozpoolReady and mozpool_state is MOZPOOL_STATE_READY:
        log.info("Mozpool State is ready skipping device checks")
        return True
    elif mozpool_state is MOZPOOL_STATE_READY:
        log.info(
            "Mozpool claims device is ready, continuing to verify device...")
    elif mozpool_state is MOZPOOL_STATE_UNKNOWN:
        log.info(
            "Mozpool knows about device, but claims we're not safe to continue"
        )
        return False
    elif mozpool_state in (MOZPOOL_STATE_ERROR, MOZPOOL_STATE_MISSING):
        log.info(
            "Unable to determine state from Mozpool, falling back to device checks"
        )
    else:
        log.info("Unexpected Mozpool State returned, hard stop.")
        return False

    if not canPing(device):
        log.info("verifyDevice: failing to ping")
        # See if we can recover the device with a reboot.
        soft_reboot(dm=dm, device=device)
        return False

    if not canTelnet(device):
        log.info("verifyDevice: failing to telnet")
        return False

    if not checkSDCard(dm):
        log.info("verifyDevice: failing to check SD card")
        return False

    if checksut and not checkVersion(dm):
        if not updateSUTVersion(dm):
            log.info("verifyDevice: failing to updateSUT")
            return False

    # Resolution Check disabled for now; Bug 737427
    if False and not checkAndFixScreen(dm, device):
        log.info("verifyDevice: failing to fix screen")
        return False

    if not cleanupDevice(device, dm):
        log.info("verifyDevice: failing to cleanup device")
        return False

    return True