Commit Graph

388 Commits

Author SHA1 Message Date
Damien George 22806ed5df extmod/vfs: Retain previous working directory if chdir fails.
Fixes issue #6069.
2020-05-29 23:05:01 +10:00
Damien George 7dffbfd22a extmod/vfs_lfsx: Fix import_stat so it takes into account current dir.
CPython semantics require searching the current directory if the import is
not absolute (when "" is in sys.path).

Fixes issue #6037.
2020-05-15 11:31:32 +10:00
robert 0f83ef395c extmod/vfs_lfsx: Fix rename to respect cur dir for new path.
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-08 21:54:04 +10:00
robert d3ea28d04a extmod/vfs_lfsx: Normalize path name in chdir.
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-08 21:52:15 +10:00
robert a5ea4b9f3f extmod/vfs_lfsx: Fix path handling in uos.stat() to consider cur dir.
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-08 21:37:51 +10:00
Damien George 73c58150f5 extmod/modbtree: Retain reference to underlying stream so it's not GC'd.
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-05-02 16:08:04 +10:00
Damien George 4fa6d939d6 tests/extmod: Add btree test for errors raised by btree DB library.
This test now passes given the previous two commits.
2020-04-27 23:59:09 +10:00
Damien George 5f0661b4fe extmod/uasyncio: Change cannot to can't in error message, and test exp.
Follow up to 8e048d2548 which missed these.
2020-04-14 21:51:25 +10:00
Damien George db137e70dc extmod/uasyncio: Add Loop.new_event_loop method.
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-13 22:16:52 +10:00
Damien George a5f2ae10fe tests/extmod: Update littlefs test output to match new library version.
The amount of free space on the VfsLfs2 filesystem after creating a large
file is reduced by 2 blocks in this test.
2020-04-09 15:59:28 +10:00
Damien George df156b18e5 docs,tests: Add docs and test for uasyncio custom exc handler methods. 2020-04-04 10:47:48 +11:00
Damien George b389bc0afa extmod/uasyncio: Implement Loop.stop() to stop the event loop. 2020-04-02 00:14:18 +11:00
David Lechner 3dc324d3f1 tests: Format all Python code with black, except tests in basics subdir.
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-30 13:21:58 +11:00
Damien George c4935f3049 tests/extmod: Add uasyncio tests.
All .exp files are included because they require CPython 3.8 which may not
always be available.
2020-03-26 01:25:45 +11:00
Damien George 8f0778b209 extmod/modlwip: Properly handle non-blocking and timeout on UDP recv.
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-18 10:51:32 +11:00
Damien George 00267aae0b extmod/modlwip: Fix polling of UDP socket so it doesn't return HUP.
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-03-18 10:49:27 +11:00
Jim Mussared f8449dd092 extmod/modframebuf: Allow blit source to be a subclass of FrameBuffer. 2020-02-21 13:32:48 +11:00
Yonatan Goldschmidt 0852acfc74 tests/run-tests: Auto-skip extmod/ticks_diff, extmod/time_ms_us tests. 2020-02-11 10:56:49 +11:00
Damien George cfddc6a8c7 tests/extmod: Add basic machine.Timer test. 2020-01-22 17:31:18 +11:00
Damien George 99a04b8060 tests/extmod: Split out VfsFat finaliser tests to separate test file.
It tests independent functionality and may need to be skipped for a given
port.
2019-12-27 12:30:51 +11:00
Damien George 7280bf40d9 tests/extmod/vfs_lfs_error: Use small ints in seek error test.
So accessing the seek offset (at the C level) doesn't cause an
OverflowError on 32-bit targets.
2019-12-13 15:59:08 +11:00
Andrew Leech 1e87f11d3f py/objdict: Support ujson.dump() of OrderedDict objects.
Following CPython, OrderedDict are dumped with the syntax of dict.
2019-11-13 13:51:18 +11:00
Damien George 43f53a2bbd tests/extmod: Add test for ussl when passing in key/cert params. 2019-10-31 16:38:20 +11:00
Damien George feaa251674 extmod/modlwip: Make socket poll return POLLNVAL in case of bad file. 2019-10-31 12:54:37 +11:00
Damien George cfe1c5abf8 extmod/vfs: Rename BP_IOCTL_xxx constants to MP_BLOCKDEV_IOCTL_xxx.
Also rename SEC_COUNT to BLOCK_COUNT and SEC_SIZE to BLOCK_SIZE.
2019-10-29 14:17:29 +11:00
Damien George 7c8fb27f38 tests/extmod: Add test for blockdev with standard and extended protocol. 2019-10-29 14:17:29 +11:00
Damien George 73fddb84e5 tests/extmod: Add littlefs tests. 2019-10-29 14:17:29 +11:00
Jim Mussared ebf8332104 extmod/re1.5: Support escaping within RE classes.
Fixes issues #3178 and #5220.

