summaryrefslogtreecommitdiff
path: root/tests/run-tests.py
AgeCommit message (Collapse)Author
2025-02-11tests/run-tests.py: Give more information when CPython crashes.Damien George
To make it easier to diagnose why CPython crashed. Signed-off-by: Damien George <damien@micropython.org>
2025-01-06tests/run-tests.py: Implement getcwd on __FS hook filesystem.Damien George
This method is needed by tests like `extmod/vfs_rom.py`. Signed-off-by: Damien George <damien@micropython.org>
2025-01-06tests/run-tests.py: Set __main__ module to __injected_test.Damien George
When using unittest (for example) with injected mpy files, not only does the name of the main test module need to be `__main__`, but also the `__main__` module should correspond to this injected module. Otherwise the unittest test won't be detected. Signed-off-by: Damien George <damien@micropython.org>
2025-01-02tests/run-tests.py: Detect inlineasm support and add tests if needed.Alessandro Gatti
This commit implements a method to detect at runtime if inline assembler support is enabled, and if so which platform it targets. This allows clean test runs even on modified version of ARM-based ports where inline assembler support is disabled, running inline assembler tests on ports that have such feature not enabled by default and manually enabled, and allows to always run the correct inlineasm tests for ports that support more than one architecture (esp32, qemu, rp2). Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-01-02py/emitinlinerv32: Add inline assembler support for RV32.Alessandro Gatti
This commit adds support for writing inline assembler functions when targeting a RV32IMC processor. Given that this takes up a bit of rodata space due to its large instruction decoding table and its extensive error messages, it is enabled by default only on offline targets such as mpy-cross and the qemu port. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-01-01tests/inlineasm: Make room for RV32IMC inline asm tests.Alessandro Gatti
Thumb/Thumb2 tests are now into their own subdirectory, as RV32IMC-specific tests will be added as part of the RV32 inline assembler support. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-12-20tests: Fix all file ioctl's to support only MP_STREAM_CLOSE.Damien George
A return value of 0 from Python-level `ioctl()` means success, but if that's returned unconditionally it means that the method supports all ioctl calls, which is not true. Returning 0 without doing anything can potentially lead to a crash, eg for MP_STREAM_SEEK which requires returning a value in the passed-in struct pointer. This commit makes it so that all `ioctl()` methods respond only to MP_STREAM_CLOSE, ie they return -1 (indicating error) for all other ioctl calls. Signed-off-by: Damien George <damien@micropython.org>
2024-12-19tests/run-tests.py: Set name of injected test module to '__main__'.Damien George
Running unittest-based tests with --via-mpy is currently broken, because the unittest test needs the module to be named `__main__`, whereas it's actually called `__injected_test`. Fix this by changing the name when the file is opened. Signed-off-by: Damien George <damien@micropython.org>
2024-12-06tests/run-tests.py: Print .out file when there is no .exp file.Damien George
So that a failing unittest-based test has its entire log printed when using `run-tests.py --print-failures`. Signed-off-by: Damien George <damien@micropython.org>
2024-12-06tests/run-tests.py: Add support for tests to use unittest.Damien George
All the existing tests require a .exp file (either manually specified or generated running the test first under CPython) that is used to check the output of running the test under MicroPython. The test passes if the output matches the expected output exactly. This has worked very well for a long time now. But some of the newer hardware tests (eg UART, SPI, PWM) don't really fit this model, for the following main reasons: - Some but not all parts of the test should be skipped on certain hardware targets. With the expected-output approach, skipping tests is either all or nothing. - It's often useful to output diagnostics as part of the test, which should not affect the result of the test (eg the diagnostics change from run to run, like timing values, or from target to target). - Sometimes a test will do a complex check and then print False/True if it passed or not, which obscures the actual test result. To improve upon this, this commit adds support to `run-tests.py` for a test to use `unittest`. It detects this by looking at the end of the output after running the test, looking for the test summary printed by `unittest` (or an error message saying `unittest` was not found). If the test uses `unittest` then it should not have a .exp file, and it's not run under CPython. A `unittest` based test passes or fails based on the summary printed by `unittest`. Note that (as long as `unittest` is installed on the target) the tests are still fully independent and you can still run them without `run-tests.py`: you just run it as usual, eg `mpremote run <test.py>`. This is very useful when creating and debugging tests. Note also that the standard test suite testing Python semantics (eg everything in `tests/basics/`) will probably never use unittest. Only more advanced tests will, and ones that are not runnable under CPython. Signed-off-by: Damien George <damien@micropython.org>
2024-11-04tests/run-tests.py: Add mimxrt and samd platforms.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-11-04tests/run-tests.py: Change --target/--device options to --test-instance.Damien George
Previously to this commit, running the test suite on a bare-metal board required specifying the target (really platform) and device, eg: $ ./run-tests.py --target pyboard --device /dev/ttyACM1 That's quite a lot to type, and you also need to know what the target platform is, when a lot of the time you either don't care or it doesn't matter. This commit makes it easier to run the tests by replacing both of these options with a single `--test-instance` (`-t` for short) option. That option specifies the executable/port/device to test. Then the target platform is automatically detected. The `--test-instance` can be passed: - "unix" (the default) to use the unix version of MicroPython - "webassembly" to test the webassembly port - anything else is considered a port/device to pass to Pyboard There are also some shortcuts to specify a port/device, following `mpremote`: - a<n> is short for /dev/ttyACM<n> - u<n> is short for /dev/ttyUSB<n> - c<n> is short for COM<n> For example: $ ./run-tests.py -t a1 Note that the default test instance is "unix" and so this commit does not change the standard way to run tests on the unix port, by just doing `./run-tests.py`. As part of this change, the platform (and it's native architecture if it supports importing native .mpy files) is show at the start of the test run. Signed-off-by: Damien George <damien@micropython.org>
2024-11-04tests/run-tests.py: Simplify the way target-specific tests are given.Damien George
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-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/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-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-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-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-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-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-07-25tests/run-tests.py: Make Windows test skipping more granular.stijn
Signed-off-by: stijn <stijn@ignitron.net>
2024-07-25github/workflows: Improve MSYS2-based CI builds.stijn
Install the mingw variant of Python since it behaves more like a 'real' Windows CPython than the msys2 variant: os.name == 'nt', not 'posix'. Note that os.sep is still '/' though so we don't actually need to skip the import_file test. This way one single Python version can be used both for running run-tests.py and getting the expected test output. Signed-off-by: stijn <stijn@ignitron.net>
2024-07-23tests/run-tests.py: Enable thread tests on esp32.Angus Gratton
Before the fix in parent commit, some of these tests hung indefinitely. After, they seem to consistently pass. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-06-21py/emitnative: Fix native async with.Damien George
The code generating the entry to the finally handler of an async-with statement was simply wrong for the case of the native emitter. Among other things the layout of the stack was incorrect. This is fixed by this commit. The setup of the async-with finally handler is now put in a dedicated emit function, for both the bytecode and native emitters to implement in their own way (the bytecode emitter is unchanged, just factored to a function). With this fix all of the async-with tests now work when using the native emitter. Signed-off-by: Damien George <damien@micropython.org>
2024-06-21py/emitnative: Place thrown value in dedicated local variable.Damien George
A value thrown/injected into a native generator needs to be stored in a dedicated variable outside `nlr_buf_t`, following the `inject_exc` variable in `py/vm.c`. Signed-off-by: Damien George <damien@micropython.org>
2024-06-17qemu-riscv: Add new QEMU RV32 port.Alessandro Gatti
This adds a QEMU-based bare metal RISC-V 32 bits port. For the time being only QEMU's "virt" 32 bits board is supported, using the ilp32 ABI and the RV32IMC architecture. The top-level README and the run-tests.py files are updated for this new port. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-05-14webassembly/mpconfigport: Enable importing of .mpy files.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-04-24webassembly: Add JavaScript-based asyncio support.Damien George
This commit adds a significant portion of the existing MicroPython asyncio module to the webassembly port, using parts of the existing asyncio code and some custom JavaScript parts. The key difference to the standard asyncio is that this version uses the JavaScript runtime to do the actual scheduling and waiting on events, eg Promise fulfillment, timeouts, fetching URLs. This implementation does not include asyncio.run(). Instead one just uses asyncio.create_task(..) to start tasks and then returns to the JavaScript. Then JavaScript will run the tasks. The implementation here tries to reuse as much existing asyncio code as possible, and gets all the semantics correct for things like cancellation and asyncio.wait_for. An alternative approach would reimplement Task, Event, etc using JavaScript Promise's. That approach is very difficult to get right when trying to implement cancellation (because it's not possible to cancel a JavaScript Promise). Signed-off-by: Damien George <damien@micropython.org>
2024-03-22tests/ports/webassembly: Add webassembly JS tests.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-03-22tests/run-tests.py: Support running webassembly tests via node.Damien George
This allows running tests with a .js/.mjs suffix, and also .py tests using node and the webassembly port. Signed-off-by: Damien George <damien@micropython.org>
2024-02-20py/objfun: Support __name__ on native functions and generators.Damien George
This is now easy to support, since the first machine-word of a native function tells how to find the prelude, from which the function name can be extracted in the same way as for bytecode. Signed-off-by: Damien George <damien@micropython.org>
2024-02-07tests: Use vfs module instead of os.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-02-06github/workflows: Move Windows CI from AppVeyor to GitHub Actions.David Lechner
By moving to GitHub actions, all MicroPython CI builds are now on GitHub actions. This allows faster parallel builds and saves time by not building when no relevant files changed. This reveals a few failing tests, so those are temporarily disabled until they can be fixed. Signed-off-by: David Lechner <david@pybricks.com> Signed-off-by: Damien George <damien@micropython.org>
2024-01-22tests/ports/rp2: Add rp2-specific tests with a test for rp2.DMA.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-01-22tests: Move port-specific test directories into tests/ports/ directory.Damien George
To keep them all together, mirroring the top-level directory structure. Signed-off-by: Damien George <damien@micropython.org>
2024-01-10tests/run-tests.py: Fix path-based special test detection.stijn
Compare the full absolute path instead of relying on the path form passed by the user. For instance, this will make python3 run-tests.py -d basics python3 run-tests.py -d ./basics python3 run-tests.py -d ../tests/basics python3 run-tests.py -d /full/path/to/basics all behave the same by correctly treating the bytes_compare3 and builtin_help tests as special, whereas previously only the first invocation would do that and hence result in these tests to fail when called with a different path form. Signed-off-by: stijn <stijn@ignitron.net>
2024-01-10tests/run-tests.py: Make repl test detection more correct.stijn
Avoid unrelated tests which happen to have "repl_" anywhere in their path to be treated as repl tests. Signed-off-by: stijn <stijn@ignitron.net>
2024-01-10tests/run-tests.py: Remove unneeded argument from run_feature_check().stijn
In 405893af this was likely left as-is to minimize the diff, but it just complicates things. Signed-off-by: stijn <stijn@ignitron.net>
2024-01-05tests/run-tests.py: Add an option for running only the failed tests.stijn
Implement the typical 're-run the failed tests' most test runners have, for convenience. Accessible via the new --run-failures argument, and implemented using a json file containing a list of the failed tests. Signed-off-by: stijn <stijn@ignitron.net>
2024-01-05tests/thread: Adjust thread tests so most are able to run on rp2 port.Damien George
The aim of this commit is to make it so that the existing thread tests can be used to test the _thread module on the rp2 port. The rp2 port only allows up to one thread to be created at a time, and does not have the GIL enabled. The following changes have been made: - run-tests.py skips mutation tests on rp2, because there's no GIL. - run-tests.py skips other tests on rp2 that require more than one thread. - The tests stop trying to start a new thread after there is an OSError, which indicates that the system cannot create more threads. - Some of these tests also now run the test function on the main thread, not just the spawned threads. - In some tests the output printing is adjusted so it's the same regardless of how many threads were spawned. - Some time.sleep(1) are replaced with time.sleep(0) to make the tests run a little faster (finish sooner when the work is done). For the most part the tests are unchanged for existing platforms like esp32 and unix. Signed-off-by: Damien George <damien@micropython.org>
2024-01-04tests/run-tests.py: Remove machine_mem.py test from skip list.Damien George
This test was removed long ago in eb0e3bab1ed5aa09e491641f427a5d637fe688bd. Signed-off-by: Damien George <damien@micropython.org>
2023-12-06tests/run-tests.py: Skip Thumb2 tests if target doesn't support them.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-09-29tests/float/float_format_ints.py: Put power-of-10 test in separate file.Damien George
This test doesn't pass on builds with 30-bit floats (object repr C). Signed-off-by: Damien George <damien@micropython.org>
2023-09-01tests/run-tests.py: Capture output of stderr when running on CPython.stephanelsmith
Signed-off-by: stephanelsmith <stephane.smith@titansensor.com>
2023-07-21all: Remove the zlib module.Jim Mussared
This will be replaced with a new deflate module providing the same functionality, with an optional frozen Python wrapper providing a replacement zlib module. binascii.crc32 is temporarily disabled. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-19tests: Rename uasyncio to asyncio.Jim Mussared
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>