Skip to content

Commit

Permalink
tests/stress/bytecode_limit.py: Make test more robust with low memory.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dpgeorge committed Jul 5, 2024
1 parent 633586a commit 358e501
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 5 additions & 1 deletion tests/stress/bytecode_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions tests/stress/bytecode_limit.py.exp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
RuntimeError
RuntimeError
cond false
cond false
[(433, 'RuntimeError'), (432, 'RuntimeError'), (431, 'ok'), (430, 'ok')]
[123]

0 comments on commit 358e501

Please sign in to comment.