This repository has been archived by the owner on Sep 15, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 690311 - clean and verify connectivity to a tegra before launchin…
…g a job on it. r=armenzg,bear Part 2 - Tie in cleanup.py and refactor it a bit to support being launched here as well
- Loading branch information
Justin Wood
committed
Mar 28, 2012
1 parent
85dd82e
commit e432036
Showing
3 changed files
with
126 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,75 +1,103 @@ | |||
#!/usr/bin/env python | #!/usr/bin/env python | ||
|
|
||
# This Source Code Form is subject to the terms of the Mozilla Public | |||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | |||
# You can obtain one at http://mozilla.org/MPL/2.0/. | |||
|
|||
import os, sys | import os, sys | ||
import time | import time | ||
import devicemanagerSUT as devicemanager | import devicemanagerSUT as devicemanager | ||
|
|
||
from sut_lib import clearFlag, setFlag, checkDeviceRoot, stopProcess, checkStalled, waitForDevice | from sut_lib import clearFlag, setFlag, checkDeviceRoot, stopProcess, checkStalled, waitForDevice | ||
|
|
||
if (len(sys.argv) <> 2): | # main() RETURN CODES | ||
print "usage: cleanup.py <ip address>" | RETCODE_SUCCESS = 0 | ||
sys.exit(1) | RETCODE_ERROR = 1 | ||
|
RETCODE_KILLSTALLED = 2 | ||
cwd = os.getcwd() |
|
||
pidDir = os.path.join(cwd, '..') | def main(tegra=None, dm=None): | ||
flagFile = os.path.join(pidDir, 'proxy.flg') | assert ((tegra is not None) or (dm is not None)) # Require one to be set | ||
errorFile = os.path.join(pidDir, 'error.flg') |
|
||
|
tegra_name = os.environ['SUT_NAME'] | ||
processNames = [ 'org.mozilla.fennec', | pidDir = os.path.join('/builds/', tegra_name) | ||
'org.mozilla.fennec_aurora', | flagFile = os.path.join(pidDir, 'proxy.flg') | ||
'org.mozilla.fennec_unofficial', | errorFile = os.path.join(pidDir, 'error.flg') | ||
'org.mozilla.firefox', |
|
||
'org.mozilla.firefox_beta', | processNames = [ 'org.mozilla.fennec', | ||
'org.mozilla.roboexample.test', | 'org.mozilla.fennec_aurora', | ||
] | 'org.mozilla.fennec_unofficial', | ||
|
'org.mozilla.firefox', | ||
if os.path.exists(flagFile): | 'org.mozilla.firefox_beta', | ||
print "Warning proxy.flg found during cleanup" | 'org.mozilla.roboexample.test', | ||
clearFlag(flagFile) | ] | ||
|
|
||
print "Connecting to: " + sys.argv[1] | if os.path.exists(flagFile): | ||
dm = devicemanager.DeviceManagerSUT(sys.argv[1]) | print "Warning proxy.flg found during cleanup" | ||
|
clearFlag(flagFile, dump=True) | ||
dm.debug = 5 |
|
||
devRoot = checkDeviceRoot(dm) | if dm is None: | ||
|
print "Connecting to: " + tegra | ||
if not str(devRoot).startswith("/mnt/sdcard"): | dm = devicemanager.DeviceManagerSUT(tegra) | ||
setFlag(errorFile, "Remote Device Error: devRoot from devicemanager [%s] is not correct" % str(devRoot)) | dm.debug = 5 | ||
sys.exit(1) |
|
||
|
for p in processNames: | ||
if dm.dirExists(devRoot): | if dm.dirExists('/data/data/%s' % p): | ||
status = dm.removeDir(devRoot) | print dm.uninstallAppAndReboot(p) | ||
print "removeDir() returned [%s]" % status | waitForDevice(dm) | ||
if status is None or not status: |
|
||
setFlag(errorFile, "Remote Device Error: call to removeDir() returned [%s]" % status) | # Now Verify that they are all gone | ||
sys.exit(1) | for p in processNames: | ||
|
if dm.dirExists('/data/data/%s' % p): | ||
if not dm.fileExists('/system/etc/hosts'): | setFlag(errorFile, "Unable to properly uninstall %s" % p) | ||
print "restoring /system/etc/hosts file" | return RETCODE_ERROR | ||
try: |
|
||
dm.sendCMD(['exec mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system']) | devRoot = checkDeviceRoot(dm) | ||
data = "127.0.0.1 localhost" |
|
||
dm.verifySendCMD(['push /mnt/sdcard/hosts ' + str(len(data)) + '\r\n', data], newline=False) | if not str(devRoot).startswith("/mnt/sdcard"): | ||
dm.verifySendCMD(['exec dd if=/mnt/sdcard/hosts of=/system/etc/hosts']) | setFlag(errorFile, "Remote Device Error: devRoot from devicemanager [%s] is not correct" % str(devRoot)) | ||
except devicemanager.DMError, e: | return RETCODE_ERROR | ||
print "Exception hit while trying to restore /system/etc/hosts: %s" % str(e) |
|
||
setFlag(errorFile, "failed to restore /system/etc/hosts") | if dm.dirExists(devRoot): | ||
sys.exit(1) | status = dm.removeDir(devRoot) | ||
print "removeDir() returned [%s]" % status | |||
if status is None or not status: | |||
setFlag(errorFile, "Remote Device Error: call to removeDir() returned [%s]" % status) | |||
return RETCODE_ERROR | |||
if dm.dirExists(devRoot): | |||
setFlag(errorFile, "Remote Device Error: Unable to properly remove %s" % devRoot) | |||
return RETCODE_ERROR | |||
|
|||
if not dm.fileExists('/system/etc/hosts'): | if not dm.fileExists('/system/etc/hosts'): | ||
setFlag(errorFile, "failed to restore /system/etc/hosts") | print "restoring /system/etc/hosts file" | ||
sys.exit(1) | try: | ||
else: | dm.sendCMD(['exec mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system']) | ||
print "successfully restored hosts file, we can test!!!" | data = "127.0.0.1 localhost" | ||
|
dm.verifySendCMD(['push /mnt/sdcard/hosts ' + str(len(data)) + '\r\n', data], newline=False) | ||
errcode = checkStalled(os.environ['SUT_NAME']) | dm.verifySendCMD(['exec dd if=/mnt/sdcard/hosts of=/system/etc/hosts']) | ||
if errcode > 1: | except devicemanager.DMError, e: | ||
if errcode == 2: | print "Exception hit while trying to restore /system/etc/hosts: %s" % str(e) | ||
print "processes from previous run were detected and cleaned up" | setFlag(errorFile, "failed to restore /system/etc/hosts") | ||
elif errocode == 3: | return RETCODE_ERROR | ||
setFlag(errorFile, "Remote Device Error: process from previous test run present") | if not dm.fileExists('/system/etc/hosts'): | ||
sys.exit(2) | setFlag(errorFile, "failed to restore /system/etc/hosts") | ||
|
return RETCODE_ERROR | ||
for p in processNames: | else: | ||
if dm.dirExists('/data/data/%s' % p): | print "successfully restored hosts file, we can test!!!" | ||
print dm.uninstallAppAndReboot(p) |
|
||
waitForDevice(dm) | errcode = checkStalled(tegra_name) | ||
if errcode > 1: | |||
if errcode == 2: | |||
print "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 | |||
|
|||
if __name__ == '__main__': | |||
if (len(sys.argv) <> 2): | |||
print "usage: cleanup.py <tegra name || ip address>" | |||
sys.exit(RETCODE_ERROR) | |||
|
|||
retval = main(tegra=sys.argv[1]) | |||
sys.exit(retval) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters