Content-Length: 402148 | pFad | http://github.com/micropython/micropython/commit/9fcc25b9d7e6246f9c1dda3c07f3e718f751e74c

6F tests/extmod/vfs_mountinfo.py: Add test for no-args mount output. · micropython/micropython@9fcc25b · GitHub
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

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

tests/extmod/vfs_mountinfo.py

+66
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

+11
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/micropython/micropython/commit/9fcc25b9d7e6246f9c1dda3c07f3e718f751e74c

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy