tests/run-tests: Improve robustness of REPL tests.
Unconditionally wait for MicroPython banner. On overloaded systems, when using emulators, etc. initial executable startup may take more than 20ms.
This commit is contained in:
parent
65888e2006
commit
ff8c4188f4
@ -51,13 +51,14 @@ def run_micropython(pyb, args, test_file):
|
|||||||
return b'SKIP\n'
|
return b'SKIP\n'
|
||||||
import select
|
import select
|
||||||
|
|
||||||
def get():
|
def get(required=False):
|
||||||
rv = b''
|
rv = b''
|
||||||
while True:
|
while True:
|
||||||
ready = select.select([master], [], [], 0.02)
|
ready = select.select([master], [], [], 0.02)
|
||||||
if ready[0] == [master]:
|
if ready[0] == [master]:
|
||||||
rv += os.read(master, 1024)
|
rv += os.read(master, 1024)
|
||||||
else:
|
else:
|
||||||
|
if not required or rv:
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
def send_get(what):
|
def send_get(what):
|
||||||
@ -69,7 +70,7 @@ def run_micropython(pyb, args, test_file):
|
|||||||
master, slave = pty.openpty()
|
master, slave = pty.openpty()
|
||||||
p = subprocess.Popen(args, stdin=slave, stdout=slave,
|
p = subprocess.Popen(args, stdin=slave, stdout=slave,
|
||||||
stderr=subprocess.STDOUT, bufsize=0)
|
stderr=subprocess.STDOUT, bufsize=0)
|
||||||
banner = get()
|
banner = get(True)
|
||||||
output_mupy = banner + b''.join(send_get(line) for line in f)
|
output_mupy = banner + b''.join(send_get(line) for line in f)
|
||||||
p.kill()
|
p.kill()
|
||||||
os.close(master)
|
os.close(master)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user