diff options
author | Damien George <damien.p.george@gmail.com> | 2017-03-13 21:42:02 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-03-13 21:42:02 +1100 |
commit | 8891b2e7006334e5333a9a35602ae01f0700b12f (patch) | |
tree | f1682bb5b86a8ef9f9a2c77e17b278a4214ed31e /tests | |
parent | 0a3ac07ec79acf580ccf3c6188f25cde2f77bbe5 (diff) | |
download | micropython-8891b2e7006334e5333a9a35602ae01f0700b12f.tar.gz micropython-8891b2e7006334e5333a9a35602ae01f0700b12f.zip |
tests/extmod: Add a test for core VFS functionality, sans any filesystem.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/extmod/vfs_basic.py | 55 | ||||
-rw-r--r-- | tests/extmod/vfs_basic.py.exp | 17 |
2 files changed, 72 insertions, 0 deletions
diff --git a/tests/extmod/vfs_basic.py b/tests/extmod/vfs_basic.py new file mode 100644 index 0000000000..b481841e62 --- /dev/null +++ b/tests/extmod/vfs_basic.py @@ -0,0 +1,55 @@ +# test VFS functionality without any particular filesystem type + +try: + try: + import uos_vfs as uos + open = uos.vfs_open + except ImportError: + import uos + uos.mount +except (ImportError, AttributeError): + print("SKIP") + import sys + sys.exit() + + +class Filesystem: + def __init__(self, id): + self.id = id + def mount(self, readonly, mkfs): + 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 chdir(self, dir): + print(self.id, 'chdir', dir) + def open(self, file, mode): + print(self.id, 'open', file, mode) + + +# basic mounting and listdir +uos.mount(Filesystem(1), '/test_mnt') +print(uos.listdir()) + +# referencing the mount point in different ways +print(uos.listdir('test_mnt')) +print(uos.listdir('/test_mnt')) + +# mounting another filesystem +uos.mount(Filesystem(2), '/test_mnt2', readonly=True) +print(uos.listdir()) +print(uos.listdir('/test_mnt2')) + +# chdir +uos.chdir('test_mnt') +print(uos.listdir()) + +# open +open('test_file') +open('test_file', 'wb') + +# umount +uos.umount('/test_mnt') +uos.umount('/test_mnt2') diff --git a/tests/extmod/vfs_basic.py.exp b/tests/extmod/vfs_basic.py.exp new file mode 100644 index 0000000000..c9ed65191b --- /dev/null +++ b/tests/extmod/vfs_basic.py.exp @@ -0,0 +1,17 @@ +1 mount False False +['test_mnt'] +1 listdir / +['a1'] +1 listdir / +['a1'] +2 mount True False +['test_mnt', 'test_mnt2'] +2 listdir / +['a2'] +1 chdir / +1 listdir +['a1'] +1 open test_file r +1 open test_file wb +1 umount +2 umount |