Tests are added, including all the cases mentioned in both bugs.
2019-10-18 12:20:32 +11:00
Damien George 2eb88f5df7 tests/extmod: Split json.loads of bytes/bytearray into separate test.
Because this functionality was introduced in Python 3.6.
2019-08-22 15:45:13 +10:00
Damien George 2dfa69efbb extmod/modujson: Support passing bytes/bytearray to json.loads.
CPython allows this, and it can be useful to reduce the number of memory
allocations.

Fixes issue #5031.
2019-08-22 15:32:26 +10:00
Damien George 7d851a27f1 extmod/modure: Make regex dump-code debugging feature optional.
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-08-19 16:43:00 +10:00
Eric Poulsen 01054f2092 py/objdict: Quote non-string types when used as keys in JSON output.
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-30 16:34:27 +10:00
Damien George 7c5cf59f8b extmod/modujson: Handle parsing of floats with + in the exponent.
Fixes issue #4780.
2019-05-14 14:45:54 +10:00
Yonatan Goldschmidt ef9843653b extmod/moducryptolib: Add AES-CTR support.
Selectable at compile time via MICROPY_PY_UCRYPTOLIB_CTR.  Disabled by
default.
2019-05-06 18:09:48 +10:00
Paul Sokolovsky 7b5400134b tests/ussl_basic: Disable setblocking() calls.
Now that setblocking() is implemented in modussl_axtls, it calls into the
underlying stream object, and io.BytesIO doesn't have setblocking().
2019-04-30 17:27:28 +10:00
Paul Sokolovsky c76445315f extmod/modussl_axtls: Add non-blocking mode support.
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-30 17:26:37 +10:00
Damien George ca39ea7cef tests: Skip tests needing machine module if (u)machine doesn't exist. 2019-04-28 22:12:17 +10:00
Damien George 968b688055 tests/extmod: Add test for FAT filesystem on a very large block device. 2019-03-27 10:22:38 +11:00
Radomir Dopieralski 20a787adb4 extmod/ure: Handle some escape sequences.
Fix MicroPython #3176

Handle escape sequences inside regular expressions. This adds
handling for \a, \b, \f, \n, \r, \v and \\.
2019-02-14 15:42:25 +01:00
Damien George b9dc23c070 extmod/modure: Add ure.sub() function and method, and tests.
This feature is controlled at compile time by MICROPY_PY_URE_SUB, disabled
by default.

Thanks to @dmazzella for the original patch for this feature; see #3770.
2019-02-14 15:42:22 +01:00
Damien George cbeac094ef extmod/modure: Add match.span(), start() and end() methods, and tests.
This feature is controlled at compile time by
MICROPY_PY_URE_MATCH_SPAN_START_END, disabled by default.

Thanks to @dmazzella for the original patch for this feature; see #3770.
2019-02-14 15:42:21 +01:00
Damien George a24fabbb6f extmod/modure: Add match.groups() method, and tests.
This feature is controlled at compile time by MICROPY_PY_URE_MATCH_GROUPS,
disabled by default.

Thanks to @dmazzella for the original patch for this feature; see #3770.
2019-02-14 15:42:19 +01:00
Yonatan Goldschmidt bc4f8b438b extmod/moduwebsocket: Refactor `websocket` to `uwebsocket`.
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-02-14 00:35:45 +11:00
Damien George 074597f172 tests/extmod/uctypes_error: Add test for unsupported unary op. 2018-12-10 14:29:41 +11:00
Paul Sokolovsky 0de6815ec1 tests/extmod/uctypes_ptr_le: Test int() operation on a pointer field. 2018-12-10 14:25:06 +11:00
stijn 06643a0df4 tests/extmod: Skip uselect test when CPython doesn't have poll().
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-30 14:49:23 +11:00
Paul Sokolovsky c638d86660 tests/extmod/uctypes_sizeof_layout: Test for sizeof of different layout.
On almost all realistic platforms, native layout should be larger (or
equal) than packed layout.
2018-10-23 11:33:35 +11:00
Paul Sokolovsky 7059b4af6d tests/uctypes_sizeof_od: Test for using OrderedDict as struct descriptor
Just a copy of uctypes_sizeof.py with minimal changes.
2018-10-13 16:08:25 +11:00
Paul Sokolovsky 6ef783527d tests/uselect_poll_basic: Add basic test for uselect.poll invariants.
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-10-05 16:57:40 +10:00
Paul Sokolovsky b6ebb4f04e tests/extmod/uhashlib_md5: Add coverage tests for MD5 algorithm.
Based on tests/extmod/uhashlib_sha1.
2018-09-11 14:52:00 +10:00
Noralf Trønnes 39ee12d1ac Fix os.stat() to use 1970 epoch
Commit 95e70cd0ea 'time: Use 1970 epoch' changed epoch for the time
module, but not for other users. This patch does the same for the only
other core timeutils user: extmod/vfs_fat.c:fat_vfs_stat().
Other timeutils users: cc3200, esp8266 and stm32, are not changed.

Ports that don't use long ints, will still get wrong time values from
os.stat().
2018-08-25 20:43:02 +02:00
Ayke van Laethem 6572029dc0 tests: Make tests work on targets without float support. 2018-08-04 15:14:23 +10:00
Damien George 571295d090 tests/extmod/ujson_dump_iobase.py: Return number of bytes written.
Otherwise returning None indicates that the write would block and nothing
was actually written.  Fixes issue #3990.
2018-07-30 12:05:48 +10:00
Ayke van Laethem 7c98c6b053
tests: Improve feature detection for VFS. 2018-07-20 00:50:57 +02:00
Dan Halbert 7c219600a2 WIP: after merge; before testing 2018-07-11 16:45:30 -04:00
Damien George e30a5fc7bc extmod/modure: Add ure.sub() function and method, and tests.
This feature is controlled at compile time by MICROPY_PY_URE_SUB, disabled
by default.

Thanks to @dmazzella for the original patch for this feature; see #3770.
2018-07-02 14:55:02 +10:00
Damien George 1e9b871d29 extmod/modure: Add match.span(), start() and end() methods, and tests.
This feature is controlled at compile time by
MICROPY_PY_URE_MATCH_SPAN_START_END, disabled by default.

Thanks to @dmazzella for the original patch for this feature; see #3770.
2018-07-02 14:54:56 +10:00
Damien George 1f86460910 extmod/modure: Add match.groups() method, and tests.
This feature is controlled at compile time by MICROPY_PY_URE_MATCH_GROUPS,
disabled by default.

Thanks to @dmazzella for the original patch for this feature; see #3770.
2018-07-02 14:53:30 +10:00
Paul Sokolovsky bb634115fc tests/extmod/ucryptolib*: Add into and inplace tests for ucryptolib.
Tests for separate input and output buffer (alloc-free operation) and
the same writable buffer used as input and output (inplace operation).
2018-06-27 14:56:46 +10:00
Paul Sokolovsky bf77f34819 tests/extmod/ucryptolib*: Add tests for ucryptolib module. 2018-06-27 14:56:31 +10:00
Damien George 48829cd3c6 tests/extmod: Add test for ujson.dump writing to a user IOBase object. 2018-06-18 12:35:56 +10:00
Damien George 0ecce77c66 tests/extmod/ujson_dump.py: Add test for dump to non-stream object. 2018-06-18 12:35:56 +10:00
Dan Halbert fa814a32ce Make Trinket M0 build fit; make RAMFS in vfs_fat_* tests be compliant with expected API 2018-06-14 21:02:12 -04:00
Damien George c901cc6862 tests/extmod: Add test for VFS and user-defined filesystem and files. 2018-06-12 12:29:26 +10:00
Damien George 5ef0d2ab14 tests/extmod: Remove conditional import of uos_vfs, it no longer exists.
This conditional import was only used to get the tests working on the unix
coverage build, which has now switched to use VFS by default so the uos
module alone has the required functionality.
2018-06-06 14:28:23 +10:00
Damien George 6c02da2eec tests/extmod: Add test for importing a script from a user VFS. 2018-06-06 14:28:23 +10:00
Jeff Epler b2084d37d6 tests: add new tests for uhashlib differences
.. these tests currently fail, but a subsequent commit will
fix them
2018-05-06 12:31:53 -05:00
Jeff Epler e7f463320f tests: Add new tests for ubinascii differences
.. some of these tests currently fail, but a subsequent commit will
fix them.
2018-04-30 20:06:29 -05:00
Jeff Epler fe7f405fc7 Add VfsFat.label property
These allow accessing the filesystem label.  For instance,
in boot.py, you can set the label on the built-in storage with:
   storage.remount('/', False)
   storage.getmount('/').label = "NEWLABEL"
   storage.remount('/', True)

