Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
38a93593
Commit
38a93593
authored
Oct 21, 2016
by
Alex March
Committed by
Damien George
Oct 27, 2016
Browse files
Options
Downloads
Patches
Plain Diff
tests/extmod/vfs_fat_fsusermount: Improve fsusermount test coverage.
parent
67b6d9d4
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/extmod/vfs_fat_fsusermount.py
+96
-0
96 additions, 0 deletions
tests/extmod/vfs_fat_fsusermount.py
tests/extmod/vfs_fat_fsusermount.py.exp
+7
-0
7 additions, 0 deletions
tests/extmod/vfs_fat_fsusermount.py.exp
with
103 additions
and
0 deletions
tests/extmod/vfs_fat_fsusermount.py
0 → 100644
+
96
−
0
View file @
38a93593
import
sys
import
uos
import
uerrno
try
:
uos
.
VfsFat
except
AttributeError
:
print
(
"
SKIP
"
)
sys
.
exit
()
class
RAMFS
:
SEC_SIZE
=
512
def
__init__
(
self
,
blocks
):
self
.
data
=
bytearray
(
blocks
*
self
.
SEC_SIZE
)
def
readblocks
(
self
,
n
,
buf
):
#print("readblocks(%s, %x(%d))" % (n, id(buf), len(buf)))
for
i
in
range
(
len
(
buf
)):
buf
[
i
]
=
self
.
data
[
n
*
self
.
SEC_SIZE
+
i
]
def
writeblocks
(
self
,
n
,
buf
):
#print("writeblocks(%s, %x)" % (n, id(buf)))
for
i
in
range
(
len
(
buf
)):
self
.
data
[
n
*
self
.
SEC_SIZE
+
i
]
=
buf
[
i
]
def
ioctl
(
self
,
op
,
arg
):
#print("ioctl(%d, %r)" % (op, arg))
if
op
==
4
:
# BP_IOCTL_SEC_COUNT
return
len
(
self
.
data
)
//
self
.
SEC_SIZE
if
op
==
5
:
# BP_IOCTL_SEC_SIZE
return
self
.
SEC_SIZE
try
:
bdev
=
RAMFS
(
48
)
except
MemoryError
:
print
(
"
SKIP
"
)
sys
.
exit
()
# can't mkfs readonly device
try
:
uos
.
vfs_mkfs
(
bdev
,
"
/ramdisk
"
,
readonly
=
True
)
except
OSError
as
e
:
print
(
e
)
# mount before mkfs
try
:
uos
.
vfs_mount
(
bdev
,
"
/ramdisk
"
)
except
OSError
as
e
:
print
(
e
)
# invalid umount
try
:
uos
.
vfs_umount
(
"
/ramdisk
"
)
except
OSError
as
e
:
print
(
e
.
args
[
0
]
==
uerrno
.
EINVAL
)
try
:
uos
.
vfs_mount
(
None
,
"
/ramdisk
"
)
except
OSError
as
e
:
print
(
e
)
try
:
uos
.
vfs_mkfs
(
None
,
"
/ramdisk
"
)
except
OSError
as
e
:
print
(
e
)
# valid mkfs/mount
uos
.
vfs_mkfs
(
bdev
,
"
/ramdisk
"
)
uos
.
vfs_mount
(
bdev
,
"
/ramdisk
"
)
# umount by path
uos
.
vfs_umount
(
"
/ramdisk
"
)
# readonly mount
uos
.
vfs_mount
(
bdev
,
"
/ramdisk
"
,
readonly
=
True
)
vfs
=
uos
.
VfsFat
(
bdev
,
"
/ramdisk
"
)
try
:
f
=
vfs
.
open
(
"
file.txt
"
,
"
w
"
)
except
OSError
as
e
:
print
(
"
EROFS:
"
,
e
.
args
[
0
]
==
30
)
# uerrno.EROFS
# device is None == umount
uos
.
vfs_mount
(
None
,
"
/ramdisk
"
)
# max mounted devices
dev
=
[]
try
:
for
i
in
range
(
0
,
4
):
dev
.
append
(
RAMFS
(
48
))
uos
.
vfs_mkfs
(
dev
[
i
],
"
/ramdisk
"
+
str
(
i
))
uos
.
vfs_mount
(
dev
[
i
],
"
/ramdisk
"
+
str
(
i
))
except
OSError
as
e
:
print
(
e
)
This diff is collapsed.
Click to expand it.
tests/extmod/vfs_fat_fsusermount.py.exp
0 → 100644
+
7
−
0
View file @
38a93593
can't mkfs
can't mount
True
can't umount
can't umount
EROFS: True
too many devices mounted
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment