def adb_keepalive(target, extra_paths): """A context manager that keeps the adb connection alive. AdbKeepalive will spin off a new process that will continuously poll for adb's connected state, and will attempt to reconnect if it ever goes down. This is the only way we can currently recover safely from (intentional) reboots. @param target: the hostname and port of the DUT. @param extra_paths: any additional components to the PATH environment variable. """ from autotest_lib.client.common_lib.cros import adb_keepalive as module # |__file__| returns the absolute path of the compiled bytecode of the # module. We want to run the original .py file, so we need to change the # extension back. script_filename = module.__file__.replace('.pyc', '.py') job = common_utils.BgJob([script_filename, target], nickname='adb_keepalive', stderr_level=logging.DEBUG, stdout_tee=common_utils.TEE_TO_LOGS, stderr_tee=common_utils.TEE_TO_LOGS, extra_paths=extra_paths) try: yield finally: # The adb_keepalive.py script runs forever until SIGTERM is sent. common_utils.nuke_subprocess(job.sp) common_utils.join_bg_jobs([job])
def __stop_loggers(self): if self._console_proc: utils.nuke_subprocess(self._console_proc) utils.nuke_subprocess(self._followfiles_proc) self._console_proc = self._followfile_proc = None if self.job: self.job.warning_loggers.discard(self._logfile_warning_stream) self._logfile_warning_stream.close()
def __stop_loggers(self): if self._console_proc: utils.nuke_subprocess(self._console_proc) utils.nuke_subprocess(self._followfiles_proc) self._console_proc = self._followfile_proc = None if self.job: self.job.warning_loggers.discard(self._logfile_warning_stream) self._logfile_warning_stream.close()
def stop_loggers(self): super(NetconsoleHost, self).stop_loggers() if self.__logger: utils.nuke_subprocess(self.__logger) self.__logger = None if self.job: self.job.warning_loggers.discard(self.__warning_stream) self.__warning_stream.close()
def stop_loggers(self): super(NetconsoleHost, self).stop_loggers() if self.__logger: utils.nuke_subprocess(self.__logger) self.__logger = None if self.job: self.job.warning_loggers.discard(self.__warning_stream) self.__warning_stream.close()
def execute(self): os.chdir(self.tmpdir) tasks_bin = os.path.join(self.srcdir, "tasks") p = subprocess.Popen([tasks_bin, " 25000"]) time.sleep(5) try: result = utils.run("cat /dev/cpuset/autotest_container/tasks", ignore_status=True) except IOError: utils.nuke_subprocess(p) raise error.TestFail("cat cpuset/tasks failed with IOError") utils.nuke_subprocess(p) if result and result.exit_status: raise error.TestFail("cat cpuset/tasks failed")
def close_u2ftest(self): """Terminate the process and check the results.""" exit_status = utils.nuke_subprocess(self.u2ftest_job.sp) stdout = self.stdout.getvalue().strip() if stdout: logging.debug('stdout of U2FTest:\n%s', stdout) if exit_status: logging.error('stderr of U2FTest:\n%s', self.output) raise error.TestError('U2FTest: %s' % self.output)
def execute(self): os.chdir(self.tmpdir) (p1, _) = utils.run_bg('dd if=/dev/hda3 of=/dev/null') time.sleep(60) blah = os.path.join(self.tmpdir, 'blah') dirty_bin = os.path.join(self.srcdir, 'dirty') dirty_op = os.path.join(self.tmpdir, 'dirty') utils.system('echo AA > ' + blah) p2 = subprocess.Popen(dirty_bin + ' ' + blah + ' 1 > ' + dirty_op, shell=True) time.sleep(600) if p2.poll() is None: utils.nuke_subprocess(p1) utils.nuke_subprocess(p2) raise error.TestFail('Writes made no progress') # Commenting out use of utils.run as there is a timeout bug # # try: # utils.run(dirty_bin + ' ' + blah + '1 > ' + dirty_op, 900, False, # None, None) # except: # utils.nuke_subprocess(p1) # raise error.TestFail('Writes made no progress') utils.nuke_subprocess(p1)
def execute(self): os.chdir(self.tmpdir) (p1, _) = utils.run_bg('dd if=/dev/hda3 of=/dev/null') time.sleep(60) blah = os.path.join(self.tmpdir, 'blah') dirty_bin = os.path.join(self.srcdir, 'dirty') dirty_op = os.path.join(self.tmpdir, 'dirty') utils.system('echo AA > ' + blah) p2 = subprocess.Popen(dirty_bin + ' ' + blah + ' 1 > ' + dirty_op, shell=True) time.sleep(600) if p2.poll() is None: utils.nuke_subprocess(p1) utils.nuke_subprocess(p2) raise error.TestFail('Writes made no progress') # Commenting out use of utils.run as there is a timeout bug # # try: # utils.run(dirty_bin + ' ' + blah + '1 > ' + dirty_op, 900, False, # None, None) # except: # utils.nuke_subprocess(p1) # raise error.TestFail('Writes made no progress') utils.nuke_subprocess(p1)
def kill_func(): #this triggers the remote kill os.write(job.sp.stdin.fileno(), "lulz\n") utils.nuke_subprocess(job.sp)
def kill_func(): #this triggers the remote kill os.write(job.sp.stdin.fileno(), "lulz\n") utils.nuke_subprocess(job.sp)