diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-04-02 21:59:56 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-04-02 22:02:11 +0300 |
commit | b9e9cfcfc1fd8e912f0e76cfe6a90c24b8f461ba (patch) | |
tree | 904c151b99a34da553fa6f7c13a58b2ab9b87b99 | |
parent | 9a973977bbba8fda284bbc6eca4991fe0fd1d5ac (diff) | |
download | micropython-b9e9cfcfc1fd8e912f0e76cfe6a90c24b8f461ba.tar.gz micropython-b9e9cfcfc1fd8e912f0e76cfe6a90c24b8f461ba.zip |
tests: vfs_fat_fileio.py is too big to be parsed in 16K heap, split in 2.
This restores ability to run testsuite with 16K heap.
-rw-r--r-- | tests/extmod/vfs_fat_fileio.py.exp | 24 | ||||
-rw-r--r-- | tests/extmod/vfs_fat_fileio1.py | 113 | ||||
-rw-r--r-- | tests/extmod/vfs_fat_fileio1.py.exp | 13 | ||||
-rw-r--r-- | tests/extmod/vfs_fat_fileio2.py (renamed from tests/extmod/vfs_fat_fileio.py) | 62 | ||||
-rw-r--r-- | tests/extmod/vfs_fat_fileio2.py.exp | 11 |
5 files changed, 137 insertions, 86 deletions
diff --git a/tests/extmod/vfs_fat_fileio.py.exp b/tests/extmod/vfs_fat_fileio.py.exp deleted file mode 100644 index 4e34e83a82..0000000000 --- a/tests/extmod/vfs_fat_fileio.py.exp +++ /dev/null @@ -1,24 +0,0 @@ -<io.TextIOWrapper > -True -True -True -True -hello!world! -12 -h -e -True -d -True -True -True -True -True -b'data in file' -True -['sub_file.txt', 'file.txt'] -['foo_file.txt', 'foo_dir', 'moved-to-root.txt'] -['foo_file.txt', 'foo_dir', 'moved-to-root.txt'] -new text -['moved-to-root.txt'] -ENOSPC: True diff --git a/tests/extmod/vfs_fat_fileio1.py b/tests/extmod/vfs_fat_fileio1.py new file mode 100644 index 0000000000..322f6831ed --- /dev/null +++ b/tests/extmod/vfs_fat_fileio1.py @@ -0,0 +1,113 @@ +import sys +import uerrno +try: + import uos_vfs as uos + open = uos.vfs_open +except ImportError: + import uos +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() + +uos.VfsFat.mkfs(bdev) +vfs = uos.VfsFat(bdev) +uos.mount(vfs, '/ramdisk') +uos.chdir('/ramdisk') + +# file IO +f = open("foo_file.txt", "w") +print(str(f)[:17], str(f)[-1:]) +f.write("hello!") +f.flush() +f.close() +f.close() # allowed +try: + f.write("world!") +except OSError as e: + print(e.args[0] == uerrno.EINVAL) + +try: + f.read() +except OSError as e: + print(e.args[0] == uerrno.EINVAL) + +try: + f.flush() +except OSError as e: + print(e.args[0] == uerrno.EINVAL) + +try: + open("foo_file.txt", "x") +except OSError as e: + print(e.args[0] == uerrno.EEXIST) + +with open("foo_file.txt", "a") as f: + f.write("world!") + +with open("foo_file.txt") as f2: + print(f2.read()) + print(f2.tell()) + + f2.seek(0, 0) # SEEK_SET + print(f2.read(1)) + + f2.seek(0, 1) # SEEK_CUR + print(f2.read(1)) + try: + f2.seek(1, 1) # SEEK_END + except OSError as e: + print(e.args[0] == uerrno.EOPNOTSUPP) + + f2.seek(-2, 2) # SEEK_END + print(f2.read(1)) + +# using constructor of FileIO type to open a file +# 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") + +try: + vfs.rmdir("foo_file.txt") +except OSError as e: + print(e.args[0] == 20) # uerrno.ENOTDIR + +vfs.remove("foo_file.txt") +print(vfs.listdir()) diff --git a/tests/extmod/vfs_fat_fileio1.py.exp b/tests/extmod/vfs_fat_fileio1.py.exp new file mode 100644 index 0000000000..7959a70eed --- /dev/null +++ b/tests/extmod/vfs_fat_fileio1.py.exp @@ -0,0 +1,13 @@ +<io.TextIOWrapper > +True +True +True +True +hello!world! +12 +h +e +True +d +True +['foo_dir'] diff --git a/tests/extmod/vfs_fat_fileio.py b/tests/extmod/vfs_fat_fileio2.py index 6fdac07102..80a614db75 100644 --- a/tests/extmod/vfs_fat_fileio.py +++ b/tests/extmod/vfs_fat_fileio2.py @@ -48,67 +48,6 @@ vfs = uos.VfsFat(bdev) uos.mount(vfs, '/ramdisk') uos.chdir('/ramdisk') -# file IO -f = open("foo_file.txt", "w") -print(str(f)[:17], str(f)[-1:]) -f.write("hello!") -f.flush() -f.close() -f.close() # allowed -try: - f.write("world!") -except OSError as e: - print(e.args[0] == uerrno.EINVAL) - -try: - f.read() -except OSError as e: - print(e.args[0] == uerrno.EINVAL) - -try: - f.flush() -except OSError as e: - print(e.args[0] == uerrno.EINVAL) - -try: - open("foo_file.txt", "x") -except OSError as e: - print(e.args[0] == uerrno.EEXIST) - -with open("foo_file.txt", "a") as f: - f.write("world!") - -with open("foo_file.txt") as f2: - print(f2.read()) - print(f2.tell()) - - f2.seek(0, 0) # SEEK_SET - print(f2.read(1)) - - f2.seek(0, 1) # SEEK_CUR - print(f2.read(1)) - try: - f2.seek(1, 1) # SEEK_END - except OSError as e: - print(e.args[0] == uerrno.EOPNOTSUPP) - - f2.seek(-2, 2) # SEEK_END - print(f2.read(1)) - -# using constructor of FileIO type to open a file -# 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") - -try: - vfs.rmdir("foo_file.txt") -except OSError as e: - print(e.args[0] == 20) # uerrno.ENOTDIR - try: vfs.mkdir("foo_dir") except OSError as e: @@ -162,7 +101,6 @@ with open("moved-to-root.txt") as f: # valid removes vfs.remove("foo_dir/sub_file.txt") -vfs.remove("foo_file.txt") vfs.rmdir("foo_dir") print(vfs.listdir()) diff --git a/tests/extmod/vfs_fat_fileio2.py.exp b/tests/extmod/vfs_fat_fileio2.py.exp new file mode 100644 index 0000000000..38ec5c9b9d --- /dev/null +++ b/tests/extmod/vfs_fat_fileio2.py.exp @@ -0,0 +1,11 @@ +True +True +True +b'data in file' +True +['sub_file.txt', 'file.txt'] +['foo_dir', 'moved-to-root.txt'] +['foo_dir', 'moved-to-root.txt'] +new text +['moved-to-root.txt'] +ENOSPC: True |