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 XXXtestOneSetOfCalls(self): root_path = sut_lib.checkDeviceRoot() source_file = 'testing' source_path = os.path.join('/path/to', source_file) installed_path = os.path.join(root_path, source_file) installApp.main(['app', 1, source_path]) the_mock.pushFile.assert_called_once_with(source_path, installed_path) the_mock.installApp.assert_called_once_with(installed_path)
def XXXtestOneSetOfCalls(self): root_path = sut_lib.checkDeviceRoot() source_file = 'testing' source_path = os.path.join('/path/to', source_file) installed_path = os.path.join(root_path, source_file) installApp.main(['app', 1, source_path]) the_mock.pushFile.assert_called_once_with(source_path, installed_path) the_mock.installApp.assert_called_once_with(installed_path)
def testSourceFileName(self): root_path = sut_lib.checkDeviceRoot() for source_file in ['test_1', 'test_2']: src_path = os.path.join('/path/to', source_file) installed_path = os.path.join(root_path, source_file) expected_args = ((installed_path, ), {}) installApp.main(['app', 1, src_path]) self.assertTrue( expected_args in the_mock.installApp.call_args_list)
def testSourceFileName(self): root_path = sut_lib.checkDeviceRoot() for source_file in ['test_1', 'test_2']: src_path = os.path.join('/path/to', source_file) installed_path = os.path.join(root_path, source_file) expected_args = ((installed_path,), {}) installApp.main(['app', 1, src_path]) self.assertTrue( expected_args in the_mock.installApp.call_args_list)
def test_robocop_not_found(self): root_path = sut_lib.checkDeviceRoot() source_file = 'fennec.eggs.arm.apk' source_path = os.path.join('build/', source_file) installed_path = os.path.join(root_path, source_file) expected_pushFile_calls = [((source_path, installed_path), {}), ] expected_installApp_calls = [((installed_path,), {}), ] # simulate not finding robocop.apk - should not attempt install # then os.path.exists.return_value = False installApp.main(['app', 1, source_path]) self.assertEqual(the_mock.installApp.call_args_list, expected_installApp_calls) self.assertEqual(the_mock.pushFile.call_args_list, expected_pushFile_calls)
def test_robocop_found(self): root_path = sut_lib.checkDeviceRoot() source_file = 'fennec.eggs.arm.apk' robocop_file = 'robocop.apk' source_path = os.path.join('build/', source_file) robocop_source_path = os.path.join('build/tests/bin', robocop_file) installed_path = os.path.join(root_path, source_file) robocop_installed_path = os.path.join(root_path, robocop_file) expected_pushFile_calls = [((source_path, installed_path), {}), ((robocop_source_path, robocop_installed_path), {})] expected_installApp_calls = [((installed_path,), {}), ((robocop_installed_path,), {})] installApp.main(['app', 1, source_path]) self.assertEqual(the_mock.installApp.call_args_list, expected_installApp_calls) self.assertEqual(the_mock.pushFile.call_args_list, expected_pushFile_calls)
def test_robocop_found(self): root_path = sut_lib.checkDeviceRoot() source_file = 'fennec.eggs.arm.apk' robocop_file = 'robocop.apk' source_path = os.path.join('build/', source_file) robocop_source_path = os.path.join('build/tests/bin', robocop_file) installed_path = os.path.join(root_path, source_file) robocop_installed_path = os.path.join(root_path, robocop_file) expected_pushFile_calls = [((source_path, installed_path), {}), ((robocop_source_path, robocop_installed_path), {})] expected_installApp_calls = [((installed_path, ), {}), ((robocop_installed_path, ), {})] installApp.main(['app', 1, source_path]) self.assertEqual(the_mock.installApp.call_args_list, expected_installApp_calls) self.assertEqual(the_mock.pushFile.call_args_list, expected_pushFile_calls)
def main(argv): if len(argv) < 2: print "usage: installWatcher.py <ip address>" sys.exit(1) ip_addr = argv[1] dm = droid.DroidSUT(ip_addr) if not dm: log.error("could not get device manager!") return 1 devRoot = checkDeviceRoot(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 test_robocop_not_found(self): root_path = sut_lib.checkDeviceRoot() source_file = 'fennec.eggs.arm.apk' source_path = os.path.join('build/', source_file) installed_path = os.path.join(root_path, source_file) expected_pushFile_calls = [ ((source_path, installed_path), {}), ] expected_installApp_calls = [ ((installed_path, ), {}), ] # simulate not finding robocop.apk - should not attempt install # then os.path.exists.return_value = False installApp.main(['app', 1, source_path]) self.assertEqual(the_mock.installApp.call_args_list, expected_installApp_calls) self.assertEqual(the_mock.pushFile.call_args_list, expected_pushFile_calls)
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
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
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)) return RETCODE_ERROR if dm.dirExists(devRoot): status = dm.removeDir(devRoot) log.info("removeDir() returned [%s]" % status) if status is None or not status: setFlag( errorFile, "Remote Device Error: call to removeDir() returned [%s]" %
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
'org.mozilla.fennec_aurora', 'org.mozilla.fennec_unofficial', 'org.mozilla.firefox', 'org.mozilla.firefox_beta', 'org.mozilla.roboexample.test', ] if os.path.exists(flagFile): print "Warning proxy.flg found during cleanup" clearFlag(flagFile) print "Connecting to: " + sys.argv[1] dm = devicemanager.DeviceManagerSUT(sys.argv[1]) dm.debug = 5 devRoot = checkDeviceRoot(dm) if not str(devRoot).startswith("/mnt/sdcard"): setFlag(errorFile, "Remote Device Error: devRoot from devicemanager [%s] is not correct" % str(devRoot)) sys.exit(1) if dm.dirExists(devRoot): 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) sys.exit(1) if not dm.fileExists('/system/etc/hosts'): print "restoring /system/etc/hosts file" try:
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