summaryrefslogtreecommitdiff
path: root/tests/extmod/vfs_posix_paths.py
AgeCommit message (Collapse)Author
2024-02-07tests: Use vfs module instead of os.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-10-19extmod/vfs_posix: Fix getcwd() on non-root VFS.Christian Walther
The unwritten API contract expected of a VFS.getcwd() by mp_vfs_getcwd() is that its return value should be either "" or "/" when the CWD is at the root of the VFS and otherwise start with a slash and not end with a slash. This was not correctly implemented in VfsPosix for instances with a non-empty root - the required leading slash, if any, was cut off because the root length includes a trailing slash. This would result in missing slashes in the middle of the return value of os.getcwd() or in uninitialized garbage from beyond a string's null terminator when the CWD was at the VFS root. Signed-off-by: Christian Walther <cwalther@gmx.ch>
2023-10-19extmod/vfs_posix: Fix relative paths on non-root VFS.Christian Walther
The unwritten API contract expected of a VFS by mp_vfs_lookup_path() is that paths passed in are relative to the root of the VFS if they start with '/' and relative to the current directory of the VFS otherwise. This was not correctly implemented in VfsPosix for instances with a non-empty root - all paths were interpreted relative to the root. Fix that. Since VfsPosix tracks its CWD using the "external" CWD of the Unix process, the correct handling for relative paths is to pass them through unmodified. Also, when concatenating absolute paths, fix an off-by-one resulting in a harmless double slash (the root path already has a trailing slash). Signed-off-by: Christian Walther <cwalther@gmx.ch>