Users with multiple CIRCUITPY boards may find it desirable to
choose a different label for each board they own.
2018-03-27 21:28:18 -05:00
Ayke van Laethem fa55b15ac6 extmod/vfs_fat_file: Implement SEEK_CUR for non-zero offset.
CPython doesn't allow SEEK_CUR with non-zero offset for files in text mode,
and uPy inherited this behaviour for both text and binary files.  It makes
sense to provide full support for SEEK_CUR of binary-mode files in uPy, and
to do this in a minimal way means also allowing to use SEEK_CUR with
non-zero offsets on text-mode files.  That seems to be a fair compromise.
2018-03-23 09:19:56 -05:00
Tom Collins 4d3a92c67c extmod/vfs_fat: Add file size as 4th element of uos.ilistdir tuple. 2018-03-12 12:26:36 +11:00
Damien George 0acf868bb7 tests/extmod/time_ms_us: Fix ticks tests, ticks_diff args are reversed. 2018-03-04 00:38:15 +11:00
Damien George e3d11b6a6e tests/extmod/time_ms_us: Add test for calling ticks_cpu().
This is just to test that the function exists and returns some kind of
valid value.  Although this file is for testing ms/us functions, put the
ticks_cpu() test here so not to add a new test file.
2018-03-04 00:17:33 +11:00
Damien George 90e719a232 tests/extmod/vfs_fat_fileio1: Add test for calling file obj finaliser. 2018-02-28 15:27:51 +11:00
Damien George 4c2230add8 tests/extmod/uzlib_decompress: Add uzlib tests to improve coverage. 2018-02-26 13:36:55 +11:00
Damien George a604451566 tests/extmod/vfs_fat_fileio1: Add test for failing alloc with finaliser. 2018-02-26 13:36:13 +11:00
Damien George d9bca1f7bd extmod/modujson: Implement ujson.dump() function. 2018-02-15 11:35:42 +11:00
Ayke van Laethem 7642785881 extmod/vfs_fat_file: Implement SEEK_CUR for non-zero offset.
CPython doesn't allow SEEK_CUR with non-zero offset for files in text mode,
and uPy inherited this behaviour for both text and binary files.  It makes
sense to provide full support for SEEK_CUR of binary-mode files in uPy, and
to do this in a minimal way means also allowing to use SEEK_CUR with
non-zero offsets on text-mode files.  That seems to be a fair compromise.
2018-01-31 17:33:07 +11:00
Damien George d35c6ffc84 tests/extmod: Add some uctypes tests to improve coverage of that module. 2017-12-19 16:48:41 +11:00
Damien George 251b00457c tests/extmod/uhashlib_sha256: Add test for hashing 56 bytes of data. 2017-12-19 14:46:31 +11:00
Damien George 46b35356e1 extmod/modframebuf: Add 8-bit greyscale format (GS8). 2017-12-14 17:36:13 +11:00
Petr Viktorin 34247465c3 extmod/modframebuf: Add 2-bit color format (GS2_HMSB).
This format is used in 2-color LED matrices and in e-ink displays like
SSD1606.
2017-12-14 17:13:02 +11:00
Damien George 3c28df1658 tests/extmod: Add test which subclasses framebuf.FrameBuffer. 2017-12-12 16:48:09 +11:00
Damien George 98dd126e98 tests/extmod: Add test for '-' in character class in regex. 2017-10-05 11:33:49 +11:00
Paul Sokolovsky 8e0b9f495b tests/extmod: Add test for ure regexes leading to infinite recursion.
These now should be caught properly and lead to RuntimeError instead of
crash.
2017-10-03 00:24:32 +03:00
Alex Robbins c89254fd0f extmod/modubinascii: Rewrite mod_binascii_a2b_base64.
This implementation ignores invalid characters in the input. This allows
it to decode the output of b2a_base64, and also mimics the behavior of
CPython.
2017-08-17 09:25:51 +03:00
Paul Sokolovsky 4368ae3142 extmod/modussl_axtls: Allow to close ssl stream multiple times.
Make sure that 2nd close has no effect and operations on closed streams
are handled properly.
2017-07-20 00:20:53 +03:00
Damien George b86c65d31c extmod/modubinascii: Add check for empty buffer passed to hexlify.
Previous to this patch hexlify(b'', b':') would lead to a bad crash due to
the computed length of the result being -1=0xffffffff.
2017-07-03 14:52:00 +10:00
Paul Sokolovsky 58b7b01cb5 extmod/modure: If input string is bytes, return bytes results too.
This applies to match.group() and split().

For ARM Thumb2, this increased code size by 12 bytes.
2017-07-01 01:25:45 +03:00
Damien George f55dcddbc7 tests/extmod/vfs_basic: Allow test to pass on embedded targets. 2017-06-11 22:56:27 +10:00
Paul Sokolovsky 85d809d1f4 tests: Convert remaining "sys.exit()" to "raise SystemExit". 2017-06-10 20:34:38 +03:00
Damien George f6ef8e3f17 extmod/vfs: Allow to statvfs the root directory. 2017-06-07 15:17:45 +10:00
Paul Sokolovsky 054a381d7c tests/extmod/vfs_fat_more: Make skippable is uos is not available.
Fixes Zephyr tests.
2017-05-13 14:13:53 +03:00
Damien George cda09727b4 tests/extmod/vfs_fat: Add test for ilistdir of a non-existent directory. 2017-05-13 19:10:15 +10:00
Damien George 852c215d76 tests/extmod/vfs: Update tests to reflect new ilistdir() method. 2017-05-10 11:39:29 +10:00
Damien George 9bd67d9fbc tests/extmod: Make some vfs tests fully unmount FSs before running.
Otherwise the existing FSs can interfere with the tests, and in some
cases the tests can write to the real FS on the device.
2017-05-09 15:50:40 +10:00
Damien George 1b3e372418 tests/extmod: Add some more VFS tests. 2017-05-05 20:15:10 +10:00
Damien George 6c8b57a902 tests/extmod: Add more tests for VFS FAT. 2017-05-05 20:15:10 +10:00
Paul Sokolovsky 9e8f316392 extmod/moductypes: Fix bigint handling for 32-bit ports. 2017-04-21 16:43:21 +03:00
Damien George 61616e84ce extmod/machine_signal: Rename "inverted" arg to "invert", it's shorter.
A shorter name takes less code size, less room in scripts and is faster to
type at the REPL.

