summaryrefslogtreecommitdiff
path: root/tests/extmod/vfs_lfs.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/extmod/vfs_lfs.py')
-rw-r--r--tests/extmod/vfs_lfs.py58
1 files changed, 31 insertions, 27 deletions
diff --git a/tests/extmod/vfs_lfs.py b/tests/extmod/vfs_lfs.py
index 46c770b43..c3656fe68 100644
--- a/tests/extmod/vfs_lfs.py
+++ b/tests/extmod/vfs_lfs.py
@@ -2,12 +2,14 @@
try:
import uos
+
uos.VfsLfs1
uos.VfsLfs2
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
+
class RAMBlockDevice:
ERASE_BLOCK_SIZE = 1024
@@ -25,15 +27,16 @@ class RAMBlockDevice:
self.data[addr + i] = buf[i]
def ioctl(self, op, arg):
- if op == 4: # block count
+ if op == 4: # block count
return len(self.data) // self.ERASE_BLOCK_SIZE
- if op == 5: # block size
+ if op == 5: # block size
return self.ERASE_BLOCK_SIZE
- if op == 6: # erase block
+ if op == 6: # erase block
return 0
+
def test(bdev, vfs_class):
- print('test', vfs_class)
+ print("test", vfs_class)
# mkfs
vfs_class.mkfs(bdev)
@@ -42,65 +45,66 @@ def test(bdev, vfs_class):
vfs = vfs_class(bdev)
# statvfs
- print(vfs.statvfs('/'))
+ print(vfs.statvfs("/"))
# open, write close
- f = vfs.open('test', 'w')
- f.write('littlefs')
+ f = vfs.open("test", "w")
+ f.write("littlefs")
f.close()
# statvfs after creating a file
- print(vfs.statvfs('/'))
+ print(vfs.statvfs("/"))
# ilistdir
print(list(vfs.ilistdir()))
- print(list(vfs.ilistdir('/')))
- print(list(vfs.ilistdir(b'/')))
+ print(list(vfs.ilistdir("/")))
+ print(list(vfs.ilistdir(b"/")))
# mkdir, rmdir
- vfs.mkdir('testdir')
+ vfs.mkdir("testdir")
print(list(vfs.ilistdir()))
- print(list(vfs.ilistdir('testdir')))
- vfs.rmdir('testdir')
+ print(list(vfs.ilistdir("testdir")))
+ vfs.rmdir("testdir")
print(list(vfs.ilistdir()))
- vfs.mkdir('testdir')
+ vfs.mkdir("testdir")
# stat a file
- print(vfs.stat('test'))
+ print(vfs.stat("test"))
# stat a dir (size seems to vary on LFS2 so don't print that)
- print(vfs.stat('testdir')[:6])
+ print(vfs.stat("testdir")[:6])
# read
- with vfs.open('test', 'r') as f:
+ with vfs.open("test", "r") as f:
print(f.read())
# create large file
- with vfs.open('testbig', 'w') as f:
- data = 'large012' * 32 * 16
- print('data length:', len(data))
+ with vfs.open("testbig", "w") as f:
+ data = "large012" * 32 * 16
+ print("data length:", len(data))
for i in range(4):
- print('write', i)
+ print("write", i)
f.write(data)
# stat after creating large file
- print(vfs.statvfs('/'))
+ print(vfs.statvfs("/"))
# rename
- vfs.rename('testbig', 'testbig2')
+ vfs.rename("testbig", "testbig2")
print(list(vfs.ilistdir()))
# remove
- vfs.remove('testbig2')
+ vfs.remove("testbig2")
print(list(vfs.ilistdir()))
# getcwd, chdir
print(vfs.getcwd())
- vfs.chdir('/testdir')
+ vfs.chdir("/testdir")
print(vfs.getcwd())
- vfs.chdir('/')
+ vfs.chdir("/")
print(vfs.getcwd())
- vfs.rmdir('testdir')
+ vfs.rmdir("testdir")
+
bdev = RAMBlockDevice(30)
test(bdev, uos.VfsLfs1)