@@ -87,28 +87,32 @@ def run_micropython(pyb, args, test_file, is_special=False):
87
87
def get (required = False ):
88
88
rv = b''
89
89
while True :
90
- ready = select .select ([master ], [], [], 0.02 )
91
- if ready [0 ] == [master ]:
92
- rv += os .read (master , 1024 )
90
+ ready = select .select ([emulator ], [], [], 0.02 )
91
+ if ready [0 ] == [emulator ]:
92
+ rv += os .read (emulator , 1024 )
93
93
else :
94
94
if not required or rv :
95
95
return rv
96
96
97
97
def send_get (what ):
98
- os .write (master , what )
98
+ os .write (emulator , what )
99
99
return get ()
100
100
101
101
with open (test_file , 'rb' ) as f :
102
102
# instead of: output_mupy = subprocess.check_output(args, stdin=f)
103
- master , slave = pty .openpty ()
104
- p = subprocess .Popen (args , stdin = slave , stdout = slave ,
103
+ # openpty returns two read/write file descriptors. The first one is
104
+ # used by the program which provides the virtual
105
+ # terminal service, and the second one is used by the
106
+ # subprogram which requires a tty to work.
107
+ emulator , subterminal = pty .openpty ()
108
+ p = subprocess .Popen (args , stdin = subterminal , stdout = subterminal ,
105
109
stderr = subprocess .STDOUT , bufsize = 0 )
106
110
banner = get (True )
107
111
output_mupy = banner + b'' .join (send_get (line ) for line in f )
108
112
send_get (b'\x04 ' ) # exit the REPL, so coverage info is saved
109
113
p .kill ()
110
- os .close (master )
111
- os .close (slave )
114
+ os .close (emulator )
115
+ os .close (subterminal )
112
116
else :
113
117
output_mupy = subprocess .check_output (args + [test_file ], stderr = subprocess .STDOUT )
114
118
except subprocess .CalledProcessError :
0 commit comments