summaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
13 daystests/ports/qemu: Add arch flags MPY import checks test.Alessandro Gatti
This commit introduces a test file (along with its necessary data) to test MPY files pass/reject cases, due to either mismatching architecture flag requirements or unneeded "no-flags" values set. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
13 daystests/run-tests.py: Pass auto-detected architecture flags to mpy-cross.Alessandro Gatti
This commit lets "run-tests.py" use the encoded architecture flags provided by the interpreter when invoking "mpy-cross". If architecture flags are detected, they're mapped into the necessary strings needed by "mpy-cross"'s "-march-flags" argument, so that tests will always use all available extensions reported by the target. Currently this is limited to the RV32 platform, as it is the only one that is making use of this facility as of now. This also lets the QEMU port remove forced arguments to "mpy-cross" when running the test suite. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
13 daystests/micropython: Extend MPY import tests for RV32.Alessandro Gatti
This commit extends the "micropython/import_mpy_native_gc" test with a pre-built serialised MPY file built for RV32. Before this commit, the test was skipped on said platform due to the lack of a known-good MPY file to test the import procedure against. Now the test is executed as part of the general CI test checks. The MPY file's Makefile script was also updated to cater for modern Linux environments where the required Python interpreter's command name isn't "python", but "python3" instead (this occurs when using the past two LTS Ubuntu releases for example). This is the same kind of change made in 31a008c6e26eccc3798a9ab4169019a02eadb830. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
13 dayspy/modsys: Add architecture flags to MicroPython metadata.Alessandro Gatti
This commit adds the currently supported architecture flags value as the upper part of "sys.implementation._mpy". This had the side effect of perturbing quite a bit of testing infrastructure and invalidating documentation related to MPY files. To make the test suite run successfully and keep the documentation in sync the following changes have been made: * The target info feature check file now isolates eventual architecture flags and adds them as a separate field * The test runner now picks up the new architecture flags field, reports it to STDOUT if needed and stores it for future uses * Relevant test files for MPY files import code had to be updated to mask out the architecture flags bits in order to perform correctly * MPY file format documentation was updated to show how to mask off and properly display the architecture flags information. This works out of the box if the flag bits can fit in a smallint value once merged with the MPY file header value. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-10-20tests/run-tests.py: Allow port:<dev> specification in run-multitests.py.Damien George
This moves the `port:<dev>` check for the test instance to the `convert_device_shortcut_to_real_device()` helper function, which means that `run-multitests.py` can use this specification. Signed-off-by: Damien George <damien@micropython.org>
2025-10-20tests/extmod/time_res.py: Properly skip functions not in time module.Damien George
If `time.time` doesn't exist, it tries to use `globals()['time']` which is the time module itself, and that causes the test to fail. Instead it should just skip `time.time`. Signed-off-by: Damien George <damien@micropython.org>
2025-10-20tests/net_hosted/ssl_verify_callback.py: Skip if no verify_callback.Damien George
axTLS does not implement the `verify_callback` attribute. Signed-off-by: Damien George <damien@micropython.org>
2025-10-20tests/net_inet/tls_text_errors.py: Add exp file to run on axTLS.Damien George
axTLS will print a warning, and the added .exp file will skip that line. Signed-off-by: Damien George <damien@micropython.org>
2025-10-20tests/net_inet/tls_num_errors.py: Switch to tls mod and require mbedTLS.Damien George
This test is very specific to mbedTLS and how it raises errors when the heap is locked. Signed-off-by: Damien George <damien@micropython.org>
2025-10-20tests/net_inet: Skip tests on axTLS when necessary.Damien George
These tests cannot run with axTLS, eg on esp8266. Signed-off-by: Damien George <damien@micropython.org>
2025-10-20tests/net_inet/resolve_on_connect.py: Convert to use unittest.Damien George
This makes it clear what this test is expected to return/do. Signed-off-by: Damien George <damien@micropython.org>
2025-10-20tests: Move ports/esp32/resolve_on_connect.py to net_inet.Damien George
The main reason for moving this test is that it needs internet connection to pass. So putting it in `net_inet` makes sure it's alongside other tests that need the internet. Also, it's a general test that could eventually run on other ports, if/when they support doing an address resolution as part of `socket.connect()`. Signed-off-by: Damien George <damien@micropython.org>
2025-10-20tests/run-tests.py: Raise OSError on invalid file open for injected FS.Damien George
This makes sure that `open()` raises `OSError(ENOENT)` if the test script attempts to open a file that does not exist. For example, the test `tests/ports/esp32/check_err_str.py` attempts to do this and this test currently fails when run with `--via-mpy` because the injected filesystem lets a file by any name be opened. The fix here tries to be as minimal as possible, so includes a size optimisation for `stat()` to use a fixed 10-tuple. It also fixes the `OSError` argument, which should be positive. Signed-off-by: Damien George <damien@micropython.org>
2025-10-06tests/cpydiff: Document unsupported float format with grouping char.Jeff Epler
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-10-06py/mpprint: Correctly format leading zeros with separators.Jeff Epler
Correctly format integers when there are leading zeros with a grouping character, such as "{:04,d}".format(0x100) -> "0,256". The new padding patterns for commas-and-zeroes and underscores-and-zeroes are smooshed together into the existing pad_zeroes to save space. Only the two combinations of (decimal + commas) and (other bases + underscores) are properly supported. Also add a test for it. Fixes issue #18082. Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-10-06webassembly/objjsproxy: Support arbitrary number of args with kwargs.Damien George
When calling from Python into JavaScript and passing along keyword arguments, the FFI bindings currently only support at most 1 positional argument. For example: import js js.func(1, b=2, c=3) This commit fixes that by supporting arbitrary number of positional arguments, in combination with keyword arguments. So now the following works: import js js.func(1, 2, c=3, d=4) Tests are added for these new, supported cases. Signed-off-by: Damien George <damien@micropython.org>
2025-10-05tests/extmod: Test websocket too-big packet transmission.Jeff Epler
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-10-05extmod/modwebsocket: Enable split frames and test them.Jeff Epler
This fixes several assertion errors that were found in fuzz testing, for unimplemented portions of the websocket spec. The assertions were either turned into Python exceptions, or the missing functionality was implemented. Split frames are now enabled and work, enabling reception of frames up to 64kB (assuming they are encoded with a 16-bit size field). Frames with a 64-bit size fields remain unsupported but no longer result in an assertion error. Instead, Initial reception of such a frame will result in OSError(EIO) and subsequent operations on the same websocket will fail because framing has been lost. Transmitting frames larger than 64kB is unsupported. Attempting to transmit such a frame will result in OSError(ENOBUFS). Subsequent operations on the websocket are possible. Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-10-04all: Replace legacy name with MicroPython and MPy as applicable.Angus Gratton
With the aim of getting consistency, and removing the need to learn an additional term, replace uses of uPy/uPython with MPy/MicroPython. Rule of thumb was to use "MPy" abbreviation where "CPy" is used nearby, but the full word MicroPython otherwise. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-10-02tests/serial_test.py: Add test for serial throughput.Damien George
This is a test script used to test USB CDC (or USB UART) serial reliability and throughput. Run against any MicroPython remote target with: $ python serial_test.py -t <device> Signed-off-by: Damien George <damien@micropython.org>
2025-10-02tests/basics: Skip exception_chain and self_type_check on unix minimal.Damien George
These two tests can't run on the unix minimal build because it doesn't have the relevant build options enabled. So skip them. Signed-off-by: Damien George <damien@micropython.org>
2025-10-02tests/ports/unix: Improve skip detection for os.getenv and time module.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-10-02tests/stress/bytecode_limit.py: Tweak to run on minimal builds.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-10-02tests/run-tests.py: Update list of tests that use float.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-10-02tests/basics/subclass_native_init.py: Skip if __init__ not supported.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-10-02tests/run-tests.py: Don't include cmdline,io tests for minimal targets.Damien George
The unix minimal variant cannot run these tests because: - it doesn't support -v -v debug printing - it doesn't have `open()` Signed-off-by: Damien George <damien@micropython.org>
2025-10-02tests/extmod/asyncio_heaplock.py: Improve skip detection of test.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-10-01tests/import: Skip import tests where needed.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-10-01tests/micropython: Improve skipping of tests using micropython module.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-10-01tests/extmod/vfs_posix_paths.py: Use tuple instead of set.Damien George
So it can be used on targets without set enabled (or at least not raise a SyntaxError when compiling it). Signed-off-by: Damien George <damien@micropython.org>
2025-10-01tests/extmod: Improve skip detection of extmod tests.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-10-01tests/run-tests.py: Skip more tests that need slice.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-10-01tests/run-tests.py: Improve skip detection for tests using slice.Damien George
This skips some additional tests that use slice, and no longer skips `basics/string_format_modulo.py` which doesn't actually use slice (but `float/string_format_modulo.py` does). Signed-off-by: Damien George <damien@micropython.org>
2025-10-01tests/misc/sys_exc_info.py: Don't rely on slicing.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-10-01tests/stress: Improve qstr_limit test to run on minimal targets.Damien George
Changes here are: - Split out string format module sub-test to a separate test file, so it can be skipped on targets that don't have str% capabilities. - Print the whole type instead of `.__name__` to support targets that don't have `.__name__` enabled (this still tests the same thing). - Print `RuntimeError` exception message to be sure the correct exception is being raised. This test now runs on unix and zephyr minimal configurations. Signed-off-by: Damien George <damien@micropython.org>
2025-10-01tests: Remove .py.exp files that match with CPython 3.8.2 or newer.Damien George
Running the tests now requires CPython 3.8.2 or newer, which was released February 2020 and should be widely available. A few examples of features that were previously not supported by CPython, but which are now: - %-formatting for bytes and bytearray (PEP 461), CPython 3.5 - annotated variables (PEP 526), CPython 3.6 - assignment expressions (PEP 572), CPython 3.8 Note that `basics/fun_code_full.py.exp` is added here because that requires CPython 3.10 or newer. Signed-off-by: Damien George <damien@micropython.org>
2025-10-01tests/run-tests.py: Skip certain tests when using --via-mpy.Damien George
These tests cannot pass when using `--via-mpy`. Signed-off-by: Damien George <damien@micropython.org>
2025-10-01extmod/vfs_blockdev: Check return type is an integer.Damien George
This catches cases where the return type is not a small int, eg it could be a string, or even a big integer. Signed-off-by: Damien George <damien@micropython.org>
2025-09-30webassembly/asyncio: Fix ThenableEvent to handle rejected thenables.Damien George
Prior to this fix, if a JavaScript thenable/Promise that was part of an asyncio chain was rejected it would be ignored because the Python-side `ThenableEvent` did not register a handler for the rejection. That's fixed by this commit, and a corresponding test added. Signed-off-by: Damien George <damien@micropython.org>
2025-09-30webassembly/objjsproxy: Fix logic that determines if asyncio is active.Damien George
`cur_task` can never be `None` in the webassembly port, so test it for the top-level task to see if an asyncio Task is active or not. This fixes a bug where await'ing on a JavaScript awaitable that ends up raising an error would not be caught on the Python side. The fix here makes sure it is caught by Python, as tested by the new test. Signed-off-by: Damien George <damien@micropython.org>
2025-09-30tests/ports/webassembly: Expand test for registerJsModule.Damien George
This tests `from mod import foo` where `mod` is a module registered using the webassembly API `registerJsModule(mod)`, and where `foo` is a JavaScript function. Prior to the parent commit, this would fail. Signed-off-by: Damien George <damien@micropython.org>
2025-09-30py/runtime: Support importing a method from an instance.Damien George
This change follows CPython behaviour, allowing use of: from instance import method to import a bound method from a class instance, eg registered via setting `sys.modules["instance"] = instance`. Admittedly this is probably a very rarely used pattern in Python, but it resolves a long standing comment about whether or not this is actually possible (it turns out it is possible!). A test is added to show how it works. The main reason for this change is to fix a problem with imports in the webassembly port: prior to this fix, it was not possible to do `from js_module import function`, where `js_module` is a JavaScript object registered to be visible to Python through the webassembly API function `registerJsModule(js_module)`. But now with this fix that is possible. Signed-off-by: Damien George <damien@micropython.org>
2025-09-28tests/stress/fun_call_limit.py: Allow to run with OBJ_REPR_B.Jeff Epler
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-09-28tests: Use OBJ_REPR_B compatible mpy file headers.Jeff Epler
So these tests can run and pass using OBJ_REPR_B. Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-09-28tests/basics/int_big_to_small.py: Bifurcate test using small-int-max.Jeff Epler
Different results are needed for different integer sizes. Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-09-28extmod/vfs_reader: Check that open() resulted in a file-like object.Jeff Epler
That is, an object whose type defines the protocol slot. Note that due to protocol confusion, a variant of the original crasher that returned e.g., a machine.Pin instance could still lead to a crash (#17852). Fixes issue #17841. Signed-off-by: Jeff Epler <jepler@gmail.com> Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-09-26webassembly: Improve identity and fix bug with lost JsProxy refs.Damien George
Commit ffa98cb0143c43af9f4c61142784a08a19f660c5 improved equality for `JsProxy` objects so that, eg, `js.Object == js.Object` is true. As mentioned in #17758, a further optimisation is to make identity work in that case, eg `js.Object is js.Object` should be true (on the Python side). This commit implements that, by keeping track of all `JsProxy` Python objects and reusing them where possible: where the underlying JS ref is equal, ie they point to the same JS object. That reduces memory churn and gives better identity behaviour of JS objects proxied over to Python. As part of this, a bug is fixed where JS objects can be freed while there's still a `JsProxy` referring to that JS object. A test is added for that exact scenario, and the test now passes. Signed-off-by: Damien George <damien@micropython.org>
2025-09-26tests/ports/webassembly: Move JsProxy identity test to separate file.Damien George
This test is not a PyProxy test, rather it's a JsProxy test. Signed-off-by: Damien George <damien@micropython.org>
2025-09-26tests: Test extremes of range() and document differences to CPython.Jeff Epler
This avoids remaining buggy cases where C signed overflow occurs. Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-09-26tests/ports/unix: Add coverage test for readinto1 stream method.Damien George
And expand the test for `readinto()` to test the difference between trying to read the requested amount by doing multiple underlying IO calls, and only doing one call. Signed-off-by: Damien George <damien@micropython.org>