Tests and HW-API examples are updated to reflect the change.
2017-04-15 21:01:47 +03:00
Damien George 967cad7434 tests/extmod/utimeq1: Improve coverage of utimeq module. 2017-04-13 23:34:28 +10:00
Peter Hinch 468c6f9da1 extmod/modframebuf: Make monochrome bitmap formats start with MONO_.
MONO_xxx is much easier to read if you're not familiar with the code.
MVLSB is deprecated but kept for backwards compatibility, for the time
being.

This patch also updates the associated docs and tests.
2017-04-04 17:38:33 +10:00
Paul Sokolovsky 499ea8b253 tests/extmod/vfs_fat_fileio*: Improve skippability.
Should be skipped on missing uso, uerrno modules.
2017-04-03 00:14:57 +03:00
Paul Sokolovsky b9e9cfcfc1 tests: vfs_fat_fileio.py is too big to be parsed in 16K heap, split in 2.
This restores ability to run testsuite with 16K heap.
2017-04-02 22:02:11 +03:00
Peter Hinch 231cfc84a7 extmod/modframebuf: Add support for monochrome horizontal format.
MHLSB and MHMSB formats are added to the framebuf module, which have 8
adjacent horizontal pixels represented in a single byte.
2017-03-20 16:21:47 +11:00
Rami Ali 8a57cacd78 tests/extmod: Improve tinfgzip.c test coverage. 2017-03-14 22:13:36 +11:00
Damien George a49a96bb5d tests/extmod/vfs_basic: Unmount all existing devices before doing test.
This is so the test can run successfully on targets that already have
something mounted.
2017-03-14 22:08:37 +11:00
Rami Ali 4e86ca398f tests/extmod: Improve re1.5/recursiveloop.c test coverage. 2017-03-14 17:17:45 +11:00
Damien George 773b0bac41 tests/extmod/vfs_basic: Add more tests for basic VFS functionality. 2017-03-14 16:07:30 +11:00
Damien George 8891b2e700 tests/extmod: Add a test for core VFS functionality, sans any filesystem. 2017-03-13 21:42:02 +11:00
Damien George f07a56fa3b tests/extmod: Rename websocket test to websocket_basic.
This is so that the filename of the test doesn't clash with the module name
itself (being "websocket"), and lead to potential problems executing the
test.
2017-03-10 15:05:08 +11:00
Alex March ce0b5e078b tests/extmod: Add websocket tests.
These short unit tests test the base uPy methods as well as parts of the
websocket protocol, as implemented by uPy.

@dpgeorge converted the original socket based tests by @hosaka to ones
that only require io.BytesIO.
2017-03-09 16:47:41 +11:00
Damien George 38f063ea72 tests/extmod: Add very basic feature test for ussl module.
This test just tests that the basic functions/methods can be called with
the appropriate arguments.  There is no real test of underlying
functionality.

Thanks to @hosaka for the initial implementation of this test.
2017-03-09 13:42:34 +11:00
Paul Sokolovsky bdd48e67ee tests/uctypes_array_assign_native_le: Split off intbig part. 2017-03-07 08:40:03 +01:00
Damien George ecc635d551 tests/extmod: Add test for machine.Signal class. 2017-03-02 16:09:16 +11:00
Paul Sokolovsky f2d732f459 tests/extmod: Make tests skippable. 2017-02-15 01:56:22 +03:00
Paul Sokolovsky d5e9ab6e61 extmod/machine_pulse: Make time_pulse_us() not throw exceptions.
machine.time_pulse_us() is intended to provide very fine timing, including
while working with signal bursts, where each transition is tracked in row.
Throwing and handling an exception may take too much time and "signal loss".
So instead, in case of a timeout, just return negative value. Cases of
timeout while waiting for initial signal stabilization, and during actual
timing, are recognized.

