Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
773b0bac
Commit
773b0bac
authored
Mar 14, 2017
by
Damien George
Browse files
tests/extmod/vfs_basic: Add more tests for basic VFS functionality.
parent
d1ae6ae0
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/extmod/vfs_basic.py
View file @
773b0bac
...
...
@@ -25,10 +25,33 @@ class Filesystem:
return
[
'a%d'
%
self
.
id
]
def
chdir
(
self
,
dir
):
print
(
self
.
id
,
'chdir'
,
dir
)
def
getcwd
(
self
):
print
(
self
.
id
,
'getcwd'
)
return
'dir%d'
%
self
.
id
def
mkdir
(
self
,
path
):
print
(
self
.
id
,
'mkdir'
,
path
)
def
remove
(
self
,
path
):
print
(
self
.
id
,
'remove'
,
path
)
def
rename
(
self
,
old_path
,
new_path
):
print
(
self
.
id
,
'rename'
,
old_path
,
new_path
)
def
rmdir
(
self
,
path
):
print
(
self
.
id
,
'rmdir'
,
path
)
def
stat
(
self
,
path
):
print
(
self
.
id
,
'stat'
,
path
)
return
(
self
.
id
,)
def
statvfs
(
self
,
path
):
print
(
self
.
id
,
'statvfs'
,
path
)
return
(
self
.
id
,)
def
open
(
self
,
file
,
mode
):
print
(
self
.
id
,
'open'
,
file
,
mode
)
# stat root dir
print
(
uos
.
stat
(
'/'
))
# getcwd when in root dir
print
(
uos
.
getcwd
())
# basic mounting and listdir
uos
.
mount
(
Filesystem
(
1
),
'/test_mnt'
)
print
(
uos
.
listdir
())
...
...
@@ -42,14 +65,43 @@ uos.mount(Filesystem(2), '/test_mnt2', readonly=True)
print
(
uos
.
listdir
())
print
(
uos
.
listdir
(
'/test_mnt2'
))
# chdir
# mounting over an existing mount point
try
:
uos
.
mount
(
Filesystem
(
3
),
'/test_mnt2'
)
except
OSError
:
print
(
'OSError'
)
# mkdir of a mount point
try
:
uos
.
mkdir
(
'/test_mnt'
)
except
OSError
:
print
(
'OSError'
)
# rename across a filesystem
try
:
uos
.
rename
(
'/test_mnt/a'
,
'/test_mnt2/b'
)
except
OSError
:
print
(
'OSError'
)
# delegating to mounted filesystem
uos
.
chdir
(
'test_mnt'
)
print
(
uos
.
listdir
())
# open
print
(
uos
.
getcwd
())
uos
.
mkdir
(
'test_dir'
)
uos
.
remove
(
'test_file'
)
uos
.
rename
(
'test_file'
,
'test_file2'
)
uos
.
rmdir
(
'test_dir'
)
print
(
uos
.
stat
(
'test_file'
))
print
(
uos
.
statvfs
(
'/test_mnt'
))
open
(
'test_file'
)
open
(
'test_file'
,
'wb'
)
# umount
uos
.
umount
(
'/test_mnt'
)
uos
.
umount
(
'/test_mnt2'
)
# umount a non-existent mount point
try
:
uos
.
umount
(
'/test_mnt'
)
except
OSError
:
print
(
'OSError'
)
tests/extmod/vfs_basic.py.exp
View file @
773b0bac
(16384, 0, 0, 0, 0, 0, 0, 0, 0, 0)
/
1 mount False False
['test_mnt']
1 listdir /
...
...
@@ -8,10 +10,25 @@
['test_mnt', 'test_mnt2']
2 listdir /
['a2']
3 mount False False
OSError
OSError
OSError
1 chdir /
1 listdir
['a1']
1 getcwd
/test_mntdir1
1 mkdir test_dir
1 remove test_file
1 rename test_file test_file2
1 rmdir test_dir
1 stat test_file
(1,)
1 statvfs /
(1,)
1 open test_file r
1 open test_file wb
1 umount
2 umount
OSError
Write
Preview
Supports
Markdown
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