|
8 | 8 | import subprocess |
9 | 9 | import sys |
10 | 10 | import argparse |
| 11 | +import re |
11 | 12 | from glob import glob |
12 | 13 |
|
13 | 14 | from test_utils import ( |
@@ -120,6 +121,19 @@ def run_benchmarks(args, target, param_n, param_m, n_average, test_list): |
120 | 121 | test_script += f.read() |
121 | 122 | test_script += b"bm_run(%u, %u)\n" % (param_n, param_m) |
122 | 123 |
|
| 124 | + # Search for the bm_params dict, to extract the minimum memory required. |
| 125 | + m = re.search(rb"bm_params = {\s+\((\d+), (\d+)\):", test_script) |
| 126 | + if not m: |
| 127 | + print(f"Test file '{test_file}' doesn't contain valid 'bm_params'") |
| 128 | + sys.exit(2) |
| 129 | + min_m = int(m.group(2)) |
| 130 | + |
| 131 | + # Skip the test if the target doesn't have enough memory. |
| 132 | + if param_m < min_m: |
| 133 | + test_results.append((test_file, "skip", "too large")) |
| 134 | + print("SKIP: too large") |
| 135 | + continue |
| 136 | + |
123 | 137 | # Write full test script if needed |
124 | 138 | if 0: |
125 | 139 | with open("%s.full" % test_file, "wb") as f: |
@@ -314,14 +328,10 @@ def main(): |
314 | 328 | args.mpy_cross_flags = "-march=armv7m" |
315 | 329 |
|
316 | 330 | if len(args.files) == 0: |
317 | | - tests_skip = ("benchrun.py",) |
318 | | - if M <= 25: |
319 | | - # These scripts are too big to be compiled by the target |
320 | | - tests_skip += ("bm_chaos.py", "bm_hexiom.py", "misc_raytrace.py") |
321 | 331 | tests = sorted( |
322 | 332 | BENCH_SCRIPT_DIR + test_file |
323 | 333 | for test_file in os.listdir(BENCH_SCRIPT_DIR) |
324 | | - if test_file.endswith(".py") and test_file not in tests_skip |
| 334 | + if test_file.endswith(".py") and test_file != "benchrun.py" |
325 | 335 | ) |
326 | 336 | else: |
327 | 337 | tests = sorted(args.files) |
|
0 commit comments