The documentation is updated accordingly, and rewritten somewhat to clarify
the function behavior.
2017-02-05 14:20:17 +03:00
Damien George a0c729681f tests/extmod/vfs_fat_ramdisk: Make it work on pyboard. 2017-01-27 23:22:15 +11:00
Damien George b9bfaa349a tests/extmod/vfs_fat: Update tests to work with new VFS sub-system.
The vfs_fat_fsusermount test is no longer relevant so has been removed.
2017-01-27 17:21:45 +11:00
Damien George 94d87fbb30 test/extmod: Update vfs_fat tests for new OO FatFs library.
The new version of FatFs requires a minimum of 50 blocks on the device.
Also, some tests no longer make sense with an OO vfs.
2017-01-27 13:19:10 +11:00
Damien George 221f88d1f3 tests/extmod: Add test for ure debug printing when compiling a regex. 2017-01-26 23:45:51 +11:00
Damien George bf51200bc1 tests/extmod/framebuf1: Fix test for framebuf invalid constructor. 2017-01-25 23:23:50 +11:00
Oleg Korsak 406fb3cb60 tests/extmod/framebuf4: Add tests for GS4_HMSB framebuf format. 2017-01-25 23:20:19 +11:00
Oleg Korsak fd99690f18 extmod/modframebuf: Add GS4_HMSB format. 2017-01-25 23:19:28 +11:00
Damien George 4c4f586e2c tests/extmod/framebuf1: Add test for no-op fill_rect. 2017-01-19 23:37:44 +11:00
Rami Ali 5e80c53c11 tests/extmod: Improve test coverage of ure module. 2017-01-17 17:42:37 +11:00
Rami Ali c15ebf7c8c tests/extmod: Improve ubinascii.c test coverage. 2016-12-29 13:22:19 +11:00
Paul Sokolovsky 492c612f9d tests/utimeq_stable: Test for partial stability of utimeq queuing. 2016-12-24 00:25:15 +03:00
Paul Sokolovsky ffe807f349 extmod/moduheapq: Revert change for adhoc relative-time queue support.
Now that specialized utimeq module has been implenented, revert previous
adhoc changes to uheapq.

This reverts commit 0cbc07227c.
2016-12-22 06:37:49 +03:00
Paul Sokolovsky 5d9025a76e tests/extmod: Add test for utimeq module. 2016-12-22 00:31:38 +03:00
Rami Ali 9112b0b62b tests/extmod: Improve modframebuf test coverage. 2016-12-13 16:29:21 +11:00
Rami Ali d22762017e tests/extmod: Improve moductypes test coverage. 2016-12-12 17:09:14 +11:00
Paul Sokolovsky aee13ef3f2 tests: Update for required byteorder arg for int.from_bytes()/to_bytes(). 2016-12-09 22:53:30 +03:00
Damien George 898d4c1217 extmod/modframebuf: Make framebuf implement the buffer protocol.
So that one can easily access the underlying data of the frame buffer, eg
to write the data out to a display.
2016-12-08 15:17:47 +11:00
Damien George 042d5f24d6 tests/extmod/framebuf1: Add basics tests for hline, vline, rect, line. 2016-12-05 11:55:43 +11:00
Paul Sokolovsky e44b236ce2 tests/extmod/btree1: Exercise btree.flush(). 2016-12-05 01:55:05 +03:00
Damien George 6194336d81 tests/extmod/vfs_fat_fileio: Add test for constructor of FileIO type. 2016-12-02 15:37:58 +11:00
Damien George b7df3e541a extmod/vfs_fat: Implement POSIX behaviour of rename, allow to overwrite.
If the destination of os.rename() exists then it will be overwritten if it
is a file.  This is the POSIX behaviour, which is also the CPython
behaviour, and so we follow suit.

See issue #2598 for discussion.
2016-12-02 15:06:09 +11:00
Damien George 81e171b7bb extmod/modframebuf: Add back legacy FrameBuffer1 "class".
For backwards compatibility.  It simple creates a frame buffer with the
MVLSB format.
2016-12-01 16:43:25 +11:00
Radomir Dopieralski 225e22b287 extmod/modframebuf: Make FrameBuffer handle 16bit depth.
Rename FrameBuffer1 into FrameBuffer and make it handle different bit
depths via a method table that has getpixel and setpixel.  Currently
supported formats are MVLSB (monochrome, vertical, LSB) and RGB565.

Also add blit() and fill_rect() methods.
2016-12-01 16:43:25 +11:00
Rami Ali 1b41cacac7 tests/extmod: Improve ujson coverage. 2016-11-22 15:48:42 +11:00
Paul Sokolovsky 0cbc07227c extmod/moduheapq: Adhoc changes to support ordering by utime.ticks_ms().
As required for further elaboration of uasyncio, like supporting baremetal
systems with wraparound timesources. This is not intended to be public
interface, and likely will be further refactored in the future.
2016-11-12 02:33:17 +03:00
Paul Sokolovsky fa3a108ed7 tests/vfs_fat_oldproto: Skip for ports not supporting "oldproto".
Otherwise this broke esp8266 testsuite.
2016-11-06 01:47:44 +03:00
Alex March 94aeba0427 tests/extmod/framebuf1: Test framebuffer pixel clear, and text function. 2016-11-03 00:10:17 +11:00
Paul Sokolovsky be6a765c69 tests/extmod/ticks_diff: Test for new semantics of ticks_diff(). 2016-10-30 21:33:12 +03:00
Paul Sokolovsky 1ba4db5685 tests/btree1: Fix out of memory error running on esp8266. 2016-10-29 19:53:31 +03:00
Alex March cc0cc67815 tests/extmod/uhashlib_sha256: Rename sha256.py test. 2016-10-28 19:51:54 +03:00
Alex March b83ac44e82 tests/extmod/uhashlib_sha1: Coverage for SHA1 algorithm. 2016-10-28 19:51:46 +03:00
Alex March fbca4f94b3 tests/extmod/vfs_fat_oldproto: Test old block device protocol. 2016-10-27 12:22:43 +11:00
Alex March 38a9359339 tests/extmod/vfs_fat_fsusermount: Improve fsusermount test coverage. 2016-10-27 12:22:42 +11:00
Damien George 5694201930 extmod/vfs_fat_file: Make file.close() a no-op if file already closed.
As per CPython semantics.  In particular, file.__del__() should not raise
an exception if the file is already closed.
2016-10-24 12:59:20 +11:00
Alex March cb20d999bc tests/extmod/vfs_fat: Improve VFS test coverage.
Covered case:
- Stat cases
- Invalid read/write/flush/close
- Invalid mkdir/rmdir/remove/getcwd
- File seek/tell, modes a/x/+, t/b
- Writing to a full disk
- Full path rename, slash trim
- Rename cases
- Bytestring listdir
- File object printing
2016-10-24 12:49:19 +11:00
Alex March e42186d356 tests/extmod/vfs_fat: Replace asserts with prints and expected outputs. 2016-10-13 14:56:47 +03:00
Damien George 11ab807d76 tests/extmod: Add test for ujson.load(). 2016-10-13 11:46:49 +11:00
Alex March f274561e16 tests/extmod/vfs_fat: Test coverage for remove() and rmdir(). 2016-10-11 16:03:52 +11:00
Alex March 9fdba0e09c tests/extmod/uzlib: Test adaptive huffman tree for tinflate coverage. 2016-10-07 01:02:11 +11:00
Alex March addd1d3db1 tests/extmod/btree1: Checks for put, seq, string print and unsupported binary op. 2016-10-05 00:17:22 +11:00
Alex March 670376c5cb tests/extmod/vfs_fat_ramdisk: Add test for VFS.statvfs(). 2016-09-27 13:48:58 +10:00
Paul Sokolovsky d46de80162 tests/uzlib_decompio_gz: Test for DecompIO with gzip bitstream. 2016-09-24 15:43:23 +03:00
Damien George b9672bcbe8 tests/extmod: Add test for machine.time_pulse_us(). 2016-09-16 23:31:02 +10:00
Damien George 67a4813601 tests/extmod/urandom: Add urandom tests for error cases. 2016-09-16 12:49:15 +10:00
Damien George cac8dc3414 tests/extmod/framebuf1: Add tests for scrolling in the x-direction. 2016-09-05 12:08:25 +10:00
Paul Sokolovsky 61e2dfd97d tests/extmod/uzlib_decompio: Add zlib bitstream testcases. 2016-09-04 14:45:27 +03:00
Damien George 2d8740a4d1 tests/extmod: Add a test for framebuf module, tested by coverage build. 2016-09-04 16:40:40 +10:00
Paul Sokolovsky fafd587514 tests/extmod: Add test for uzlib.DecompIO. 2016-09-03 00:20:30 +03:00
Radomir Dopieralski fea7fe45ea tests/extmod/vfs_fat_ramdisk: Add tests for VFS.umount()
Try to un-mount a file system and re-mount it again.
2016-08-26 23:24:32 +03:00
Paul Sokolovsky c428367543 extmod/modubinascii: Make crc32() support configurable.
Disable by default, enable in unix port.
2016-08-24 18:28:43 +03:00
Pavol Rusnak 39799f7564
extmod/modubinascii: implement binascii.crc32 2016-08-24 10:42:46 +02:00
Paul Sokolovsky a6fc90f92a tests/uzlib_decompress: Actually test raw DEFLATE stream. 2016-08-17 06:10:16 +03:00
Paul Sokolovsky 0be4a7712d tests: Rename zlibd_decompress.py -> uzlib_decompress.py.
To use the actual current name.
2016-08-12 22:50:45 +03:00
Paul Sokolovsky 3eb532e974 extmod/modbtree: Implement __contains__ operation. 2016-08-02 00:24:59 +03:00
Paul Sokolovsky bc3912980a tests/machine1: Revamp to work with unix port (which has "umachine"). 2016-07-31 04:30:48 +03:00
Paul Sokolovsky eb0e3bab1e tests/machine_mem.py: Too non-portable, rework as an example for unix port. 2016-07-31 04:22:09 +03:00
Paul Sokolovsky 617bda27e9 tests/extmod/btree1: Tests against in-memory DB (using io.BytesIO). 2016-07-31 02:29:05 +03:00
Paul Sokolovsky 5a38694f55 tests/extmod/btree1: Close database at the end of test. 2016-07-24 00:30:32 +03:00
Paul Sokolovsky c3f519adfe tests/extmod/machine_pinbase: Skip if machine.PinBase is not available. 2016-07-17 16:30:24 +03:00
Paul Sokolovsky 0fb7a7a7ce tests/btree1: Add testcase for iterating btree object directly. 2016-06-24 23:43:20 +03:00
Paul Sokolovsky d5835261af tests/extmod: Add "btree" module test. 2016-06-21 10:00:02 +03:00
Paul Sokolovsky 119b3dabf7 tests: Add a testcase for machine.PinBase class. 2016-06-19 19:45:29 +03:00
Paul Sokolovsky f0eea1fdf9 tests/extmod/vfs_fat_ramdisk: Add testcases for chdir(), getcwd(). 2016-05-29 18:54:14 +03:00
Damien George 07615d9f7e tests/extmod: Move split-on-empty-match tests to a separate test file.
And provide an expected-output file because these tests have a different
behaviour under CPython.
2016-04-26 10:19:04 +01:00
Damien George da161fd9f0 extmod/uctypes: Finish support for FLOAT32 and FLOAT64 types. 2016-03-19 21:59:42 +00:00
Paul Sokolovsky 2740dd85f2 tests/vfs_fat_ramdisk: Add testcase for .rename(). 2016-02-29 01:24:18 +02:00
Paul Sokolovsky 9fb36af9af tests/vfs_fat_ramdisk: Allow to run in native mode (don't use "with"). 2016-02-29 01:03:32 +02:00
Paul Sokolovsky eaa96a7610 tests/vfs_fat_ramdisk: Add testcase for .mkdir(). 2016-02-29 00:06:44 +02:00
Paul Sokolovsky 57425b648f tests/vfs_fat_ramdisk: Add testcase for .remove(). 2016-02-28 20:30:59 +02:00
Paul Sokolovsky 9c081b740b tests/vfs_fat_ramdisk: Add .listdir() testcase. 2016-02-28 17:19:12 +02:00
Paul Sokolovsky dfc35afba1 tests/vfs_fat_ramdisk: Skip test if can't allocate ramdisk. 2016-02-15 17:27:57 +02:00
Paul Sokolovsky 9fdac9144d tests/vfs_fat_ramdisk: Allow to override sector size. 2016-02-14 20:52:38 +02:00
Paul Sokolovsky 9d0525182d tests/vfs_fat_ramdisk: Switch to ioctl-based blockdev API. 2016-02-14 20:45:08 +02:00
Paul Sokolovsky 0ee1d0f407 tests/vfs_fat_ramdisk: Add test for VfsFat. 2016-02-14 19:15:22 +02:00
Damien George ac11e89fa3 tests: For urandom test, use sys.exit() instead of sys.exit(1). 2016-01-26 21:57:02 +00:00
Damien George 0ae97f531d tests: Add some tests for urandom module. 2016-01-26 15:27:00 +00:00
Dave Hylands 66d0c1052a extmod: Fix uctypes size calculation for bitfields 2016-01-10 23:31:26 +02:00
Antonin ENFRUN b50030b1d0 tests/uctypes: Test item assignment for scalar arrays. 2016-01-03 20:32:51 +02:00
Dave Hylands 5a4a2b1db3 extmod: Add test which demonstrates LITTLE_ENDIAN packing failure 2015-12-09 21:43:28 +02:00
Paul Sokolovsky aee704ebe1 extmod/modure: Make sure that errors in regexps are caught early. 2015-11-01 00:38:22 +03:00
Paul Sokolovsky acea9352a9 tests/extmod: Add tests for sleep_ms/us(), ticks_ms/us/diff().
Simple smoke tests, mostly for coverage. Added to extmod based on the fact
that they're extensions to standard modules.
2015-10-20 01:54:20 +03:00
Damien George 25afc7da0d tests: Add tests to improve coverage of objstr.c. 2015-09-03 23:06:18 +01:00
Paul Sokolovsky 354d17523f modmachine: Implement physical memory access using /dev/mem (Linux, etc).
This requires root access. And on recent Linux kernels, with
CONFIG_STRICT_DEVMEM option enabled, only address ranges listed in
/proc/iomem can be accessed. The above compiled-time option can be
however overriden with boot-time option "iomem=relaxed".

This also removed separate read/write paths - there unlikely would
be a case when they're different.
2015-07-08 11:37:23 +03:00