tests/extmod/vfs_fat_finaliser.py: Tweak test so files are collected.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
7c88cdda49
commit
62c3033ba6
|
@ -64,7 +64,7 @@ import gc
|
|||
# in turn allocate new qstrs and/or a new qstr pool).
|
||||
f = None
|
||||
n = None
|
||||
names = ["x%d" % i for i in range(4)]
|
||||
names = ["x%d" % i for i in range(5)]
|
||||
|
||||
# Do a large number of single-block allocations to move the GC head forwards,
|
||||
# ensuring that the files are allocated from never-before-used blocks and
|
||||
|
@ -74,12 +74,13 @@ for i in range(1024):
|
|||
[]
|
||||
|
||||
# Run the test: create files without closing them, run GC, then read back files.
|
||||
# Only read back N-1 files because the last one may not be finalised due to
|
||||
# references to it being left on the C stack.
|
||||
for n in names:
|
||||
f = vfs.open(n, "w")
|
||||
f.write(n)
|
||||
f = None # release f without closing
|
||||
sorted([0, 1, 2, 3], key=lambda x: x) # use up Python and C stack so f is really gone
|
||||
gc.collect() # should finalise all N files by closing them
|
||||
for n in names:
|
||||
gc.collect() # should finalise at least the first N-1 files by closing them
|
||||
for n in names[:-1]:
|
||||
with vfs.open(n, "r") as f:
|
||||
print(f.read())
|
||||
|
|
Loading…
Reference in New Issue