summaryrefslogtreecommitdiffstatshomepage
path: root/tests/extmod/vfs_mountinfo.py
diff options
context:
space:
mode:
authorAnson Mansfield <amansfield@mantaro.com>2025-03-03 14:05:31 -0500
committerDamien George <damien@micropython.org>2025-03-27 16:37:04 +1100
commit9fcc25b9d7e6246f9c1dda3c07f3e718f751e74c (patch)
treead0d3b829ff4cd7cac1b0393aaf9012cd298c69e /tests/extmod/vfs_mountinfo.py
parent1487a13079ec5e33cac8d273e6d2fa805bca4b1e (diff)
downloadmicropython-9fcc25b9d7e6246f9c1dda3c07f3e718f751e74c.tar.gz
micropython-9fcc25b9d7e6246f9c1dda3c07f3e718f751e74c.zip
tests/extmod/vfs_mountinfo.py: Add test for no-args mount output.
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Diffstat (limited to 'tests/extmod/vfs_mountinfo.py')
-rw-r--r--tests/extmod/vfs_mountinfo.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/extmod/vfs_mountinfo.py b/tests/extmod/vfs_mountinfo.py
new file mode 100644
index 0000000000..f674e80763
--- /dev/null
+++ b/tests/extmod/vfs_mountinfo.py
@@ -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())