summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-07-05 17:07:30 +1000
committerDamien George <damien@micropython.org>2024-07-05 17:07:30 +1000
commit358e501e75c028133cff1045d2062ae31206a22c (patch)
tree4eb8aa1f9c20ae3bfefce6f44420043e1baa8f6e
parent633586a7162ea508b472ab5e82a512b38eff370f (diff)
tests/stress/bytecode_limit.py: Make test more robust with low memory.
A target may have enough RAM to run the n=433 test but then run out of RAM on the n=432 test. So allow the test to skip on the n=432 case before it prints any output. Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--tests/stress/bytecode_limit.py6
-rw-r--r--tests/stress/bytecode_limit.py.exp3
2 files changed, 6 insertions, 3 deletions
diff --git a/tests/stress/bytecode_limit.py b/tests/stress/bytecode_limit.py
index ad090637f..948d7668d 100644
--- a/tests/stress/bytecode_limit.py
+++ b/tests/stress/bytecode_limit.py
@@ -3,14 +3,18 @@
body = " with f()()() as a:\n try:\n f()()()\n except Exception:\n pass\n"
# Test overflow of jump offset.
+# Print results at the end in case an intermediate value of n fails with MemoryError.
+results = []
for n in (433, 432, 431, 430):
try:
exec("cond = 0\nif cond:\n" + body * n + "else:\n print('cond false')\n")
+ results.append((n, "ok"))
except MemoryError:
print("SKIP")
raise SystemExit
except RuntimeError:
- print("RuntimeError")
+ results.append((n, "RuntimeError"))
+print(results)
# Test changing size of code info (source line/bytecode mapping) due to changing
# bytecode size in the final passes. This test is very specific to how the
diff --git a/tests/stress/bytecode_limit.py.exp b/tests/stress/bytecode_limit.py.exp
index 1d892250b..cda52b1b9 100644
--- a/tests/stress/bytecode_limit.py.exp
+++ b/tests/stress/bytecode_limit.py.exp
@@ -1,5 +1,4 @@
-RuntimeError
-RuntimeError
cond false
cond false
+[(433, 'RuntimeError'), (432, 'RuntimeError'), (431, 'ok'), (430, 'ok')]
[123]