From ff6491ded0ebaa7728ecba67c18641941885feb5 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 22 Jul 2025 14:52:17 +1000 Subject: [PATCH] tests/run-natmodtests.py: Automatically skip tests that are too large. This follows a similar change made for `run-tests.py` in commit 229104558fb7f9d283b7302bc3720bc35c5c49cf. The change here uses the same logic to detect if a natmod test is too big for the target (eg overflows (I)RAM loading the native .mpy), by printing "START TEST" at the start of the test. Typical output is now something like this: ... pass extmod/random_basic.py pass extmod/random_extra_float.py pass extmod/random_extra.py SKIP extmod/random_seed_default.py LRGE extmod/re1.py SKIP extmod/re_debug.py pass extmod/re_error.py pass extmod/re_group.py pass extmod/re_groups.py ... and the tests that are too large are reported at the end, and written to the `_result.json` file. Signed-off-by: Damien George --- tests/run-natmodtests.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/run-natmodtests.py b/tests/run-natmodtests.py index f9d2074f6f..55adb6049a 100755 --- a/tests/run-natmodtests.py +++ b/tests/run-natmodtests.py @@ -170,6 +170,7 @@ def run_tests(target_truth, target, args, resolved_arch): print("skip {} - mpy file not compiled".format(test_file)) continue test_script += bytes(injected_import_hook_code.format(test_module), "ascii") + test_script += b"print('START TEST')\n" test_script += test_file_data # Run test under MicroPython @@ -177,8 +178,18 @@ def run_tests(target_truth, target, args, resolved_arch): # Work out result of test extra = "" + result_out = result_out.removeprefix(b"START TEST\n") if error is None and result_out == b"SKIP\n": result = "SKIP" + elif ( + error is not None + and error.args[0] == "exception" + and error.args[1] == b"" + and b"MemoryError" in error.args[2] + ): + # Test had a MemoryError before anything (should be at least "START TEST") + # was printed, so the test is too big for the target. + result = "LRGE" elif error is not None: result = "FAIL" extra = " - " + str(error) @@ -203,6 +214,8 @@ def run_tests(target_truth, target, args, resolved_arch): test_results.append((test_file, "pass", "")) elif result == "SKIP": test_results.append((test_file, "skip", "")) + elif result == "LRGE": + test_results.append((test_file, "skip", "too large")) else: test_results.append((test_file, "fail", ""))