Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
8891b2e7
Commit
8891b2e7
authored
Mar 13, 2017
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests/extmod: Add a test for core VFS functionality, sans any filesystem.
parent
0a3ac07e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
+72
-0
tests/extmod/vfs_basic.py
tests/extmod/vfs_basic.py
+55
-0
tests/extmod/vfs_basic.py.exp
tests/extmod/vfs_basic.py.exp
+17
-0
No files found.
tests/extmod/vfs_basic.py
0 → 100644
View file @
8891b2e7
# test VFS functionality without any particular filesystem type
try
:
try
:
import
uos_vfs
as
uos
open
=
uos
.
vfs_open
except
ImportError
:
import
uos
uos
.
mount
except
(
ImportError
,
AttributeError
):
print
(
"SKIP"
)
import
sys
sys
.
exit
()
class
Filesystem
:
def
__init__
(
self
,
id
):
self
.
id
=
id
def
mount
(
self
,
readonly
,
mkfs
):
print
(
self
.
id
,
'mount'
,
readonly
,
mkfs
)
def
umount
(
self
):
print
(
self
.
id
,
'umount'
)
def
listdir
(
self
,
dir
):
print
(
self
.
id
,
'listdir'
,
dir
)
return
[
'a%d'
%
self
.
id
]
def
chdir
(
self
,
dir
):
print
(
self
.
id
,
'chdir'
,
dir
)
def
open
(
self
,
file
,
mode
):
print
(
self
.
id
,
'open'
,
file
,
mode
)
# basic mounting and listdir
uos
.
mount
(
Filesystem
(
1
),
'/test_mnt'
)
print
(
uos
.
listdir
())
# referencing the mount point in different ways
print
(
uos
.
listdir
(
'test_mnt'
))
print
(
uos
.
listdir
(
'/test_mnt'
))
# mounting another filesystem
uos
.
mount
(
Filesystem
(
2
),
'/test_mnt2'
,
readonly
=
True
)
print
(
uos
.
listdir
())
print
(
uos
.
listdir
(
'/test_mnt2'
))
# chdir
uos
.
chdir
(
'test_mnt'
)
print
(
uos
.
listdir
())
# open
open
(
'test_file'
)
open
(
'test_file'
,
'wb'
)
# umount
uos
.
umount
(
'/test_mnt'
)
uos
.
umount
(
'/test_mnt2'
)
tests/extmod/vfs_basic.py.exp
0 → 100644
View file @
8891b2e7
1 mount False False
['test_mnt']
1 listdir /
['a1']
1 listdir /
['a1']
2 mount True False
['test_mnt', 'test_mnt2']
2 listdir /
['a2']
1 chdir /
1 listdir
['a1']
1 open test_file r
1 open test_file wb
1 umount
2 umount
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment