diff options
| author | Damien George <damien@micropython.org> | 2022-04-21 10:54:02 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-04-21 14:25:17 +1000 |
| commit | 8631753ff450850fabc7cb925b829030f0e51f44 (patch) | |
| tree | f32e25c37fd9b9de3a22fa2a2cc785c7128f2476 /tests/run-tests.py | |
| parent | 81c9219375a005e5fd1abee236733fa4c95b19da (diff) | |
tests/run-tests.py: Add timeout for running PC-based MicroPython test.
So the test suite runs to completion, even if the interpreter locks up.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/run-tests.py')
| -rwxr-xr-x | tests/run-tests.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/run-tests.py b/tests/run-tests.py index d0ecc74a9..3732e47ad 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -13,6 +13,9 @@ from multiprocessing.pool import ThreadPool import threading import tempfile +# Maximum time to run a PC-based test, in seconds. +TEST_TIMEOUT = 30 + # See stackoverflow.com/questions/2632199: __file__ nor sys.argv[0] # are guaranteed to always work, this one should though. BASEPATH = os.path.dirname(os.path.abspath(inspect.getsourcefile(lambda: None))) @@ -178,10 +181,15 @@ def run_micropython(pyb, args, test_file, is_special=False): # run the actual test try: - output_mupy = subprocess.check_output(cmdlist, stderr=subprocess.STDOUT) + output_mupy = subprocess.check_output( + cmdlist, stderr=subprocess.STDOUT, timeout=TEST_TIMEOUT + ) except subprocess.CalledProcessError as er: had_crash = True output_mupy = er.output + b"CRASH" + except subprocess.TimeoutExpired as er: + had_crash = True + output_mupy = (er.output or b"") + b"TIMEOUT" # clean up if we had an intermediate .mpy file if args.via_mpy: |
