tests/extmod/vfs_mountinfo.py: Add test for no-args mount output.
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
This commit is contained in:
committed by
Damien George
parent
1487a13079
commit
9fcc25b9d7
66
tests/extmod/vfs_mountinfo.py
Normal file
66
tests/extmod/vfs_mountinfo.py
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
# test VFS functionality without any particular filesystem type
|
||||||
|
|
||||||
|
try:
|
||||||
|
import os, vfs
|
||||||
|
except ImportError:
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
import errno
|
||||||
|
|
||||||
|
|
||||||
|
class Filesystem:
|
||||||
|
def __init__(self, id, paths=[]):
|
||||||
|
self.id = id
|
||||||
|
self.paths = paths
|
||||||
|
|
||||||
|
def mount(self, readonly, mksfs):
|
||||||
|
print("mount", self)
|
||||||
|
|
||||||
|
def umount(self):
|
||||||
|
print("umount", self)
|
||||||
|
|
||||||
|
def stat(self, path):
|
||||||
|
if path in self.paths:
|
||||||
|
return (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
|
else:
|
||||||
|
raise OSError
|
||||||
|
|
||||||
|
statvfs = stat
|
||||||
|
|
||||||
|
def open(self, path, mode):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "Filesystem(%d)" % self.id
|
||||||
|
|
||||||
|
|
||||||
|
# first we umount any existing mount points the target may have
|
||||||
|
try:
|
||||||
|
vfs.umount("/")
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
for path in os.listdir("/"):
|
||||||
|
vfs.umount("/" + path)
|
||||||
|
|
||||||
|
|
||||||
|
print(vfs.mount())
|
||||||
|
|
||||||
|
vfs.mount(Filesystem(1), "/foo")
|
||||||
|
|
||||||
|
print(vfs.mount())
|
||||||
|
|
||||||
|
vfs.mount(Filesystem(2), "/bar/baz")
|
||||||
|
|
||||||
|
print(vfs.mount())
|
||||||
|
|
||||||
|
vfs.mount(Filesystem(3), "/bar")
|
||||||
|
|
||||||
|
print(vfs.mount())
|
||||||
|
|
||||||
|
vfs.umount("/bar/baz")
|
||||||
|
|
||||||
|
print(vfs.mount())
|
||||||
|
|
||||||
|
vfs.mount(Filesystem(4), "/")
|
||||||
|
|
||||||
|
print(vfs.mount())
|
||||||
11
tests/extmod/vfs_mountinfo.py.exp
Normal file
11
tests/extmod/vfs_mountinfo.py.exp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[]
|
||||||
|
mount Filesystem(1)
|
||||||
|
[(Filesystem(1), '/foo')]
|
||||||
|
mount Filesystem(2)
|
||||||
|
[(Filesystem(1), '/foo'), (Filesystem(2), '/bar/baz')]
|
||||||
|
mount Filesystem(3)
|
||||||
|
[(Filesystem(1), '/foo'), (Filesystem(2), '/bar/baz'), (Filesystem(3), '/bar')]
|
||||||
|
umount Filesystem(2)
|
||||||
|
[(Filesystem(1), '/foo'), (Filesystem(3), '/bar')]
|
||||||
|
mount Filesystem(4)
|
||||||
|
[(Filesystem(1), '/foo'), (Filesystem(3), '/bar'), (Filesystem(4), '/')]
|
||||||
Reference in New Issue
Block a user