summaryrefslogtreecommitdiff
path: root/tests/micropython/import_mpy_invalid.py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-11-15 13:52:04 +1100
committerDamien George <damien@micropython.org>2024-12-20 21:52:19 +1100
commita3128f89ccb1d24d0ddaec7164d2fa8a101b8ac3 (patch)
tree3ee8220ae691d2baf23b70891b8a7ebcbd334175 /tests/micropython/import_mpy_invalid.py
parent4e76acc88d8673ce4f43698fbb4c2913e63b0135 (diff)
tests: Fix all file ioctl's to support only MP_STREAM_CLOSE.
A return value of 0 from Python-level `ioctl()` means success, but if that's returned unconditionally it means that the method supports all ioctl calls, which is not true. Returning 0 without doing anything can potentially lead to a crash, eg for MP_STREAM_SEEK which requires returning a value in the passed-in struct pointer. This commit makes it so that all `ioctl()` methods respond only to MP_STREAM_CLOSE, ie they return -1 (indicating error) for all other ioctl calls. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/micropython/import_mpy_invalid.py')
-rw-r--r--tests/micropython/import_mpy_invalid.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/micropython/import_mpy_invalid.py b/tests/micropython/import_mpy_invalid.py
index 89fdf4483..f928d45c7 100644
--- a/tests/micropython/import_mpy_invalid.py
+++ b/tests/micropython/import_mpy_invalid.py
@@ -22,7 +22,9 @@ class UserFile(io.IOBase):
return n
def ioctl(self, req, arg):
- return 0
+ if req == 4: # MP_STREAM_CLOSE
+ return 0
+ return -1
class UserFS: