Skip to content

Commit 9fcc25b

Browse files
AJMansfielddpgeorge
authored andcommitted
tests/extmod/vfs_mountinfo.py: Add test for no-args mount output.
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
1 parent 1487a13 commit 9fcc25b

2 files changed

Lines changed: 77 additions & 0 deletions

File tree

tests/extmod/vfs_mountinfo.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# test VFS functionality without any particular filesystem type
2+
3+
try:
4+
import os, vfs
5+
except ImportError:
6+
print("SKIP")
7+
raise SystemExit
8+
import errno
9+
10+
11+
class Filesystem:
12+
def __init__(self, id, paths=[]):
13+
self.id = id
14+
self.paths = paths
15+
16+
def mount(self, readonly, mksfs):
17+
print("mount", self)
18+
19+
def umount(self):
20+
print("umount", self)
21+
22+
def stat(self, path):
23+
if path in self.paths:
24+
return (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
25+
else:
26+
raise OSError
27+
28+
statvfs = stat
29+
30+
def open(self, path, mode):
31+
pass
32+
33+
def __repr__(self):
34+
return "Filesystem(%d)" % self.id
35+
36+
37+
# first we umount any existing mount points the target may have
38+
try:
39+
vfs.umount("/")
40+
except OSError:
41+
pass
42+
for path in os.listdir("/"):
43+
vfs.umount("/" + path)
44+
45+
46+
print(vfs.mount())
47+
48+
vfs.mount(Filesystem(1), "/foo")
49+
50+
print(vfs.mount())
51+
52+
vfs.mount(Filesystem(2), "/bar/baz")
53+
54+
print(vfs.mount())
55+
56+
vfs.mount(Filesystem(3), "/bar")
57+
58+
print(vfs.mount())
59+
60+
vfs.umount("/bar/baz")
61+
62+
print(vfs.mount())
63+
64+
vfs.mount(Filesystem(4), "/")
65+
66+
print(vfs.mount())

tests/extmod/vfs_mountinfo.py.exp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[]
2+
mount Filesystem(1)
3+
[(Filesystem(1), '/foo')]
4+
mount Filesystem(2)
5+
[(Filesystem(1), '/foo'), (Filesystem(2), '/bar/baz')]
6+
mount Filesystem(3)
7+
[(Filesystem(1), '/foo'), (Filesystem(2), '/bar/baz'), (Filesystem(3), '/bar')]
8+
umount Filesystem(2)
9+
[(Filesystem(1), '/foo'), (Filesystem(3), '/bar')]
10+
mount Filesystem(4)
11+
[(Filesystem(1), '/foo'), (Filesystem(3), '/bar'), (Filesystem(4), '/')]

0 commit comments

Comments
 (0)