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
968b6880
Commit
968b6880
authored
Mar 26, 2019
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests/extmod: Add test for FAT filesystem on a very large block device.
parent
781947af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
0 deletions
+73
-0
tests/extmod/vfs_fat_ramdisklarge.py
tests/extmod/vfs_fat_ramdisklarge.py
+70
-0
tests/extmod/vfs_fat_ramdisklarge.py.exp
tests/extmod/vfs_fat_ramdisklarge.py.exp
+3
-0
No files found.
tests/extmod/vfs_fat_ramdisklarge.py
0 → 100644
View file @
968b6880
# test making a FAT filesystem on a very large block device
try
:
import
uos
except
ImportError
:
print
(
"SKIP"
)
raise
SystemExit
try
:
uos
.
VfsFat
except
AttributeError
:
print
(
"SKIP"
)
raise
SystemExit
class
RAMBDevSparse
:
SEC_SIZE
=
512
def
__init__
(
self
,
blocks
):
self
.
blocks
=
blocks
self
.
data
=
{}
def
readblocks
(
self
,
n
,
buf
):
#print("readblocks(%s, %x(%d))" % (n, id(buf), len(buf)))
assert
len
(
buf
)
==
self
.
SEC_SIZE
if
n
not
in
self
.
data
:
self
.
data
[
n
]
=
bytearray
(
self
.
SEC_SIZE
)
buf
[:]
=
self
.
data
[
n
]
def
writeblocks
(
self
,
n
,
buf
):
#print("writeblocks(%s, %x)" % (n, id(buf)))
mv
=
memoryview
(
buf
)
for
off
in
range
(
0
,
len
(
buf
),
self
.
SEC_SIZE
):
s
=
n
+
off
//
self
.
SEC_SIZE
if
s
not
in
self
.
data
:
self
.
data
[
s
]
=
bytearray
(
self
.
SEC_SIZE
)
self
.
data
[
s
][:]
=
mv
[
off
:
off
+
self
.
SEC_SIZE
]
def
ioctl
(
self
,
op
,
arg
):
#print("ioctl(%d, %r)" % (op, arg))
if
op
==
4
:
# BP_IOCTL_SEC_COUNT
return
self
.
blocks
if
op
==
5
:
# BP_IOCTL_SEC_SIZE
return
self
.
SEC_SIZE
try
:
bdev
=
RAMBDevSparse
(
4
*
1024
*
1024
*
1024
//
RAMBDevSparse
.
SEC_SIZE
)
uos
.
VfsFat
.
mkfs
(
bdev
)
except
MemoryError
:
print
(
"SKIP"
)
raise
SystemExit
vfs
=
uos
.
VfsFat
(
bdev
)
uos
.
mount
(
vfs
,
"/ramdisk"
)
print
(
"statvfs:"
,
vfs
.
statvfs
(
"/ramdisk"
))
f
=
open
(
'/ramdisk/test.txt'
,
'w'
)
f
.
write
(
'test file'
)
f
.
close
()
print
(
"statvfs:"
,
vfs
.
statvfs
(
"/ramdisk"
))
f
=
open
(
'/ramdisk/test.txt'
)
print
(
f
.
read
())
f
.
close
()
uos
.
umount
(
vfs
)
tests/extmod/vfs_fat_ramdisklarge.py.exp
0 → 100644
View file @
968b6880
statvfs: (32768, 32768, 131054, 131053, 131053, 0, 0, 0, 0, 255)
statvfs: (32768, 32768, 131054, 131052, 131052, 0, 0, 0, 0, 255)
test file
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