summaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2019-08-15tests/misc/sys_atexit: Add test for new sys.atexit feature.Milan Rossa
2019-08-06py: Allow to pass in read-only buffers to viper and inline-asm funcs.Damien George
Fixes #4936.
2019-07-31tests: Add tests for overriding builtins.__import__.Damien George
2019-07-31py/builtinimport: Populate __file__ when importing frozen or mpy files.Paul m. p. P
Note that bytecode already includes the source filename as a qstr so there is no additional memory used by the interning operation here.
2019-07-30py/objdict: Quote non-string types when used as keys in JSON output.Eric Poulsen
JSON requires that keys of objects be strings. CPython will therefore automatically quote simple types (NoneType, bool, int, float) when they are used directly as keys in JSON output. To prevent subtle bugs and emit compliant JSON, MicroPython should at least test for such keys so they aren't silently let through. Then doing the actual quoting is a similar cost to raising an exception, so that's what is implemented by this patch. Fixes issue #4790.
2019-07-19tests/run-perfbench.py: Add --emit option to select emitter for tests.Damien George
2019-07-17tests/stress/recursive_iternext.py: Increase large depth to 5000.Damien George
So it fails correctly on Linux with clang.
2019-06-28tests/perf_bench: Add some viper performance benchmarks.Damien George
To test raw viper function call overhead: function entry, exit and conversion of arguments to/from objects.
2019-06-28tests/perf_bench: Add some miscellaneous performance benchmarks.Damien George
misc_aes.py and misc_mandel.py are adapted from sources in this repository. misc_pystone.py is the standard Python pystone test. misc_raytrace.py is written from scratch.
2019-06-28tests/perf_bench: Add some benchmarks from python-performance.Damien George
From https://github.com/python/pyperformance commit 6690642ddeda46fc5ee6e97c3ef4b2f292348ab8
2019-06-28tests: Add performance benchmarking test-suite framework.Damien George
This benchmarking test suite is intended to be run on any MicroPython target. As such all tests are parameterised with N and M: N is the approximate CPU frequency (in MHz) of the target and M is the approximate amount of heap memory (in kbytes) available on the target. When running the benchmark suite these parameters must be specified and then each test is tuned to run on that target in a reasonable time (<1 second). The test scripts are not standalone: they require adding some extra code at the end to run the test with the appropriate parameters. This is done automatically by the run-perfbench.py script, in such a way that imports are minimised (so the tests can be run on targets without filesystem support). To interface with the benchmarking framework, each test provides a bm_params dict and a bm_setup function, with the later taking a set of parameters (chosen based on N, M) and returning a pair of functions, one to run the test and one to get the results. When running the test the number of microseconds taken by the test are recorded. Then this is converted into a benchmark score by inverting it (so higher number is faster) and normalising it with an appropriate factor (based roughly on the amount of work done by the test, eg number of iterations). Test outputs are also compared against a "truth" value, computed by running the test with CPython. This provides a basic way of making sure the test actually ran correctly. Each test is run multiple times and the results averaged and standard deviation computed. This is output as a summary of the test. To make comparisons of performance across different runs the run-perfbench.py script also includes a diff mode that reads in the output of two previous runs and computes the difference in performance. Reports are given as a percentage change in performance with a combined standard deviation to give an indication if the noise in the benchmarking is less than the thing that is being measured. Example invocations for PC, pyboard and esp8266 targets respectively: $ ./run-perfbench.py 1000 1000 $ ./run-perfbench.py --pyboard 100 100 $ ./run-perfbench.py --pyboard --device /dev/ttyUSB0 50 25
2019-06-28tests: Rename "bench" tests to "internal_bench" and run-internalbench.pyDamien George
To emphasise these benchmark tests compare the internal performance of features amongst themselves, rather than absolute performance testing.
2019-05-21py/objarray: Add decode method to bytearray.stijn
Reuse the implementation for bytes since it works the same way regardless of the underlying type. This method gets added for CPython compatibility of bytearray, but to keep the code simple and small array.array now also has a working decode method, which is non-standard but doesn't hurt.
2019-05-14tests/basics: Add coverage tests for memoryview attributes.Damien George
2019-05-14py/objarray: Add support for memoryview.itemsize attribute.stijn
This allows figuring out the number of bytes in the memoryview object as len(memview) * memview.itemsize. The feature is enabled via MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE and is disabled by default.
2019-05-14tests/pyb: Update UART expected output now that default timeout is 0.Damien George
Follow up to commit 34942d0a72980173eca51b201f271f67bcae46b5
2019-05-14extmod/modujson: Handle parsing of floats with + in the exponent.Damien George
Fixes issue #4780.
2019-05-09py/objgenerator: Fix handling of None passed as 2nd arg to throw().Damien George
Fixes issue #4527.
2019-05-06extmod/moducryptolib: Add AES-CTR support.Yonatan Goldschmidt
Selectable at compile time via MICROPY_PY_UCRYPTOLIB_CTR. Disabled by default.
2019-05-03unix/coverage: Add test for printing literal % character.Damien George
2019-05-03tests/basics/sys1.py: Add test for calling sys.exit() without any args.Damien George
2019-05-03py/native: Improve support for bool type in viper functions.Damien George
Variables with type bool now act more like an int, and there is proper casting to/from Python objects.
2019-04-30tests/ussl_basic: Disable setblocking() calls.Paul Sokolovsky
Now that setblocking() is implemented in modussl_axtls, it calls into the underlying stream object, and io.BytesIO doesn't have setblocking().
2019-04-30extmod/modussl_axtls: Add non-blocking mode support.Paul Sokolovsky
It consists of: 1. "do_handhake" param (default True) to wrap_socket(). If it's False, handshake won't be performed by wrap_socket(), as it would be done in blocking way normally. Instead, SSL socket can be set to non-blocking mode, and handshake would be performed before the first read/write request (by just returning EAGAIN to these requests, while instead reading/writing/ processing handshake over the connection). Unfortunately, axTLS doesn't really support non-blocking handshake correctly. So, while framework for this is implemented on MicroPython's module side, in case of axTLS, it won't work reliably. 2. Implementation of .setblocking() method. It must be called on SSL socket for blocking vs non-blocking operation to be handled correctly (for example, it's not enough to wrap non-blocking socket with wrap_socket() call - resulting SSL socket won't be itself non-blocking). Note that .setblocking() propagates call to the underlying socket object, as expected.
2019-04-28tests: Skip tests needing machine module if (u)machine doesn't exist.Damien George
2019-04-18tests/micropython: Add some tests for failed heap allocation.Damien George
This adds tests for some locations in the code where a memory allocation should raise an exception.
2019-04-04tests/run-tests: Ignore exception in process kill when ending repl test.stijn
When running Linux on WSL, Popen.kill() can raise a ProcessLookupError if the process does not exist anymore, which can happen here since the previous statement already tries to close the process by sending Ctrl-D to the running repl. This doesn't seem to be a problem on other OSes, so just swallow the exception silently since it indicates the process has been closed already, which after all is what we want.
2019-03-27tests/extmod: Add test for FAT filesystem on a very large block device.Damien George
2019-03-26py/scheduler: Convert micropythyon.schedule() to a circular buffer.Andrew Leech
This means the schedule operates on a first-in, first-executed manner rather than the current last-in, first executed.
2019-03-08tests/import: Add test for importing x64 native code.Damien George
2019-03-08tests/run-tests: Support running native tests via mpy.Damien George
2019-03-05py/persistentcode: Add a qstr window to save mpy files more efficiently.Damien George
This is an implementation of a sliding qstr window used to reduce the number of qstrs stored in a .mpy file. The window size is configured to 32 entries which takes a fixed 64 bytes (16-bits each) on the C stack when loading/saving a .mpy file. It allows to remember the most recent 32 qstrs so they don't need to be stored again in the .mpy file. The qstr window uses a simple least-recently-used mechanism to discard the least recently used qstr when the window overflows (similar to dictionary compression). This scheme only needs a single pass to save/load the .mpy file. Reduces mpy file size by about 25% with a window size of 32.
2019-03-05py: Replace POP_BLOCK and POP_EXCEPT opcodes with POP_EXCEPT_JUMP.Damien George
POP_BLOCK and POP_EXCEPT are now the same, and are always followed by a JUMP. So this optimisation reduces code size, and RAM usage of bytecode by two bytes for each try-except handler.
2019-03-05py: Fix VM crash with unwinding jump out of a finally block.Damien George
This patch fixes a bug in the VM when breaking within a try-finally. The bug has to do with executing a break within the finally block of a try-finally statement. For example: def f(): for x in (1,): print('a', x) try: raise Exception finally: print(1) break print('b', x) f() Currently in uPy the above code will print: a 1 1 1 segmentation fault (core dumped) micropython Not only is there a seg fault, but the "1" in the finally block is printed twice. This is because when the VM executes a finally block it doesn't really know if that block was executed due to a fall-through of the try (no exception raised), or because an exception is active. In particular, for nested finallys the VM has no idea which of the nested ones have active exceptions and which are just fall-throughs. So when a break (or continue) is executed it tries to unwind all of the finallys, when in fact only some may be active. It's questionable whether break (or return or continue) should be allowed within a finally block, because they implicitly swallow any active exception, but nevertheless it's allowed by CPython (although almost never used in the standard library). And uPy should at least not crash in such a case. The solution here relies on the fact that exception and finally handlers always appear in the bytecode after the try body. Note: there was a similar bug with a return in a finally block, but that was previously fixed in b735208403a54774f9fd3d966f7c1a194c41870f
2019-02-26py/compile: Fix handling of unwinding BaseException in async with.Damien George
All exceptions that unwind through the async-with must be caught and BaseException is the top-level class, which includes Exception and others. Fixes issue #4552.
2019-02-21tests/basics: Add tests for try-except-else and try-except-else-finally.Damien George
2019-02-14extmod/moduwebsocket: Refactor `websocket` to `uwebsocket`.Yonatan Goldschmidt
As mentioned in #4450, `websocket` was experimental with a single intended user, `webrepl`. Therefore, we'll make this change without a weak link `websocket` -> `uwebsocket`.
2019-01-27py: Add optional support for 2-argument version of built-in next().stijn
Configurable via MICROPY_PY_BUILTINS_NEXT2, disabled by default.
2018-12-13tests/basics/special_methods2: Typo fix in comment.Paul Sokolovsky
2018-12-10tests/extmod/uctypes_error: Add test for unsupported unary op.Damien George
2018-12-10tests/extmod/uctypes_ptr_le: Test int() operation on a pointer field.Paul Sokolovsky
2018-12-07tests/basics/special_methods: Add testcases for __int__.Paul Sokolovsky
2018-12-06py/objboundmeth: Support loading generic attrs from the method.Damien George
Instead of assuming that the method is a bytecode object, and only supporting load of __name__, make the operation generic by delegating the load to the method object itself. Saves a bit of code size and fixes the case of attempting to load __name__ on a native method, see issue #4028.
2018-12-05stm32/uart: Add rxbuf keyword arg to UART constructor and init method.Damien George
As per the machine.UART documentation, this is used to set the length of the RX buffer. The legacy read_buf_len argument is retained for backwards compatibility, with rxbuf overriding it if provided.
2018-12-04stm32/uart: Always show the flow setting when printing a UART object.Damien George
Also change the order of printing of flow so it is after stop (so bits, parity, stop are one after the other), and reduce code size by using mp_print_str instead of mp_printf where possible. See issue #1981.
2018-11-26tests/io: Update tests to use uos.remove() instead of uos.unlink().Paul Sokolovsky
After Unix port switches from one to another, to be consistent with baremetal ports.
2018-11-26py/unicode: Fix check for valid utf8 being stricter about contn chars.Damien George
2018-11-01tests/import_long_dyn: Test for "import *" of a long dynamic name.Paul Sokolovsky
Such names aren't stored as qstr in module dict, and there was a bug in "import *" handling which assumed any name in a module dict is a qstr.
2018-10-30tests/extmod: Skip uselect test when CPython doesn't have poll().stijn
CPython does not have an implementation of select.poll() on some operating systems (Windows, OSX depending on version) so skip the test in those cases instead of failing it.
2018-10-28py/compile: Fix case of eager implicit conversion of local to nonlocal.Damien George
This ensures that implicit variables are only converted to implicit closed-over variables (nonlocals) at the very end of the function scope. If variables are closed-over when first used (read from, as was done prior to this commit) then this can be incorrect because the variable may be assigned to later on in the function which means they are just a plain local, not closed over. Fixes issue #4272.