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
852c215d
Commit
852c215d
authored
May 05, 2017
by
Damien George
Browse files
tests/extmod/vfs: Update tests to reflect new ilistdir() method.
parent
d4cd4831
Changes
10
Hide whitespace changes
Inline
Side-by-side
tests/extmod/vfs_basic.py
View file @
852c215d
...
...
@@ -20,9 +20,9 @@ class Filesystem:
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
i
listdir
(
self
,
dir
):
print
(
self
.
id
,
'
i
listdir'
,
dir
)
return
iter
([(
'a%d'
%
self
.
id
,
0
,
0
)])
def
chdir
(
self
,
dir
):
print
(
self
.
id
,
'chdir'
,
dir
)
def
getcwd
(
self
):
...
...
@@ -64,6 +64,18 @@ print(uos.getcwd())
uos
.
mount
(
Filesystem
(
1
),
'/test_mnt'
)
print
(
uos
.
listdir
())
# ilistdir
i
=
uos
.
ilistdir
()
print
(
next
(
i
))
try
:
next
(
i
)
except
StopIteration
:
print
(
'StopIteration'
)
try
:
next
(
i
)
except
StopIteration
:
print
(
'StopIteration'
)
# referencing the mount point in different ways
print
(
uos
.
listdir
(
'test_mnt'
))
print
(
uos
.
listdir
(
'/test_mnt'
))
...
...
tests/extmod/vfs_basic.py.exp
View file @
852c215d
...
...
@@ -2,20 +2,23 @@
/
1 mount False False
['test_mnt']
1 listdir /
('test_mnt', 16384, 0)
StopIteration
StopIteration
1 ilistdir /
['a1']
1 listdir /
1
i
listdir /
['a1']
2 mount True False
['test_mnt', 'test_mnt2']
2 listdir /
2
i
listdir /
['a2']
3 mount False False
OSError
OSError
OSError
1 chdir /
1 listdir
1
i
listdir
['a1']
1 getcwd
/test_mntdir1
...
...
@@ -33,19 +36,19 @@ OSError
2 umount
OSError
3 mount False False
3 listdir /
3
i
listdir /
['a3']
3 open test r
4 mount False False
3 listdir /
3
i
listdir /
['mnt', 'a3']
4 listdir /
4
i
listdir /
['a4']
4 chdir /
4 listdir
4
i
listdir
['a4']
3 chdir /subdir
3 listdir
3
i
listdir
['a3']
3 chdir /
3 umount
...
...
tests/extmod/vfs_fat_fileio1.py
View file @
852c215d
...
...
@@ -115,4 +115,4 @@ except OSError as e:
print
(
e
.
args
[
0
]
==
20
)
# uerrno.ENOTDIR
vfs
.
remove
(
"foo_file.txt"
)
print
(
vfs
.
listdir
())
print
(
list
(
vfs
.
i
listdir
())
)
tests/extmod/vfs_fat_fileio1.py.exp
View file @
852c215d
...
...
@@ -10,4 +10,4 @@ e
True
d
True
['foo_dir']
[
(
'foo_dir'
, 16384, 0)
]
tests/extmod/vfs_fat_fileio2.py
View file @
852c215d
...
...
@@ -91,23 +91,23 @@ except OSError as e:
# trim full path
vfs
.
rename
(
"foo_dir/file-in-dir.txt"
,
"foo_dir/file.txt"
)
print
(
vfs
.
listdir
(
"foo_dir"
))
print
(
list
(
vfs
.
i
listdir
(
"foo_dir"
))
)
vfs
.
rename
(
"foo_dir/file.txt"
,
"moved-to-root.txt"
)
print
(
vfs
.
listdir
())
print
(
list
(
vfs
.
i
listdir
())
)
# check that renaming to existing file will overwrite it
with
open
(
"temp"
,
"w"
)
as
f
:
f
.
write
(
"new text"
)
vfs
.
rename
(
"temp"
,
"moved-to-root.txt"
)
print
(
vfs
.
listdir
())
print
(
list
(
vfs
.
i
listdir
())
)
with
open
(
"moved-to-root.txt"
)
as
f
:
print
(
f
.
read
())
# valid removes
vfs
.
remove
(
"foo_dir/sub_file.txt"
)
vfs
.
rmdir
(
"foo_dir"
)
print
(
vfs
.
listdir
())
print
(
list
(
vfs
.
i
listdir
())
)
# disk full
try
:
...
...
tests/extmod/vfs_fat_fileio2.py.exp
View file @
852c215d
...
...
@@ -3,9 +3,9 @@ True
True
b'data in file'
True
['sub_file.txt',
'file.txt'
]
['foo_dir', 'moved-to-root.txt']
['foo_dir', 'moved-to-root.txt']
[
(
'sub_file.txt',
32768, 0), ('file.txt', 32768, 0)
]
[
(
'foo_dir',
16384, 0), (
'moved-to-root.txt'
, 32768, 0)
]
[
(
'foo_dir',
16384, 0), (
'moved-to-root.txt'
, 32768, 0)
]
new text
['moved-to-root.txt']
[
(
'moved-to-root.txt'
, 32768, 0)
]
ENOSPC: True
tests/extmod/vfs_fat_oldproto.py
View file @
852c215d
...
...
@@ -53,10 +53,10 @@ uos.mount(vfs, "/ramdisk")
with
vfs
.
open
(
"file.txt"
,
"w"
)
as
f
:
f
.
write
(
"hello!"
)
print
(
vfs
.
listdir
())
print
(
list
(
vfs
.
i
listdir
())
)
with
vfs
.
open
(
"file.txt"
,
"r"
)
as
f
:
print
(
f
.
read
())
vfs
.
remove
(
"file.txt"
)
print
(
vfs
.
listdir
())
print
(
list
(
vfs
.
i
listdir
())
)
tests/extmod/vfs_fat_oldproto.py.exp
View file @
852c215d
['file.txt']
[
(
'file.txt'
, 32768, 0)
]
hello!
[]
tests/extmod/vfs_fat_ramdisk.py
View file @
852c215d
...
...
@@ -65,7 +65,7 @@ except OSError as e:
with
vfs
.
open
(
"foo_file.txt"
,
"w"
)
as
f
:
f
.
write
(
"hello!"
)
print
(
vfs
.
listdir
())
print
(
list
(
vfs
.
i
listdir
())
)
print
(
"stat root:"
,
vfs
.
stat
(
"/"
))
print
(
"stat file:"
,
vfs
.
stat
(
"foo_file.txt"
)[:
-
3
])
# timestamps differ across runs
...
...
@@ -76,7 +76,7 @@ print(b"hello!" in bdev.data)
vfs
.
mkdir
(
"foo_dir"
)
vfs
.
chdir
(
"foo_dir"
)
print
(
"getcwd:"
,
vfs
.
getcwd
())
print
(
vfs
.
listdir
())
print
(
list
(
vfs
.
i
listdir
())
)
with
vfs
.
open
(
"sub_file.txt"
,
"w"
)
as
f
:
f
.
write
(
"subdir file"
)
...
...
@@ -92,4 +92,4 @@ print("getcwd:", vfs.getcwd())
uos
.
umount
(
vfs
)
vfs
=
uos
.
VfsFat
(
bdev
)
print
(
vfs
.
listdir
(
b
""
))
print
(
list
(
vfs
.
i
listdir
(
b
""
))
)
tests/extmod/vfs_fat_ramdisk.py.exp
View file @
852c215d
...
...
@@ -3,7 +3,7 @@ True
statvfs: (512, 512, 16, 16, 16, 0, 0, 0, 0, 255)
getcwd: /
True
['foo_file.txt']
[
(
'foo_file.txt'
, 32768, 0)
]
stat root: (16384, 0, 0, 0, 0, 0, 0, 0, 0, 0)
stat file: (32768, 0, 0, 0, 0, 0, 6)
True
...
...
@@ -12,4 +12,4 @@ getcwd: /foo_dir
[]
True
getcwd: /
[b'foo_file.txt',
b'foo_dir'
]
[
(
b'foo_file.txt',
32768, 0), (b'foo_dir', 16384, 0)
]
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