def main(argv): if (len(argv) < 3): print "usage: installWatcher.py <ip address> <localfilename>" sys.exit(1) ip_addr = argv[1] path_to_main_apk = argv[2] dm = droid.DroidSUT(ip_addr) if not dm: log.error("could not get device manager!") return 1 devRoot = checkDeviceRoot(dm) if install(dm, devRoot, path_to_main_apk, "com.mozilla.watcher"): log.error("install failed") return 1 dm.reboot() waitForDevice(dm) # we can't use the following dm.getFile method, since only Watcher runtime user has read access # to this file, so we need to be root to read it, hence the slightly more convoluted version # using dm._runCmds below... # cannot use -> print dm.getFile('/data/data/com.mozilla.watcher/files/version.txt') status = dm._runCmds([{ 'cmd': 'exec su -c "cat /data/data/com.mozilla.watcher/files/version.txt"' }]).split('\n') log.info('Watcher version: %s' % status) return 0
def main(argv): if (len(argv) < 3): print "usage: installWatcher.py <ip address> <localfilename>" sys.exit(1) ip_addr = argv[1] path_to_main_apk = argv[2] dm = droid.DroidSUT(ip_addr) if not dm: log.error("could not get device manager!") return 1 devRoot = checkDeviceRoot(dm) if install(dm, devRoot, path_to_main_apk, "com.mozilla.watcher"): log.error("install failed") return 1 dm.reboot() waitForDevice(dm) # we can't use the following dm.getFile method, since only Watcher runtime user has read access # to this file, so we need to be root to read it, hence the slightly more convoluted version # using dm._runCmds below... # cannot use -> print dm.getFile('/data/data/com.mozilla.watcher/files/version.txt') status = dm._runCmds([{'cmd': 'exec su -c "cat /data/data/com.mozilla.watcher/files/version.txt"'}]).split('\n') log.info('Watcher version: %s' % status) return 0
def main(argv): if (len(argv) < 3): print "usage: installApp.py <ip address> <localfilename> [<processName>]" sys.exit(1) # N.B. 3rd arg not used anywhere ip_addr = argv[1] path_to_main_apk = argv[2] dm, devRoot = one_time_setup(ip_addr, path_to_main_apk) if not dm: return 1 # errorFile is already created globally in one_time_setup call above if installOneApp(dm, devRoot, path_to_main_apk, errorFile): return 1 # also install robocop if it's available robocop_to_use = find_robocop() if robocop_to_use is not None: waitForDevice(dm) # errorFile is already created globally in one_time_setup call above if installOneApp(dm, devRoot, robocop_to_use, errorFile): return 1 # make sure we're all the way back up before we finish waitForDevice(dm) return 0
def cleanupDevice(device=None, dm=None): assert ((device is not None) or (dm is not None)) # Require one to be set if not device: device = os.environ['SUT_NAME'] pidDir = os.path.join('/builds/', device) errorFile = os.path.join(pidDir, 'error.flg') reboot_needed = False processNames = [ 'org.mozilla.fennec_aurora', 'org.mozilla.fennec_unofficial', 'org.mozilla.fennec', 'org.mozilla.firefox_beta', 'org.mozilla.firefox', 'org.mozilla.roboexample.test', ] if dm is None: log.info("Connecting to: " + device) dm = devicemanager.DeviceManagerSUT(device) dm.debug = 5 packages = dm._runCmds([{'cmd': 'exec pm list packages'}]) for package in packages.split('\n'): if not package.strip().startswith("package:"): continue # unknown entry package_basename = package.strip()[8:] for proc in processNames: if package_basename == "%s" % proc or \ package_basename.startswith("%s_" % proc): log.info("Uninstalling %s..." % package_basename) 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
def cleanupDevice(device=None, dm=None): assert ((device is not None) or (dm is not None)) # Require one to be set if not device: device = os.environ['SUT_NAME'] pidDir = os.path.join('/builds/', device) errorFile = os.path.join(pidDir, 'error.flg') reboot_needed = False processNames = ['org.mozilla.fennec_aurora', 'org.mozilla.fennec_unofficial', 'org.mozilla.fennec', 'org.mozilla.firefox_beta', 'org.mozilla.firefox', 'org.mozilla.roboexample.test', ] if dm is None: log.info("Connecting to: " + device) dm = devicemanager.DeviceManagerSUT(device) dm.debug = 5 packages = dm._runCmds([{'cmd': 'exec pm list packages'}]) for package in packages.split('\n'): if not package.strip().startswith("package:"): continue # unknown entry package_basename = package.strip()[8:] for proc in processNames: if package_basename == "%s" % proc or \ package_basename.startswith("%s_" % proc): log.info("Uninstalling %s..." % package_basename) 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
def main(argv): if len(argv) < 3: print "usage: installApp.py <ip address> <localfilename> [<processName>]" sys.exit(1) # N.B. 3rd arg not used anywhere if len(argv) > 3: processName = argv[3] else: processName = "org.mozilla.fennec" ip_addr = argv[1] path_to_main_apk = argv[2] dm, devRoot = one_time_setup(ip_addr, path_to_main_apk) installOneApp(dm, devRoot, path_to_main_apk) # also install robocop if it's available robocop_to_use = find_robocop() if robocop_to_use is not None: waitForDevice(dm) installOneApp(dm, devRoot, robocop_to_use) # make sure we're all the way back up before we finish waitForDevice(dm)
def main(argv): if (len(argv) < 3): print "usage: installApp.py <ip address> <localfilename> [<processName>]" sys.exit(1) # N.B. 3rd arg not used anywhere if len(argv) > 3: processName = argv[3] else: processName = 'org.mozilla.fennec' ip_addr = argv[1] path_to_main_apk = argv[2] dm, devRoot = one_time_setup(ip_addr, path_to_main_apk) installOneApp(dm, devRoot, path_to_main_apk) # also install robocop if it's available robocop_to_use = find_robocop() if robocop_to_use is not None: waitForDevice(dm) installOneApp(dm, devRoot, robocop_to_use) # make sure we're all the way back up before we finish waitForDevice(dm)
if not dm.fileExists('/system/etc/hosts'): print "restoring /system/etc/hosts file" try: dm.sendCMD(['exec mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system']) data = "127.0.0.1 localhost" dm.verifySendCMD(['push /mnt/sdcard/hosts ' + str(len(data)) + '\r\n', data], newline=False) dm.verifySendCMD(['exec dd if=/mnt/sdcard/hosts of=/system/etc/hosts']) except devicemanager.DMError, e: print "Exception hit while trying to restore /system/etc/hosts: %s" % str(e) setFlag(errorFile, "failed to restore /system/etc/hosts") sys.exit(1) if not dm.fileExists('/system/etc/hosts'): setFlag(errorFile, "failed to restore /system/etc/hosts") sys.exit(1) else: print "successfully restored hosts file, we can test!!!" errcode = checkStalled(os.environ['SUT_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") sys.exit(2) for p in processNames: if dm.dirExists('/data/data/%s' % p): print dm.uninstallAppAndReboot(p) waitForDevice(dm)
def one_time_setup(ip_addr, major_source): """ One time setup of state ip_addr - of the tegra 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: We two globals, needed for error reporting: errorFile, proxyFile """ # set up the flag files, used throughout cwd = os.getcwd() global proxyFile, errorFile proxyFile = os.path.join(cwd, "..", "proxy.flg") errorFile = os.path.join(cwd, "..", "error.flg") 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") print "copying %s to %s" % (inifile, remoteappini) runCommand(["cp", inifile, remoteappini]) print "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) sys.exit(1) try: setFlag(proxyFile) print 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 >= 1050 or height >= 1050: dm.adjustResolution(1024, 768, "crt") print "calling reboot" dm.reboot(proxyIP, proxyPort) waitForDevice(dm) width, height = getResolution(dm) if width != 1024 and height != 768: clearFlag(proxyFile) setFlag( errorFile, "Remote Device Error: Resolution change failed. Should be %d/%d but is %d/%d" % (1024, 768, width, height), ) sys.exit(1) finally: clearFlag(proxyFile) return dm, devRoot
errorFile = os.path.join(cwd, '..', 'error.flg') proxyIP = getOurIP() proxyPort = calculatePort() print "connecting to: %s" % sys.argv[1] dm = devicemanager.DeviceManagerSUT(sys.argv[1]) dm.debug = 5 setFlag(proxyFile) try: dm.getInfo('process') print dm.sendCMD(['exec su -c "logcat -d -v time *:W"']) print 'calling dm.reboot()' status = dm.reboot(ipAddr=proxyIP, port=proxyPort) print status finally: try: waitForDevice(dm, waitTime=600) except SystemExit: clearFlag(proxyFile) setFlag(errorFile, "Remote Device Error: call for device reboot failed") sys.exit(1) clearFlag(proxyFile) #if status is None or not status: # print "Remote Device Error: call for device reboot failed" # sys.exit(1)
def one_time_setup(ip_addr, major_source): ''' One time setup of state ip_addr - of the tegra 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: We two globals, needed for error reporting: errorFile, proxyFile ''' # set up the flag files, used throughout cwd = os.getcwd() global proxyFile, errorFile proxyFile = os.path.join(cwd, '..', 'proxy.flg') errorFile = os.path.join(cwd, '..', 'error.flg') 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') print 'copying %s to %s' % (inifile, remoteappini) runCommand(['cp', inifile, remoteappini]) print "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) sys.exit(1) try: setFlag(proxyFile) print 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 >= 1050 or height >= 1050): dm.adjustResolution(1024, 768, 'crt') print 'calling reboot' dm.reboot(proxyIP, proxyPort) waitForDevice(dm) width, height = getResolution(dm) if width != 1024 and height != 768: clearFlag(proxyFile) setFlag( errorFile, "Remote Device Error: Resolution change failed. Should be %d/%d but is %d/%d" % (1024, 768, width, height)) sys.exit(1) finally: clearFlag(proxyFile) return dm, devRoot
if dm.fileExists('/system/etc/hosts'): print "removing /system/etc/hosts file" try: dm.sendCMD(['exec mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system']) dm.sendCMD(['exec rm /system/etc/hosts']) except devicemanager.DMError, e: print "Exception hit while trying to remove /system/etc/hosts: %s" % str(e) setFlag(errorFile, "failed to remove /system/etc/hosts") sys.exit(1) if dm.fileExists('/system/etc/hosts'): setFlag(errorFile, "failed to remove /system/etc/hosts") sys.exit(1) else: print "successfully removed hosts file, we can test!!!" for f in ('runtestsremote', 'remotereftest', 'remotereftest.pid.xpcshell'): pidFile = os.path.join(pidDir, '%s.pid' % f) print "checking for previous test processes ... %s" % pidFile if os.path.exists(pidFile): print "pidfile from prior test run found, trying to kill" stopProcess(pidFile, f) if os.path.exists(pidFile): setFlag(errorFile, "Remote Device Error: process from previous test run present [%s]" % f) sys.exit(2) for p in processNames: if dm.dirExists('/data/data/%s' % p): print dm.uninstallAppAndReboot(p) waitForDevice(dm)