summaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
11 dayspy/asmrv32: Reserve a flag for the Zcmp RV32 CPU extension.Alessandro Gatti
This commit performs the necessary changes to handle an additional RV32 CPU extension flag, for the Zcmp extension in this case. The changes are not limited to RV32-only code, as other parts of the tooling need to be modified for this: the testing framework has to be made aware that an extra bit can be set in sys.implementation._mpy and needs to know how it is called, and "mpy-cross" must be able to actually set that flag bit in the first place via the appropriate command line argument. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
11 daystests/run-tests.py: Discover RV32 extension inlineasm tests.Alessandro Gatti
This commit extends the test runner to automatically discover inline assembler tests for known RV32 extensions, and checks whether to add the discovered tests to the enabled tests list. Automatic discovery requires that inline assembler tests for RV32 extensions follow a specific pattern both for filenames and for the tests' output in case of success. A valid RV32 extension test must have: * A code fragment that checks for support of the extension on the running target in "/tests/feature_check", called "inlineasm_rv32_<extensionname>.py" that should print the string "rv32_<extensionname>" if the extension is supported * A matching expected result file in "/tests/feature_check" called "inlineasm_rv32_<extensionname>.py.exp" that must contain the string "rv32_<extensionname>" (without quotes) * A regular MicroPython test file in "/tests/inlineasm/rv32" called "asm_ext_<extensionname>.py" For example, to test the Zba extension, there must be a file called "/tests/feature_check/inlineasm_rv32_zba.py" that should print the string "rv32_zba" if the extension is supported, together with a file called "/test/feature_check/inlineasm_rv32_zba.py.exp" that contains the string "rv32_zba" in it, and finally there must be a regular MicroPython test file called "/tests/inlineasm/rv32/asm_ext_zba.py". Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
14 daystests/target_wiring: Provide an ESP8266 target wiring module.Alessandro Gatti
This commit introduces ESP8266 support for target wiring tests, fixing execution of relevant tests that once failed on that platform. ESP8266 boards need to have GPIO4 and GPIO5 connected together to provide a UART loopback, in order to test whether UART data effectively flows through. The wiring-enabled UART transmission timing test was also updated with measurements compatible with a few ESP8266 test boards. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
14 daystests/extmod/vfs_blockdev_invalid.py: Handle low memory conditions.Alessandro Gatti
This commit modifies the "extmod/vfs_blockdev_invalid" test to better behave on boards with low available memory. Before these changes the test would fail on ESP8266 (at least), due to low memory, but in a way that could not be easily solved as the error occurred in the middle of the test. The test has been rewritten to delay its output until the very end, so if a low memory condition occurs and needs to stop execution then no real output will show up before the skip marker. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
14 daystests/run-tests.py: Skip list sort stress test for ESP8266.Alessandro Gatti
This commit marks the "stress/list_sort.py" test to be skipped when running on ESP8266. The test just takes too long without yielding to the OS whilst doing the sort, causing the internal software watchdog to kick in and reboot the board. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-12-17tests/basics/string_fstring.py: Test fstring nested replacement fields.Jeff Epler
This does not actually cover any additional lines, but it does cover new functionality not previously covered. Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-12-16tests/ports/esp32/check_err_str.py: Preallocate global variable.Damien George
This test fails on all esp32 boards without this fix, because the try/except that runs with the heap locked attempts to increase the size of the globals dict when assigning to the exception variable `e`. Fix that by preallocating the global variable `e`. Signed-off-by: Damien George <damien@micropython.org>
2025-12-07tests/basics/builtin_help.py: Test correct handling of deleted entries.Anson Mansfield
This test reproduces the bug that gave rise to the esp32 segfaults in issues #18061 and #18481 on all platforms. Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
2025-12-07tests/net_inet: Update micropython.org certificate for SSL tests.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-12-07tests/serial_test.py: Add a serial echo test.Damien George
The existing `serial_test.py` script tests data in/out throughput and reliability. But it only tests data sizes that are a power of two, which may not catch certain errors with USB transmission (because FS packet size is 64 bytes). This commit adds a new echo sub-test to the `serial_test.py` script. It sends out data to the target and gets the target to echo it back, and then compares the result (the echo'd data should be equal to the sent data). It does this for data packets between 1 and 520 (inclusive) bytes, which covers USB FS and HS packet sizes (64 and 512 respectively). It uses random data for the test, but seeded by a constant seed so that it's deterministic. If there's an error then it prints out all the sent and echo'd data to make it easier to see where it went wrong (eg if the previous packet was repeated). Signed-off-by: Damien George <damien@micropython.org>
2025-12-07tests/serial_test.py: Factor common reset code into send_script func.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-11-25tests/multi_espnow: Add test case for espnow rate changes.Angus Gratton
Uses constants added in previous commit. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-11-22tests/run-tests.py: Add general newline normalization function.Andrew Leech
Add a general normalize_newlines() function that handles newline variations (\\r\\r\\n, \\r\\n) to \\n while preserving literal \\r characters that are part of test content. This provides a robust solution for cross-platform test compatibility, particularly addressing PTY double-newline issues that can occur with some terminal implementations. The function is applied to all test output before comparison, eliminating platform-specific newline issues. Includes a unit test to verify the normalization behavior. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2025-11-22shared/runtime/pyexec: Provide support for compile-only mode.Andrew Leech
When `MICROPY_PYEXEC_COMPILE_ONLY` is enabled and the global `mp_compile_only` is True, code is compiled but not executed. Also add comprehensive tests for compile-only functionality covering both successful compilation and syntax error detection. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2025-11-22shared/runtime/pyexec: Set __file__ for file input when enabled.Andrew Leech
When `MICROPY_MODULE___FILE__` is enabled and parsing file input, set the global `__file__` variable to the source filename. This matches the behavior of the unix port and provides the current filename to the executing script. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2025-11-22unix/main: Use standard pyexec REPL for unix and windows ports.Andrew Leech
This improves REPL usage consistency across ports, by utilizing the pyexec code for the unix REPL. Only enabled when MICROPY_USE_READLINE == 1 (the default). Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2025-11-21py/objdict: Implement bool and len unary ops for dict views.Damien George
Currently, dict views (eg `dict.keys()`, `dict.values()`) do not implement the `bool` or `len` unary operations. That may seem like a reasonable omission for MicroPython to keep code size down, but it actually leads to silently incorrect bool operations, because by default things are true. Eg we currently have: >>> bool(dict().keys()) True which is wrong, it should be `False` because the dict is empty. This commit implements `bool` and `len` unary operations on dict views by simply delegating to the existing dict unary op function. Fixes issue #12385. Signed-off-by: Damien George <damien@micropython.org>
2025-11-21py/builtinimport: Support relative import in custom __import__ callback.Chris Liechti
The globals need to be forwarded from the caller's context. Signed-off-by: Damien George <damien@micropython.org>
2025-11-19tests/extmod_hardware/machine_encoder.py: Use target_wiring for encoder.Ihor Nehrutsa
Signed-off-by: Ihor Nehrutsa <Ihor.Nehrutsa@gmail.com>
2025-11-19tests/extmod_hardware/machine_encoder.py: Fix initial rotation count.Ihor Nehrutsa
ESP32 requires initial high levels of the channels before starting the count, in order to have 4 pulse for the first rotation. Also add tests for encoder phases x2 and x4. Signed-off-by: Ihor Nehrutsa <Ihor.Nehrutsa@gmail.com>
2025-11-19tests/import: Remove .py.exp files where they match CPython.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-11-19tests/import: Make import_override and pkg7 tests behave under CPython.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-11-19tests/extmod/machine_i2s_rate.py: Adjust pins when running on ESP32-C3.Jos Verlinde
Changed the pin numbers used for the I2S rate testing as the pin numbers used were incompatible with the limited GPIO pins availalbe on the ESP32-C3, causing the tests to fail. Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
2025-11-06tests/serial_test.py: Allow up to 2 seconds between bytes.Angus Gratton
Only a problem when UART TX is also enabled and goes first (i.e. esp32 port) as sending 16384 bytes in one go triggers the timeout. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-10-24tests/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>
2025-10-24tests/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>
2025-10-24tests/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>
2025-10-24py/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>