Skip to content

Commit a604451

Browse files
committed
tests/extmod/vfs_fat_fileio1: Add test for failing alloc with finaliser.
1 parent 62be14d commit a604451

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

tests/extmod/vfs_fat_fileio1.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,15 @@ def ioctl(self, op, arg):
113113

114114
vfs.remove("foo_file.txt")
115115
print(list(vfs.ilistdir()))
116+
117+
# Here we test that opening a file with the heap locked fails correctly. This
118+
# is a special case because file objects use a finaliser and allocating with a
119+
# finaliser is a different path to normal allocation. It would be better to
120+
# test this in the core tests but there are no core objects that use finaliser.
121+
import micropython
122+
micropython.heap_lock()
123+
try:
124+
vfs.open('x', 'r')
125+
except MemoryError:
126+
print('MemoryError')
127+
micropython.heap_unlock()

tests/extmod/vfs_fat_fileio1.py.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ o
1111
d
1212
True
1313
[('foo_dir', 16384, 0)]
14+
MemoryError

0 commit comments

Comments
 (0)