diff --git a/dist/pythonlibs/testrunner/spawn.py b/dist/pythonlibs/testrunner/spawn.py index 606114175..032618a24 100644 --- a/dist/pythonlibs/testrunner/spawn.py +++ b/dist/pythonlibs/testrunner/spawn.py @@ -28,6 +28,10 @@ MAKE_TERM_STARTED_DELAY = int(os.environ.get('TESTRUNNER_START_DELAY') or 3) # default value (0, no delay) MAKE_RESET_DELAY = int(os.environ.get('TESTRUNNER_RESET_DELAY') or 0) +# Setting an empty 'TESTRUNNER_CONNECT_DELAY' environment variable use the +# default value (0) +MAKE_TERM_CONNECT_DELAY = int(os.environ.get('TESTRUNNER_CONNECT_DELAY') or 0) + # Allow customizing test interactive settings with environment variables TEST_INTERACTIVE_RETRIES = int(os.environ.get('TEST_INTERACTIVE_RETRIES') or 5) TEST_INTERACTIVE_DELAY = int(os.environ.get('TEST_INTERACTIVE_DELAY') or 1) @@ -66,6 +70,10 @@ def setup_child(timeout=10, spawnclass=pexpect.spawnu, env=None, logfile=None): # before `cleanterm`. _reset_board(env) + # on platforms exposing UART over USB, wait a little before connecting to + # the serial terminal. This gives time for stdio to be ready. + time.sleep(MAKE_TERM_CONNECT_DELAY) + child = spawnclass("make cleanterm", env=env, timeout=timeout, codec_errors='replace', echo=False)