Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Commit

Permalink
Bug 825132 - verify.py should cleanup stray procs on a foopy prior to…
Browse files Browse the repository at this point in the history
… pinging device. r=jmaher
  • Loading branch information
Callek committed Dec 29, 2012
1 parent 549cc27 commit 4aa00f7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
27 changes: 17 additions & 10 deletions sut_tools/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@
RETCODE_ERROR = 1
RETCODE_KILLSTALLED = 2

def main(device=None, dm=None, doCheckStalled=True):
def cleanupFoopy(device=None):
errcode = checkStalled(device_name)
if errcode == 2:
log.error("processes from previous run were detected and cleaned up")
elif errocode == 3:
setFlag(errorFile, "Remote Device Error: process from previous test run present")
return RETCODE_KILLSTALLED
return RETCODE_SUCCESS

def cleanupDevice(device=None, dm=None):
assert ((device is not None) or (dm is not None)) # Require one to be set

device_name = os.environ['SUT_NAME']
Expand Down Expand Up @@ -96,17 +105,15 @@ def main(device=None, dm=None, doCheckStalled=True):
else:
log.info("successfully restored hosts file, we can test!!!")

if doCheckStalled:
errcode = checkStalled(device_name)
if errcode > 1:
if errcode == 2:
log.error("processes from previous run were detected and cleaned up")
elif errocode == 3:
setFlag(errorFile, "Remote Device Error: process from previous test run present")
return RETCODE_KILLSTALLED

return RETCODE_SUCCESS

def main(device=None, dm=None, doCheckStalled=True):
if doCheckStalled:
retcode = cleanupFoopy(device)
if not retcode == RETCODE_SUCCESS:
return retcode
return cleanupDevice(device, dm)

if __name__ == '__main__':
device_name = None
if (len(sys.argv) <> 2):
Expand Down
25 changes: 22 additions & 3 deletions sut_tools/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,21 @@ def checkSDCard(dm):
return False
return True

def cleanupDevice(device, dm, doCheckStalled):
def cleanupFoopy(device):
""" Do cleanup actions necessary to ensure foopy in a good state
Returns False on failure, True on Success
"""
import cleanup
retval = cleanup.cleanupFoopy(device=device)
if retval == cleanup.RETCODE_SUCCESS:
# All is good
return True
# else:
setFlag(errorFile, "Automation Error: Unable to properly cleanup foopy processes")
return False

def cleanupDevice(device, dm):
""" Do cleanup actions necessary to ensure starting in a good state
Returns False on failure, True on Success
Expand All @@ -189,7 +203,7 @@ def cleanupDevice(device, dm, doCheckStalled):

import cleanup
try:
retval = cleanup.main(device=device, dm=dm, doCheckStalled=doCheckStalled)
retval = cleanup.cleanupDevice(device=device, dm=dm)
if retval == cleanup.RETCODE_SUCCESS:
# All is good
return True
Expand Down Expand Up @@ -261,6 +275,11 @@ def verifyDevice(device, checksut=True, doCheckStalled=True, watcherINI=False):
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

if not canPing(device):
# TODO Reboot via PDU if ping fails
log.info("verifyDevice: failing to ping")
Expand All @@ -284,7 +303,7 @@ def verifyDevice(device, checksut=True, doCheckStalled=True, watcherINI=False):
log.info("verifyDevice: failing to fix screen")
return False

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

Expand Down

0 comments on commit 4aa00f7

Please sign in to comment.