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: ...@@ -34,7 +34,7 @@ class RAMFS:
try: try:
bdev = RAMFS(48) bdev = RAMFS(50)
except MemoryError: except MemoryError:
print("SKIP") print("SKIP")
sys.exit() sys.exit()
...@@ -91,7 +91,7 @@ with vfs.open("foo_file.txt") as f2: ...@@ -91,7 +91,7 @@ with vfs.open("foo_file.txt") as f2:
# using constructor of FileIO type to open a file # using constructor of FileIO type to open a file
FileIO = type(f) FileIO = type(f)
with FileIO("foo_file.txt") as f: with FileIO("/ramdisk/foo_file.txt") as f:
print(f.read()) print(f.read())
# dirs # dirs
...@@ -118,9 +118,9 @@ except OSError as e: ...@@ -118,9 +118,9 @@ except OSError as e:
print(e.args[0] == uerrno.ENOENT) print(e.args[0] == uerrno.ENOENT)
try: try:
vfs.rename("foo_dir", "/null") vfs.rename("foo_dir", "/null/file")
except OSError as e: except OSError as e:
print(e.args[0] == uerrno.ENODEV) print(e.args[0] == uerrno.ENOENT)
# file in dir # file in dir
with vfs.open("foo_dir/file-in-dir.txt", "w+t") as f: with vfs.open("foo_dir/file-in-dir.txt", "w+t") as f:
...@@ -139,7 +139,7 @@ except OSError as e: ...@@ -139,7 +139,7 @@ except OSError as e:
print(e.args[0] == uerrno.EACCES) print(e.args[0] == uerrno.EACCES)
# trim full path # 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")) print(vfs.listdir("foo_dir"))
vfs.rename("foo_dir/file.txt", "moved-to-root.txt") vfs.rename("foo_dir/file.txt", "moved-to-root.txt")
......
...@@ -34,7 +34,7 @@ class RAMFS: ...@@ -34,7 +34,7 @@ class RAMFS:
try: try:
bdev = RAMFS(48) bdev = RAMFS(50)
except MemoryError: except MemoryError:
print("SKIP") print("SKIP")
sys.exit() sys.exit()
...@@ -75,6 +75,7 @@ uos.vfs_mount(bdev, "/ramdisk") ...@@ -75,6 +75,7 @@ uos.vfs_mount(bdev, "/ramdisk")
uos.vfs_umount("/ramdisk") uos.vfs_umount("/ramdisk")
# readonly mount # readonly mount
# note: this test doesn't work correctly with new OO FatFs
uos.vfs_mount(bdev, "/ramdisk", readonly=True) uos.vfs_mount(bdev, "/ramdisk", readonly=True)
vfs = uos.VfsFat(bdev, "/ramdisk") vfs = uos.VfsFat(bdev, "/ramdisk")
try: try:
...@@ -89,7 +90,7 @@ uos.vfs_mount(None, "/ramdisk") ...@@ -89,7 +90,7 @@ uos.vfs_mount(None, "/ramdisk")
dev = [] dev = []
try: try:
for i in range(0,4): for i in range(0,4):
dev.append(RAMFS(48)) dev.append(RAMFS(50))
uos.vfs_mkfs(dev[i], "/ramdisk" + str(i)) uos.vfs_mkfs(dev[i], "/ramdisk" + str(i))
uos.vfs_mount(dev[i], "/ramdisk" + str(i)) uos.vfs_mount(dev[i], "/ramdisk" + str(i))
except OSError as e: except OSError as e:
......
...@@ -3,5 +3,4 @@ can't mount ...@@ -3,5 +3,4 @@ can't mount
True True
can't umount can't umount
can't umount can't umount
EROFS: True
too many devices mounted too many devices mounted
...@@ -34,7 +34,7 @@ class RAMFS_OLD: ...@@ -34,7 +34,7 @@ class RAMFS_OLD:
try: try:
bdev = RAMFS_OLD(48) bdev = RAMFS_OLD(50)
except MemoryError: except MemoryError:
print("SKIP") print("SKIP")
sys.exit() sys.exit()
...@@ -57,7 +57,3 @@ print(vfs.listdir()) ...@@ -57,7 +57,3 @@ print(vfs.listdir())
# umount by device # umount by device
uos.vfs_umount(bdev) uos.vfs_umount(bdev)
try:
vfs.listdir()
except OSError as e:
print(e.args[0] == uerrno.ENODEV)
['file.txt'] ['file.txt']
hello! hello!
[] []
True
...@@ -34,7 +34,7 @@ class RAMFS: ...@@ -34,7 +34,7 @@ class RAMFS:
try: try:
bdev = RAMFS(48) bdev = RAMFS(50)
except MemoryError: except MemoryError:
print("SKIP") print("SKIP")
sys.exit() sys.exit()
...@@ -46,11 +46,6 @@ print(b"hello!" not in bdev.data) ...@@ -46,11 +46,6 @@ print(b"hello!" not in bdev.data)
vfs = uos.VfsFat(bdev, "/ramdisk") 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("statvfs:", vfs.statvfs("/ramdisk"))
print("getcwd:", vfs.getcwd()) print("getcwd:", vfs.getcwd())
...@@ -87,15 +82,6 @@ vfs.chdir("..") ...@@ -87,15 +82,6 @@ vfs.chdir("..")
print("getcwd:", vfs.getcwd()) print("getcwd:", vfs.getcwd())
vfs.umount() 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") vfs = uos.VfsFat(bdev, "/ramdisk")
print(vfs.listdir(b"")) print(vfs.listdir(b""))
True True
True True
True statvfs: (512, 512, 16, 16, 16, 0, 0, 0, 0, 255)
statvfs: (512, 512, 14, 14, 14, 0, 0, 0, 0, 255)
getcwd: /ramdisk getcwd: /ramdisk
True True
['foo_file.txt'] ['foo_file.txt']
...@@ -14,6 +13,4 @@ getcwd: /ramdisk/foo_dir ...@@ -14,6 +13,4 @@ getcwd: /ramdisk/foo_dir
[] []
True True
getcwd: /ramdisk getcwd: /ramdisk
True
True
[b'foo_file.txt', b'foo_dir'] [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