tests/extmod/vfs_fat_ramdisk: Add testcases for chdir(), getcwd().

This commit is contained in:
Paul Sokolovsky 2016-05-29 18:54:14 +03:00
parent ee5e3f6527
commit f0eea1fdf9
2 changed files with 16 additions and 0 deletions

View File

@ -45,6 +45,8 @@ assert b"hello!" not in bdev.data
vfs = uos.VfsFat(bdev, "/ramdisk") vfs = uos.VfsFat(bdev, "/ramdisk")
print("getcwd:", vfs.getcwd())
f = vfs.open("foo_file.txt", "w") f = vfs.open("foo_file.txt", "w")
f.write("hello!") f.write("hello!")
f.close() f.close()
@ -71,3 +73,14 @@ assert vfs.listdir("foo_dir") == ['file-in-dir.txt']
vfs.rename("foo_dir/file-in-dir.txt", "moved-to-root.txt") vfs.rename("foo_dir/file-in-dir.txt", "moved-to-root.txt")
assert vfs.listdir() == ['foo_dir', 'moved-to-root.txt'] assert vfs.listdir() == ['foo_dir', 'moved-to-root.txt']
vfs.chdir("foo_dir")
print("getcwd:", vfs.getcwd())
assert vfs.listdir() == []
with vfs.open("sub_file.txt", "w") as f:
f.write("test2")
assert vfs.listdir() == ["sub_file.txt"]
vfs.chdir("..")
print("getcwd:", vfs.getcwd())

View File

@ -1 +1,4 @@
getcwd: /ramdisk
hello! hello!
getcwd: /ramdisk/foo_dir
getcwd: /ramdisk