Skip to content

Commit 852c215

Browse files
committed
tests/extmod/vfs: Update tests to reflect new ilistdir() method.
1 parent d4cd483 commit 852c215

10 files changed

+45
-30
lines changed

tests/extmod/vfs_basic.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ def mount(self, readonly, mkfs):
2020
print(self.id, 'mount', readonly, mkfs)
2121
def umount(self):
2222
print(self.id, 'umount')
23-
def listdir(self, dir):
24-
print(self.id, 'listdir', dir)
25-
return ['a%d' % self.id]
23+
def ilistdir(self, dir):
24+
print(self.id, 'ilistdir', dir)
25+
return iter([('a%d' % self.id, 0, 0)])
2626
def chdir(self, dir):
2727
print(self.id, 'chdir', dir)
2828
def getcwd(self):
@@ -64,6 +64,18 @@ def open(self, file, mode):
6464
uos.mount(Filesystem(1), '/test_mnt')
6565
print(uos.listdir())
6666

67+
# ilistdir
68+
i = uos.ilistdir()
69+
print(next(i))
70+
try:
71+
next(i)
72+
except StopIteration:
73+
print('StopIteration')
74+
try:
75+
next(i)
76+
except StopIteration:
77+
print('StopIteration')
78+
6779
# referencing the mount point in different ways
6880
print(uos.listdir('test_mnt'))
6981
print(uos.listdir('/test_mnt'))

tests/extmod/vfs_basic.py.exp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@
22
/
33
1 mount False False
44
['test_mnt']
5-
1 listdir /
5+
('test_mnt', 16384, 0)
6+
StopIteration
7+
StopIteration
8+
1 ilistdir /
69
['a1']
7-
1 listdir /
10+
1 ilistdir /
811
['a1']
912
2 mount True False
1013
['test_mnt', 'test_mnt2']
11-
2 listdir /
14+
2 ilistdir /
1215
['a2']
1316
3 mount False False
1417
OSError
1518
OSError
1619
OSError
1720
1 chdir /
18-
1 listdir
21+
1 ilistdir
1922
['a1']
2023
1 getcwd
2124
/test_mntdir1
@@ -33,19 +36,19 @@ OSError
3336
2 umount
3437
OSError
3538
3 mount False False
36-
3 listdir /
39+
3 ilistdir /
3740
['a3']
3841
3 open test r
3942
4 mount False False
40-
3 listdir /
43+
3 ilistdir /
4144
['mnt', 'a3']
42-
4 listdir /
45+
4 ilistdir /
4346
['a4']
4447
4 chdir /
45-
4 listdir
48+
4 ilistdir
4649
['a4']
4750
3 chdir /subdir
48-
3 listdir
51+
3 ilistdir
4952
['a3']
5053
3 chdir /
5154
3 umount

tests/extmod/vfs_fat_fileio1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,4 @@ def ioctl(self, op, arg):
115115
print(e.args[0] == 20) # uerrno.ENOTDIR
116116

117117
vfs.remove("foo_file.txt")
118-
print(vfs.listdir())
118+
print(list(vfs.ilistdir()))

tests/extmod/vfs_fat_fileio1.py.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ e
1010
True
1111
d
1212
True
13-
['foo_dir']
13+
[('foo_dir', 16384, 0)]

tests/extmod/vfs_fat_fileio2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,23 +91,23 @@ def ioctl(self, op, arg):
9191

9292
# trim full path
9393
vfs.rename("foo_dir/file-in-dir.txt", "foo_dir/file.txt")
94-
print(vfs.listdir("foo_dir"))
94+
print(list(vfs.ilistdir("foo_dir")))
9595

9696
vfs.rename("foo_dir/file.txt", "moved-to-root.txt")
97-
print(vfs.listdir())
97+
print(list(vfs.ilistdir()))
9898

9999
# check that renaming to existing file will overwrite it
100100
with open("temp", "w") as f:
101101
f.write("new text")
102102
vfs.rename("temp", "moved-to-root.txt")
103-
print(vfs.listdir())
103+
print(list(vfs.ilistdir()))
104104
with open("moved-to-root.txt") as f:
105105
print(f.read())
106106

107107
# valid removes
108108
vfs.remove("foo_dir/sub_file.txt")
109109
vfs.rmdir("foo_dir")
110-
print(vfs.listdir())
110+
print(list(vfs.ilistdir()))
111111

112112
# disk full
113113
try:

tests/extmod/vfs_fat_fileio2.py.exp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ True
33
True
44
b'data in file'
55
True
6-
['sub_file.txt', 'file.txt']
7-
['foo_dir', 'moved-to-root.txt']
8-
['foo_dir', 'moved-to-root.txt']
6+
[('sub_file.txt', 32768, 0), ('file.txt', 32768, 0)]
7+
[('foo_dir', 16384, 0), ('moved-to-root.txt', 32768, 0)]
8+
[('foo_dir', 16384, 0), ('moved-to-root.txt', 32768, 0)]
99
new text
10-
['moved-to-root.txt']
10+
[('moved-to-root.txt', 32768, 0)]
1111
ENOSPC: True

tests/extmod/vfs_fat_oldproto.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ def count(self):
5353
with vfs.open("file.txt", "w") as f:
5454
f.write("hello!")
5555

56-
print(vfs.listdir())
56+
print(list(vfs.ilistdir()))
5757

5858
with vfs.open("file.txt", "r") as f:
5959
print(f.read())
6060

6161
vfs.remove("file.txt")
62-
print(vfs.listdir())
62+
print(list(vfs.ilistdir()))

tests/extmod/vfs_fat_oldproto.py.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
['file.txt']
1+
[('file.txt', 32768, 0)]
22
hello!
33
[]

tests/extmod/vfs_fat_ramdisk.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def ioctl(self, op, arg):
6565

6666
with vfs.open("foo_file.txt", "w") as f:
6767
f.write("hello!")
68-
print(vfs.listdir())
68+
print(list(vfs.ilistdir()))
6969

7070
print("stat root:", vfs.stat("/"))
7171
print("stat file:", vfs.stat("foo_file.txt")[:-3]) # timestamps differ across runs
@@ -76,7 +76,7 @@ def ioctl(self, op, arg):
7676
vfs.mkdir("foo_dir")
7777
vfs.chdir("foo_dir")
7878
print("getcwd:", vfs.getcwd())
79-
print(vfs.listdir())
79+
print(list(vfs.ilistdir()))
8080

8181
with vfs.open("sub_file.txt", "w") as f:
8282
f.write("subdir file")
@@ -92,4 +92,4 @@ def ioctl(self, op, arg):
9292
uos.umount(vfs)
9393

9494
vfs = uos.VfsFat(bdev)
95-
print(vfs.listdir(b""))
95+
print(list(vfs.ilistdir(b"")))

tests/extmod/vfs_fat_ramdisk.py.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ True
33
statvfs: (512, 512, 16, 16, 16, 0, 0, 0, 0, 255)
44
getcwd: /
55
True
6-
['foo_file.txt']
6+
[('foo_file.txt', 32768, 0)]
77
stat root: (16384, 0, 0, 0, 0, 0, 0, 0, 0, 0)
88
stat file: (32768, 0, 0, 0, 0, 0, 6)
99
True
@@ -12,4 +12,4 @@ getcwd: /foo_dir
1212
[]
1313
True
1414
getcwd: /
15-
[b'foo_file.txt', b'foo_dir']
15+
[(b'foo_file.txt', 32768, 0), (b'foo_dir', 16384, 0)]

0 commit comments

Comments
 (0)