From 9737dd9c308df0d7356ee5ff727e34a93a88e302 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 14 Jun 2020 14:28:32 -0500 Subject: [PATCH] Scripts: Change wording for pseudoterminals --- tests/run-tests | 20 ++++++++++++-------- tools/pyboard.py | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/run-tests b/tests/run-tests index 6e980f03ce..151d48095b 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -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: diff --git a/tools/pyboard.py b/tools/pyboard.py index 16ee41f703..bb5642bd78 100755 --- a/tools/pyboard.py +++ b/tools/pyboard.py @@ -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."""