tests/extmod/vfs_lfs_error.py: Test value of all OSError's errno.
Some checks failed
JavaScript code lint and formatting with Biome / eslint (push) Has been cancelled
Check code formatting / code-formatting (push) Has been cancelled
Check spelling with codespell / codespell (push) Has been cancelled
Build docs / build (push) Has been cancelled
Check examples / embedding (push) Has been cancelled
Package mpremote / build (push) Has been cancelled
.mpy file format and tools / test (push) Has been cancelled
Build ports metadata / build (push) Has been cancelled
alif port / build_alif (alif_ae3_build) (push) Has been cancelled
cc3200 port / build (push) Has been cancelled
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Has been cancelled
esp32 port / build_idf (esp32_build_s3_c3) (push) Has been cancelled
esp8266 port / build (push) Has been cancelled
mimxrt port / build (push) Has been cancelled
nrf port / build (push) Has been cancelled
powerpc port / build (push) Has been cancelled
qemu port / build_and_test_arm (push) Has been cancelled
qemu port / build_and_test_rv32 (push) Has been cancelled
renesas-ra port / build_renesas_ra_board (push) Has been cancelled
rp2 port / build (push) Has been cancelled
samd port / build (push) Has been cancelled
stm32 port / build_stm32 (stm32_misc_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_nucleo_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_pyb_build) (push) Has been cancelled
unix port / minimal (push) Has been cancelled
unix port / reproducible (push) Has been cancelled
unix port / standard (push) Has been cancelled
unix port / standard_v2 (push) Has been cancelled
unix port / coverage (push) Has been cancelled
unix port / coverage_32bit (push) Has been cancelled
unix port / nanbox (push) Has been cancelled
unix port / float (push) Has been cancelled
unix port / stackless_clang (push) Has been cancelled
unix port / float_clang (push) Has been cancelled
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled

To make sure they have the correct value.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2025-05-13 12:55:01 +10:00
parent 62d26bfc15
commit 44bcfe53de
2 changed files with 45 additions and 45 deletions

View File

@@ -1,7 +1,7 @@
# Test for VfsLittle using a RAM device, testing error handling # Test for VfsLittle using a RAM device, testing error handling
try: try:
import vfs import errno, vfs
vfs.VfsLfs1 vfs.VfsLfs1
vfs.VfsLfs2 vfs.VfsLfs2
@@ -41,14 +41,14 @@ def test(bdev, vfs_class):
# mkfs with too-small block device # mkfs with too-small block device
try: try:
vfs_class.mkfs(RAMBlockDevice(1)) vfs_class.mkfs(RAMBlockDevice(1))
except OSError: except OSError as er:
print("mkfs OSError") print("mkfs OSError", er.errno > 0)
# mount with invalid filesystem # mount with invalid filesystem
try: try:
vfs_class(bdev) vfs_class(bdev)
except OSError: except OSError as er:
print("mount OSError") print("mount OSError", er.errno > 0)
# set up for following tests # set up for following tests
vfs_class.mkfs(bdev) vfs_class.mkfs(bdev)
@@ -60,60 +60,60 @@ def test(bdev, vfs_class):
# ilistdir # ilistdir
try: try:
fs.ilistdir("noexist") fs.ilistdir("noexist")
except OSError: except OSError as er:
print("ilistdir OSError") print("ilistdir OSError", er)
# remove # remove
try: try:
fs.remove("noexist") fs.remove("noexist")
except OSError: except OSError as er:
print("remove OSError") print("remove OSError", er)
# rmdir # rmdir
try: try:
fs.rmdir("noexist") fs.rmdir("noexist")
except OSError: except OSError as er:
print("rmdir OSError") print("rmdir OSError", er)
# rename # rename
try: try:
fs.rename("noexist", "somethingelse") fs.rename("noexist", "somethingelse")
except OSError: except OSError as er:
print("rename OSError") print("rename OSError", er)
# mkdir # mkdir
try: try:
fs.mkdir("testdir") fs.mkdir("testdir")
except OSError: except OSError as er:
print("mkdir OSError") print("mkdir OSError", er)
# chdir to nonexistent # chdir to nonexistent
try: try:
fs.chdir("noexist") fs.chdir("noexist")
except OSError: except OSError as er:
print("chdir OSError") print("chdir OSError", er)
print(fs.getcwd()) # check still at root print(fs.getcwd()) # check still at root
# chdir to file # chdir to file
try: try:
fs.chdir("testfile") fs.chdir("testfile")
except OSError: except OSError as er:
print("chdir OSError") print("chdir OSError", er)
print(fs.getcwd()) # check still at root print(fs.getcwd()) # check still at root
# stat # stat
try: try:
fs.stat("noexist") fs.stat("noexist")
except OSError: except OSError as er:
print("stat OSError") print("stat OSError", er)
# error during seek # error during seek
with fs.open("testfile", "r") as f: with fs.open("testfile", "r") as f:
f.seek(1 << 30) # SEEK_SET f.seek(1 << 30) # SEEK_SET
try: try:
f.seek(1 << 30, 1) # SEEK_CUR f.seek(1 << 30, 1) # SEEK_CUR
except OSError: except OSError as er:
print("seek OSError") print("seek OSError", er)
bdev = RAMBlockDevice(30) bdev = RAMBlockDevice(30)

View File

@@ -1,28 +1,28 @@
test <class 'VfsLfs1'> test <class 'VfsLfs1'>
mkfs OSError mkfs OSError True
mount OSError mount OSError True
ilistdir OSError ilistdir OSError [Errno 2] ENOENT
remove OSError remove OSError [Errno 2] ENOENT
rmdir OSError rmdir OSError [Errno 2] ENOENT
rename OSError rename OSError [Errno 2] ENOENT
mkdir OSError mkdir OSError [Errno 17] EEXIST
chdir OSError chdir OSError [Errno 2] ENOENT
/ /
chdir OSError chdir OSError [Errno 2] ENOENT
/ /
stat OSError stat OSError [Errno 2] ENOENT
seek OSError seek OSError [Errno 22] EINVAL
test <class 'VfsLfs2'> test <class 'VfsLfs2'>
mkfs OSError mkfs OSError True
mount OSError mount OSError True
ilistdir OSError ilistdir OSError [Errno 2] ENOENT
remove OSError remove OSError [Errno 2] ENOENT
rmdir OSError rmdir OSError [Errno 2] ENOENT
rename OSError rename OSError [Errno 2] ENOENT
mkdir OSError mkdir OSError [Errno 17] EEXIST
chdir OSError chdir OSError [Errno 2] ENOENT
/ /
chdir OSError chdir OSError [Errno 2] ENOENT
/ /
stat OSError stat OSError [Errno 2] ENOENT
seek OSError seek OSError [Errno 22] EINVAL