aboutsummaryrefslogtreecommitdiff
path: root/tests/extmod
AgeCommit message (Collapse)Author
2020-07-20extmod/modussl: Improve exception error messages.Thorsten von Eicken
This commit adds human readable error messages when mbedtls or axtls raise an exception. Currently often just an EIO error is raised so the user is lost and can't tell whether it's a cert error, buffer overrun, connecting to a non-ssl port, etc. The axtls and mbedtls error raising in the ussl module is modified to raise: OSError(-err_num, "error string") For axtls a small error table of strings is added and used for the second argument of the OSErrer. For mbedtls the code uses mbedtls' built-in strerror function, and if there is an out of memory condition it just produces OSError(-err_num). Producing the error string for mbedtls is conditional on them being included in the mbedtls build, via MBEDTLS_ERROR_C.
2020-06-10extmod/uasyncio: Add asyncio.wait_for_ms function.Damien George
Fixes issue #6107.
2020-06-08extmod/ure: Use single function for match/search/sub.stijn
Saves about 500 bytes on unix x64 and enables CPython-conform usage of passing a re object to these functions.
2020-05-29extmod/vfs: Retain previous working directory if chdir fails.Damien George
Fixes issue #6069.
2020-05-15extmod/vfs_lfsx: Fix import_stat so it takes into account current dir.Damien George
CPython semantics require searching the current directory if the import is not absolute (when "" is in sys.path). Fixes issue #6037.
2020-05-08extmod/vfs_lfsx: Fix rename to respect cur dir for new path.robert
If the new name start with '/', cur_dir is not prepened any more, so that the current working directory is respected. And extend the test cases for rename to cover this functionality.
2020-05-08extmod/vfs_lfsx: Normalize path name in chdir.robert
This change scans for '.', '..' and multiple '/' and normalizes the new path name. If the resulting path does not exist, an error is raised. Non-existing interim path elements are ignored if they are removed during normalization.
2020-05-08extmod/vfs_lfsx: Fix path handling in uos.stat() to consider cur dir.robert
This fixes the bug, that stat(filename) would not consider the current working directory. So if e.g. the cwd is "lib", then stat("main.py") would return the info for "/main.py" instead of "/lib/main.py".
2020-05-02extmod/modbtree: Retain reference to underlying stream so it's not GC'd.Damien George
For ports that have a system malloc which is not garbage collected (eg unix, esp32), the stream object for the DB must be retained separately to prevent it from being reclaimed by the MicroPython GC (because the berkeley-db library uses malloc to allocate the DB structure which stores the only reference to the stream). Although in some cases the user code will explicitly retain a reference to the underlying stream because it needs to call close() on it, this is not always the case, eg in cases where the DB is intended to live forever. Fixes issue #5940.
2020-04-27tests/extmod: Add btree test for errors raised by btree DB library.Damien George
This test now passes given the previous two commits.
2020-04-14extmod/uasyncio: Change cannot to can't in error message, and test exp.Damien George
Follow up to 8e048d2548867aac743866ca5a4c244b7b5aac09 which missed these.
2020-04-13extmod/uasyncio: Add Loop.new_event_loop method.Damien George
This commit adds Loop.new_event_loop() which is used to reset the singleton event loop. This functionality is put here instead of in Loop.close() to make it possible to write code that is compatible with CPython.
2020-04-09tests/extmod: Update littlefs test output to match new library version.Damien George
The amount of free space on the VfsLfs2 filesystem after creating a large file is reduced by 2 blocks in this test.
2020-04-04docs,tests: Add docs and test for uasyncio custom exc handler methods.Damien George
2020-04-02extmod/uasyncio: Implement Loop.stop() to stop the event loop.Damien George
2020-03-30tests: Format all Python code with black, except tests in basics subdir.David Lechner
This adds the Python files in the tests/ directory to be formatted with ./tools/codeformat.py. The basics/ subdirectory is excluded for now so we aren't changing too much at once. In a few places `# fmt: off`/`# fmt: on` was used where the code had special formatting for readability or where the test was actually testing the specific formatting.
2020-03-26tests/extmod: Add uasyncio tests.Damien George
All .exp files are included because they require CPython 3.8 which may not always be available.
2020-03-18extmod/modlwip: Properly handle non-blocking and timeout on UDP recv.Damien George
Fixes UDP non-blocking recv so it returns EAGAIN instead of ETIMEDOUT. Timeout waiting for incoming data is also improved by replacing 100ms delay with poll_sockets(), as is done in other parts of this module. Fixes issue #5759.
2020-03-18extmod/modlwip: Fix polling of UDP socket so it doesn't return HUP.Damien George
STATE_NEW will return HUP when polled so put active UDP sockets into a new state which is different to STATE_NEW. Fixes issue #5758.
2020-02-21extmod/modframebuf: Allow blit source to be a subclass of FrameBuffer.Jim Mussared
2020-02-11tests/run-tests: Auto-skip extmod/ticks_diff, extmod/time_ms_us tests.Yonatan Goldschmidt
2020-01-22tests/extmod: Add basic machine.Timer test.Damien George
2019-12-27tests/extmod: Split out VfsFat finaliser tests to separate test file.Damien George
It tests independent functionality and may need to be skipped for a given port.
2019-12-13tests/extmod/vfs_lfs_error: Use small ints in seek error test.Damien George
So accessing the seek offset (at the C level) doesn't cause an OverflowError on 32-bit targets.
2019-11-13py/objdict: Support ujson.dump() of OrderedDict objects.Andrew Leech
Following CPython, OrderedDict are dumped with the syntax of dict.
2019-10-31tests/extmod: Add test for ussl when passing in key/cert params.Damien George
2019-10-31extmod/modlwip: Make socket poll return POLLNVAL in case of bad file.Damien George
2019-10-29extmod/vfs: Rename BP_IOCTL_xxx constants to MP_BLOCKDEV_IOCTL_xxx.Damien George
Also rename SEC_COUNT to BLOCK_COUNT and SEC_SIZE to BLOCK_SIZE.
2019-10-29tests/extmod: Add test for blockdev with standard and extended protocol.Damien George
2019-10-29tests/extmod: Add littlefs tests.Damien George
2019-10-18extmod/re1.5: Support escaping within RE classes.Jim Mussared
Fixes issues #3178 and #5220. Tests are added, including all the cases mentioned in both bugs.
2019-08-22tests/extmod: Split json.loads of bytes/bytearray into separate test.Damien George
Because this functionality was introduced in Python 3.6.
2019-08-22extmod/modujson: Support passing bytes/bytearray to json.loads.Damien George
CPython allows this, and it can be useful to reduce the number of memory allocations. Fixes issue #5031.
2019-08-19extmod/modure: Make regex dump-code debugging feature optional.Damien George
Enabled via MICROPY_PY_URE_DEBUG, disabled by default (but enabled on unix coverage build). This is a rarely used feature that costs a lot of code (500-800 bytes flash). Debugging of regular expressions can be done offline with other tools.
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-05-14extmod/modujson: Handle parsing of floats with + in the exponent.Damien George
Fixes issue #4780.
2019-05-06extmod/moducryptolib: Add AES-CTR support.Yonatan Goldschmidt
Selectable at compile time via MICROPY_PY_UCRYPTOLIB_CTR. Disabled by default.
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-03-27tests/extmod: Add test for FAT filesystem on a very large block device.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`.
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-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-23tests/extmod/uctypes_sizeof_layout: Test for sizeof of different layout.Paul Sokolovsky
On almost all realistic platforms, native layout should be larger (or equal) than packed layout.
2018-10-13tests/uctypes_sizeof_od: Test for using OrderedDict as struct descriptorPaul Sokolovsky
Just a copy of uctypes_sizeof.py with minimal changes.
2018-10-05tests/uselect_poll_basic: Add basic test for uselect.poll invariants.Paul Sokolovsky
This test doesn't check the actual I/O behavior, just "static" invariants like behavior on duplicate calls or calls when I/O object is not registered with poller.
2018-09-11tests/extmod/uhashlib_md5: Add coverage tests for MD5 algorithm.Paul Sokolovsky
Based on tests/extmod/uhashlib_sha1.
2018-08-04tests: Make tests work on targets without float support.Ayke van Laethem