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
6c8b57a9
Commit
6c8b57a9
authored
8 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
tests/extmod: Add more tests for VFS FAT.
parent
c9a3a68a
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_more.py
+104
-0
104 additions, 0 deletions
tests/extmod/vfs_fat_more.py
tests/extmod/vfs_fat_more.py.exp
+28
-0
28 additions, 0 deletions
tests/extmod/vfs_fat_more.py.exp
with
132 additions
and
0 deletions
tests/extmod/vfs_fat_more.py
0 → 100644
+
104
−
0
View file @
6c8b57a9
import
sys
import
uerrno
try
:
import
uos_vfs
as
uos
open
=
uos
.
vfs_open
except
ImportError
:
import
uos
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
(
50
)
bdev2
=
RAMFS
(
50
)
except
MemoryError
:
print
(
"
SKIP
"
)
sys
.
exit
()
uos
.
VfsFat
.
mkfs
(
bdev
)
uos
.
mount
(
bdev
,
'
/
'
)
print
(
uos
.
getcwd
())
f
=
open
(
'
test.txt
'
,
'
w
'
)
f
.
write
(
'
hello
'
)
f
.
close
()
print
(
uos
.
listdir
())
print
(
uos
.
listdir
(
'
/
'
))
print
(
uos
.
stat
(
''
)[:
-
3
])
print
(
uos
.
stat
(
'
/
'
)[:
-
3
])
print
(
uos
.
stat
(
'
test.txt
'
)[:
-
3
])
print
(
uos
.
stat
(
'
/test.txt
'
)[:
-
3
])
f
=
open
(
'
/test.txt
'
)
print
(
f
.
read
())
f
.
close
()
uos
.
rename
(
'
test.txt
'
,
'
test2.txt
'
)
print
(
uos
.
listdir
())
uos
.
rename
(
'
test2.txt
'
,
'
/test3.txt
'
)
print
(
uos
.
listdir
())
uos
.
rename
(
'
/test3.txt
'
,
'
test4.txt
'
)
print
(
uos
.
listdir
())
uos
.
rename
(
'
/test4.txt
'
,
'
/test5.txt
'
)
print
(
uos
.
listdir
())
uos
.
mkdir
(
'
dir
'
)
print
(
uos
.
listdir
())
uos
.
mkdir
(
'
/dir2
'
)
print
(
uos
.
listdir
())
uos
.
mkdir
(
'
dir/subdir
'
)
print
(
uos
.
listdir
(
'
dir
'
))
for
exist
in
(
''
,
'
/
'
,
'
dir
'
,
'
/dir
'
,
'
dir/subdir
'
):
try
:
uos
.
mkdir
(
exist
)
except
OSError
as
er
:
print
(
'
mkdir OSError
'
,
er
.
args
[
0
]
==
17
)
# EEXIST
uos
.
chdir
(
'
/
'
)
print
(
uos
.
stat
(
'
test5.txt
'
)[:
-
3
])
uos
.
VfsFat
.
mkfs
(
bdev2
)
uos
.
mount
(
bdev2
,
'
/sys
'
)
print
(
uos
.
listdir
())
print
(
uos
.
listdir
(
'
sys
'
))
print
(
uos
.
listdir
(
'
/sys
'
))
uos
.
rmdir
(
'
dir2
'
)
uos
.
remove
(
'
test5.txt
'
)
print
(
uos
.
listdir
())
uos
.
umount
(
'
/
'
)
print
(
uos
.
getcwd
())
print
(
uos
.
listdir
())
print
(
uos
.
listdir
(
'
sys
'
))
This diff is collapsed.
Click to expand it.
tests/extmod/vfs_fat_more.py.exp
0 → 100644
+
28
−
0
View file @
6c8b57a9
/
['test.txt']
['test.txt']
(16384, 0, 0, 0, 0, 0, 0)
(16384, 0, 0, 0, 0, 0, 0)
(32768, 0, 0, 0, 0, 0, 5)
(32768, 0, 0, 0, 0, 0, 5)
hello
['test2.txt']
['test3.txt']
['test4.txt']
['test5.txt']
['test5.txt', 'dir']
['test5.txt', 'dir', 'dir2']
['subdir']
mkdir OSError True
mkdir OSError True
mkdir OSError True
mkdir OSError True
mkdir OSError True
(32768, 0, 0, 0, 0, 0, 5)
['sys', 'test5.txt', 'dir', 'dir2']
[]
[]
['sys', 'dir']
/
['sys']
[]
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