Skip to content

tests/run-natmodtests.py: Automatically skip tests that are too large. #17738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dpgeorge
Copy link
Member

Summary

This follows a similar change made for run-tests.py in PR #17361 / commit 2291045. 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, and checking if a MemoryError is raised before that is printed (if so, the test is too large).

Typical output from run-natmodtests.py 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 (using the existing, common create_test_report() function).

Testing

Tested using the command:

./run-natmodtests.py extmod/btree*.py extmod/deflate*.py extmod/framebuf*.py extmod/heapq1.py extmod/random*.py extmod/re*.py

with optional -p to run on bare-metal.

Tested on unix-standard

All existing tests still run and pass:

...
35 tests performed
35 tests passed
4 tests skipped: extmod/random_seed_default.py extmod/re_debug.py extmod/re_sub.py extmod/re_sub_unmatched.py

Tested on ADAFRUIT_ITSYBITSY_M0_EXPRESS

Prior to this PR:

platform=samd arch=armv6m
FAIL  extmod/btree1.py - ('exception', b'', b'MemoryError: memory allocation failed, allocating 14079 bytes\r\n')
FAIL  extmod/btree_closed.py - ('exception', b'', b'MemoryError: memory allocation failed, allocating 14079 bytes\r\n')
FAIL  extmod/btree_error.py - ('exception', b'', b'MemoryError: memory allocation failed, allocating 14079 bytes\r\n')
FAIL  extmod/btree_gc.py - ('exception', b'', b'MemoryError: memory allocation failed, allocating 14079 bytes\r\n')
pass  extmod/deflate_compress_memory_error.py
FAIL  extmod/deflate_compress.py - ('exception', b'', b'MemoryError: \r\n')
FAIL  extmod/deflate_decompress.py - ('exception', b'', b'MemoryError: memory allocation failed, allocating 768 bytes\r\n')
pass  extmod/deflate_stream_error.py
FAIL  extmod/framebuf16.py - ('exception', b'', b'Traceback (most recent call last):\r\n  File "<stdin>", line 34, in <module>\r\nMemoryError: memory allocation failed, allocating 6516 bytes\r\n')
FAIL  extmod/framebuf1.py - ('exception', b'', b'MemoryError: memory allocation failed, allocating 136 bytes\r\n')
FAIL  extmod/framebuf2.py - ('exception', b'', b'MemoryError: memory allocation failed, allocating 136 bytes\r\n')
FAIL  extmod/framebuf4.py - ('exception', b'', b'MemoryError: memory allocation failed, allocating 256 bytes\r\n')
FAIL  extmod/framebuf8.py - ('exception', b'', b'Traceback (most recent call last):\r\n  File "<stdin>", line 34, in <module>\r\nMemoryError: memory allocation failed, allocating 6516 bytes\r\n')
FAIL  extmod/framebuf_blit.py - ('exception', b'', b'Traceback (most recent call last):\r\n  File "<stdin>", line 34, in <module>\r\nMemoryError: memory allocation failed, allocating 6516 bytes\r\n')
FAIL  extmod/framebuf_bounds.py - ('exception', b'', b'MemoryError: memory allocation failed, allocating 136 bytes\r\n')
FAIL  extmod/framebuf_ellipse.py - ('exception', b'', b'Traceback (most recent call last):\r\n  File "<stdin>", line 34, in <module>\r\nMemoryError: memory allocation failed, allocating 6516 bytes\r\n')
FAIL  extmod/framebuf_palette.py - ('exception', b'', b'Traceback (most recent call last):\r\n  File "<stdin>", line 34, in <module>\r\nMemoryError: memory allocation failed, allocating 6516 bytes\r\n')
FAIL  extmod/framebuf_polygon.py - ('exception', b'', b'MemoryError: memory allocation failed, allocating 136 bytes\r\n')
FAIL  extmod/framebuf_scroll.py - ('exception', b'', b'Traceback (most recent call last):\r\n  File "<stdin>", line 34, in <module>\r\nMemoryError: memory allocation failed, allocating 6516 bytes\r\n')
FAIL  extmod/framebuf_subclass.py - ('exception', b'', b'Traceback (most recent call last):\r\n  File "<stdin>", line 34, in <module>\r\nMemoryError: memory allocation failed, allocating 6516 bytes\r\n')
pass  extmod/heapq1.py
pass  extmod/random_basic.py
pass  extmod/random_extra_float.py
pass  extmod/random_extra.py
SKIP  extmod/random_seed_default.py
FAIL  extmod/re1.py - ('exception', b'', b'MemoryError: \r\n')
SKIP  extmod/re_debug.py
pass  extmod/re_error.py
pass  extmod/re_group.py
pass  extmod/re_groups.py
pass  extmod/re_limit.py
pass  extmod/re_namedclass.py
pass  extmod/re_span.py
pass  extmod/re_split_empty.py
pass  extmod/re_split_notimpl.py
pass  extmod/re_split.py
pass  extmod/re_stack_overflow.py
SKIP  extmod/re_sub.py
SKIP  extmod/re_sub_unmatched.py
35 tests performed
16 tests passed
4 tests skipped
19 tests failed: extmod/btree1.py extmod/btree_closed.py extmod/btree_error.py extmod/btree_gc.py extmod/deflate_compress.py extmod/deflate_decompress.py extmod/framebuf16.py extmod/framebuf1.py extmod/framebuf2.py extmod/framebuf4.py extmod/framebuf8.py extmod/framebuf_blit.py extmod/framebuf_bounds.py extmod/framebuf_ellipse.py extmod/framebuf_palette.py extmod/framebuf_polygon.py extmod/framebuf_scroll.py extmod/framebuf_subclass.py extmod/re1.py

With this PR:

platform=samd arch=armv6m
LRGE  extmod/btree1.py
LRGE  extmod/btree_closed.py
LRGE  extmod/btree_error.py
LRGE  extmod/btree_gc.py
pass  extmod/deflate_compress_memory_error.py
LRGE  extmod/deflate_compress.py
LRGE  extmod/deflate_decompress.py
pass  extmod/deflate_stream_error.py
LRGE  extmod/framebuf16.py
LRGE  extmod/framebuf1.py
LRGE  extmod/framebuf2.py
LRGE  extmod/framebuf4.py
LRGE  extmod/framebuf8.py
LRGE  extmod/framebuf_blit.py
LRGE  extmod/framebuf_bounds.py
LRGE  extmod/framebuf_ellipse.py
LRGE  extmod/framebuf_palette.py
LRGE  extmod/framebuf_polygon.py
LRGE  extmod/framebuf_scroll.py
LRGE  extmod/framebuf_subclass.py
pass  extmod/heapq1.py
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
pass  extmod/re_limit.py
pass  extmod/re_namedclass.py
pass  extmod/re_span.py
pass  extmod/re_split_empty.py
pass  extmod/re_split_notimpl.py
pass  extmod/re_split.py
pass  extmod/re_stack_overflow.py
SKIP  extmod/re_sub.py
SKIP  extmod/re_sub_unmatched.py
16 tests performed
16 tests passed
4 tests skipped
19 tests skipped because they are too large

Tested on ESP8266

With this PR the output is:

platform=esp8266 arch=xtensa
LRGE  extmod/btree1.py
LRGE  extmod/btree_closed.py
LRGE  extmod/btree_error.py
LRGE  extmod/btree_gc.py
LRGE  extmod/deflate_compress_memory_error.py
LRGE  extmod/deflate_compress.py
LRGE  extmod/deflate_decompress.py
LRGE  extmod/deflate_stream_error.py
LRGE  extmod/framebuf16.py
LRGE  extmod/framebuf1.py
LRGE  extmod/framebuf2.py
LRGE  extmod/framebuf4.py
LRGE  extmod/framebuf8.py
LRGE  extmod/framebuf_blit.py
LRGE  extmod/framebuf_bounds.py
LRGE  extmod/framebuf_ellipse.py
LRGE  extmod/framebuf_palette.py
LRGE  extmod/framebuf_polygon.py
LRGE  extmod/framebuf_scroll.py
LRGE  extmod/framebuf_subclass.py
pass  extmod/heapq1.py
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
LRGE  extmod/re_debug.py
LRGE  extmod/re_error.py
LRGE  extmod/re_group.py
LRGE  extmod/re_groups.py
LRGE  extmod/re_limit.py
LRGE  extmod/re_namedclass.py
LRGE  extmod/re_span.py
LRGE  extmod/re_split_empty.py
LRGE  extmod/re_split_notimpl.py
LRGE  extmod/re_split.py
LRGE  extmod/re_stack_overflow.py
LRGE  extmod/re_sub.py
LRGE  extmod/re_sub_unmatched.py
4 tests performed
4 tests passed
1 tests skipped: extmod/random_seed_default.py
34 tests skipped because they are too large: extmod/btree1.py extmod/btree_closed.py extmod/btree_error.py extmod/btree_gc.py extmod/deflate_compress_memory_error.py extmod/deflate_compress.py extmod/deflate_decompress.py extmod/deflate_stream_error.py extmod/framebuf16.py extmod/framebuf1.py extmod/framebuf2.py extmod/framebuf4.py extmod/framebuf8.py extmod/framebuf_blit.py extmod/framebuf_bounds.py extmod/framebuf_ellipse.py extmod/framebuf_palette.py extmod/framebuf_polygon.py extmod/framebuf_scroll.py extmod/framebuf_subclass.py extmod/re1.py extmod/re_debug.py extmod/re_error.py extmod/re_group.py extmod/re_groups.py extmod/re_limit.py extmod/re_namedclass.py extmod/re_span.py extmod/re_split_empty.py extmod/re_split_notimpl.py extmod/re_split.py extmod/re_stack_overflow.py extmod/re_sub.py extmod/re_sub_unmatched.py

This follows a similar change made for `run-tests.py` in commit
2291045.  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 <damien@micropython.org>
@dpgeorge dpgeorge added the tests Relates to tests/ directory in source label Jul 22, 2025
Copy link

codecov bot commented Jul 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.41%. Comparing base (e993f53) to head (ecf5b02).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17738   +/-   ##
=======================================
  Coverage   98.41%   98.41%           
=======================================
  Files         171      171           
  Lines       22210    22210           
=======================================
  Hits        21857    21857           
  Misses        353      353           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dpgeorge
Copy link
Member Author

This PR was triggered by Octoprobe failing a lot of natmod tests. Running this PR on Octoprobe, the results look very good: https://reports.octoprobe.org/github_selfhosted_testrun_190/octoprobe_summary_report.html

@hmaerki FYI

@dpgeorge dpgeorge requested a review from projectgus July 23, 2025 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Relates to tests/ directory in source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy