Commit 94d87fbb authored by Damien George's avatar Damien George
Browse files

test/extmod: Update vfs_fat tests for new OO FatFs library.

The new version of FatFs requires a minimum of 50 blocks on the device.
Also, some tests no longer make sense with an OO vfs.
parent 5395f5bc
......@@ -34,7 +34,7 @@ class RAMFS:
try:
bdev = RAMFS(48)
bdev = RAMFS(50)
except MemoryError:
print("SKIP")
sys.exit()
......@@ -91,7 +91,7 @@ with vfs.open("foo_file.txt") as f2:
# using constructor of FileIO type to open a file
FileIO = type(f)
with FileIO("foo_file.txt") as f:
with FileIO("/ramdisk/foo_file.txt") as f:
print(f.read())
# dirs
......@@ -118,9 +118,9 @@ except OSError as e:
print(e.args[0] == uerrno.ENOENT)
try:
vfs.rename("foo_dir", "/null")
vfs.rename("foo_dir", "/null/file")
except OSError as e:
print(e.args[0] == uerrno.ENODEV)
print(e.args[0] == uerrno.ENOENT)
# file in dir
with vfs.open("foo_dir/file-in-dir.txt", "w+t") as f:
......@@ -139,7 +139,7 @@ except OSError as e:
print(e.args[0] == uerrno.EACCES)
# trim full path
vfs.rename("foo_dir/file-in-dir.txt", "/ramdisk/foo_dir/file.txt")
vfs.rename("foo_dir/file-in-dir.txt", "foo_dir/file.txt")
print(vfs.listdir("foo_dir"))
vfs.rename("foo_dir/file.txt", "moved-to-root.txt")
......
......@@ -34,7 +34,7 @@ class RAMFS:
try:
bdev = RAMFS(48)
bdev = RAMFS(50)
except MemoryError:
print("SKIP")
sys.exit()
......@@ -75,6 +75,7 @@ uos.vfs_mount(bdev, "/ramdisk")
uos.vfs_umount("/ramdisk")
# readonly mount
# note: this test doesn't work correctly with new OO FatFs
uos.vfs_mount(bdev, "/ramdisk", readonly=True)
vfs = uos.VfsFat(bdev, "/ramdisk")
try:
......@@ -89,7 +90,7 @@ uos.vfs_mount(None, "/ramdisk")
dev = []
try:
for i in range(0,4):
dev.append(RAMFS(48))
dev.append(RAMFS(50))
uos.vfs_mkfs(dev[i], "/ramdisk" + str(i))
uos.vfs_mount(dev[i], "/ramdisk" + str(i))
except OSError as e:
......
......@@ -3,5 +3,4 @@ can't mount
True
can't umount
can't umount
EROFS: True
too many devices mounted
......@@ -34,7 +34,7 @@ class RAMFS_OLD:
try:
bdev = RAMFS_OLD(48)
bdev = RAMFS_OLD(50)
except MemoryError:
print("SKIP")
sys.exit()
......@@ -57,7 +57,3 @@ print(vfs.listdir())
# umount by device
uos.vfs_umount(bdev)
try:
vfs.listdir()
except OSError as e:
print(e.args[0] == uerrno.ENODEV)
......@@ -34,7 +34,7 @@ class RAMFS:
try:
bdev = RAMFS(48)
bdev = RAMFS(50)
except MemoryError:
print("SKIP")
sys.exit()
......@@ -46,11 +46,6 @@ print(b"hello!" not in bdev.data)
vfs = uos.VfsFat(bdev, "/ramdisk")
try:
vfs.statvfs("/null")
except OSError as e:
print(e.args[0] == uerrno.ENODEV)
print("statvfs:", vfs.statvfs("/ramdisk"))
print("getcwd:", vfs.getcwd())
......@@ -87,15 +82,6 @@ vfs.chdir("..")
print("getcwd:", vfs.getcwd())
vfs.umount()
try:
vfs.listdir()
except OSError as e:
print(e.args[0] == uerrno.ENODEV)
try:
vfs.getcwd()
except OSError as e:
print(e.args[0] == uerrno.ENODEV)
vfs = uos.VfsFat(bdev, "/ramdisk")
print(vfs.listdir(b""))
True
True
True
statvfs: (512, 512, 14, 14, 14, 0, 0, 0, 0, 255)
statvfs: (512, 512, 16, 16, 16, 0, 0, 0, 0, 255)
getcwd: /ramdisk
True
['foo_file.txt']
......@@ -14,6 +13,4 @@ getcwd: /ramdisk/foo_dir
[]
True
getcwd: /ramdisk
True
True
[b'foo_file.txt', b'foo_dir']
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment