Skip to content

Commit 44bcfe5

Browse files
committed
tests/extmod/vfs_lfs_error.py: Test value of all OSError's errno.
To make sure they have the correct value. Signed-off-by: Damien George <[email protected]>
1 parent 62d26bf commit 44bcfe5

File tree

2 files changed

+45
-45
lines changed

2 files changed

+45
-45
lines changed

tests/extmod/vfs_lfs_error.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Test for VfsLittle using a RAM device, testing error handling
22

33
try:
4-
import vfs
4+
import errno, vfs
55

66
vfs.VfsLfs1
77
vfs.VfsLfs2
@@ -41,14 +41,14 @@ def test(bdev, vfs_class):
4141
# mkfs with too-small block device
4242
try:
4343
vfs_class.mkfs(RAMBlockDevice(1))
44-
except OSError:
45-
print("mkfs OSError")
44+
except OSError as er:
45+
print("mkfs OSError", er.errno > 0)
4646

4747
# mount with invalid filesystem
4848
try:
4949
vfs_class(bdev)
50-
except OSError:
51-
print("mount OSError")
50+
except OSError as er:
51+
print("mount OSError", er.errno > 0)
5252

5353
# set up for following tests
5454
vfs_class.mkfs(bdev)
@@ -60,60 +60,60 @@ def test(bdev, vfs_class):
6060
# ilistdir
6161
try:
6262
fs.ilistdir("noexist")
63-
except OSError:
64-
print("ilistdir OSError")
63+
except OSError as er:
64+
print("ilistdir OSError", er)
6565

6666
# remove
6767
try:
6868
fs.remove("noexist")
69-
except OSError:
70-
print("remove OSError")
69+
except OSError as er:
70+
print("remove OSError", er)
7171

7272
# rmdir
7373
try:
7474
fs.rmdir("noexist")
75-
except OSError:
76-
print("rmdir OSError")
75+
except OSError as er:
76+
print("rmdir OSError", er)
7777

7878
# rename
7979
try:
8080
fs.rename("noexist", "somethingelse")
81-
except OSError:
82-
print("rename OSError")
81+
except OSError as er:
82+
print("rename OSError", er)
8383

8484
# mkdir
8585
try:
8686
fs.mkdir("testdir")
87-
except OSError:
88-
print("mkdir OSError")
87+
except OSError as er:
88+
print("mkdir OSError", er)
8989

9090
# chdir to nonexistent
9191
try:
9292
fs.chdir("noexist")
93-
except OSError:
94-
print("chdir OSError")
93+
except OSError as er:
94+
print("chdir OSError", er)
9595
print(fs.getcwd()) # check still at root
9696

9797
# chdir to file
9898
try:
9999
fs.chdir("testfile")
100-
except OSError:
101-
print("chdir OSError")
100+
except OSError as er:
101+
print("chdir OSError", er)
102102
print(fs.getcwd()) # check still at root
103103

104104
# stat
105105
try:
106106
fs.stat("noexist")
107-
except OSError:
108-
print("stat OSError")
107+
except OSError as er:
108+
print("stat OSError", er)
109109

110110
# error during seek
111111
with fs.open("testfile", "r") as f:
112112
f.seek(1 << 30) # SEEK_SET
113113
try:
114114
f.seek(1 << 30, 1) # SEEK_CUR
115-
except OSError:
116-
print("seek OSError")
115+
except OSError as er:
116+
print("seek OSError", er)
117117

118118

119119
bdev = RAMBlockDevice(30)

tests/extmod/vfs_lfs_error.py.exp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
test <class 'VfsLfs1'>
2-
mkfs OSError
3-
mount OSError
4-
ilistdir OSError
5-
remove OSError
6-
rmdir OSError
7-
rename OSError
8-
mkdir OSError
9-
chdir OSError
2+
mkfs OSError True
3+
mount OSError True
4+
ilistdir OSError [Errno 2] ENOENT
5+
remove OSError [Errno 2] ENOENT
6+
rmdir OSError [Errno 2] ENOENT
7+
rename OSError [Errno 2] ENOENT
8+
mkdir OSError [Errno 17] EEXIST
9+
chdir OSError [Errno 2] ENOENT
1010
/
11-
chdir OSError
11+
chdir OSError [Errno 2] ENOENT
1212
/
13-
stat OSError
14-
seek OSError
13+
stat OSError [Errno 2] ENOENT
14+
seek OSError [Errno 22] EINVAL
1515
test <class 'VfsLfs2'>
16-
mkfs OSError
17-
mount OSError
18-
ilistdir OSError
19-
remove OSError
20-
rmdir OSError
21-
rename OSError
22-
mkdir OSError
23-
chdir OSError
16+
mkfs OSError True
17+
mount OSError True
18+
ilistdir OSError [Errno 2] ENOENT
19+
remove OSError [Errno 2] ENOENT
20+
rmdir OSError [Errno 2] ENOENT
21+
rename OSError [Errno 2] ENOENT
22+
mkdir OSError [Errno 17] EEXIST
23+
chdir OSError [Errno 2] ENOENT
2424
/
25-
chdir OSError
25+
chdir OSError [Errno 2] ENOENT
2626
/
27-
stat OSError
28-
seek OSError
27+
stat OSError [Errno 2] ENOENT
28+
seek OSError [Errno 22] EINVAL

0 commit comments

Comments
 (0)