summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--tests/extmod/vfs_fat_fileio1.py12
-rw-r--r--tests/extmod/vfs_fat_fileio1.py.exp1
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