diff options
author | Damien George <damien.p.george@gmail.com> | 2018-02-26 13:36:13 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-02-26 13:36:13 +1100 |
commit | a604451566ca415cc6ab6f9cce40c19045cb8e16 (patch) | |
tree | 794e54f8794fb3cccbfc7919b923fd951cb90ac5 | |
parent | 62be14d77c1c61c7636e9ffe6b7e0c744ace58c6 (diff) | |
download | micropython-a604451566ca415cc6ab6f9cce40c19045cb8e16.tar.gz micropython-a604451566ca415cc6ab6f9cce40c19045cb8e16.zip |
tests/extmod/vfs_fat_fileio1: Add test for failing alloc with finaliser.
-rw-r--r-- | tests/extmod/vfs_fat_fileio1.py | 12 | ||||
-rw-r--r-- | tests/extmod/vfs_fat_fileio1.py.exp | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/extmod/vfs_fat_fileio1.py b/tests/extmod/vfs_fat_fileio1.py index 8b9ff92eb8..8c8ec57472 100644 --- a/tests/extmod/vfs_fat_fileio1.py +++ b/tests/extmod/vfs_fat_fileio1.py @@ -113,3 +113,15 @@ except OSError as e: vfs.remove("foo_file.txt") print(list(vfs.ilistdir())) + +# Here we test that opening a file with the heap locked fails correctly. This +# is a special case because file objects use a finaliser and allocating with a +# finaliser is a different path to normal allocation. It would be better to +# test this in the core tests but there are no core objects that use finaliser. +import micropython +micropython.heap_lock() +try: + vfs.open('x', 'r') +except MemoryError: + print('MemoryError') +micropython.heap_unlock() diff --git a/tests/extmod/vfs_fat_fileio1.py.exp b/tests/extmod/vfs_fat_fileio1.py.exp index a66f07605c..a304c75d96 100644 --- a/tests/extmod/vfs_fat_fileio1.py.exp +++ b/tests/extmod/vfs_fat_fileio1.py.exp @@ -11,3 +11,4 @@ o d True [('foo_dir', 16384, 0)] +MemoryError |