summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-04-21 10:54:02 +1000
committerDamien George <damien@micropython.org>2022-04-21 14:25:17 +1000
commit8631753ff450850fabc7cb925b829030f0e51f44 (patch)
treef32e25c37fd9b9de3a22fa2a2cc785c7128f2476 /tests
parent81c9219375a005e5fd1abee236733fa4c95b19da (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')
-rwxr-xr-xtests/run-tests.py10
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: