-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
tests: automatically skip tests that are too large for the target (not enough memory) #17361
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
tests: automatically skip tests that are too large for the target (not enough memory) #17361
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #17361 +/- ##
=======================================
Coverage 98.54% 98.54%
=======================================
Files 169 169
Lines 21943 21943
=======================================
Hits 21623 21623
Misses 320 320 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
tests/run-tests.py
Outdated
@@ -1072,6 +1098,7 @@ def to_json(obj): | |||
"args": vars(args), | |||
"passed_tests": [test[1] for test in passed_tests], | |||
"skipped_tests": [test[1] for test in skipped_tests], | |||
"skipped_tests_too_large": [test[1] for test in skipped_tests_too_large], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After discussion with @hmaerki , would be better to reorganise this data structure to be a list of 3-tuples, containing test name, result and reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #17373
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now reorganised. Much better!
e30f0fe
to
a4aaab7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a great improvement!
Some tests are just too big for targets that don't have much heap memory, eg `tests/extmod/vfs_rom.py`. Other tests are too large because the target doesn't have enough IRAM for native code, eg esp8266 running `tests/micropython/viper_args.py`. Previously, such tests were explicitly skipped on targets known to have little memory, eg esp8266. But this doesn't scale to multiple targets, nor to more and more tests which are too large. This commit addresses that by adding logic to the test runner so it can automatically skip tests when they don't fit in the target's memory. It does this by prepending a `print('START TEST')` to every test, and if a `MemoryError` occurs before that line is printed then the test was too big. This works for standard tests, tests that go via .mpy files, and tests that run in native emitter mode via .mpy files. For tests that are too big, it prints `lrge <test name>` on the output, and at the end prints them on a separate line of skipped tests so they can be distinguished. They are also distinguished in the `_result.json` file as a skipped test with reason "too large". Signed-off-by: Damien George <damien@micropython.org>
It's no longer used. Signed-off-by: Damien George <damien@micropython.org>
a4aaab7
to
5b340b1
Compare
Summary
Some tests are just too big for targets that don't have much heap memory. Eg
tests/extmod/vfs_rom.py
. Other tests are too large because the target doesn't have enough IRAM for native code, egtests/micropython/ viper_args.py
.Previously, such tests were explicitly skipped on targets known to have little memory, eg esp8266. But this doesn't scale to multiple targets, nor to more and more tests which are too large.
This PR addresses that by adding logic to the test runner so it can automatically skip tests when they don't fit in the target's memory. It does this by prepending a
print('START TEST')
to every test, and if aMemoryError
occurs before that line is printed then the test was too big. This works for standard tests, tests that go via .mpy files, and tests that run in native emitter mode via .mpy files.For tests that are too big, it prints
lrge <test name>
on the output, and adds them to a separate list of skipped tests so they can be distinguished. They are also written to the_result.json
file in a separate entry.Testing
Tested on esp8266:
Also ran
--via-mpy
tests on esp8266: it skipped the two testsviper_args
andviper_binop_arith
because they were too large but was able to runvfs_rom
because that can fit when compiled as .mpy (although it still skipped due to the target not supportingVfsRom
but at least it shows that the auto-skipping due to OOM is working well).Also ran
--via-mpy --emit native
on esp8266: prior to this PR running that would have 343 tests fail, but now with this PR it's348 tests skipped because they are too large
and10 tests failed
which is a very big improvement.Also ran tests on RPI_PICO2_W. They run as usual and nothing is skipped.
Trade-offs and Alternatives
print
statement. As a consequence a test that may have fit previously might not fit now. But such tests were already on the edge of having enough RAM to run anyway.print
can be inserted before the comment and not change the line numbering.