From a91c4bf7e6b996d76087f3edb9d5d1860634a430 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Thu, 19 Dec 2019 15:00:42 +0100 Subject: [PATCH] dist/testrunner: add optional delay before opening serial This option is null by default but is useful when used with boards exposing their stdio over USB --- dist/pythonlibs/testrunner/spawn.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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)