Skip to content

Commit f0eea1f

Browse files
committed
tests/extmod/vfs_fat_ramdisk: Add testcases for chdir(), getcwd().
1 parent ee5e3f6 commit f0eea1f

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

tests/extmod/vfs_fat_ramdisk.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ def ioctl(self, op, arg):
4545

4646
vfs = uos.VfsFat(bdev, "/ramdisk")
4747

48+
print("getcwd:", vfs.getcwd())
49+
4850
f = vfs.open("foo_file.txt", "w")
4951
f.write("hello!")
5052
f.close()
@@ -71,3 +73,14 @@ def ioctl(self, op, arg):
7173

7274
vfs.rename("foo_dir/file-in-dir.txt", "moved-to-root.txt")
7375
assert vfs.listdir() == ['foo_dir', 'moved-to-root.txt']
76+
77+
vfs.chdir("foo_dir")
78+
print("getcwd:", vfs.getcwd())
79+
assert vfs.listdir() == []
80+
81+
with vfs.open("sub_file.txt", "w") as f:
82+
f.write("test2")
83+
assert vfs.listdir() == ["sub_file.txt"]
84+
85+
vfs.chdir("..")
86+
print("getcwd:", vfs.getcwd())
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
getcwd: /ramdisk
12
hello!
3+
getcwd: /ramdisk/foo_dir
4+
getcwd: /ramdisk

0 commit comments

Comments
 (0)