Signed-off-by: Janusz Dziedzic <janusz.dziedzic@xxxxxxxxx> --- tests/hwsim/remotehost.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/hwsim/remotehost.py b/tests/hwsim/remotehost.py index 9d7c657a1..d0efa210b 100644 --- a/tests/hwsim/remotehost.py +++ b/tests/hwsim/remotehost.py @@ -161,8 +161,8 @@ class Host(): if t.is_alive(): t.join(wait) - def pending(self, s, timeout=0): - [r, w, e] = select.select([s], [], [], timeout) + def proc_pending(self, proc, timeout=0): + [r, w, e] = select.select([proc.stdout], [], [], timeout) if r: return True return False @@ -194,7 +194,7 @@ class Host(): start = os.times()[4] try: while True: - while self.pending(proc.stdout): + while self.proc_pending(proc): line = proc.stdout.readline() if not line: return None @@ -207,13 +207,26 @@ class Host(): remaining = start + timeout - now if remaining <= 0: break - if not self.pending(proc.stdout, timeout=remaining): + if not self.proc_pending(proc, timeout=remaining): break except: logger.debug(traceback.format_exc()) pass return None + def proc_write(self, proc, cmd): + return proc.stdout.write(cmd) + + def proc_read(self, proc, timeout=0): + if not self.proc_pending(proc): + return None + res = proc.stdout.read(4094).decode() + try: + r = str(res) + except UnicodeDecodeError as e: + r = res + return r + def proc_stop(self, proc): if not proc: return -- 2.25.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap