Scripts: Change wording for pseudoterminals

This commit is contained in:
Jeff Epler 2020-06-14 14:28:32 -05:00 committed by Jeff Epler
parent 9110e36636
commit 9737dd9c30
2 changed files with 13 additions and 9 deletions

View File

@ -87,28 +87,32 @@ def run_micropython(pyb, args, test_file, is_special=False):
def get(required=False):
rv = b''
while True:
ready = select.select([master], [], [], 0.02)
if ready[0] == [master]:
rv += os.read(master, 1024)
ready = select.select([emulator], [], [], 0.02)
if ready[0] == [emulator]:
rv += os.read(emulator, 1024)
else:
if not required or rv:
return rv
def send_get(what):
os.write(master, what)
os.write(emulator, what)
return get()
with open(test_file, 'rb') as f:
# instead of: output_mupy = subprocess.check_output(args, stdin=f)
master, slave = pty.openpty()
p = subprocess.Popen(args, stdin=slave, stdout=slave,
# openpty returns two read/write file descriptors. The first one is
# used by the program which provides the virtual
# terminal service, and the second one is used by the
# subprogram which requires a tty to work.
emulator, subterminal = pty.openpty()
p = subprocess.Popen(args, stdin=subterminal, stdout=subterminal,
stderr=subprocess.STDOUT, bufsize=0)
banner = get(True)
output_mupy = banner + b''.join(send_get(line) for line in f)
send_get(b'\x04') # exit the REPL, so coverage info is saved
p.kill()
os.close(master)
os.close(slave)
os.close(emulator)
os.close(subterminal)
else:
output_mupy = subprocess.check_output(args + [test_file], stderr=subprocess.STDOUT)
except subprocess.CalledProcessError:

View File

@ -191,7 +191,7 @@ class ProcessToSerial:
class ProcessPtyToTerminal:
"""Execute a process which creates a PTY and prints slave PTY as
"""Execute a process which creates a PTY and prints secondary PTY as
first line of its output, and emulate serial connection using
this PTY."""