From 94d87fbb308bf26e35cbb50f294fb06f178df871 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 24 Jan 2017 20:55:05 +1100 Subject: test/extmod: Update vfs_fat tests for new OO FatFs library. The new version of FatFs requires a minimum of 50 blocks on the device. Also, some tests no longer make sense with an OO vfs. --- tests/extmod/vfs_fat_ramdisk.py.exp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'tests/extmod/vfs_fat_ramdisk.py.exp') diff --git a/tests/extmod/vfs_fat_ramdisk.py.exp b/tests/extmod/vfs_fat_ramdisk.py.exp index eaf637199..095620f17 100644 --- a/tests/extmod/vfs_fat_ramdisk.py.exp +++ b/tests/extmod/vfs_fat_ramdisk.py.exp @@ -1,7 +1,6 @@ True True -True -statvfs: (512, 512, 14, 14, 14, 0, 0, 0, 0, 255) +statvfs: (512, 512, 16, 16, 16, 0, 0, 0, 0, 255) getcwd: /ramdisk True ['foo_file.txt'] @@ -14,6 +13,4 @@ getcwd: /ramdisk/foo_dir [] True getcwd: /ramdisk -True -True [b'foo_file.txt', b'foo_dir'] -- cgit v1.2.3 From b9bfaa349aaba4462522fd9330dbc5b21f47d906 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 27 Jan 2017 15:34:36 +1100 Subject: tests/extmod/vfs_fat: Update tests to work with new VFS sub-system. The vfs_fat_fsusermount test is no longer relevant so has been removed. --- tests/extmod/vfs_fat_fileio.py | 37 ++++++++----- tests/extmod/vfs_fat_fileio.py.exp | 1 - tests/extmod/vfs_fat_fsusermount.py | 97 --------------------------------- tests/extmod/vfs_fat_fsusermount.py.exp | 6 -- tests/extmod/vfs_fat_oldproto.py | 16 +++--- tests/extmod/vfs_fat_ramdisk.py | 13 +++-- tests/extmod/vfs_fat_ramdisk.py.exp | 7 +-- 7 files changed, 40 insertions(+), 137 deletions(-) delete mode 100644 tests/extmod/vfs_fat_fsusermount.py delete mode 100644 tests/extmod/vfs_fat_fsusermount.py.exp (limited to 'tests/extmod/vfs_fat_ramdisk.py.exp') diff --git a/tests/extmod/vfs_fat_fileio.py b/tests/extmod/vfs_fat_fileio.py index fd84cdca8..6fdac0710 100644 --- a/tests/extmod/vfs_fat_fileio.py +++ b/tests/extmod/vfs_fat_fileio.py @@ -1,6 +1,10 @@ import sys -import uos import uerrno +try: + import uos_vfs as uos + open = uos.vfs_open +except ImportError: + import uos try: uos.VfsFat except AttributeError: @@ -40,10 +44,12 @@ except MemoryError: sys.exit() uos.VfsFat.mkfs(bdev) -vfs = uos.VfsFat(bdev, "/ramdisk") +vfs = uos.VfsFat(bdev) +uos.mount(vfs, '/ramdisk') +uos.chdir('/ramdisk') # file IO -f = vfs.open("foo_file.txt", "w") +f = open("foo_file.txt", "w") print(str(f)[:17], str(f)[-1:]) f.write("hello!") f.flush() @@ -65,14 +71,14 @@ except OSError as e: print(e.args[0] == uerrno.EINVAL) try: - vfs.open("foo_file.txt", "x") + open("foo_file.txt", "x") except OSError as e: print(e.args[0] == uerrno.EEXIST) -with vfs.open("foo_file.txt", "a") as f: +with open("foo_file.txt", "a") as f: f.write("world!") -with vfs.open("foo_file.txt") as f2: +with open("foo_file.txt") as f2: print(f2.read()) print(f2.tell()) @@ -90,9 +96,10 @@ with vfs.open("foo_file.txt") as f2: print(f2.read(1)) # using constructor of FileIO type to open a file -FileIO = type(f) -with FileIO("/ramdisk/foo_file.txt") as f: - print(f.read()) +# no longer working with new VFS sub-system +#FileIO = type(f) +#with FileIO("/ramdisk/foo_file.txt") as f: +# print(f.read()) # dirs vfs.mkdir("foo_dir") @@ -123,13 +130,13 @@ except OSError as e: print(e.args[0] == uerrno.ENOENT) # file in dir -with vfs.open("foo_dir/file-in-dir.txt", "w+t") as f: +with open("foo_dir/file-in-dir.txt", "w+t") as f: f.write("data in file") -with vfs.open("foo_dir/file-in-dir.txt", "r+b") as f: +with open("foo_dir/file-in-dir.txt", "r+b") as f: print(f.read()) -with vfs.open("foo_dir/sub_file.txt", "w") as f: +with open("foo_dir/sub_file.txt", "w") as f: f.write("subdir file") # directory not empty @@ -146,11 +153,11 @@ vfs.rename("foo_dir/file.txt", "moved-to-root.txt") print(vfs.listdir()) # check that renaming to existing file will overwrite it -with vfs.open("temp", "w") as f: +with open("temp", "w") as f: f.write("new text") vfs.rename("temp", "moved-to-root.txt") print(vfs.listdir()) -with vfs.open("moved-to-root.txt") as f: +with open("moved-to-root.txt") as f: print(f.read()) # valid removes @@ -163,7 +170,7 @@ print(vfs.listdir()) try: bsize = vfs.statvfs("/ramdisk")[0] free = vfs.statvfs("/ramdisk")[2] + 1 - f = vfs.open("large_file.txt", "wb") + f = open("large_file.txt", "wb") f.write(bytearray(bsize * free)) except OSError as e: print("ENOSPC:", e.args[0] == 28) # uerrno.ENOSPC diff --git a/tests/extmod/vfs_fat_fileio.py.exp b/tests/extmod/vfs_fat_fileio.py.exp index a09442ae8..4e34e83a8 100644 --- a/tests/extmod/vfs_fat_fileio.py.exp +++ b/tests/extmod/vfs_fat_fileio.py.exp @@ -9,7 +9,6 @@ h e True d -hello!world! True True True diff --git a/tests/extmod/vfs_fat_fsusermount.py b/tests/extmod/vfs_fat_fsusermount.py deleted file mode 100644 index 0ab15d827..000000000 --- a/tests/extmod/vfs_fat_fsusermount.py +++ /dev/null @@ -1,97 +0,0 @@ -import sys -import uos -import uerrno -try: - uos.VfsFat -except AttributeError: - print("SKIP") - sys.exit() - - -class RAMFS: - - SEC_SIZE = 512 - - def __init__(self, blocks): - self.data = bytearray(blocks * self.SEC_SIZE) - - def readblocks(self, n, buf): - #print("readblocks(%s, %x(%d))" % (n, id(buf), len(buf))) - for i in range(len(buf)): - buf[i] = self.data[n * self.SEC_SIZE + i] - - def writeblocks(self, n, buf): - #print("writeblocks(%s, %x)" % (n, id(buf))) - for i in range(len(buf)): - self.data[n * self.SEC_SIZE + i] = buf[i] - - def ioctl(self, op, arg): - #print("ioctl(%d, %r)" % (op, arg)) - if op == 4: # BP_IOCTL_SEC_COUNT - return len(self.data) // self.SEC_SIZE - if op == 5: # BP_IOCTL_SEC_SIZE - return self.SEC_SIZE - - -try: - bdev = RAMFS(50) -except MemoryError: - print("SKIP") - sys.exit() - -# can't mkfs readonly device -try: - uos.vfs_mkfs(bdev, "/ramdisk", readonly=True) -except OSError as e: - print(e) - -# mount before mkfs -try: - uos.vfs_mount(bdev, "/ramdisk") -except OSError as e: - print(e) - -# invalid umount -try: - uos.vfs_umount("/ramdisk") -except OSError as e: - print(e.args[0] == uerrno.EINVAL) - -try: - uos.vfs_mount(None, "/ramdisk") -except OSError as e: - print(e) - -try: - uos.vfs_mkfs(None, "/ramdisk") -except OSError as e: - print(e) - -# valid mkfs/mount -uos.vfs_mkfs(bdev, "/ramdisk") -uos.vfs_mount(bdev, "/ramdisk") - -# umount by path -uos.vfs_umount("/ramdisk") - -# readonly mount -# note: this test doesn't work correctly with new OO FatFs -uos.vfs_mount(bdev, "/ramdisk", readonly=True) -vfs = uos.VfsFat(bdev, "/ramdisk") -try: - f = vfs.open("file.txt", "w") -except OSError as e: - print("EROFS:", e.args[0] == 30) # uerrno.EROFS - -# device is None == umount -uos.vfs_mount(None, "/ramdisk") - -# max mounted devices -dev = [] -try: - for i in range(0,4): - dev.append(RAMFS(50)) - uos.vfs_mkfs(dev[i], "/ramdisk" + str(i)) - uos.vfs_mount(dev[i], "/ramdisk" + str(i)) -except OSError as e: - print(e) diff --git a/tests/extmod/vfs_fat_fsusermount.py.exp b/tests/extmod/vfs_fat_fsusermount.py.exp deleted file mode 100644 index 3ace58372..000000000 --- a/tests/extmod/vfs_fat_fsusermount.py.exp +++ /dev/null @@ -1,6 +0,0 @@ -can't mkfs -can't mount -True -can't umount -can't umount -too many devices mounted diff --git a/tests/extmod/vfs_fat_oldproto.py b/tests/extmod/vfs_fat_oldproto.py index b43fbd286..03ab76e35 100644 --- a/tests/extmod/vfs_fat_oldproto.py +++ b/tests/extmod/vfs_fat_oldproto.py @@ -1,10 +1,11 @@ import sys -import uos import uerrno +try: + import uos_vfs as uos +except ImportError: + import uos try: uos.VfsFat - uos.vfs_mkfs - uos.vfs_mount except AttributeError: print("SKIP") sys.exit() @@ -39,11 +40,11 @@ except MemoryError: print("SKIP") sys.exit() -uos.vfs_mkfs(bdev, "/ramdisk") -uos.vfs_mount(bdev, "/ramdisk") +uos.VfsFat.mkfs(bdev) +vfs = uos.VfsFat(bdev) +uos.mount(vfs, "/ramdisk") # file io -vfs = uos.VfsFat(bdev, "/ramdisk") with vfs.open("file.txt", "w") as f: f.write("hello!") @@ -54,6 +55,3 @@ with vfs.open("file.txt", "r") as f: vfs.remove("file.txt") print(vfs.listdir()) - -# umount by device -uos.vfs_umount(bdev) diff --git a/tests/extmod/vfs_fat_ramdisk.py b/tests/extmod/vfs_fat_ramdisk.py index 1480d52f6..a9eb1679a 100644 --- a/tests/extmod/vfs_fat_ramdisk.py +++ b/tests/extmod/vfs_fat_ramdisk.py @@ -1,6 +1,9 @@ import sys -import uos import uerrno +try: + import uos_vfs as uos +except ImportError: + import uos try: uos.VfsFat except AttributeError: @@ -44,7 +47,8 @@ uos.VfsFat.mkfs(bdev) print(b"FOO_FILETXT" not in bdev.data) print(b"hello!" not in bdev.data) -vfs = uos.VfsFat(bdev, "/ramdisk") +vfs = uos.VfsFat(bdev) +uos.mount(vfs, "/ramdisk") print("statvfs:", vfs.statvfs("/ramdisk")) print("getcwd:", vfs.getcwd()) @@ -59,7 +63,6 @@ with vfs.open("foo_file.txt", "w") as f: print(vfs.listdir()) print("stat root:", vfs.stat("/")) -print("stat disk:", vfs.stat("/ramdisk/")) print("stat file:", vfs.stat("foo_file.txt")) print(b"FOO_FILETXT" in bdev.data) @@ -81,7 +84,7 @@ except OSError as e: vfs.chdir("..") print("getcwd:", vfs.getcwd()) -vfs.umount() +uos.umount(vfs) -vfs = uos.VfsFat(bdev, "/ramdisk") +vfs = uos.VfsFat(bdev) print(vfs.listdir(b"")) diff --git a/tests/extmod/vfs_fat_ramdisk.py.exp b/tests/extmod/vfs_fat_ramdisk.py.exp index 095620f17..fda7d300e 100644 --- a/tests/extmod/vfs_fat_ramdisk.py.exp +++ b/tests/extmod/vfs_fat_ramdisk.py.exp @@ -1,16 +1,15 @@ True True statvfs: (512, 512, 16, 16, 16, 0, 0, 0, 0, 255) -getcwd: /ramdisk +getcwd: / True ['foo_file.txt'] stat root: (16384, 0, 0, 0, 0, 0, 0, 0, 0, 0) -stat disk: (16384, 0, 0, 0, 0, 0, 0, 0, 0, 0) stat file: (32768, 0, 0, 0, 0, 0, 6, -631238400, -631238400, -631238400) True True -getcwd: /ramdisk/foo_dir +getcwd: /foo_dir [] True -getcwd: /ramdisk +getcwd: / [b'foo_file.txt', b'foo_dir'] -- cgit v1.2.3 From a0c729681faa3a0b1a6150d5462647bad60038bf Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 27 Jan 2017 23:15:09 +1100 Subject: tests/extmod/vfs_fat_ramdisk: Make it work on pyboard. --- tests/extmod/vfs_fat_ramdisk.py | 2 +- tests/extmod/vfs_fat_ramdisk.py.exp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/extmod/vfs_fat_ramdisk.py.exp') diff --git a/tests/extmod/vfs_fat_ramdisk.py b/tests/extmod/vfs_fat_ramdisk.py index a9eb1679a..dc4a1c305 100644 --- a/tests/extmod/vfs_fat_ramdisk.py +++ b/tests/extmod/vfs_fat_ramdisk.py @@ -63,7 +63,7 @@ with vfs.open("foo_file.txt", "w") as f: print(vfs.listdir()) print("stat root:", vfs.stat("/")) -print("stat file:", vfs.stat("foo_file.txt")) +print("stat file:", vfs.stat("foo_file.txt")[:-3]) # timestamps differ across runs print(b"FOO_FILETXT" in bdev.data) print(b"hello!" in bdev.data) diff --git a/tests/extmod/vfs_fat_ramdisk.py.exp b/tests/extmod/vfs_fat_ramdisk.py.exp index fda7d300e..137db5841 100644 --- a/tests/extmod/vfs_fat_ramdisk.py.exp +++ b/tests/extmod/vfs_fat_ramdisk.py.exp @@ -5,7 +5,7 @@ getcwd: / True ['foo_file.txt'] stat root: (16384, 0, 0, 0, 0, 0, 0, 0, 0, 0) -stat file: (32768, 0, 0, 0, 0, 0, 6, -631238400, -631238400, -631238400) +stat file: (32768, 0, 0, 0, 0, 0, 6) True True getcwd: /foo_dir -- cgit v1.2.3 From 852c215d76de082adf57d3724907ab2c8d790e78 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 5 May 2017 23:35:49 +1000 Subject: tests/extmod/vfs: Update tests to reflect new ilistdir() method. --- tests/extmod/vfs_basic.py | 18 +++++++++++++++--- tests/extmod/vfs_basic.py.exp | 21 ++++++++++++--------- tests/extmod/vfs_fat_fileio1.py | 2 +- tests/extmod/vfs_fat_fileio1.py.exp | 2 +- tests/extmod/vfs_fat_fileio2.py | 8 ++++---- tests/extmod/vfs_fat_fileio2.py.exp | 8 ++++---- tests/extmod/vfs_fat_oldproto.py | 4 ++-- tests/extmod/vfs_fat_oldproto.py.exp | 2 +- tests/extmod/vfs_fat_ramdisk.py | 6 +++--- tests/extmod/vfs_fat_ramdisk.py.exp | 4 ++-- 10 files changed, 45 insertions(+), 30 deletions(-) (limited to 'tests/extmod/vfs_fat_ramdisk.py.exp') diff --git a/tests/extmod/vfs_basic.py b/tests/extmod/vfs_basic.py index 32bfe8ab4..a3b2f3c29 100644 --- a/tests/extmod/vfs_basic.py +++ b/tests/extmod/vfs_basic.py @@ -20,9 +20,9 @@ class Filesystem: print(self.id, 'mount', readonly, mkfs) def umount(self): print(self.id, 'umount') - def listdir(self, dir): - print(self.id, 'listdir', dir) - return ['a%d' % self.id] + def ilistdir(self, dir): + print(self.id, 'ilistdir', dir) + return iter([('a%d' % self.id, 0, 0)]) def chdir(self, dir): print(self.id, 'chdir', dir) def getcwd(self): @@ -64,6 +64,18 @@ print(uos.getcwd()) uos.mount(Filesystem(1), '/test_mnt') print(uos.listdir()) +# ilistdir +i = uos.ilistdir() +print(next(i)) +try: + next(i) +except StopIteration: + print('StopIteration') +try: + next(i) +except StopIteration: + print('StopIteration') + # referencing the mount point in different ways print(uos.listdir('test_mnt')) print(uos.listdir('/test_mnt')) diff --git a/tests/extmod/vfs_basic.py.exp b/tests/extmod/vfs_basic.py.exp index 416d45961..8a23aa8ae 100644 --- a/tests/extmod/vfs_basic.py.exp +++ b/tests/extmod/vfs_basic.py.exp @@ -2,20 +2,23 @@ / 1 mount False False ['test_mnt'] -1 listdir / +('test_mnt', 16384, 0) +StopIteration +StopIteration +1 ilistdir / ['a1'] -1 listdir / +1 ilistdir / ['a1'] 2 mount True False ['test_mnt', 'test_mnt2'] -2 listdir / +2 ilistdir / ['a2'] 3 mount False False OSError OSError OSError 1 chdir / -1 listdir +1 ilistdir ['a1'] 1 getcwd /test_mntdir1 @@ -33,19 +36,19 @@ OSError 2 umount OSError 3 mount False False -3 listdir / +3 ilistdir / ['a3'] 3 open test r 4 mount False False -3 listdir / +3 ilistdir / ['mnt', 'a3'] -4 listdir / +4 ilistdir / ['a4'] 4 chdir / -4 listdir +4 ilistdir ['a4'] 3 chdir /subdir -3 listdir +3 ilistdir ['a3'] 3 chdir / 3 umount diff --git a/tests/extmod/vfs_fat_fileio1.py b/tests/extmod/vfs_fat_fileio1.py index 526b3f5c1..9036df7a5 100644 --- a/tests/extmod/vfs_fat_fileio1.py +++ b/tests/extmod/vfs_fat_fileio1.py @@ -115,4 +115,4 @@ except OSError as e: print(e.args[0] == 20) # uerrno.ENOTDIR vfs.remove("foo_file.txt") -print(vfs.listdir()) +print(list(vfs.ilistdir())) diff --git a/tests/extmod/vfs_fat_fileio1.py.exp b/tests/extmod/vfs_fat_fileio1.py.exp index 7959a70ee..d777585cf 100644 --- a/tests/extmod/vfs_fat_fileio1.py.exp +++ b/tests/extmod/vfs_fat_fileio1.py.exp @@ -10,4 +10,4 @@ e True d True -['foo_dir'] +[('foo_dir', 16384, 0)] diff --git a/tests/extmod/vfs_fat_fileio2.py b/tests/extmod/vfs_fat_fileio2.py index 111abfa7e..b2a0ba70f 100644 --- a/tests/extmod/vfs_fat_fileio2.py +++ b/tests/extmod/vfs_fat_fileio2.py @@ -91,23 +91,23 @@ except OSError as e: # trim full path vfs.rename("foo_dir/file-in-dir.txt", "foo_dir/file.txt") -print(vfs.listdir("foo_dir")) +print(list(vfs.ilistdir("foo_dir"))) vfs.rename("foo_dir/file.txt", "moved-to-root.txt") -print(vfs.listdir()) +print(list(vfs.ilistdir())) # check that renaming to existing file will overwrite it with open("temp", "w") as f: f.write("new text") vfs.rename("temp", "moved-to-root.txt") -print(vfs.listdir()) +print(list(vfs.ilistdir())) with open("moved-to-root.txt") as f: print(f.read()) # valid removes vfs.remove("foo_dir/sub_file.txt") vfs.rmdir("foo_dir") -print(vfs.listdir()) +print(list(vfs.ilistdir())) # disk full try: diff --git a/tests/extmod/vfs_fat_fileio2.py.exp b/tests/extmod/vfs_fat_fileio2.py.exp index 38ec5c9b9..118dee26b 100644 --- a/tests/extmod/vfs_fat_fileio2.py.exp +++ b/tests/extmod/vfs_fat_fileio2.py.exp @@ -3,9 +3,9 @@ True True b'data in file' True -['sub_file.txt', 'file.txt'] -['foo_dir', 'moved-to-root.txt'] -['foo_dir', 'moved-to-root.txt'] +[('sub_file.txt', 32768, 0), ('file.txt', 32768, 0)] +[('foo_dir', 16384, 0), ('moved-to-root.txt', 32768, 0)] +[('foo_dir', 16384, 0), ('moved-to-root.txt', 32768, 0)] new text -['moved-to-root.txt'] +[('moved-to-root.txt', 32768, 0)] ENOSPC: True diff --git a/tests/extmod/vfs_fat_oldproto.py b/tests/extmod/vfs_fat_oldproto.py index 77d349212..3e66758c3 100644 --- a/tests/extmod/vfs_fat_oldproto.py +++ b/tests/extmod/vfs_fat_oldproto.py @@ -53,10 +53,10 @@ uos.mount(vfs, "/ramdisk") with vfs.open("file.txt", "w") as f: f.write("hello!") -print(vfs.listdir()) +print(list(vfs.ilistdir())) with vfs.open("file.txt", "r") as f: print(f.read()) vfs.remove("file.txt") -print(vfs.listdir()) +print(list(vfs.ilistdir())) diff --git a/tests/extmod/vfs_fat_oldproto.py.exp b/tests/extmod/vfs_fat_oldproto.py.exp index a389a5217..ab8338cbb 100644 --- a/tests/extmod/vfs_fat_oldproto.py.exp +++ b/tests/extmod/vfs_fat_oldproto.py.exp @@ -1,3 +1,3 @@ -['file.txt'] +[('file.txt', 32768, 0)] hello! [] diff --git a/tests/extmod/vfs_fat_ramdisk.py b/tests/extmod/vfs_fat_ramdisk.py index 81f9418b2..89b40e3a2 100644 --- a/tests/extmod/vfs_fat_ramdisk.py +++ b/tests/extmod/vfs_fat_ramdisk.py @@ -65,7 +65,7 @@ except OSError as e: with vfs.open("foo_file.txt", "w") as f: f.write("hello!") -print(vfs.listdir()) +print(list(vfs.ilistdir())) print("stat root:", vfs.stat("/")) print("stat file:", vfs.stat("foo_file.txt")[:-3]) # timestamps differ across runs @@ -76,7 +76,7 @@ print(b"hello!" in bdev.data) vfs.mkdir("foo_dir") vfs.chdir("foo_dir") print("getcwd:", vfs.getcwd()) -print(vfs.listdir()) +print(list(vfs.ilistdir())) with vfs.open("sub_file.txt", "w") as f: f.write("subdir file") @@ -92,4 +92,4 @@ print("getcwd:", vfs.getcwd()) uos.umount(vfs) vfs = uos.VfsFat(bdev) -print(vfs.listdir(b"")) +print(list(vfs.ilistdir(b""))) diff --git a/tests/extmod/vfs_fat_ramdisk.py.exp b/tests/extmod/vfs_fat_ramdisk.py.exp index 137db5841..6298a7efd 100644 --- a/tests/extmod/vfs_fat_ramdisk.py.exp +++ b/tests/extmod/vfs_fat_ramdisk.py.exp @@ -3,7 +3,7 @@ True statvfs: (512, 512, 16, 16, 16, 0, 0, 0, 0, 255) getcwd: / True -['foo_file.txt'] +[('foo_file.txt', 32768, 0)] stat root: (16384, 0, 0, 0, 0, 0, 0, 0, 0, 0) stat file: (32768, 0, 0, 0, 0, 0, 6) True @@ -12,4 +12,4 @@ getcwd: /foo_dir [] True getcwd: / -[b'foo_file.txt', b'foo_dir'] +[(b'foo_file.txt', 32768, 0), (b'foo_dir', 16384, 0)] -- cgit v1.2.3 From cda09727b451b6b928cc0129c4be7d3127f1aaad Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 13 May 2017 19:10:15 +1000 Subject: tests/extmod/vfs_fat: Add test for ilistdir of a non-existent directory. --- tests/extmod/vfs_fat_ramdisk.py | 6 ++++++ tests/extmod/vfs_fat_ramdisk.py.exp | 1 + 2 files changed, 7 insertions(+) (limited to 'tests/extmod/vfs_fat_ramdisk.py.exp') diff --git a/tests/extmod/vfs_fat_ramdisk.py b/tests/extmod/vfs_fat_ramdisk.py index 89b40e3a2..fe72a8bef 100644 --- a/tests/extmod/vfs_fat_ramdisk.py +++ b/tests/extmod/vfs_fat_ramdisk.py @@ -93,3 +93,9 @@ uos.umount(vfs) vfs = uos.VfsFat(bdev) print(list(vfs.ilistdir(b""))) + +# list a non-existent directory +try: + vfs.ilistdir(b"no_exist") +except OSError as e: + print('ENOENT:', e.args[0] == uerrno.ENOENT) diff --git a/tests/extmod/vfs_fat_ramdisk.py.exp b/tests/extmod/vfs_fat_ramdisk.py.exp index 6298a7efd..ccd0f7134 100644 --- a/tests/extmod/vfs_fat_ramdisk.py.exp +++ b/tests/extmod/vfs_fat_ramdisk.py.exp @@ -13,3 +13,4 @@ getcwd: /foo_dir True getcwd: / [(b'foo_file.txt', 32768, 0), (b'foo_dir', 16384, 0)] +ENOENT: True -- cgit v1.2.3