Files
micropython/tests/test_utils.py
Damien George 6436f8b93f tests/run-tests.py: Abort test run if enter_raw_repl fails many times.
Prior to this change, if a test crashed a board to the point that it was no
longer responsive but the serial connection was still alive and able to
read/write (eg due to an infinite loop with ctrl-C unavailable), it would
take (30 + 10 * number-of-remaining-tests) seconds to finish the test run.
That can be 10 minutes or more.

The change here aborts the test run if the target does not respond 4 times
to when trying to enter the raw REPL at the start of a test.  Now, it only
takes a maximum of (30 + 4 * 5) = 50 seconds to detect a crashed state and
abort the entire test run.

Can test this by adding the following to a test:

    import time, micropython
    micropython.kbd_intr(-1)
    while 1:
        time.sleep(1)

For example, add the above to the end of `tests/extmod/random_extra.py` and
test via:

    $ ./run-tests.py -t a0 extmod/[r-z]*.py
    $ ./run-natmodtests.py -t a0 extmod/[r-z]*.py

Previously the `run-tests.py` run would take around 16 minutes.  Now it
takes under a minute.

Signed-off-by: Damien George <damien@micropython.org>
2026-02-04 20:17:11 +11:00

12 KiB