summaryrefslogtreecommitdiff
path: root/tests/extmod/vfs_fat_ramdisk.py
diff options
context:
space:
mode:
authorAlex March <alex.march.dev@gmail.com>2016-10-07 10:19:04 +0100
committerDamien George <damien.p.george@gmail.com>2016-10-11 16:03:52 +1100
commitf274561e16dd35242d34c9b8fa7a09905857992c (patch)
tree88dcf1e5f0614e6917d3b5fe2d90f7ceb1d768e4 /tests/extmod/vfs_fat_ramdisk.py
parentd02f3a57f47b44bf31769fb089f1f18060ea3b4d (diff)
tests/extmod/vfs_fat: Test coverage for remove() and rmdir().
Diffstat (limited to 'tests/extmod/vfs_fat_ramdisk.py')
-rw-r--r--tests/extmod/vfs_fat_ramdisk.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/extmod/vfs_fat_ramdisk.py b/tests/extmod/vfs_fat_ramdisk.py
index f470dbcfe..d11ad324f 100644
--- a/tests/extmod/vfs_fat_ramdisk.py
+++ b/tests/extmod/vfs_fat_ramdisk.py
@@ -62,11 +62,22 @@ assert b"hello!" in bdev.data
assert vfs.listdir() == ['foo_file.txt']
+try:
+ vfs.rmdir("foo_file.txt")
+except OSError as e:
+ print(e.args[0] == 20) # uerrno.ENOTDIR
+
vfs.remove('foo_file.txt')
assert vfs.listdir() == []
vfs.mkdir("foo_dir")
assert vfs.listdir() == ['foo_dir']
+
+try:
+ vfs.remove("foo_dir")
+except OSError as e:
+ print(e.args[0] == uerrno.EISDIR)
+
f = vfs.open("foo_dir/file-in-dir.txt", "w")
f.write("data in file")
f.close()
@@ -84,9 +95,22 @@ with vfs.open("sub_file.txt", "w") as f:
f.write("test2")
assert vfs.listdir() == ["sub_file.txt"]
+try:
+ vfs.chdir("sub_file.txt")
+except OSError as e:
+ print(e.args[0] == uerrno.ENOENT)
+
vfs.chdir("..")
print("getcwd:", vfs.getcwd())
+try:
+ vfs.rmdir("foo_dir")
+except OSError as e:
+ print(e.args[0] == uerrno.EACCES)
+
+vfs.remove("foo_dir/sub_file.txt")
+vfs.rmdir("foo_dir")
+print(vfs.listdir())
vfs.umount()
try:
@@ -97,4 +121,4 @@ else:
raise AssertionError("expected OSError not thrown")
vfs = uos.VfsFat(bdev, "/ramdisk")
-assert vfs.listdir() == ['foo_dir', 'moved-to-root.txt']
+assert vfs.listdir() == ['moved-to-root.txt']