summaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2024-10-24tests/extmod: Add test to compare time_ns with time.Damien George
They should be close together. Signed-off-by: Damien George <damien@micropython.org>
2024-10-24tests/extmod: Use time_ns instead of time in lfs mtime test.Damien George
Because VfsLfs2 uses time_ns to create timestamps for files, and for the test to give consistent results it also needs to use this same function. Signed-off-by: Damien George <damien@micropython.org>
2024-10-24tests/extmod: Fix access of RTC class in machine.RTC test.Damien George
This previously passed on some targets that automatically import the `machine` module in `boot.py`. Signed-off-by: Damien George <damien@micropython.org>
2024-10-24tests/extmod: Add a simple test for machine.RTC.Damien George
Tests at least that the datetime can be set and get correctly. Signed-off-by: Damien George <damien@micropython.org>
2024-10-22tests/extmod: Support esp32,mimxrt,stm32,samd ports in UART TX test.Damien George
Getting this test running on stm32- and mimxrt-based boards requires adding a small delay after constructing the UART so that the initial idle frame has time to be transmitted before the test starts. Also, the timing margin needs to account for an additional 1-bit worth of time on some MCUs. Thanks to @robert-hh for the esp32, mimxrt and samd settings. Signed-off-by: Damien George <damien@micropython.org>
2024-10-22tests/extmod: Make invalid-blockdev test work consistently on all ports.Damien George
Some ports (eg stm32) configure the FAT driver differently (eg with multi-partition support) and that leads to a slightly different sequence of block reads, compared to other configurations (eg rp2). Comment out the printing in `readblocks()` so the tests are deterministic (the printing is still useful for debugging). Signed-off-by: Damien George <damien@micropython.org>
2024-10-22tests/run-tests.py: Skip large viper test on esp8266.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-10-22tests/micropython: Tweak ringio test for targets with terse errors.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-10-22tests/extmod: Adjust ssl/tls tests to run on targets with axTLS.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-10-22tests/extmod: Config SPI test for esp8266 and skip SoftTimer test.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-10-22extmod/modframebuf: Fix FrameBuffer size check for stride corner-cases.Corran Webster
This is a fix for issue #15944, and handles corner cases in the FrameBuffer code when using stride values where the last line's stride may extend past the end of the underlying buffer. This commit includes extra tests for these corner cases. For example a GS8 format FrameBuffer with a width of 8, height of 2 and stride of 10 should be able to fit into a buffer of size 18 (10 bytes for the first horizontal line, and 8 bytes for the second -- the full 10 bytes are not needed). Similarly a 1 by 9 FrameBuffer in MONO_VLSB format with a stride of 10 should be able to fit into a buffer of length 11 (10 bytes for the first 8 lines, and then one byte for the 9th line. Being able to do this is particularly important when cropping the corner of an existing FrameBuffer, either to copy a sprite or to clip drawing. Signed-off-by: Corran Webster <cwebster@unital.dev>
2024-10-22rp2/machine_uart: Make it so TX is done only when no longer busy.Damien George
Prior to this commit, when flushing a UART on the rp2 port, it returns just before the last character is sent out the wire. Fix this by waiting until the BUSY flag is cleared. This also fixes the behaviour of `UART.txdone()` to return `True` only when the last byte has gone out. Updated docs and tests to match. The test now checks that UART TX time is very close to the expected time (prior, it was just testing that the TX time was less than the expected time). Signed-off-by: Damien George <damien@micropython.org>
2024-10-16py/objtype: Don't delegate lookup of descriptor methods to __getattr__.Damien George
When descriptors are enabled, lookup of the `__get__`, `__set__` and `__delete__` descriptor methods should not be delegated to `__getattr__`. That follows CPython behaviour. Signed-off-by: Damien George <damien@micropython.org>
2024-10-15tests/run-tests.py: Only run inlineasm tests on rp2 ARM targets.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-10-15tests/ports/rp2: Update lightsleep/machine_idle to skip on RP2350.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-10-15tests/ports/rp2: Add simple rp2-specific UART test.Damien George
To test construction of UART instances. Signed-off-by: Damien George <damien@micropython.org>
2024-10-15tests/ports/rp2: Update DMA test to work on RP2350.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-10-15tests/run-tests.py: Wait for soft reset if a target skips a test.Damien George
Commit 69c25ea8653566ec97690b5121bd10b753c89426 made raising `SystemExit` do a soft reset (on bare-metal targets). This means that any test which is skipped by a target (by raising `SystemExit`) will trigger a soft reset on that target, and then it must execute its startup code, such as `boot.py`. If the timing is right, this startup code can be unintentionally interrupted by the test runner when preparing the next test, because the test runner enters the raw REPL again via a Ctrl-C Ctrl-A ctrl-D sequence (in `Pyboard.enter_raw_repl()`). When this happens (`boot.py` is interrupted) the target may not be set up correctly, and it may (in the case of stm32 boards) flash LEDs and take extra time, slowing down the test run. Fix this by explicitly waiting for the target to finish its soft reset when it skips a test. Signed-off-by: Damien George <damien@micropython.org>
2024-10-10esp32: Fix hang in taskYIELD() on riscv CPUs when IRQs disabled.Angus Gratton
Regression introduced in 337742f. The hang occurs because the esp32 port was calling "from ISR" port-layer functions to set/clear the interrupt mask. FreeRTOS kernel therefore doesn't know the CPU is in a critical section. In taskYIELD() the riscv port layer blocks after yielding until it knows the yield has happened, and would block indefinitely if IRQs are disabled (until INT WDT triggers). Moving to the "public" portENTER_CRITICAL/portEXIT_CRITICAL API means that FreeRTOS knows we're in a critical section and can react accordingly. Adds a regression test for this case (should be safe to run on all ports). On single core CPUs, this should result in almost exactly the same behaviour apart from fixing this case. On dual core CPUs, we now have cross-CPU mutual exclusion for atomic sections. This also shouldn't change anything, mostly because all the code which enters an atomic section runs on the same CPU. If it does change something, it will be to fix a thread safety bug. There is some risk that this change triggers a FreeRTOS crash where there is a call to a blocking FreeRTOS API with interrupts disabled. Previously this code might have worked, but was probably thread unsafe and would have hung in some circumstances. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-10-09tests: Tweak machine SPI and UART tests to work with esp32c6.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-10-09tests/README: Update instructions for key/cert pair usage on device.Andrew Leech
Signed-off-by: Andrew Leech <andrew@alelec.net>
2024-10-07py/objtype: Allow passing keyword arguments to native base __init__.stijn
Allowing passing keyword arguments to a native base's __init__, i.e. `make_new` in the C code. Previously only positional arguments were allowed. The main trade-off in this commit is that every call to the native base's `make_new` is now going to be preceded by a call to `mp_map_init_fixed_table` even though most of what that does is unused and instead it merely serves as a way to pass the number of keyword arguments. Fixes issue #15465. Signed-off-by: stijn <stijn@ignitron.net>
2024-09-26py/mpz: Skip separators when running out of digits to print.Alessandro Gatti
This commit fixes the addition of a stray separator before the number when printing an MPZ-backed integer and the first group is three digits long. This fixes #8984. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-26py/persistentcode: Explicitly track native BSS/rodata when needed.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-09-26extmod/vfs_blockdev: Implement common helper for read and write.Angus Gratton
- Code size saving as all of these functions are very similar. - Resolves the "TODO" of the plain read and write functions not propagating errors. An error in the underlying block device now causes VFatFs to return EIO, for example. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-26extmod/vfs_blockdev: Check block device function positive results.Angus Gratton
A positive result here can result in eventual memory corruption as littlefs expects the result of a cache read/write function to be 0 or a negative integer for an error. Closes #13046 This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-19py/objringio: Add micropython.RingIO() interface for general use.Andrew Leech
This commit adds a new `RingIO` type which exposes the internal ring-buffer code for general use in Python programs. It has the stream interface making it similar to `StringIO` and `BytesIO`, except `RingIO` has a fixed buffer size and is automatically safe when reads and writes are in different threads or an IRQ. This new type is enabled at the "extra features" ROM level. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2024-09-19tests/ports/unix: Update and extend the modffi integer tests.Michael Sawyer
Added the "long" modffi tests. The tests could not be added to the existing ffi_types test because two .exp files were required for the 32-bit and 64-bit results. Code common to both the ffi_types and type "long" tests was factored into ffi_int_base. ffi_types was renamed to ffi_int_types to group the related tests under the "ffi_int" prefix. Signed-off-by: Michael Sawyer <mjfsawyer@gmail.com>
2024-09-19tests/run-tests.py: Remove --write-exp and --list-tests options.Damien George
Removing the now-unused (see previous commit for details) `--write-exp` and `--list-tests` options helps to simplify the rather complex logic in `run-tests.py`. Signed-off-by: Damien George <damien@micropython.org>
2024-09-19shared/tinyusb: Only run TinyUSB on the main thread if GIL is disabled.Angus Gratton
If GIL is disabled then there's threat of a race condition if some other code specifically requests USB processing (i.e. to unblock stdio), while a scheduled TinyUSB callback is already running on another thread. Relies on the change in the parent commit, where scheduler is restricted to main thread if GIL is disabled. Fixes #15390 - "TinyUSB callback can't recurse" exceptions on rp2 when using _thread module and USB serial I/O. Adds a unit test for stdin functioning correctly in threads (fails on rp2 port without this fix). This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-06tests/run-tests.py: Add a zephyr test target.Damien George
So that certain tests can be skipped when running on this target. These thread tests do not pass because the zephyr port cannot create more than 4 threads at once. Signed-off-by: Damien George <damien@micropython.org>
2024-09-06tests/thread: Adapt stress_aes.py to run on zephyr.danicampora
Signed-off-by: danicampora <danicampora@gmail.com>
2024-09-06tests/extmod/machine_uart_irq_txidle.py: Simplify the test script.robert-hh
Now that no minimal delay time is required for SAMD devices. Signed-off-by: robert-hh <robert@hammelrath.com>
2024-09-06shared/runtime/sys_stdio_mphal: Fix printed type for stdio streams.timdechant
The printed type for stdio streams indicates "FileIO", which is a binary IO stream. Stdio is not binary by design, and its printed type should indicate a text stream. "TextIOWrapper" suits that purpose, and is used by VfsPosix files. Signed-off-by: timdechant <timdechant.git@gmail.com>
2024-09-06qemu: Rename qemu-arm port to qemu.Damien George
Because this port now supports multiple architectures. Signed-off-by: Damien George <damien@micropython.org>
2024-09-06all: Remove remaining qemu-riscv references.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-09-04tests/run-tests.py: Automatically detect native arch and mpy-cross flag.Damien George
Now that some ports support multiple architectures (eg esp32 has both Xtensa and RISC-V CPUs) it's no longer possible to set mpy-cross flags based on the target, eg `./run-tests.py --target esp32`. Instead this commit makes it so the `-march=xxx` argument to mpy-cross is detected automatically via evaluation of `sys.implementation._mpy`. Signed-off-by: Damien George <damien@micropython.org>
2024-09-04tests/net_inet: Update micropython.org certificate for SSL tests.Damien George
The Let's Encrypt root certificate has changed so needs updating in this test. Signed-off-by: Damien George <damien@micropython.org>
2024-09-02tests/basics: Add tests for optional args to int.to_bytes/from_bytes.Amirreza Hamzavi
Signed-off-by: Amirreza Hamzavi <amirrezahamzavi2000@gmail.com>
2024-08-29tests/extmod_hardware: Add tests for machine.UART.IRQ_RX/RXIDLE/BREAK.Damien George
These all require hardware connections, so live in a different directory. Except for the IRQ_BREAK test of ESP32 devices a single UART with loopback is sufficient. General: SAMD21: Due to the limited flash size only SAMD21 devices with external flash support uart.irq(). IRQ_BREAK: ESP32 needs different UART devices for creating and sensing a break. Lacking a second UART the test is skipped for ESP32S2 and ESP32C3. RP2 does not pass the test reliable at 115200 baud, reason to be found. Thus the upper limit is set to 57600 Baud. Coverage: esp32 pass when different UART devices are used. rp2 pass up to 57600 baud IRQ_RX: SAMD21: Being a slow device it needs data to be sent byte-by-byte at 9600 baud, since the IRQ callback is scheduled delayed and then the flags do not match any more. The data matches since it is queued in the FIFO resp. ringbuffer. CC3200: The test cannot be performed since no calls are accepted in the IRQ handler like u.read(). Skipped. Coverage: cc3200 fail due to major differences in the implementation. esp32 pass nrf pass renesas-ra pass samd pass see the notes. stm32 pass IRQ_RXIDLE: STM32: With PyBoard the IRQ is called several times, but only once with the flag IRQ_RXIDLE set. Coverage: esp32 pass mimxrt pass renesas-ra pass rp2 pass samd pass for both SAMD21 and SAMD51 stm32 fail. see notes. Signed-off-by: Damien George <damien@micropython.org> Signed-off-by: robert-hh <robert@hammelrath.com>
2024-08-29tests/extmod: Add test for machine.UART.IRQ_TXIDLE.Damien George
The test checks whether the message created by the IRQ handler appears about at the end of the data sent by UART. Supported MCUs resp. boards: - RP2040 - Teensy 4.x - Adafruit ItsyBitsy M0 - Adafruit ItsyBitsy M4 - NRF52 (Arduino Nano Connect 33 BLE) Signed-off-by: Damien George <damien@micropython.org>
2024-08-28qemu-arm: Rework to provide a REPL and run tests via a pty serial port.Damien George
Currently, the qemu-arm (and qemu-riscv) port has two build modes: - a simple test that executes a Python string; and - a full test that uses tinytest to embed all tests within the firmware, then executes that and captures the output. This is very different to all the other ports. A difficulty with using tinytest is that with the large number of tests the firmware overflows its virtual flash size. It's also hard to run tests via .mpy files and with the native emitter. Being different to the other ports also means an extra burden on maintenance. This commit reworks the qemu-arm port so that it has a single build target that creates a standard firmware which has a REPL. When run under qemu-system-arm, the REPL acts like any other bare-metal port, complete with soft reset (use machine.reset() to turn it off and exit qemu-system-arm). This approach gives many benefits: - allows playing with a REPL without hardware; - allows running the test suite as it would on a bare-metal board, by making qemu-system-arm redirect the UART serial of the virtual device to a /dev/pts/xx file, and then running run-tests.py against that serial device; - skipping tests is now done via the logic in `run-tests.py` and no longer needs multiple places to define which tests to skip (`tools/tinytest-codegen.py`, `ports/qemu-arm/tests_profile.txt` and also `tests/run-tests.py`); - allows testing/using mpremote with the qemu-arm port. Eventually the qemu-riscv port would have a similar change. Prior to this commit the test results were: 743 tests ok. (121 skipped) With this commit the test results are: 753 tests performed (22673 individual testcases) 753 tests passed 138 tests skipped More tests are skipped because more are included in the run. But overall more tests pass. Signed-off-by: Damien George <damien@micropython.org>
2024-08-28tests/run-tests.py: Skip additional tests when slice unavailable.Damien George
Both of these tests require slice to be enabled. Signed-off-by: Damien George <damien@micropython.org>
2024-08-19py/objstr: Skip whitespace in bytes.fromhex().Glenn Moloney
Skip whitespace characters between pairs of hex numbers. This makes `bytes.fromhex()` compatible with cpython. Includes simple test in `tests/basic/builtin_str_hex.py`. Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
2024-08-14test/extmod: Fix machine_spi_rate test on ESP32-C3.Angus Gratton
Update to the test added in 1e98c4cb75bf3015d816455fc46ba28d5bcd9275, changes the SPI pins for ESP32-C3 (IO 18 and 19 are the native USB pins). Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-08-14unix: Switch stack limit check to new cstack API.Angus Gratton
Necessary to pass CI when testing the V2 preview APIs. Also adds an extra coverage test for the legacy stackctrl API, to maintain coverage and check for any regression. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-08-14tests/run-tests.py: Enable stress tests on esp32 port.Angus Gratton
Now passing on ESP32-S3 and ESP32-C3. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-08-13tests/extmod/ssl_keycert.py: Add test for PKCS8 formatted DER key.Peter Züger
Signed-off-by: Peter Züger <zueger.peter@icloud.com>
2024-08-07tests/extmod: Add machine_spi_rate test.Angus Gratton
Based on machine_i2s_rate, allows testing basic SPI functionality and timings. Implemented and confirmed working for rp2, esp32, and pyboard. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-08-07tests/extmod: Rename machine_timer exp file to machine_soft_timer.Damien George
This was missed in 9ba04cc7563ec934ca14d66aa18ae3563c8d1aea Signed-off-by: Damien George <damien@micropython.org>