Commenting out outdated functions for now
This makes it easier to evaluate the code/stack/etc sizes and run tests without bringing in all of the outdated code. I guess this officially makes this branch more-or-less a full rewrite, though the benefit of commenting vs deleting this code is that it can be easily pulled back in when useful.
This commit is contained in:
+717
-717
File diff suppressed because it is too large
Load Diff
+316
-316
@@ -1,316 +1,316 @@
|
|||||||
[cases.test_attrs_get_set]
|
#[cases.test_attrs_get_set]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "hello") => 0;
|
# lfs_mkdir(&lfs, "hello") => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
|
# lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
|
||||||
lfs_file_close(&lfs, &file);
|
# lfs_file_close(&lfs, &file);
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
memset(buffer, 0, sizeof(buffer));
|
# memset(buffer, 0, sizeof(buffer));
|
||||||
lfs_setattr(&lfs, "hello", 'A', "aaaa", 4) => 0;
|
# lfs_setattr(&lfs, "hello", 'A', "aaaa", 4) => 0;
|
||||||
lfs_setattr(&lfs, "hello", 'B', "bbbbbb", 6) => 0;
|
# lfs_setattr(&lfs, "hello", 'B', "bbbbbb", 6) => 0;
|
||||||
lfs_setattr(&lfs, "hello", 'C', "ccccc", 5) => 0;
|
# lfs_setattr(&lfs, "hello", 'C', "ccccc", 5) => 0;
|
||||||
lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
|
# lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
|
||||||
lfs_getattr(&lfs, "hello", 'B', buffer+4, 6) => 6;
|
# lfs_getattr(&lfs, "hello", 'B', buffer+4, 6) => 6;
|
||||||
lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
|
# lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "bbbbbb", 6) => 0;
|
# memcmp(buffer+4, "bbbbbb", 6) => 0;
|
||||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
# memcmp(buffer+10, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
lfs_setattr(&lfs, "hello", 'B', "", 0) => 0;
|
# lfs_setattr(&lfs, "hello", 'B', "", 0) => 0;
|
||||||
lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
|
# lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
|
||||||
lfs_getattr(&lfs, "hello", 'B', buffer+4, 6) => 0;
|
# lfs_getattr(&lfs, "hello", 'B', buffer+4, 6) => 0;
|
||||||
lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
|
# lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "\0\0\0\0\0\0", 6) => 0;
|
# memcmp(buffer+4, "\0\0\0\0\0\0", 6) => 0;
|
||||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
# memcmp(buffer+10, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
lfs_removeattr(&lfs, "hello", 'B') => 0;
|
# lfs_removeattr(&lfs, "hello", 'B') => 0;
|
||||||
lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
|
# lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
|
||||||
lfs_getattr(&lfs, "hello", 'B', buffer+4, 6) => LFS_ERR_NOATTR;
|
# lfs_getattr(&lfs, "hello", 'B', buffer+4, 6) => LFS_ERR_NOATTR;
|
||||||
lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
|
# lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "\0\0\0\0\0\0", 6) => 0;
|
# memcmp(buffer+4, "\0\0\0\0\0\0", 6) => 0;
|
||||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
# memcmp(buffer+10, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
lfs_setattr(&lfs, "hello", 'B', "dddddd", 6) => 0;
|
# lfs_setattr(&lfs, "hello", 'B', "dddddd", 6) => 0;
|
||||||
lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
|
# lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
|
||||||
lfs_getattr(&lfs, "hello", 'B', buffer+4, 6) => 6;
|
# lfs_getattr(&lfs, "hello", 'B', buffer+4, 6) => 6;
|
||||||
lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
|
# lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "dddddd", 6) => 0;
|
# memcmp(buffer+4, "dddddd", 6) => 0;
|
||||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
# memcmp(buffer+10, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
lfs_setattr(&lfs, "hello", 'B', "eee", 3) => 0;
|
# lfs_setattr(&lfs, "hello", 'B', "eee", 3) => 0;
|
||||||
lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
|
# lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
|
||||||
lfs_getattr(&lfs, "hello", 'B', buffer+4, 6) => 3;
|
# lfs_getattr(&lfs, "hello", 'B', buffer+4, 6) => 3;
|
||||||
lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
|
# lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "eee\0\0\0", 6) => 0;
|
# memcmp(buffer+4, "eee\0\0\0", 6) => 0;
|
||||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
# memcmp(buffer+10, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
lfs_setattr(&lfs, "hello", 'A', buffer, LFS_ATTR_MAX+1) => LFS_ERR_NOSPC;
|
# lfs_setattr(&lfs, "hello", 'A', buffer, LFS_ATTR_MAX+1) => LFS_ERR_NOSPC;
|
||||||
lfs_setattr(&lfs, "hello", 'B', "fffffffff", 9) => 0;
|
# lfs_setattr(&lfs, "hello", 'B', "fffffffff", 9) => 0;
|
||||||
lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
|
# lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
|
||||||
lfs_getattr(&lfs, "hello", 'B', buffer+4, 6) => 9;
|
# lfs_getattr(&lfs, "hello", 'B', buffer+4, 6) => 9;
|
||||||
lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
|
# lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
|
||||||
|
#
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
memset(buffer, 0, sizeof(buffer));
|
# memset(buffer, 0, sizeof(buffer));
|
||||||
lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
|
# lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
|
||||||
lfs_getattr(&lfs, "hello", 'B', buffer+4, 9) => 9;
|
# lfs_getattr(&lfs, "hello", 'B', buffer+4, 9) => 9;
|
||||||
lfs_getattr(&lfs, "hello", 'C', buffer+13, 5) => 5;
|
# lfs_getattr(&lfs, "hello", 'C', buffer+13, 5) => 5;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "fffffffff", 9) => 0;
|
# memcmp(buffer+4, "fffffffff", 9) => 0;
|
||||||
memcmp(buffer+13, "ccccc", 5) => 0;
|
# memcmp(buffer+13, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
lfs_file_open(&lfs, &file, "hello/hello", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "hello/hello", LFS_O_RDONLY) => 0;
|
||||||
lfs_file_read(&lfs, &file, buffer, sizeof(buffer)) => strlen("hello");
|
# lfs_file_read(&lfs, &file, buffer, sizeof(buffer)) => strlen("hello");
|
||||||
memcmp(buffer, "hello", strlen("hello")) => 0;
|
# memcmp(buffer, "hello", strlen("hello")) => 0;
|
||||||
lfs_file_close(&lfs, &file);
|
# lfs_file_close(&lfs, &file);
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
[cases.test_attrs_get_set_root]
|
#[cases.test_attrs_get_set_root]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "hello") => 0;
|
# lfs_mkdir(&lfs, "hello") => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
|
# lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
|
||||||
lfs_file_close(&lfs, &file);
|
# lfs_file_close(&lfs, &file);
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
memset(buffer, 0, sizeof(buffer));
|
# memset(buffer, 0, sizeof(buffer));
|
||||||
lfs_setattr(&lfs, "/", 'A', "aaaa", 4) => 0;
|
# lfs_setattr(&lfs, "/", 'A', "aaaa", 4) => 0;
|
||||||
lfs_setattr(&lfs, "/", 'B', "bbbbbb", 6) => 0;
|
# lfs_setattr(&lfs, "/", 'B', "bbbbbb", 6) => 0;
|
||||||
lfs_setattr(&lfs, "/", 'C', "ccccc", 5) => 0;
|
# lfs_setattr(&lfs, "/", 'C', "ccccc", 5) => 0;
|
||||||
lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
|
# lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
|
||||||
lfs_getattr(&lfs, "/", 'B', buffer+4, 6) => 6;
|
# lfs_getattr(&lfs, "/", 'B', buffer+4, 6) => 6;
|
||||||
lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
|
# lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "bbbbbb", 6) => 0;
|
# memcmp(buffer+4, "bbbbbb", 6) => 0;
|
||||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
# memcmp(buffer+10, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
lfs_setattr(&lfs, "/", 'B', "", 0) => 0;
|
# lfs_setattr(&lfs, "/", 'B', "", 0) => 0;
|
||||||
lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
|
# lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
|
||||||
lfs_getattr(&lfs, "/", 'B', buffer+4, 6) => 0;
|
# lfs_getattr(&lfs, "/", 'B', buffer+4, 6) => 0;
|
||||||
lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
|
# lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "\0\0\0\0\0\0", 6) => 0;
|
# memcmp(buffer+4, "\0\0\0\0\0\0", 6) => 0;
|
||||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
# memcmp(buffer+10, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
lfs_removeattr(&lfs, "/", 'B') => 0;
|
# lfs_removeattr(&lfs, "/", 'B') => 0;
|
||||||
lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
|
# lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
|
||||||
lfs_getattr(&lfs, "/", 'B', buffer+4, 6) => LFS_ERR_NOATTR;
|
# lfs_getattr(&lfs, "/", 'B', buffer+4, 6) => LFS_ERR_NOATTR;
|
||||||
lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
|
# lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "\0\0\0\0\0\0", 6) => 0;
|
# memcmp(buffer+4, "\0\0\0\0\0\0", 6) => 0;
|
||||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
# memcmp(buffer+10, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
lfs_setattr(&lfs, "/", 'B', "dddddd", 6) => 0;
|
# lfs_setattr(&lfs, "/", 'B', "dddddd", 6) => 0;
|
||||||
lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
|
# lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
|
||||||
lfs_getattr(&lfs, "/", 'B', buffer+4, 6) => 6;
|
# lfs_getattr(&lfs, "/", 'B', buffer+4, 6) => 6;
|
||||||
lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
|
# lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "dddddd", 6) => 0;
|
# memcmp(buffer+4, "dddddd", 6) => 0;
|
||||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
# memcmp(buffer+10, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
lfs_setattr(&lfs, "/", 'B', "eee", 3) => 0;
|
# lfs_setattr(&lfs, "/", 'B', "eee", 3) => 0;
|
||||||
lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
|
# lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
|
||||||
lfs_getattr(&lfs, "/", 'B', buffer+4, 6) => 3;
|
# lfs_getattr(&lfs, "/", 'B', buffer+4, 6) => 3;
|
||||||
lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
|
# lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "eee\0\0\0", 6) => 0;
|
# memcmp(buffer+4, "eee\0\0\0", 6) => 0;
|
||||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
# memcmp(buffer+10, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
lfs_setattr(&lfs, "/", 'A', buffer, LFS_ATTR_MAX+1) => LFS_ERR_NOSPC;
|
# lfs_setattr(&lfs, "/", 'A', buffer, LFS_ATTR_MAX+1) => LFS_ERR_NOSPC;
|
||||||
lfs_setattr(&lfs, "/", 'B', "fffffffff", 9) => 0;
|
# lfs_setattr(&lfs, "/", 'B', "fffffffff", 9) => 0;
|
||||||
lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
|
# lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
|
||||||
lfs_getattr(&lfs, "/", 'B', buffer+4, 6) => 9;
|
# lfs_getattr(&lfs, "/", 'B', buffer+4, 6) => 9;
|
||||||
lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
|
# lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
memset(buffer, 0, sizeof(buffer));
|
# memset(buffer, 0, sizeof(buffer));
|
||||||
lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
|
# lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
|
||||||
lfs_getattr(&lfs, "/", 'B', buffer+4, 9) => 9;
|
# lfs_getattr(&lfs, "/", 'B', buffer+4, 9) => 9;
|
||||||
lfs_getattr(&lfs, "/", 'C', buffer+13, 5) => 5;
|
# lfs_getattr(&lfs, "/", 'C', buffer+13, 5) => 5;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "fffffffff", 9) => 0;
|
# memcmp(buffer+4, "fffffffff", 9) => 0;
|
||||||
memcmp(buffer+13, "ccccc", 5) => 0;
|
# memcmp(buffer+13, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
lfs_file_open(&lfs, &file, "hello/hello", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "hello/hello", LFS_O_RDONLY) => 0;
|
||||||
lfs_file_read(&lfs, &file, buffer, sizeof(buffer)) => strlen("hello");
|
# lfs_file_read(&lfs, &file, buffer, sizeof(buffer)) => strlen("hello");
|
||||||
memcmp(buffer, "hello", strlen("hello")) => 0;
|
# memcmp(buffer, "hello", strlen("hello")) => 0;
|
||||||
lfs_file_close(&lfs, &file);
|
# lfs_file_close(&lfs, &file);
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
[cases.test_attrs_get_set_file]
|
#[cases.test_attrs_get_set_file]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "hello") => 0;
|
# lfs_mkdir(&lfs, "hello") => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
|
# lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
|
||||||
lfs_file_close(&lfs, &file);
|
# lfs_file_close(&lfs, &file);
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
memset(buffer, 0, sizeof(buffer));
|
# memset(buffer, 0, sizeof(buffer));
|
||||||
struct lfs_attr attrs1[] = {
|
# struct lfs_attr attrs1[] = {
|
||||||
{'A', buffer, 4},
|
# {'A', buffer, 4},
|
||||||
{'B', buffer+4, 6},
|
# {'B', buffer+4, 6},
|
||||||
{'C', buffer+10, 5},
|
# {'C', buffer+10, 5},
|
||||||
};
|
# };
|
||||||
struct lfs_file_config cfg1 = {.attrs=attrs1, .attr_count=3};
|
# struct lfs_file_config cfg1 = {.attrs=attrs1, .attr_count=3};
|
||||||
|
#
|
||||||
lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
|
# lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
|
||||||
memcpy(buffer, "aaaa", 4);
|
# memcpy(buffer, "aaaa", 4);
|
||||||
memcpy(buffer+4, "bbbbbb", 6);
|
# memcpy(buffer+4, "bbbbbb", 6);
|
||||||
memcpy(buffer+10, "ccccc", 5);
|
# memcpy(buffer+10, "ccccc", 5);
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
memset(buffer, 0, 15);
|
# memset(buffer, 0, 15);
|
||||||
lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
|
# lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "bbbbbb", 6) => 0;
|
# memcmp(buffer+4, "bbbbbb", 6) => 0;
|
||||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
# memcmp(buffer+10, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
attrs1[1].size = 0;
|
# attrs1[1].size = 0;
|
||||||
lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
|
# lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
memset(buffer, 0, 15);
|
# memset(buffer, 0, 15);
|
||||||
attrs1[1].size = 6;
|
# attrs1[1].size = 6;
|
||||||
lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
|
# lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "\0\0\0\0\0\0", 6) => 0;
|
# memcmp(buffer+4, "\0\0\0\0\0\0", 6) => 0;
|
||||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
# memcmp(buffer+10, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
attrs1[1].size = 6;
|
# attrs1[1].size = 6;
|
||||||
lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
|
# lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
|
||||||
memcpy(buffer+4, "dddddd", 6);
|
# memcpy(buffer+4, "dddddd", 6);
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
memset(buffer, 0, 15);
|
# memset(buffer, 0, 15);
|
||||||
attrs1[1].size = 6;
|
# attrs1[1].size = 6;
|
||||||
lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
|
# lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "dddddd", 6) => 0;
|
# memcmp(buffer+4, "dddddd", 6) => 0;
|
||||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
# memcmp(buffer+10, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
attrs1[1].size = 3;
|
# attrs1[1].size = 3;
|
||||||
lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
|
# lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
|
||||||
memcpy(buffer+4, "eee", 3);
|
# memcpy(buffer+4, "eee", 3);
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
memset(buffer, 0, 15);
|
# memset(buffer, 0, 15);
|
||||||
attrs1[1].size = 6;
|
# attrs1[1].size = 6;
|
||||||
lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
|
# lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "eee\0\0\0", 6) => 0;
|
# memcmp(buffer+4, "eee\0\0\0", 6) => 0;
|
||||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
# memcmp(buffer+10, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
attrs1[0].size = LFS_ATTR_MAX+1;
|
# attrs1[0].size = LFS_ATTR_MAX+1;
|
||||||
lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1)
|
# lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1)
|
||||||
=> LFS_ERR_NOSPC;
|
# => LFS_ERR_NOSPC;
|
||||||
|
#
|
||||||
struct lfs_attr attrs2[] = {
|
# struct lfs_attr attrs2[] = {
|
||||||
{'A', buffer, 4},
|
# {'A', buffer, 4},
|
||||||
{'B', buffer+4, 9},
|
# {'B', buffer+4, 9},
|
||||||
{'C', buffer+13, 5},
|
# {'C', buffer+13, 5},
|
||||||
};
|
# };
|
||||||
struct lfs_file_config cfg2 = {.attrs=attrs2, .attr_count=3};
|
# struct lfs_file_config cfg2 = {.attrs=attrs2, .attr_count=3};
|
||||||
lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDWR, &cfg2) => 0;
|
# lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDWR, &cfg2) => 0;
|
||||||
memcpy(buffer+4, "fffffffff", 9);
|
# memcpy(buffer+4, "fffffffff", 9);
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
attrs1[0].size = 4;
|
# attrs1[0].size = 4;
|
||||||
lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
|
# lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
memset(buffer, 0, sizeof(buffer));
|
# memset(buffer, 0, sizeof(buffer));
|
||||||
struct lfs_attr attrs3[] = {
|
# struct lfs_attr attrs3[] = {
|
||||||
{'A', buffer, 4},
|
# {'A', buffer, 4},
|
||||||
{'B', buffer+4, 9},
|
# {'B', buffer+4, 9},
|
||||||
{'C', buffer+13, 5},
|
# {'C', buffer+13, 5},
|
||||||
};
|
# };
|
||||||
struct lfs_file_config cfg3 = {.attrs=attrs3, .attr_count=3};
|
# struct lfs_file_config cfg3 = {.attrs=attrs3, .attr_count=3};
|
||||||
|
#
|
||||||
lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg3) => 0;
|
# lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg3) => 0;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
memcmp(buffer, "aaaa", 4) => 0;
|
# memcmp(buffer, "aaaa", 4) => 0;
|
||||||
memcmp(buffer+4, "fffffffff", 9) => 0;
|
# memcmp(buffer+4, "fffffffff", 9) => 0;
|
||||||
memcmp(buffer+13, "ccccc", 5) => 0;
|
# memcmp(buffer+13, "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
lfs_file_open(&lfs, &file, "hello/hello", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "hello/hello", LFS_O_RDONLY) => 0;
|
||||||
lfs_file_read(&lfs, &file, buffer, sizeof(buffer)) => strlen("hello");
|
# lfs_file_read(&lfs, &file, buffer, sizeof(buffer)) => strlen("hello");
|
||||||
memcmp(buffer, "hello", strlen("hello")) => 0;
|
# memcmp(buffer, "hello", strlen("hello")) => 0;
|
||||||
lfs_file_close(&lfs, &file);
|
# lfs_file_close(&lfs, &file);
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
[cases.test_attrs_deferred_file]
|
#[cases.test_attrs_deferred_file]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "hello") => 0;
|
# lfs_mkdir(&lfs, "hello") => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
|
# lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
|
||||||
lfs_file_close(&lfs, &file);
|
# lfs_file_close(&lfs, &file);
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_setattr(&lfs, "hello/hello", 'B', "fffffffff", 9) => 0;
|
# lfs_setattr(&lfs, "hello/hello", 'B', "fffffffff", 9) => 0;
|
||||||
lfs_setattr(&lfs, "hello/hello", 'C', "ccccc", 5) => 0;
|
# lfs_setattr(&lfs, "hello/hello", 'C', "ccccc", 5) => 0;
|
||||||
|
#
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
memset(buffer, 0, sizeof(buffer));
|
# memset(buffer, 0, sizeof(buffer));
|
||||||
struct lfs_attr attrs1[] = {
|
# struct lfs_attr attrs1[] = {
|
||||||
{'B', "gggg", 4},
|
# {'B', "gggg", 4},
|
||||||
{'C', "", 0},
|
# {'C', "", 0},
|
||||||
{'D', "hhhh", 4},
|
# {'D', "hhhh", 4},
|
||||||
};
|
# };
|
||||||
struct lfs_file_config cfg1 = {.attrs=attrs1, .attr_count=3};
|
# struct lfs_file_config cfg1 = {.attrs=attrs1, .attr_count=3};
|
||||||
|
#
|
||||||
lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
|
# lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
|
||||||
|
#
|
||||||
lfs_getattr(&lfs, "hello/hello", 'B', buffer, 9) => 9;
|
# lfs_getattr(&lfs, "hello/hello", 'B', buffer, 9) => 9;
|
||||||
lfs_getattr(&lfs, "hello/hello", 'C', buffer+9, 9) => 5;
|
# lfs_getattr(&lfs, "hello/hello", 'C', buffer+9, 9) => 5;
|
||||||
lfs_getattr(&lfs, "hello/hello", 'D', buffer+18, 9) => LFS_ERR_NOATTR;
|
# lfs_getattr(&lfs, "hello/hello", 'D', buffer+18, 9) => LFS_ERR_NOATTR;
|
||||||
memcmp(buffer, "fffffffff", 9) => 0;
|
# memcmp(buffer, "fffffffff", 9) => 0;
|
||||||
memcmp(buffer+9, "ccccc\0\0\0\0", 9) => 0;
|
# memcmp(buffer+9, "ccccc\0\0\0\0", 9) => 0;
|
||||||
memcmp(buffer+18, "\0\0\0\0\0\0\0\0\0", 9) => 0;
|
# memcmp(buffer+18, "\0\0\0\0\0\0\0\0\0", 9) => 0;
|
||||||
|
#
|
||||||
lfs_file_sync(&lfs, &file) => 0;
|
# lfs_file_sync(&lfs, &file) => 0;
|
||||||
lfs_getattr(&lfs, "hello/hello", 'B', buffer, 9) => 4;
|
# lfs_getattr(&lfs, "hello/hello", 'B', buffer, 9) => 4;
|
||||||
lfs_getattr(&lfs, "hello/hello", 'C', buffer+9, 9) => 0;
|
# lfs_getattr(&lfs, "hello/hello", 'C', buffer+9, 9) => 0;
|
||||||
lfs_getattr(&lfs, "hello/hello", 'D', buffer+18, 9) => 4;
|
# lfs_getattr(&lfs, "hello/hello", 'D', buffer+18, 9) => 4;
|
||||||
memcmp(buffer, "gggg\0\0\0\0\0", 9) => 0;
|
# memcmp(buffer, "gggg\0\0\0\0\0", 9) => 0;
|
||||||
memcmp(buffer+9, "\0\0\0\0\0\0\0\0\0", 9) => 0;
|
# memcmp(buffer+9, "\0\0\0\0\0\0\0\0\0", 9) => 0;
|
||||||
memcmp(buffer+18, "hhhh\0\0\0\0\0", 9) => 0;
|
# memcmp(buffer+18, "hhhh\0\0\0\0\0", 9) => 0;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
|||||||
+260
-260
@@ -1,260 +1,260 @@
|
|||||||
# bad blocks with block cycles should be tested in test_relocations
|
## bad blocks with block cycles should be tested in test_relocations
|
||||||
if = '(int32_t)BLOCK_CYCLES == -1'
|
#if = '(int32_t)BLOCK_CYCLES == -1'
|
||||||
|
#
|
||||||
[cases.test_badblocks_single]
|
#[cases.test_badblocks_single]
|
||||||
defines.BLOCK_COUNT = 256 # small bd so test runs faster
|
#defines.BLOCK_COUNT = 256 # small bd so test runs faster
|
||||||
defines.ERASE_CYCLES = 0xffffffff
|
#defines.ERASE_CYCLES = 0xffffffff
|
||||||
defines.ERASE_VALUE = [0x00, 0xff, -1]
|
#defines.ERASE_VALUE = [0x00, 0xff, -1]
|
||||||
defines.BADBLOCK_BEHAVIOR = [
|
#defines.BADBLOCK_BEHAVIOR = [
|
||||||
'LFS_EMUBD_BADBLOCK_PROGERROR',
|
# 'LFS_EMUBD_BADBLOCK_PROGERROR',
|
||||||
'LFS_EMUBD_BADBLOCK_ERASEERROR',
|
# 'LFS_EMUBD_BADBLOCK_ERASEERROR',
|
||||||
'LFS_EMUBD_BADBLOCK_READERROR',
|
# 'LFS_EMUBD_BADBLOCK_READERROR',
|
||||||
'LFS_EMUBD_BADBLOCK_PROGNOOP',
|
# 'LFS_EMUBD_BADBLOCK_PROGNOOP',
|
||||||
'LFS_EMUBD_BADBLOCK_ERASENOOP',
|
# 'LFS_EMUBD_BADBLOCK_ERASENOOP',
|
||||||
]
|
#]
|
||||||
defines.NAMEMULT = 64
|
#defines.NAMEMULT = 64
|
||||||
defines.FILEMULT = 1
|
#defines.FILEMULT = 1
|
||||||
code = '''
|
#code = '''
|
||||||
for (lfs_block_t badblock = 2; badblock < BLOCK_COUNT; badblock++) {
|
# for (lfs_block_t badblock = 2; badblock < BLOCK_COUNT; badblock++) {
|
||||||
lfs_emubd_setwear(cfg, badblock-1, 0) => 0;
|
# lfs_emubd_setwear(cfg, badblock-1, 0) => 0;
|
||||||
lfs_emubd_setwear(cfg, badblock, 0xffffffff) => 0;
|
# lfs_emubd_setwear(cfg, badblock, 0xffffffff) => 0;
|
||||||
|
#
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
for (int i = 1; i < 10; i++) {
|
# for (int i = 1; i < 10; i++) {
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
for (int j = 0; j < NAMEMULT; j++) {
|
# for (int j = 0; j < NAMEMULT; j++) {
|
||||||
buffer[j] = '0'+i;
|
# buffer[j] = '0'+i;
|
||||||
}
|
# }
|
||||||
buffer[NAMEMULT] = '\0';
|
# buffer[NAMEMULT] = '\0';
|
||||||
lfs_mkdir(&lfs, (char*)buffer) => 0;
|
# lfs_mkdir(&lfs, (char*)buffer) => 0;
|
||||||
|
#
|
||||||
buffer[NAMEMULT] = '/';
|
# buffer[NAMEMULT] = '/';
|
||||||
for (int j = 0; j < NAMEMULT; j++) {
|
# for (int j = 0; j < NAMEMULT; j++) {
|
||||||
buffer[j+NAMEMULT+1] = '0'+i;
|
# buffer[j+NAMEMULT+1] = '0'+i;
|
||||||
}
|
# }
|
||||||
buffer[2*NAMEMULT+1] = '\0';
|
# buffer[2*NAMEMULT+1] = '\0';
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, (char*)buffer,
|
# lfs_file_open(&lfs, &file, (char*)buffer,
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
|
#
|
||||||
lfs_size_t size = NAMEMULT;
|
# lfs_size_t size = NAMEMULT;
|
||||||
for (int j = 0; j < i*FILEMULT; j++) {
|
# for (int j = 0; j < i*FILEMULT; j++) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
for (int i = 1; i < 10; i++) {
|
# for (int i = 1; i < 10; i++) {
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
for (int j = 0; j < NAMEMULT; j++) {
|
# for (int j = 0; j < NAMEMULT; j++) {
|
||||||
buffer[j] = '0'+i;
|
# buffer[j] = '0'+i;
|
||||||
}
|
# }
|
||||||
buffer[NAMEMULT] = '\0';
|
# buffer[NAMEMULT] = '\0';
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, (char*)buffer, &info) => 0;
|
# lfs_stat(&lfs, (char*)buffer, &info) => 0;
|
||||||
info.type => LFS_TYPE_DIR;
|
# info.type => LFS_TYPE_DIR;
|
||||||
|
#
|
||||||
buffer[NAMEMULT] = '/';
|
# buffer[NAMEMULT] = '/';
|
||||||
for (int j = 0; j < NAMEMULT; j++) {
|
# for (int j = 0; j < NAMEMULT; j++) {
|
||||||
buffer[j+NAMEMULT+1] = '0'+i;
|
# buffer[j+NAMEMULT+1] = '0'+i;
|
||||||
}
|
# }
|
||||||
buffer[2*NAMEMULT+1] = '\0';
|
# buffer[2*NAMEMULT+1] = '\0';
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, (char*)buffer, LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, (char*)buffer, LFS_O_RDONLY) => 0;
|
||||||
|
#
|
||||||
int size = NAMEMULT;
|
# int size = NAMEMULT;
|
||||||
for (int j = 0; j < i*FILEMULT; j++) {
|
# for (int j = 0; j < i*FILEMULT; j++) {
|
||||||
uint8_t rbuffer[1024];
|
# uint8_t rbuffer[1024];
|
||||||
lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
# lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
||||||
memcmp(buffer, rbuffer, size) => 0;
|
# memcmp(buffer, rbuffer, size) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
}
|
# }
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
[cases.test_badblocks_region_corruption] # (causes cascading failures)
|
#[cases.test_badblocks_region_corruption] # (causes cascading failures)
|
||||||
defines.BLOCK_COUNT = 256 # small bd so test runs faster
|
#defines.BLOCK_COUNT = 256 # small bd so test runs faster
|
||||||
defines.ERASE_CYCLES = 0xffffffff
|
#defines.ERASE_CYCLES = 0xffffffff
|
||||||
defines.ERASE_VALUE = [0x00, 0xff, -1]
|
#defines.ERASE_VALUE = [0x00, 0xff, -1]
|
||||||
defines.BADBLOCK_BEHAVIOR = [
|
#defines.BADBLOCK_BEHAVIOR = [
|
||||||
'LFS_EMUBD_BADBLOCK_PROGERROR',
|
# 'LFS_EMUBD_BADBLOCK_PROGERROR',
|
||||||
'LFS_EMUBD_BADBLOCK_ERASEERROR',
|
# 'LFS_EMUBD_BADBLOCK_ERASEERROR',
|
||||||
'LFS_EMUBD_BADBLOCK_READERROR',
|
# 'LFS_EMUBD_BADBLOCK_READERROR',
|
||||||
'LFS_EMUBD_BADBLOCK_PROGNOOP',
|
# 'LFS_EMUBD_BADBLOCK_PROGNOOP',
|
||||||
'LFS_EMUBD_BADBLOCK_ERASENOOP',
|
# 'LFS_EMUBD_BADBLOCK_ERASENOOP',
|
||||||
]
|
#]
|
||||||
defines.NAMEMULT = 64
|
#defines.NAMEMULT = 64
|
||||||
defines.FILEMULT = 1
|
#defines.FILEMULT = 1
|
||||||
code = '''
|
#code = '''
|
||||||
for (lfs_block_t i = 0; i < (BLOCK_COUNT-2)/2; i++) {
|
# for (lfs_block_t i = 0; i < (BLOCK_COUNT-2)/2; i++) {
|
||||||
lfs_emubd_setwear(cfg, i+2, 0xffffffff) => 0;
|
# lfs_emubd_setwear(cfg, i+2, 0xffffffff) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
for (int i = 1; i < 10; i++) {
|
# for (int i = 1; i < 10; i++) {
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
for (int j = 0; j < NAMEMULT; j++) {
|
# for (int j = 0; j < NAMEMULT; j++) {
|
||||||
buffer[j] = '0'+i;
|
# buffer[j] = '0'+i;
|
||||||
}
|
# }
|
||||||
buffer[NAMEMULT] = '\0';
|
# buffer[NAMEMULT] = '\0';
|
||||||
lfs_mkdir(&lfs, (char*)buffer) => 0;
|
# lfs_mkdir(&lfs, (char*)buffer) => 0;
|
||||||
|
#
|
||||||
buffer[NAMEMULT] = '/';
|
# buffer[NAMEMULT] = '/';
|
||||||
for (int j = 0; j < NAMEMULT; j++) {
|
# for (int j = 0; j < NAMEMULT; j++) {
|
||||||
buffer[j+NAMEMULT+1] = '0'+i;
|
# buffer[j+NAMEMULT+1] = '0'+i;
|
||||||
}
|
# }
|
||||||
buffer[2*NAMEMULT+1] = '\0';
|
# buffer[2*NAMEMULT+1] = '\0';
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, (char*)buffer,
|
# lfs_file_open(&lfs, &file, (char*)buffer,
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
|
#
|
||||||
lfs_size_t size = NAMEMULT;
|
# lfs_size_t size = NAMEMULT;
|
||||||
for (int j = 0; j < i*FILEMULT; j++) {
|
# for (int j = 0; j < i*FILEMULT; j++) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
for (int i = 1; i < 10; i++) {
|
# for (int i = 1; i < 10; i++) {
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
for (int j = 0; j < NAMEMULT; j++) {
|
# for (int j = 0; j < NAMEMULT; j++) {
|
||||||
buffer[j] = '0'+i;
|
# buffer[j] = '0'+i;
|
||||||
}
|
# }
|
||||||
buffer[NAMEMULT] = '\0';
|
# buffer[NAMEMULT] = '\0';
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, (char*)buffer, &info) => 0;
|
# lfs_stat(&lfs, (char*)buffer, &info) => 0;
|
||||||
info.type => LFS_TYPE_DIR;
|
# info.type => LFS_TYPE_DIR;
|
||||||
|
#
|
||||||
buffer[NAMEMULT] = '/';
|
# buffer[NAMEMULT] = '/';
|
||||||
for (int j = 0; j < NAMEMULT; j++) {
|
# for (int j = 0; j < NAMEMULT; j++) {
|
||||||
buffer[j+NAMEMULT+1] = '0'+i;
|
# buffer[j+NAMEMULT+1] = '0'+i;
|
||||||
}
|
# }
|
||||||
buffer[2*NAMEMULT+1] = '\0';
|
# buffer[2*NAMEMULT+1] = '\0';
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, (char*)buffer, LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, (char*)buffer, LFS_O_RDONLY) => 0;
|
||||||
|
#
|
||||||
lfs_size_t size = NAMEMULT;
|
# lfs_size_t size = NAMEMULT;
|
||||||
for (int j = 0; j < i*FILEMULT; j++) {
|
# for (int j = 0; j < i*FILEMULT; j++) {
|
||||||
uint8_t rbuffer[1024];
|
# uint8_t rbuffer[1024];
|
||||||
lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
# lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
||||||
memcmp(buffer, rbuffer, size) => 0;
|
# memcmp(buffer, rbuffer, size) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
[cases.test_badblocks_alternating_corruption] # (causes cascading failures)
|
#[cases.test_badblocks_alternating_corruption] # (causes cascading failures)
|
||||||
defines.BLOCK_COUNT = 256 # small bd so test runs faster
|
#defines.BLOCK_COUNT = 256 # small bd so test runs faster
|
||||||
defines.ERASE_CYCLES = 0xffffffff
|
#defines.ERASE_CYCLES = 0xffffffff
|
||||||
defines.ERASE_VALUE = [0x00, 0xff, -1]
|
#defines.ERASE_VALUE = [0x00, 0xff, -1]
|
||||||
defines.BADBLOCK_BEHAVIOR = [
|
#defines.BADBLOCK_BEHAVIOR = [
|
||||||
'LFS_EMUBD_BADBLOCK_PROGERROR',
|
# 'LFS_EMUBD_BADBLOCK_PROGERROR',
|
||||||
'LFS_EMUBD_BADBLOCK_ERASEERROR',
|
# 'LFS_EMUBD_BADBLOCK_ERASEERROR',
|
||||||
'LFS_EMUBD_BADBLOCK_READERROR',
|
# 'LFS_EMUBD_BADBLOCK_READERROR',
|
||||||
'LFS_EMUBD_BADBLOCK_PROGNOOP',
|
# 'LFS_EMUBD_BADBLOCK_PROGNOOP',
|
||||||
'LFS_EMUBD_BADBLOCK_ERASENOOP',
|
# 'LFS_EMUBD_BADBLOCK_ERASENOOP',
|
||||||
]
|
#]
|
||||||
defines.NAMEMULT = 64
|
#defines.NAMEMULT = 64
|
||||||
defines.FILEMULT = 1
|
#defines.FILEMULT = 1
|
||||||
code = '''
|
#code = '''
|
||||||
for (lfs_block_t i = 0; i < (BLOCK_COUNT-2)/2; i++) {
|
# for (lfs_block_t i = 0; i < (BLOCK_COUNT-2)/2; i++) {
|
||||||
lfs_emubd_setwear(cfg, (2*i) + 2, 0xffffffff) => 0;
|
# lfs_emubd_setwear(cfg, (2*i) + 2, 0xffffffff) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
for (int i = 1; i < 10; i++) {
|
# for (int i = 1; i < 10; i++) {
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
for (int j = 0; j < NAMEMULT; j++) {
|
# for (int j = 0; j < NAMEMULT; j++) {
|
||||||
buffer[j] = '0'+i;
|
# buffer[j] = '0'+i;
|
||||||
}
|
# }
|
||||||
buffer[NAMEMULT] = '\0';
|
# buffer[NAMEMULT] = '\0';
|
||||||
lfs_mkdir(&lfs, (char*)buffer) => 0;
|
# lfs_mkdir(&lfs, (char*)buffer) => 0;
|
||||||
|
#
|
||||||
buffer[NAMEMULT] = '/';
|
# buffer[NAMEMULT] = '/';
|
||||||
for (int j = 0; j < NAMEMULT; j++) {
|
# for (int j = 0; j < NAMEMULT; j++) {
|
||||||
buffer[j+NAMEMULT+1] = '0'+i;
|
# buffer[j+NAMEMULT+1] = '0'+i;
|
||||||
}
|
# }
|
||||||
buffer[2*NAMEMULT+1] = '\0';
|
# buffer[2*NAMEMULT+1] = '\0';
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, (char*)buffer,
|
# lfs_file_open(&lfs, &file, (char*)buffer,
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
|
#
|
||||||
lfs_size_t size = NAMEMULT;
|
# lfs_size_t size = NAMEMULT;
|
||||||
for (int j = 0; j < i*FILEMULT; j++) {
|
# for (int j = 0; j < i*FILEMULT; j++) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
for (int i = 1; i < 10; i++) {
|
# for (int i = 1; i < 10; i++) {
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
for (int j = 0; j < NAMEMULT; j++) {
|
# for (int j = 0; j < NAMEMULT; j++) {
|
||||||
buffer[j] = '0'+i;
|
# buffer[j] = '0'+i;
|
||||||
}
|
# }
|
||||||
buffer[NAMEMULT] = '\0';
|
# buffer[NAMEMULT] = '\0';
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, (char*)buffer, &info) => 0;
|
# lfs_stat(&lfs, (char*)buffer, &info) => 0;
|
||||||
info.type => LFS_TYPE_DIR;
|
# info.type => LFS_TYPE_DIR;
|
||||||
|
#
|
||||||
buffer[NAMEMULT] = '/';
|
# buffer[NAMEMULT] = '/';
|
||||||
for (int j = 0; j < NAMEMULT; j++) {
|
# for (int j = 0; j < NAMEMULT; j++) {
|
||||||
buffer[j+NAMEMULT+1] = '0'+i;
|
# buffer[j+NAMEMULT+1] = '0'+i;
|
||||||
}
|
# }
|
||||||
buffer[2*NAMEMULT+1] = '\0';
|
# buffer[2*NAMEMULT+1] = '\0';
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, (char*)buffer, LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, (char*)buffer, LFS_O_RDONLY) => 0;
|
||||||
|
#
|
||||||
lfs_size_t size = NAMEMULT;
|
# lfs_size_t size = NAMEMULT;
|
||||||
for (int j = 0; j < i*FILEMULT; j++) {
|
# for (int j = 0; j < i*FILEMULT; j++) {
|
||||||
uint8_t rbuffer[1024];
|
# uint8_t rbuffer[1024];
|
||||||
lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
# lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
||||||
memcmp(buffer, rbuffer, size) => 0;
|
# memcmp(buffer, rbuffer, size) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# other corner cases
|
## other corner cases
|
||||||
[cases.test_badblocks_superblocks] # (corrupt 1 or 0)
|
#[cases.test_badblocks_superblocks] # (corrupt 1 or 0)
|
||||||
defines.ERASE_CYCLES = 0xffffffff
|
#defines.ERASE_CYCLES = 0xffffffff
|
||||||
defines.ERASE_VALUE = [0x00, 0xff, -1]
|
#defines.ERASE_VALUE = [0x00, 0xff, -1]
|
||||||
defines.BADBLOCK_BEHAVIOR = [
|
#defines.BADBLOCK_BEHAVIOR = [
|
||||||
'LFS_EMUBD_BADBLOCK_PROGERROR',
|
# 'LFS_EMUBD_BADBLOCK_PROGERROR',
|
||||||
'LFS_EMUBD_BADBLOCK_ERASEERROR',
|
# 'LFS_EMUBD_BADBLOCK_ERASEERROR',
|
||||||
'LFS_EMUBD_BADBLOCK_READERROR',
|
# 'LFS_EMUBD_BADBLOCK_READERROR',
|
||||||
'LFS_EMUBD_BADBLOCK_PROGNOOP',
|
# 'LFS_EMUBD_BADBLOCK_PROGNOOP',
|
||||||
'LFS_EMUBD_BADBLOCK_ERASENOOP',
|
# 'LFS_EMUBD_BADBLOCK_ERASENOOP',
|
||||||
]
|
#]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_emubd_setwear(cfg, 0, 0xffffffff) => 0;
|
# lfs_emubd_setwear(cfg, 0, 0xffffffff) => 0;
|
||||||
lfs_emubd_setwear(cfg, 1, 0xffffffff) => 0;
|
# lfs_emubd_setwear(cfg, 1, 0xffffffff) => 0;
|
||||||
|
#
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => LFS_ERR_NOSPC;
|
# lfs_format(&lfs, cfg) => LFS_ERR_NOSPC;
|
||||||
lfs_mount(&lfs, cfg) => LFS_ERR_CORRUPT;
|
# lfs_mount(&lfs, cfg) => LFS_ERR_CORRUPT;
|
||||||
'''
|
#'''
|
||||||
|
|||||||
+932
-932
File diff suppressed because it is too large
Load Diff
+642
-642
File diff suppressed because it is too large
Load Diff
+306
-306
@@ -1,306 +1,306 @@
|
|||||||
# Tests for recovering from conditions which shouldn't normally
|
## Tests for recovering from conditions which shouldn't normally
|
||||||
# happen during normal operation of littlefs
|
## happen during normal operation of littlefs
|
||||||
|
#
|
||||||
# invalid pointer tests (outside of block_count)
|
## invalid pointer tests (outside of block_count)
|
||||||
|
#
|
||||||
[cases.test_evil_invalid_tail_pointer]
|
#[cases.test_evil_invalid_tail_pointer]
|
||||||
defines.TAIL_TYPE = ['LFS_TYPE_HARDTAIL', 'LFS_TYPE_SOFTTAIL']
|
#defines.TAIL_TYPE = ['LFS_TYPE_HARDTAIL', 'LFS_TYPE_SOFTTAIL']
|
||||||
defines.INVALSET = [0x3, 0x1, 0x2]
|
#defines.INVALSET = [0x3, 0x1, 0x2]
|
||||||
in = "lfs.c"
|
#in = "lfs.c"
|
||||||
code = '''
|
#code = '''
|
||||||
// create littlefs
|
# // create littlefs
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
|
#
|
||||||
// change tail-pointer to invalid pointers
|
# // change tail-pointer to invalid pointers
|
||||||
lfs_init(&lfs, cfg) => 0;
|
# lfs_init(&lfs, cfg) => 0;
|
||||||
lfs_mdir_t mdir;
|
# lfs_mdir_t mdir;
|
||||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
# lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||||
lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
|
# lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
|
||||||
{LFS_MKTAG(LFS_TYPE_HARDTAIL, 0x3ff, 8),
|
# {LFS_MKTAG(LFS_TYPE_HARDTAIL, 0x3ff, 8),
|
||||||
(lfs_block_t[2]){
|
# (lfs_block_t[2]){
|
||||||
(INVALSET & 0x1) ? 0xcccccccc : 0,
|
# (INVALSET & 0x1) ? 0xcccccccc : 0,
|
||||||
(INVALSET & 0x2) ? 0xcccccccc : 0}})) => 0;
|
# (INVALSET & 0x2) ? 0xcccccccc : 0}})) => 0;
|
||||||
lfs_deinit(&lfs) => 0;
|
# lfs_deinit(&lfs) => 0;
|
||||||
|
#
|
||||||
// test that mount fails gracefully
|
# // test that mount fails gracefully
|
||||||
lfs_mount(&lfs, cfg) => LFS_ERR_CORRUPT;
|
# lfs_mount(&lfs, cfg) => LFS_ERR_CORRUPT;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
[cases.test_evil_invalid_dir_pointer]
|
#[cases.test_evil_invalid_dir_pointer]
|
||||||
defines.INVALSET = [0x3, 0x1, 0x2]
|
#defines.INVALSET = [0x3, 0x1, 0x2]
|
||||||
in = "lfs.c"
|
#in = "lfs.c"
|
||||||
code = '''
|
#code = '''
|
||||||
// create littlefs
|
# // create littlefs
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
// make a dir
|
# // make a dir
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "dir_here") => 0;
|
# lfs_mkdir(&lfs, "dir_here") => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
// change the dir pointer to be invalid
|
# // change the dir pointer to be invalid
|
||||||
lfs_init(&lfs, cfg) => 0;
|
# lfs_init(&lfs, cfg) => 0;
|
||||||
lfs_mdir_t mdir;
|
# lfs_mdir_t mdir;
|
||||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
# lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||||
// make sure id 1 == our directory
|
# // make sure id 1 == our directory
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
lfs_dir_get(&lfs, &mdir,
|
# lfs_dir_get(&lfs, &mdir,
|
||||||
LFS_MKTAG(0x700, 0x3ff, 0),
|
# LFS_MKTAG(0x700, 0x3ff, 0),
|
||||||
LFS_MKTAG(LFS_TYPE_NAME, 1, strlen("dir_here")), buffer)
|
# LFS_MKTAG(LFS_TYPE_NAME, 1, strlen("dir_here")), buffer)
|
||||||
=> LFS_MKTAG(LFS_TYPE_DIR, 1, strlen("dir_here"));
|
# => LFS_MKTAG(LFS_TYPE_DIR, 1, strlen("dir_here"));
|
||||||
assert(memcmp((char*)buffer, "dir_here", strlen("dir_here")) == 0);
|
# assert(memcmp((char*)buffer, "dir_here", strlen("dir_here")) == 0);
|
||||||
// change dir pointer
|
# // change dir pointer
|
||||||
lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
|
# lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
|
||||||
{LFS_MKTAG(LFS_TYPE_DIRSTRUCT, 1, 8),
|
# {LFS_MKTAG(LFS_TYPE_DIRSTRUCT, 1, 8),
|
||||||
(lfs_block_t[2]){
|
# (lfs_block_t[2]){
|
||||||
(INVALSET & 0x1) ? 0xcccccccc : 0,
|
# (INVALSET & 0x1) ? 0xcccccccc : 0,
|
||||||
(INVALSET & 0x2) ? 0xcccccccc : 0}})) => 0;
|
# (INVALSET & 0x2) ? 0xcccccccc : 0}})) => 0;
|
||||||
lfs_deinit(&lfs) => 0;
|
# lfs_deinit(&lfs) => 0;
|
||||||
|
#
|
||||||
// test that accessing our bad dir fails, note there's a number
|
# // test that accessing our bad dir fails, note there's a number
|
||||||
// of ways to access the dir, some can fail, but some don't
|
# // of ways to access the dir, some can fail, but some don't
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, "dir_here", &info) => 0;
|
# lfs_stat(&lfs, "dir_here", &info) => 0;
|
||||||
assert(strcmp(info.name, "dir_here") == 0);
|
# assert(strcmp(info.name, "dir_here") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
|
#
|
||||||
lfs_dir_t dir;
|
# lfs_dir_t dir;
|
||||||
lfs_dir_open(&lfs, &dir, "dir_here") => LFS_ERR_CORRUPT;
|
# lfs_dir_open(&lfs, &dir, "dir_here") => LFS_ERR_CORRUPT;
|
||||||
lfs_stat(&lfs, "dir_here/file_here", &info) => LFS_ERR_CORRUPT;
|
# lfs_stat(&lfs, "dir_here/file_here", &info) => LFS_ERR_CORRUPT;
|
||||||
lfs_dir_open(&lfs, &dir, "dir_here/dir_here") => LFS_ERR_CORRUPT;
|
# lfs_dir_open(&lfs, &dir, "dir_here/dir_here") => LFS_ERR_CORRUPT;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "dir_here/file_here",
|
# lfs_file_open(&lfs, &file, "dir_here/file_here",
|
||||||
LFS_O_RDONLY) => LFS_ERR_CORRUPT;
|
# LFS_O_RDONLY) => LFS_ERR_CORRUPT;
|
||||||
lfs_file_open(&lfs, &file, "dir_here/file_here",
|
# lfs_file_open(&lfs, &file, "dir_here/file_here",
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_CORRUPT;
|
# LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_CORRUPT;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
[cases.test_evil_invalid_file_pointer]
|
#[cases.test_evil_invalid_file_pointer]
|
||||||
in = "lfs.c"
|
#in = "lfs.c"
|
||||||
defines.SIZE = [10, 1000, 100000] # faked file size
|
#defines.SIZE = [10, 1000, 100000] # faked file size
|
||||||
code = '''
|
#code = '''
|
||||||
// create littlefs
|
# // create littlefs
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
// make a file
|
# // make a file
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "file_here",
|
# lfs_file_open(&lfs, &file, "file_here",
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
// change the file pointer to be invalid
|
# // change the file pointer to be invalid
|
||||||
lfs_init(&lfs, cfg) => 0;
|
# lfs_init(&lfs, cfg) => 0;
|
||||||
lfs_mdir_t mdir;
|
# lfs_mdir_t mdir;
|
||||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
# lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||||
// make sure id 1 == our file
|
# // make sure id 1 == our file
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
lfs_dir_get(&lfs, &mdir,
|
# lfs_dir_get(&lfs, &mdir,
|
||||||
LFS_MKTAG(0x700, 0x3ff, 0),
|
# LFS_MKTAG(0x700, 0x3ff, 0),
|
||||||
LFS_MKTAG(LFS_TYPE_NAME, 1, strlen("file_here")), buffer)
|
# LFS_MKTAG(LFS_TYPE_NAME, 1, strlen("file_here")), buffer)
|
||||||
=> LFS_MKTAG(LFS_TYPE_REG, 1, strlen("file_here"));
|
# => LFS_MKTAG(LFS_TYPE_REG, 1, strlen("file_here"));
|
||||||
assert(memcmp((char*)buffer, "file_here", strlen("file_here")) == 0);
|
# assert(memcmp((char*)buffer, "file_here", strlen("file_here")) == 0);
|
||||||
// change file pointer
|
# // change file pointer
|
||||||
lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
|
# lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
|
||||||
{LFS_MKTAG(LFS_TYPE_CTZSTRUCT, 1, sizeof(struct lfs_ctz)),
|
# {LFS_MKTAG(LFS_TYPE_CTZSTRUCT, 1, sizeof(struct lfs_ctz)),
|
||||||
&(struct lfs_ctz){0xcccccccc, lfs_tole32(SIZE)}})) => 0;
|
# &(struct lfs_ctz){0xcccccccc, lfs_tole32(SIZE)}})) => 0;
|
||||||
lfs_deinit(&lfs) => 0;
|
# lfs_deinit(&lfs) => 0;
|
||||||
|
#
|
||||||
// test that accessing our bad file fails, note there's a number
|
# // test that accessing our bad file fails, note there's a number
|
||||||
// of ways to access the dir, some can fail, but some don't
|
# // of ways to access the dir, some can fail, but some don't
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, "file_here", &info) => 0;
|
# lfs_stat(&lfs, "file_here", &info) => 0;
|
||||||
assert(strcmp(info.name, "file_here") == 0);
|
# assert(strcmp(info.name, "file_here") == 0);
|
||||||
assert(info.type == LFS_TYPE_REG);
|
# assert(info.type == LFS_TYPE_REG);
|
||||||
assert(info.size == SIZE);
|
# assert(info.size == SIZE);
|
||||||
|
#
|
||||||
lfs_file_open(&lfs, &file, "file_here", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "file_here", LFS_O_RDONLY) => 0;
|
||||||
lfs_file_read(&lfs, &file, buffer, SIZE) => LFS_ERR_CORRUPT;
|
# lfs_file_read(&lfs, &file, buffer, SIZE) => LFS_ERR_CORRUPT;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
// any allocs that traverse CTZ must unfortunately must fail
|
# // any allocs that traverse CTZ must unfortunately must fail
|
||||||
if (SIZE > 2*BLOCK_SIZE) {
|
# if (SIZE > 2*BLOCK_SIZE) {
|
||||||
lfs_mkdir(&lfs, "dir_here") => LFS_ERR_CORRUPT;
|
# lfs_mkdir(&lfs, "dir_here") => LFS_ERR_CORRUPT;
|
||||||
}
|
# }
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
[cases.test_evil_invalid_ctz_pointer] # invalid pointer in CTZ skip-list test
|
#[cases.test_evil_invalid_ctz_pointer] # invalid pointer in CTZ skip-list test
|
||||||
defines.SIZE = ['2*BLOCK_SIZE', '3*BLOCK_SIZE', '4*BLOCK_SIZE']
|
#defines.SIZE = ['2*BLOCK_SIZE', '3*BLOCK_SIZE', '4*BLOCK_SIZE']
|
||||||
in = "lfs.c"
|
#in = "lfs.c"
|
||||||
code = '''
|
#code = '''
|
||||||
// create littlefs
|
# // create littlefs
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
// make a file
|
# // make a file
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "file_here",
|
# lfs_file_open(&lfs, &file, "file_here",
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
for (int i = 0; i < SIZE; i++) {
|
# for (int i = 0; i < SIZE; i++) {
|
||||||
char c = 'c';
|
# char c = 'c';
|
||||||
lfs_file_write(&lfs, &file, &c, 1) => 1;
|
# lfs_file_write(&lfs, &file, &c, 1) => 1;
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
// change pointer in CTZ skip-list to be invalid
|
# // change pointer in CTZ skip-list to be invalid
|
||||||
lfs_init(&lfs, cfg) => 0;
|
# lfs_init(&lfs, cfg) => 0;
|
||||||
lfs_mdir_t mdir;
|
# lfs_mdir_t mdir;
|
||||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
# lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||||
// make sure id 1 == our file and get our CTZ structure
|
# // make sure id 1 == our file and get our CTZ structure
|
||||||
uint8_t buffer[4*BLOCK_SIZE];
|
# uint8_t buffer[4*BLOCK_SIZE];
|
||||||
lfs_dir_get(&lfs, &mdir,
|
# lfs_dir_get(&lfs, &mdir,
|
||||||
LFS_MKTAG(0x700, 0x3ff, 0),
|
# LFS_MKTAG(0x700, 0x3ff, 0),
|
||||||
LFS_MKTAG(LFS_TYPE_NAME, 1, strlen("file_here")), buffer)
|
# LFS_MKTAG(LFS_TYPE_NAME, 1, strlen("file_here")), buffer)
|
||||||
=> LFS_MKTAG(LFS_TYPE_REG, 1, strlen("file_here"));
|
# => LFS_MKTAG(LFS_TYPE_REG, 1, strlen("file_here"));
|
||||||
assert(memcmp((char*)buffer, "file_here", strlen("file_here")) == 0);
|
# assert(memcmp((char*)buffer, "file_here", strlen("file_here")) == 0);
|
||||||
struct lfs_ctz ctz;
|
# struct lfs_ctz ctz;
|
||||||
lfs_dir_get(&lfs, &mdir,
|
# lfs_dir_get(&lfs, &mdir,
|
||||||
LFS_MKTAG(0x700, 0x3ff, 0),
|
# LFS_MKTAG(0x700, 0x3ff, 0),
|
||||||
LFS_MKTAG(LFS_TYPE_STRUCT, 1, sizeof(struct lfs_ctz)), &ctz)
|
# LFS_MKTAG(LFS_TYPE_STRUCT, 1, sizeof(struct lfs_ctz)), &ctz)
|
||||||
=> LFS_MKTAG(LFS_TYPE_CTZSTRUCT, 1, sizeof(struct lfs_ctz));
|
# => LFS_MKTAG(LFS_TYPE_CTZSTRUCT, 1, sizeof(struct lfs_ctz));
|
||||||
lfs_ctz_fromle32(&ctz);
|
# lfs_ctz_fromle32(&ctz);
|
||||||
// rewrite block to contain bad pointer
|
# // rewrite block to contain bad pointer
|
||||||
uint8_t bbuffer[BLOCK_SIZE];
|
# uint8_t bbuffer[BLOCK_SIZE];
|
||||||
cfg->read(cfg, ctz.head, 0, bbuffer, BLOCK_SIZE) => 0;
|
# cfg->read(cfg, ctz.head, 0, bbuffer, BLOCK_SIZE) => 0;
|
||||||
uint32_t bad = lfs_tole32(0xcccccccc);
|
# uint32_t bad = lfs_tole32(0xcccccccc);
|
||||||
memcpy(&bbuffer[0], &bad, sizeof(bad));
|
# memcpy(&bbuffer[0], &bad, sizeof(bad));
|
||||||
memcpy(&bbuffer[4], &bad, sizeof(bad));
|
# memcpy(&bbuffer[4], &bad, sizeof(bad));
|
||||||
cfg->erase(cfg, ctz.head) => 0;
|
# cfg->erase(cfg, ctz.head) => 0;
|
||||||
cfg->prog(cfg, ctz.head, 0, bbuffer, BLOCK_SIZE) => 0;
|
# cfg->prog(cfg, ctz.head, 0, bbuffer, BLOCK_SIZE) => 0;
|
||||||
lfs_deinit(&lfs) => 0;
|
# lfs_deinit(&lfs) => 0;
|
||||||
|
#
|
||||||
// test that accessing our bad file fails, note there's a number
|
# // test that accessing our bad file fails, note there's a number
|
||||||
// of ways to access the dir, some can fail, but some don't
|
# // of ways to access the dir, some can fail, but some don't
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, "file_here", &info) => 0;
|
# lfs_stat(&lfs, "file_here", &info) => 0;
|
||||||
assert(strcmp(info.name, "file_here") == 0);
|
# assert(strcmp(info.name, "file_here") == 0);
|
||||||
assert(info.type == LFS_TYPE_REG);
|
# assert(info.type == LFS_TYPE_REG);
|
||||||
assert(info.size == SIZE);
|
# assert(info.size == SIZE);
|
||||||
|
#
|
||||||
lfs_file_open(&lfs, &file, "file_here", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "file_here", LFS_O_RDONLY) => 0;
|
||||||
lfs_file_read(&lfs, &file, buffer, SIZE) => LFS_ERR_CORRUPT;
|
# lfs_file_read(&lfs, &file, buffer, SIZE) => LFS_ERR_CORRUPT;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
// any allocs that traverse CTZ must unfortunately must fail
|
# // any allocs that traverse CTZ must unfortunately must fail
|
||||||
if (SIZE > 2*BLOCK_SIZE) {
|
# if (SIZE > 2*BLOCK_SIZE) {
|
||||||
lfs_mkdir(&lfs, "dir_here") => LFS_ERR_CORRUPT;
|
# lfs_mkdir(&lfs, "dir_here") => LFS_ERR_CORRUPT;
|
||||||
}
|
# }
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
|
#
|
||||||
[cases.test_evil_invalid_gstate_pointer]
|
#[cases.test_evil_invalid_gstate_pointer]
|
||||||
defines.INVALSET = [0x3, 0x1, 0x2]
|
#defines.INVALSET = [0x3, 0x1, 0x2]
|
||||||
in = "lfs.c"
|
#in = "lfs.c"
|
||||||
code = '''
|
#code = '''
|
||||||
// create littlefs
|
# // create littlefs
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
|
#
|
||||||
// create an invalid gstate
|
# // create an invalid gstate
|
||||||
lfs_init(&lfs, cfg) => 0;
|
# lfs_init(&lfs, cfg) => 0;
|
||||||
lfs_mdir_t mdir;
|
# lfs_mdir_t mdir;
|
||||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
# lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||||
lfs_fs_prepmove(&lfs, 1, (lfs_block_t [2]){
|
# lfs_fs_prepmove(&lfs, 1, (lfs_block_t [2]){
|
||||||
(INVALSET & 0x1) ? 0xcccccccc : 0,
|
# (INVALSET & 0x1) ? 0xcccccccc : 0,
|
||||||
(INVALSET & 0x2) ? 0xcccccccc : 0});
|
# (INVALSET & 0x2) ? 0xcccccccc : 0});
|
||||||
lfs_dir_commit(&lfs, &mdir, NULL, 0) => 0;
|
# lfs_dir_commit(&lfs, &mdir, NULL, 0) => 0;
|
||||||
lfs_deinit(&lfs) => 0;
|
# lfs_deinit(&lfs) => 0;
|
||||||
|
#
|
||||||
// test that mount fails gracefully
|
# // test that mount fails gracefully
|
||||||
// mount may not fail, but our first alloc should fail when
|
# // mount may not fail, but our first alloc should fail when
|
||||||
// we try to fix the gstate
|
# // we try to fix the gstate
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "should_fail") => LFS_ERR_CORRUPT;
|
# lfs_mkdir(&lfs, "should_fail") => LFS_ERR_CORRUPT;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# cycle detection/recovery tests
|
## cycle detection/recovery tests
|
||||||
|
#
|
||||||
[cases.test_evil_mdir_loop] # metadata-pair threaded-list loop test
|
#[cases.test_evil_mdir_loop] # metadata-pair threaded-list loop test
|
||||||
in = "lfs.c"
|
#in = "lfs.c"
|
||||||
code = '''
|
#code = '''
|
||||||
// create littlefs
|
# // create littlefs
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
|
#
|
||||||
// change tail-pointer to point to ourself
|
# // change tail-pointer to point to ourself
|
||||||
lfs_init(&lfs, cfg) => 0;
|
# lfs_init(&lfs, cfg) => 0;
|
||||||
lfs_mdir_t mdir;
|
# lfs_mdir_t mdir;
|
||||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
# lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||||
lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
|
# lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
|
||||||
{LFS_MKTAG(LFS_TYPE_HARDTAIL, 0x3ff, 8),
|
# {LFS_MKTAG(LFS_TYPE_HARDTAIL, 0x3ff, 8),
|
||||||
(lfs_block_t[2]){0, 1}})) => 0;
|
# (lfs_block_t[2]){0, 1}})) => 0;
|
||||||
lfs_deinit(&lfs) => 0;
|
# lfs_deinit(&lfs) => 0;
|
||||||
|
#
|
||||||
// test that mount fails gracefully
|
# // test that mount fails gracefully
|
||||||
lfs_mount(&lfs, cfg) => LFS_ERR_CORRUPT;
|
# lfs_mount(&lfs, cfg) => LFS_ERR_CORRUPT;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
[cases.test_evil_mdir_loop2] # metadata-pair threaded-list 2-length loop test
|
#[cases.test_evil_mdir_loop2] # metadata-pair threaded-list 2-length loop test
|
||||||
in = "lfs.c"
|
#in = "lfs.c"
|
||||||
code = '''
|
#code = '''
|
||||||
// create littlefs with child dir
|
# // create littlefs with child dir
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "child") => 0;
|
# lfs_mkdir(&lfs, "child") => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
// find child
|
# // find child
|
||||||
lfs_init(&lfs, cfg) => 0;
|
# lfs_init(&lfs, cfg) => 0;
|
||||||
lfs_mdir_t mdir;
|
# lfs_mdir_t mdir;
|
||||||
lfs_block_t pair[2];
|
# lfs_block_t pair[2];
|
||||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
# lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||||
lfs_dir_get(&lfs, &mdir,
|
# lfs_dir_get(&lfs, &mdir,
|
||||||
LFS_MKTAG(0x7ff, 0x3ff, 0),
|
# LFS_MKTAG(0x7ff, 0x3ff, 0),
|
||||||
LFS_MKTAG(LFS_TYPE_DIRSTRUCT, 1, sizeof(pair)), pair)
|
# LFS_MKTAG(LFS_TYPE_DIRSTRUCT, 1, sizeof(pair)), pair)
|
||||||
=> LFS_MKTAG(LFS_TYPE_DIRSTRUCT, 1, sizeof(pair));
|
# => LFS_MKTAG(LFS_TYPE_DIRSTRUCT, 1, sizeof(pair));
|
||||||
lfs_pair_fromle32(pair);
|
# lfs_pair_fromle32(pair);
|
||||||
// change tail-pointer to point to root
|
# // change tail-pointer to point to root
|
||||||
lfs_dir_fetch(&lfs, &mdir, pair) => 0;
|
# lfs_dir_fetch(&lfs, &mdir, pair) => 0;
|
||||||
lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
|
# lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
|
||||||
{LFS_MKTAG(LFS_TYPE_HARDTAIL, 0x3ff, 8),
|
# {LFS_MKTAG(LFS_TYPE_HARDTAIL, 0x3ff, 8),
|
||||||
(lfs_block_t[2]){0, 1}})) => 0;
|
# (lfs_block_t[2]){0, 1}})) => 0;
|
||||||
lfs_deinit(&lfs) => 0;
|
# lfs_deinit(&lfs) => 0;
|
||||||
|
#
|
||||||
// test that mount fails gracefully
|
# // test that mount fails gracefully
|
||||||
lfs_mount(&lfs, cfg) => LFS_ERR_CORRUPT;
|
# lfs_mount(&lfs, cfg) => LFS_ERR_CORRUPT;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
[cases.test_evil_mdir_loop_child] # metadata-pair threaded-list 1-length child loop test
|
#[cases.test_evil_mdir_loop_child] # metadata-pair threaded-list 1-length child loop test
|
||||||
in = "lfs.c"
|
#in = "lfs.c"
|
||||||
code = '''
|
#code = '''
|
||||||
// create littlefs with child dir
|
# // create littlefs with child dir
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "child") => 0;
|
# lfs_mkdir(&lfs, "child") => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
// find child
|
# // find child
|
||||||
lfs_init(&lfs, cfg) => 0;
|
# lfs_init(&lfs, cfg) => 0;
|
||||||
lfs_mdir_t mdir;
|
# lfs_mdir_t mdir;
|
||||||
lfs_block_t pair[2];
|
# lfs_block_t pair[2];
|
||||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
# lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||||
lfs_dir_get(&lfs, &mdir,
|
# lfs_dir_get(&lfs, &mdir,
|
||||||
LFS_MKTAG(0x7ff, 0x3ff, 0),
|
# LFS_MKTAG(0x7ff, 0x3ff, 0),
|
||||||
LFS_MKTAG(LFS_TYPE_DIRSTRUCT, 1, sizeof(pair)), pair)
|
# LFS_MKTAG(LFS_TYPE_DIRSTRUCT, 1, sizeof(pair)), pair)
|
||||||
=> LFS_MKTAG(LFS_TYPE_DIRSTRUCT, 1, sizeof(pair));
|
# => LFS_MKTAG(LFS_TYPE_DIRSTRUCT, 1, sizeof(pair));
|
||||||
lfs_pair_fromle32(pair);
|
# lfs_pair_fromle32(pair);
|
||||||
// change tail-pointer to point to ourself
|
# // change tail-pointer to point to ourself
|
||||||
lfs_dir_fetch(&lfs, &mdir, pair) => 0;
|
# lfs_dir_fetch(&lfs, &mdir, pair) => 0;
|
||||||
lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
|
# lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
|
||||||
{LFS_MKTAG(LFS_TYPE_HARDTAIL, 0x3ff, 8), pair})) => 0;
|
# {LFS_MKTAG(LFS_TYPE_HARDTAIL, 0x3ff, 8), pair})) => 0;
|
||||||
lfs_deinit(&lfs) => 0;
|
# lfs_deinit(&lfs) => 0;
|
||||||
|
#
|
||||||
// test that mount fails gracefully
|
# // test that mount fails gracefully
|
||||||
lfs_mount(&lfs, cfg) => LFS_ERR_CORRUPT;
|
# lfs_mount(&lfs, cfg) => LFS_ERR_CORRUPT;
|
||||||
'''
|
#'''
|
||||||
|
|||||||
+505
-505
File diff suppressed because it is too large
Load Diff
+516
-516
File diff suppressed because it is too large
Load Diff
+270
-270
@@ -1,270 +1,270 @@
|
|||||||
|
#
|
||||||
[cases.test_interspersed_files]
|
#[cases.test_interspersed_files]
|
||||||
defines.SIZE = [10, 100]
|
#defines.SIZE = [10, 100]
|
||||||
defines.FILES = [4, 10, 26]
|
#defines.FILES = [4, 10, 26]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_file_t files[FILES];
|
# lfs_file_t files[FILES];
|
||||||
const char alphas[] = "abcdefghijklmnopqrstuvwxyz";
|
# const char alphas[] = "abcdefghijklmnopqrstuvwxyz";
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "%c", alphas[j]);
|
# sprintf(path, "%c", alphas[j]);
|
||||||
lfs_file_open(&lfs, &files[j], path,
|
# lfs_file_open(&lfs, &files[j], path,
|
||||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (int i = 0; i < SIZE; i++) {
|
# for (int i = 0; i < SIZE; i++) {
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
lfs_file_write(&lfs, &files[j], &alphas[j], 1) => 1;
|
# lfs_file_write(&lfs, &files[j], &alphas[j], 1) => 1;
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
lfs_file_close(&lfs, &files[j]);
|
# lfs_file_close(&lfs, &files[j]);
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_dir_t dir;
|
# lfs_dir_t dir;
|
||||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
# lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
assert(strcmp(info.name, ".") == 0);
|
# assert(strcmp(info.name, ".") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
assert(strcmp(info.name, "..") == 0);
|
# assert(strcmp(info.name, "..") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "%c", alphas[j]);
|
# sprintf(path, "%c", alphas[j]);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
assert(strcmp(info.name, path) == 0);
|
# assert(strcmp(info.name, path) == 0);
|
||||||
assert(info.type == LFS_TYPE_REG);
|
# assert(info.type == LFS_TYPE_REG);
|
||||||
assert(info.size == SIZE);
|
# assert(info.size == SIZE);
|
||||||
}
|
# }
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 0;
|
# lfs_dir_read(&lfs, &dir, &info) => 0;
|
||||||
lfs_dir_close(&lfs, &dir) => 0;
|
# lfs_dir_close(&lfs, &dir) => 0;
|
||||||
|
#
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "%c", alphas[j]);
|
# sprintf(path, "%c", alphas[j]);
|
||||||
lfs_file_open(&lfs, &files[j], path, LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &files[j], path, LFS_O_RDONLY) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (int i = 0; i < 10; i++) {
|
# for (int i = 0; i < 10; i++) {
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
lfs_file_read(&lfs, &files[j], buffer, 1) => 1;
|
# lfs_file_read(&lfs, &files[j], buffer, 1) => 1;
|
||||||
assert(buffer[0] == alphas[j]);
|
# assert(buffer[0] == alphas[j]);
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
lfs_file_close(&lfs, &files[j]);
|
# lfs_file_close(&lfs, &files[j]);
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
[cases.test_interspersed_remove_files]
|
#[cases.test_interspersed_remove_files]
|
||||||
defines.SIZE = [10, 100]
|
#defines.SIZE = [10, 100]
|
||||||
defines.FILES = [4, 10, 26]
|
#defines.FILES = [4, 10, 26]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
const char alphas[] = "abcdefghijklmnopqrstuvwxyz";
|
# const char alphas[] = "abcdefghijklmnopqrstuvwxyz";
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "%c", alphas[j]);
|
# sprintf(path, "%c", alphas[j]);
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, path,
|
# lfs_file_open(&lfs, &file, path,
|
||||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
||||||
for (int i = 0; i < SIZE; i++) {
|
# for (int i = 0; i < SIZE; i++) {
|
||||||
lfs_file_write(&lfs, &file, &alphas[j], 1) => 1;
|
# lfs_file_write(&lfs, &file, &alphas[j], 1) => 1;
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file);
|
# lfs_file_close(&lfs, &file);
|
||||||
}
|
# }
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "zzz", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# lfs_file_open(&lfs, &file, "zzz", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
lfs_file_write(&lfs, &file, (const void*)"~", 1) => 1;
|
# lfs_file_write(&lfs, &file, (const void*)"~", 1) => 1;
|
||||||
lfs_file_sync(&lfs, &file) => 0;
|
# lfs_file_sync(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "%c", alphas[j]);
|
# sprintf(path, "%c", alphas[j]);
|
||||||
lfs_remove(&lfs, path) => 0;
|
# lfs_remove(&lfs, path) => 0;
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file);
|
# lfs_file_close(&lfs, &file);
|
||||||
|
#
|
||||||
lfs_dir_t dir;
|
# lfs_dir_t dir;
|
||||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
# lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
assert(strcmp(info.name, ".") == 0);
|
# assert(strcmp(info.name, ".") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
assert(strcmp(info.name, "..") == 0);
|
# assert(strcmp(info.name, "..") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
assert(strcmp(info.name, "zzz") == 0);
|
# assert(strcmp(info.name, "zzz") == 0);
|
||||||
assert(info.type == LFS_TYPE_REG);
|
# assert(info.type == LFS_TYPE_REG);
|
||||||
assert(info.size == FILES);
|
# assert(info.size == FILES);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 0;
|
# lfs_dir_read(&lfs, &dir, &info) => 0;
|
||||||
lfs_dir_close(&lfs, &dir) => 0;
|
# lfs_dir_close(&lfs, &dir) => 0;
|
||||||
|
#
|
||||||
lfs_file_open(&lfs, &file, "zzz", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "zzz", LFS_O_RDONLY) => 0;
|
||||||
for (int i = 0; i < FILES; i++) {
|
# for (int i = 0; i < FILES; i++) {
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
lfs_file_read(&lfs, &file, buffer, 1) => 1;
|
# lfs_file_read(&lfs, &file, buffer, 1) => 1;
|
||||||
assert(buffer[0] == '~');
|
# assert(buffer[0] == '~');
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file);
|
# lfs_file_close(&lfs, &file);
|
||||||
|
#
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
[cases.test_interspersed_remove_inconveniently]
|
#[cases.test_interspersed_remove_inconveniently]
|
||||||
defines.SIZE = [10, 100]
|
#defines.SIZE = [10, 100]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t files[3];
|
# lfs_file_t files[3];
|
||||||
lfs_file_open(&lfs, &files[0], "e", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# lfs_file_open(&lfs, &files[0], "e", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
lfs_file_open(&lfs, &files[1], "f", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# lfs_file_open(&lfs, &files[1], "f", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
lfs_file_open(&lfs, &files[2], "g", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# lfs_file_open(&lfs, &files[2], "g", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
|
#
|
||||||
for (int i = 0; i < SIZE/2; i++) {
|
# for (int i = 0; i < SIZE/2; i++) {
|
||||||
lfs_file_write(&lfs, &files[0], (const void*)"e", 1) => 1;
|
# lfs_file_write(&lfs, &files[0], (const void*)"e", 1) => 1;
|
||||||
lfs_file_write(&lfs, &files[1], (const void*)"f", 1) => 1;
|
# lfs_file_write(&lfs, &files[1], (const void*)"f", 1) => 1;
|
||||||
lfs_file_write(&lfs, &files[2], (const void*)"g", 1) => 1;
|
# lfs_file_write(&lfs, &files[2], (const void*)"g", 1) => 1;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_remove(&lfs, "f") => 0;
|
# lfs_remove(&lfs, "f") => 0;
|
||||||
|
#
|
||||||
for (int i = 0; i < SIZE/2; i++) {
|
# for (int i = 0; i < SIZE/2; i++) {
|
||||||
lfs_file_write(&lfs, &files[0], (const void*)"e", 1) => 1;
|
# lfs_file_write(&lfs, &files[0], (const void*)"e", 1) => 1;
|
||||||
lfs_file_write(&lfs, &files[1], (const void*)"f", 1) => 1;
|
# lfs_file_write(&lfs, &files[1], (const void*)"f", 1) => 1;
|
||||||
lfs_file_write(&lfs, &files[2], (const void*)"g", 1) => 1;
|
# lfs_file_write(&lfs, &files[2], (const void*)"g", 1) => 1;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &files[0]);
|
# lfs_file_close(&lfs, &files[0]);
|
||||||
lfs_file_close(&lfs, &files[1]);
|
# lfs_file_close(&lfs, &files[1]);
|
||||||
lfs_file_close(&lfs, &files[2]);
|
# lfs_file_close(&lfs, &files[2]);
|
||||||
|
#
|
||||||
lfs_dir_t dir;
|
# lfs_dir_t dir;
|
||||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
# lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
assert(strcmp(info.name, ".") == 0);
|
# assert(strcmp(info.name, ".") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
assert(strcmp(info.name, "..") == 0);
|
# assert(strcmp(info.name, "..") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
assert(strcmp(info.name, "e") == 0);
|
# assert(strcmp(info.name, "e") == 0);
|
||||||
assert(info.type == LFS_TYPE_REG);
|
# assert(info.type == LFS_TYPE_REG);
|
||||||
assert(info.size == SIZE);
|
# assert(info.size == SIZE);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
assert(strcmp(info.name, "g") == 0);
|
# assert(strcmp(info.name, "g") == 0);
|
||||||
assert(info.type == LFS_TYPE_REG);
|
# assert(info.type == LFS_TYPE_REG);
|
||||||
assert(info.size == SIZE);
|
# assert(info.size == SIZE);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 0;
|
# lfs_dir_read(&lfs, &dir, &info) => 0;
|
||||||
lfs_dir_close(&lfs, &dir) => 0;
|
# lfs_dir_close(&lfs, &dir) => 0;
|
||||||
|
#
|
||||||
lfs_file_open(&lfs, &files[0], "e", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &files[0], "e", LFS_O_RDONLY) => 0;
|
||||||
lfs_file_open(&lfs, &files[1], "g", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &files[1], "g", LFS_O_RDONLY) => 0;
|
||||||
for (int i = 0; i < SIZE; i++) {
|
# for (int i = 0; i < SIZE; i++) {
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
lfs_file_read(&lfs, &files[0], buffer, 1) => 1;
|
# lfs_file_read(&lfs, &files[0], buffer, 1) => 1;
|
||||||
assert(buffer[0] == 'e');
|
# assert(buffer[0] == 'e');
|
||||||
lfs_file_read(&lfs, &files[1], buffer, 1) => 1;
|
# lfs_file_read(&lfs, &files[1], buffer, 1) => 1;
|
||||||
assert(buffer[0] == 'g');
|
# assert(buffer[0] == 'g');
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &files[0]);
|
# lfs_file_close(&lfs, &files[0]);
|
||||||
lfs_file_close(&lfs, &files[1]);
|
# lfs_file_close(&lfs, &files[1]);
|
||||||
|
#
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
[cases.test_interspersed_reentrant_files]
|
#[cases.test_interspersed_reentrant_files]
|
||||||
defines.SIZE = [10, 100]
|
#defines.SIZE = [10, 100]
|
||||||
defines.FILES = [4, 10, 26]
|
#defines.FILES = [4, 10, 26]
|
||||||
reentrant = true
|
#reentrant = true
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_file_t files[FILES];
|
# lfs_file_t files[FILES];
|
||||||
const char alphas[] = "abcdefghijklmnopqrstuvwxyz";
|
# const char alphas[] = "abcdefghijklmnopqrstuvwxyz";
|
||||||
|
#
|
||||||
int err = lfs_mount(&lfs, cfg);
|
# int err = lfs_mount(&lfs, cfg);
|
||||||
if (err) {
|
# if (err) {
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "%c", alphas[j]);
|
# sprintf(path, "%c", alphas[j]);
|
||||||
lfs_file_open(&lfs, &files[j], path,
|
# lfs_file_open(&lfs, &files[j], path,
|
||||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (int i = 0; i < SIZE; i++) {
|
# for (int i = 0; i < SIZE; i++) {
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
lfs_ssize_t size = lfs_file_size(&lfs, &files[j]);
|
# lfs_ssize_t size = lfs_file_size(&lfs, &files[j]);
|
||||||
assert(size >= 0);
|
# assert(size >= 0);
|
||||||
if ((int)size <= i) {
|
# if ((int)size <= i) {
|
||||||
lfs_file_write(&lfs, &files[j], &alphas[j], 1) => 1;
|
# lfs_file_write(&lfs, &files[j], &alphas[j], 1) => 1;
|
||||||
lfs_file_sync(&lfs, &files[j]) => 0;
|
# lfs_file_sync(&lfs, &files[j]) => 0;
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
lfs_file_close(&lfs, &files[j]);
|
# lfs_file_close(&lfs, &files[j]);
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_dir_t dir;
|
# lfs_dir_t dir;
|
||||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
# lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
assert(strcmp(info.name, ".") == 0);
|
# assert(strcmp(info.name, ".") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
assert(strcmp(info.name, "..") == 0);
|
# assert(strcmp(info.name, "..") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "%c", alphas[j]);
|
# sprintf(path, "%c", alphas[j]);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
assert(strcmp(info.name, path) == 0);
|
# assert(strcmp(info.name, path) == 0);
|
||||||
assert(info.type == LFS_TYPE_REG);
|
# assert(info.type == LFS_TYPE_REG);
|
||||||
assert(info.size == SIZE);
|
# assert(info.size == SIZE);
|
||||||
}
|
# }
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 0;
|
# lfs_dir_read(&lfs, &dir, &info) => 0;
|
||||||
lfs_dir_close(&lfs, &dir) => 0;
|
# lfs_dir_close(&lfs, &dir) => 0;
|
||||||
|
#
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "%c", alphas[j]);
|
# sprintf(path, "%c", alphas[j]);
|
||||||
lfs_file_open(&lfs, &files[j], path, LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &files[j], path, LFS_O_RDONLY) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (int i = 0; i < 10; i++) {
|
# for (int i = 0; i < 10; i++) {
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
lfs_file_read(&lfs, &files[j], buffer, 1) => 1;
|
# lfs_file_read(&lfs, &files[j], buffer, 1) => 1;
|
||||||
assert(buffer[0] == alphas[j]);
|
# assert(buffer[0] == alphas[j]);
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (int j = 0; j < FILES; j++) {
|
# for (int j = 0; j < FILES; j++) {
|
||||||
lfs_file_close(&lfs, &files[j]);
|
# lfs_file_close(&lfs, &files[j]);
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
|||||||
+1897
-1897
File diff suppressed because it is too large
Load Diff
+129
-129
@@ -1,129 +1,129 @@
|
|||||||
[cases.test_orphans_normal]
|
#[cases.test_orphans_normal]
|
||||||
in = "lfs.c"
|
#in = "lfs.c"
|
||||||
if = 'PROG_SIZE <= 0x3fe' # only works with one crc per commit
|
#if = 'PROG_SIZE <= 0x3fe' # only works with one crc per commit
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "parent") => 0;
|
# lfs_mkdir(&lfs, "parent") => 0;
|
||||||
lfs_mkdir(&lfs, "parent/orphan") => 0;
|
# lfs_mkdir(&lfs, "parent/orphan") => 0;
|
||||||
lfs_mkdir(&lfs, "parent/child") => 0;
|
# lfs_mkdir(&lfs, "parent/child") => 0;
|
||||||
lfs_remove(&lfs, "parent/orphan") => 0;
|
# lfs_remove(&lfs, "parent/orphan") => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
// corrupt the child's most recent commit, this should be the update
|
# // corrupt the child's most recent commit, this should be the update
|
||||||
// to the linked-list entry, which should orphan the orphan. Note this
|
# // to the linked-list entry, which should orphan the orphan. Note this
|
||||||
// makes a lot of assumptions about the remove operation.
|
# // makes a lot of assumptions about the remove operation.
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_dir_t dir;
|
# lfs_dir_t dir;
|
||||||
lfs_dir_open(&lfs, &dir, "parent/child") => 0;
|
# lfs_dir_open(&lfs, &dir, "parent/child") => 0;
|
||||||
lfs_block_t block = dir.m.pair[0];
|
# lfs_block_t block = dir.m.pair[0];
|
||||||
lfs_dir_close(&lfs, &dir) => 0;
|
# lfs_dir_close(&lfs, &dir) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
uint8_t buffer[BLOCK_SIZE];
|
# uint8_t buffer[BLOCK_SIZE];
|
||||||
cfg->read(cfg, block, 0, buffer, BLOCK_SIZE) => 0;
|
# cfg->read(cfg, block, 0, buffer, BLOCK_SIZE) => 0;
|
||||||
int off = BLOCK_SIZE-1;
|
# int off = BLOCK_SIZE-1;
|
||||||
while (off >= 0 && buffer[off] == ERASE_VALUE) {
|
# while (off >= 0 && buffer[off] == ERASE_VALUE) {
|
||||||
off -= 1;
|
# off -= 1;
|
||||||
}
|
# }
|
||||||
memset(&buffer[off-3], BLOCK_SIZE, 3);
|
# memset(&buffer[off-3], BLOCK_SIZE, 3);
|
||||||
cfg->erase(cfg, block) => 0;
|
# cfg->erase(cfg, block) => 0;
|
||||||
cfg->prog(cfg, block, 0, buffer, BLOCK_SIZE) => 0;
|
# cfg->prog(cfg, block, 0, buffer, BLOCK_SIZE) => 0;
|
||||||
cfg->sync(cfg) => 0;
|
# cfg->sync(cfg) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
|
# lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
|
||||||
lfs_stat(&lfs, "parent/child", &info) => 0;
|
# lfs_stat(&lfs, "parent/child", &info) => 0;
|
||||||
lfs_fs_size(&lfs) => 8;
|
# lfs_fs_size(&lfs) => 8;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
|
# lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
|
||||||
lfs_stat(&lfs, "parent/child", &info) => 0;
|
# lfs_stat(&lfs, "parent/child", &info) => 0;
|
||||||
lfs_fs_size(&lfs) => 8;
|
# lfs_fs_size(&lfs) => 8;
|
||||||
// this mkdir should both create a dir and deorphan, so size
|
# // this mkdir should both create a dir and deorphan, so size
|
||||||
// should be unchanged
|
# // should be unchanged
|
||||||
lfs_mkdir(&lfs, "parent/otherchild") => 0;
|
# lfs_mkdir(&lfs, "parent/otherchild") => 0;
|
||||||
lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
|
# lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
|
||||||
lfs_stat(&lfs, "parent/child", &info) => 0;
|
# lfs_stat(&lfs, "parent/child", &info) => 0;
|
||||||
lfs_stat(&lfs, "parent/otherchild", &info) => 0;
|
# lfs_stat(&lfs, "parent/otherchild", &info) => 0;
|
||||||
lfs_fs_size(&lfs) => 8;
|
# lfs_fs_size(&lfs) => 8;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
|
# lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
|
||||||
lfs_stat(&lfs, "parent/child", &info) => 0;
|
# lfs_stat(&lfs, "parent/child", &info) => 0;
|
||||||
lfs_stat(&lfs, "parent/otherchild", &info) => 0;
|
# lfs_stat(&lfs, "parent/otherchild", &info) => 0;
|
||||||
lfs_fs_size(&lfs) => 8;
|
# lfs_fs_size(&lfs) => 8;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# reentrant testing for orphans, basically just spam mkdir/remove
|
## reentrant testing for orphans, basically just spam mkdir/remove
|
||||||
[cases.test_orphans_reentrant]
|
#[cases.test_orphans_reentrant]
|
||||||
reentrant = true
|
#reentrant = true
|
||||||
# TODO fix this case, caused by non-DAG trees
|
## TODO fix this case, caused by non-DAG trees
|
||||||
if = '!(DEPTH == 3 && CACHE_SIZE != 64)'
|
#if = '!(DEPTH == 3 && CACHE_SIZE != 64)'
|
||||||
defines = [
|
#defines = [
|
||||||
{FILES=6, DEPTH=1, CYCLES=20},
|
# {FILES=6, DEPTH=1, CYCLES=20},
|
||||||
{FILES=26, DEPTH=1, CYCLES=20},
|
# {FILES=26, DEPTH=1, CYCLES=20},
|
||||||
{FILES=3, DEPTH=3, CYCLES=20},
|
# {FILES=3, DEPTH=3, CYCLES=20},
|
||||||
]
|
#]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
int err = lfs_mount(&lfs, cfg);
|
# int err = lfs_mount(&lfs, cfg);
|
||||||
if (err) {
|
# if (err) {
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
uint32_t prng = 1;
|
# uint32_t prng = 1;
|
||||||
const char alpha[] = "abcdefghijklmnopqrstuvwxyz";
|
# const char alpha[] = "abcdefghijklmnopqrstuvwxyz";
|
||||||
for (unsigned i = 0; i < CYCLES; i++) {
|
# for (unsigned i = 0; i < CYCLES; i++) {
|
||||||
// create random path
|
# // create random path
|
||||||
char full_path[256];
|
# char full_path[256];
|
||||||
for (unsigned d = 0; d < DEPTH; d++) {
|
# for (unsigned d = 0; d < DEPTH; d++) {
|
||||||
sprintf(&full_path[2*d], "/%c", alpha[TEST_PRNG(&prng) % FILES]);
|
# sprintf(&full_path[2*d], "/%c", alpha[TEST_PRNG(&prng) % FILES]);
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
// if it does not exist, we create it, else we destroy
|
# // if it does not exist, we create it, else we destroy
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
int res = lfs_stat(&lfs, full_path, &info);
|
# int res = lfs_stat(&lfs, full_path, &info);
|
||||||
if (res == LFS_ERR_NOENT) {
|
# if (res == LFS_ERR_NOENT) {
|
||||||
// create each directory in turn, ignore if dir already exists
|
# // create each directory in turn, ignore if dir already exists
|
||||||
for (unsigned d = 0; d < DEPTH; d++) {
|
# for (unsigned d = 0; d < DEPTH; d++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
strcpy(path, full_path);
|
# strcpy(path, full_path);
|
||||||
path[2*d+2] = '\0';
|
# path[2*d+2] = '\0';
|
||||||
err = lfs_mkdir(&lfs, path);
|
# err = lfs_mkdir(&lfs, path);
|
||||||
assert(!err || err == LFS_ERR_EXIST);
|
# assert(!err || err == LFS_ERR_EXIST);
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (unsigned d = 0; d < DEPTH; d++) {
|
# for (unsigned d = 0; d < DEPTH; d++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
strcpy(path, full_path);
|
# strcpy(path, full_path);
|
||||||
path[2*d+2] = '\0';
|
# path[2*d+2] = '\0';
|
||||||
lfs_stat(&lfs, path, &info) => 0;
|
# lfs_stat(&lfs, path, &info) => 0;
|
||||||
assert(strcmp(info.name, &path[2*d+1]) == 0);
|
# assert(strcmp(info.name, &path[2*d+1]) == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
}
|
# }
|
||||||
} else {
|
# } else {
|
||||||
// is valid dir?
|
# // is valid dir?
|
||||||
assert(strcmp(info.name, &full_path[2*(DEPTH-1)+1]) == 0);
|
# assert(strcmp(info.name, &full_path[2*(DEPTH-1)+1]) == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
|
#
|
||||||
// try to delete path in reverse order, ignore if dir is not empty
|
# // try to delete path in reverse order, ignore if dir is not empty
|
||||||
for (int d = DEPTH-1; d >= 0; d--) {
|
# for (int d = DEPTH-1; d >= 0; d--) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
strcpy(path, full_path);
|
# strcpy(path, full_path);
|
||||||
path[2*d+2] = '\0';
|
# path[2*d+2] = '\0';
|
||||||
err = lfs_remove(&lfs, path);
|
# err = lfs_remove(&lfs, path);
|
||||||
assert(!err || err == LFS_ERR_NOTEMPTY);
|
# assert(!err || err == LFS_ERR_NOTEMPTY);
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_stat(&lfs, full_path, &info) => LFS_ERR_NOENT;
|
# lfs_stat(&lfs, full_path, &info) => LFS_ERR_NOENT;
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
|
|||||||
+336
-336
@@ -1,336 +1,336 @@
|
|||||||
|
#
|
||||||
# simple path test
|
## simple path test
|
||||||
[cases.test_paths_normal]
|
#[cases.test_paths_normal]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "tea") => 0;
|
# lfs_mkdir(&lfs, "tea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/hottea") => 0;
|
# lfs_mkdir(&lfs, "tea/hottea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
# lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/coldtea") => 0;
|
# lfs_mkdir(&lfs, "tea/coldtea") => 0;
|
||||||
|
#
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, "tea/hottea", &info) => 0;
|
# lfs_stat(&lfs, "tea/hottea", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
lfs_stat(&lfs, "/tea/hottea", &info) => 0;
|
# lfs_stat(&lfs, "/tea/hottea", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
|
#
|
||||||
lfs_mkdir(&lfs, "/milk") => 0;
|
# lfs_mkdir(&lfs, "/milk") => 0;
|
||||||
lfs_stat(&lfs, "/milk", &info) => 0;
|
# lfs_stat(&lfs, "/milk", &info) => 0;
|
||||||
assert(strcmp(info.name, "milk") == 0);
|
# assert(strcmp(info.name, "milk") == 0);
|
||||||
lfs_stat(&lfs, "milk", &info) => 0;
|
# lfs_stat(&lfs, "milk", &info) => 0;
|
||||||
assert(strcmp(info.name, "milk") == 0);
|
# assert(strcmp(info.name, "milk") == 0);
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# redundant slashes
|
## redundant slashes
|
||||||
[cases.test_paths_redundant_slashes]
|
#[cases.test_paths_redundant_slashes]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "tea") => 0;
|
# lfs_mkdir(&lfs, "tea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/hottea") => 0;
|
# lfs_mkdir(&lfs, "tea/hottea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
# lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/coldtea") => 0;
|
# lfs_mkdir(&lfs, "tea/coldtea") => 0;
|
||||||
|
#
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, "/tea/hottea", &info) => 0;
|
# lfs_stat(&lfs, "/tea/hottea", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
lfs_stat(&lfs, "//tea//hottea", &info) => 0;
|
# lfs_stat(&lfs, "//tea//hottea", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
lfs_stat(&lfs, "///tea///hottea", &info) => 0;
|
# lfs_stat(&lfs, "///tea///hottea", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
|
#
|
||||||
lfs_mkdir(&lfs, "////milk") => 0;
|
# lfs_mkdir(&lfs, "////milk") => 0;
|
||||||
lfs_stat(&lfs, "////milk", &info) => 0;
|
# lfs_stat(&lfs, "////milk", &info) => 0;
|
||||||
assert(strcmp(info.name, "milk") == 0);
|
# assert(strcmp(info.name, "milk") == 0);
|
||||||
lfs_stat(&lfs, "milk", &info) => 0;
|
# lfs_stat(&lfs, "milk", &info) => 0;
|
||||||
assert(strcmp(info.name, "milk") == 0);
|
# assert(strcmp(info.name, "milk") == 0);
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# dot path test
|
## dot path test
|
||||||
[cases.test_paths_dot]
|
#[cases.test_paths_dot]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "tea") => 0;
|
# lfs_mkdir(&lfs, "tea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/hottea") => 0;
|
# lfs_mkdir(&lfs, "tea/hottea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
# lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/coldtea") => 0;
|
# lfs_mkdir(&lfs, "tea/coldtea") => 0;
|
||||||
|
#
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, "./tea/hottea", &info) => 0;
|
# lfs_stat(&lfs, "./tea/hottea", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
lfs_stat(&lfs, "/./tea/hottea", &info) => 0;
|
# lfs_stat(&lfs, "/./tea/hottea", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
lfs_stat(&lfs, "/././tea/hottea", &info) => 0;
|
# lfs_stat(&lfs, "/././tea/hottea", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
lfs_stat(&lfs, "/./tea/./hottea", &info) => 0;
|
# lfs_stat(&lfs, "/./tea/./hottea", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
|
#
|
||||||
lfs_mkdir(&lfs, "/./milk") => 0;
|
# lfs_mkdir(&lfs, "/./milk") => 0;
|
||||||
lfs_stat(&lfs, "/./milk", &info) => 0;
|
# lfs_stat(&lfs, "/./milk", &info) => 0;
|
||||||
assert(strcmp(info.name, "milk") == 0);
|
# assert(strcmp(info.name, "milk") == 0);
|
||||||
lfs_stat(&lfs, "milk", &info) => 0;
|
# lfs_stat(&lfs, "milk", &info) => 0;
|
||||||
assert(strcmp(info.name, "milk") == 0);
|
# assert(strcmp(info.name, "milk") == 0);
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# dot dot path test
|
## dot dot path test
|
||||||
[cases.test_paths_dot_dot]
|
#[cases.test_paths_dot_dot]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "tea") => 0;
|
# lfs_mkdir(&lfs, "tea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/hottea") => 0;
|
# lfs_mkdir(&lfs, "tea/hottea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
# lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/coldtea") => 0;
|
# lfs_mkdir(&lfs, "tea/coldtea") => 0;
|
||||||
lfs_mkdir(&lfs, "coffee") => 0;
|
# lfs_mkdir(&lfs, "coffee") => 0;
|
||||||
lfs_mkdir(&lfs, "coffee/hotcoffee") => 0;
|
# lfs_mkdir(&lfs, "coffee/hotcoffee") => 0;
|
||||||
lfs_mkdir(&lfs, "coffee/warmcoffee") => 0;
|
# lfs_mkdir(&lfs, "coffee/warmcoffee") => 0;
|
||||||
lfs_mkdir(&lfs, "coffee/coldcoffee") => 0;
|
# lfs_mkdir(&lfs, "coffee/coldcoffee") => 0;
|
||||||
|
#
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, "coffee/../tea/hottea", &info) => 0;
|
# lfs_stat(&lfs, "coffee/../tea/hottea", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
lfs_stat(&lfs, "tea/coldtea/../hottea", &info) => 0;
|
# lfs_stat(&lfs, "tea/coldtea/../hottea", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
lfs_stat(&lfs, "coffee/coldcoffee/../../tea/hottea", &info) => 0;
|
# lfs_stat(&lfs, "coffee/coldcoffee/../../tea/hottea", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
lfs_stat(&lfs, "coffee/../coffee/../tea/hottea", &info) => 0;
|
# lfs_stat(&lfs, "coffee/../coffee/../tea/hottea", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
|
#
|
||||||
lfs_mkdir(&lfs, "coffee/../milk") => 0;
|
# lfs_mkdir(&lfs, "coffee/../milk") => 0;
|
||||||
lfs_stat(&lfs, "coffee/../milk", &info) => 0;
|
# lfs_stat(&lfs, "coffee/../milk", &info) => 0;
|
||||||
strcmp(info.name, "milk") => 0;
|
# strcmp(info.name, "milk") => 0;
|
||||||
lfs_stat(&lfs, "milk", &info) => 0;
|
# lfs_stat(&lfs, "milk", &info) => 0;
|
||||||
strcmp(info.name, "milk") => 0;
|
# strcmp(info.name, "milk") => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# trailing dot path test
|
## trailing dot path test
|
||||||
[cases.test_paths_trailing_dot]
|
#[cases.test_paths_trailing_dot]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "tea") => 0;
|
# lfs_mkdir(&lfs, "tea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/hottea") => 0;
|
# lfs_mkdir(&lfs, "tea/hottea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
# lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/coldtea") => 0;
|
# lfs_mkdir(&lfs, "tea/coldtea") => 0;
|
||||||
|
#
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, "tea/hottea/", &info) => 0;
|
# lfs_stat(&lfs, "tea/hottea/", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
lfs_stat(&lfs, "tea/hottea/.", &info) => 0;
|
# lfs_stat(&lfs, "tea/hottea/.", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
lfs_stat(&lfs, "tea/hottea/./.", &info) => 0;
|
# lfs_stat(&lfs, "tea/hottea/./.", &info) => 0;
|
||||||
assert(strcmp(info.name, "hottea") == 0);
|
# assert(strcmp(info.name, "hottea") == 0);
|
||||||
lfs_stat(&lfs, "tea/hottea/..", &info) => 0;
|
# lfs_stat(&lfs, "tea/hottea/..", &info) => 0;
|
||||||
assert(strcmp(info.name, "tea") == 0);
|
# assert(strcmp(info.name, "tea") == 0);
|
||||||
lfs_stat(&lfs, "tea/hottea/../.", &info) => 0;
|
# lfs_stat(&lfs, "tea/hottea/../.", &info) => 0;
|
||||||
assert(strcmp(info.name, "tea") == 0);
|
# assert(strcmp(info.name, "tea") == 0);
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# leading dot path test
|
## leading dot path test
|
||||||
[cases.test_paths_leading_dot]
|
#[cases.test_paths_leading_dot]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, ".milk") => 0;
|
# lfs_mkdir(&lfs, ".milk") => 0;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, ".milk", &info) => 0;
|
# lfs_stat(&lfs, ".milk", &info) => 0;
|
||||||
strcmp(info.name, ".milk") => 0;
|
# strcmp(info.name, ".milk") => 0;
|
||||||
lfs_stat(&lfs, "tea/.././.milk", &info) => 0;
|
# lfs_stat(&lfs, "tea/.././.milk", &info) => 0;
|
||||||
strcmp(info.name, ".milk") => 0;
|
# strcmp(info.name, ".milk") => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# root dot dot path test
|
## root dot dot path test
|
||||||
[cases.test_paths_root_dot_dot]
|
#[cases.test_paths_root_dot_dot]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "tea") => 0;
|
# lfs_mkdir(&lfs, "tea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/hottea") => 0;
|
# lfs_mkdir(&lfs, "tea/hottea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
# lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
||||||
lfs_mkdir(&lfs, "tea/coldtea") => 0;
|
# lfs_mkdir(&lfs, "tea/coldtea") => 0;
|
||||||
lfs_mkdir(&lfs, "coffee") => 0;
|
# lfs_mkdir(&lfs, "coffee") => 0;
|
||||||
lfs_mkdir(&lfs, "coffee/hotcoffee") => 0;
|
# lfs_mkdir(&lfs, "coffee/hotcoffee") => 0;
|
||||||
lfs_mkdir(&lfs, "coffee/warmcoffee") => 0;
|
# lfs_mkdir(&lfs, "coffee/warmcoffee") => 0;
|
||||||
lfs_mkdir(&lfs, "coffee/coldcoffee") => 0;
|
# lfs_mkdir(&lfs, "coffee/coldcoffee") => 0;
|
||||||
|
#
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, "coffee/../../../../../../tea/hottea", &info) => 0;
|
# lfs_stat(&lfs, "coffee/../../../../../../tea/hottea", &info) => 0;
|
||||||
strcmp(info.name, "hottea") => 0;
|
# strcmp(info.name, "hottea") => 0;
|
||||||
|
#
|
||||||
lfs_mkdir(&lfs, "coffee/../../../../../../milk") => 0;
|
# lfs_mkdir(&lfs, "coffee/../../../../../../milk") => 0;
|
||||||
lfs_stat(&lfs, "coffee/../../../../../../milk", &info) => 0;
|
# lfs_stat(&lfs, "coffee/../../../../../../milk", &info) => 0;
|
||||||
strcmp(info.name, "milk") => 0;
|
# strcmp(info.name, "milk") => 0;
|
||||||
lfs_stat(&lfs, "milk", &info) => 0;
|
# lfs_stat(&lfs, "milk", &info) => 0;
|
||||||
strcmp(info.name, "milk") => 0;
|
# strcmp(info.name, "milk") => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# invalid path tests
|
## invalid path tests
|
||||||
[cases.test_paths_invalid]
|
#[cases.test_paths_invalid]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg);
|
# lfs_format(&lfs, cfg);
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, "dirt", &info) => LFS_ERR_NOENT;
|
# lfs_stat(&lfs, "dirt", &info) => LFS_ERR_NOENT;
|
||||||
lfs_stat(&lfs, "dirt/ground", &info) => LFS_ERR_NOENT;
|
# lfs_stat(&lfs, "dirt/ground", &info) => LFS_ERR_NOENT;
|
||||||
lfs_stat(&lfs, "dirt/ground/earth", &info) => LFS_ERR_NOENT;
|
# lfs_stat(&lfs, "dirt/ground/earth", &info) => LFS_ERR_NOENT;
|
||||||
|
#
|
||||||
lfs_remove(&lfs, "dirt") => LFS_ERR_NOENT;
|
# lfs_remove(&lfs, "dirt") => LFS_ERR_NOENT;
|
||||||
lfs_remove(&lfs, "dirt/ground") => LFS_ERR_NOENT;
|
# lfs_remove(&lfs, "dirt/ground") => LFS_ERR_NOENT;
|
||||||
lfs_remove(&lfs, "dirt/ground/earth") => LFS_ERR_NOENT;
|
# lfs_remove(&lfs, "dirt/ground/earth") => LFS_ERR_NOENT;
|
||||||
|
#
|
||||||
lfs_mkdir(&lfs, "dirt/ground") => LFS_ERR_NOENT;
|
# lfs_mkdir(&lfs, "dirt/ground") => LFS_ERR_NOENT;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "dirt/ground", LFS_O_WRONLY | LFS_O_CREAT)
|
# lfs_file_open(&lfs, &file, "dirt/ground", LFS_O_WRONLY | LFS_O_CREAT)
|
||||||
=> LFS_ERR_NOENT;
|
# => LFS_ERR_NOENT;
|
||||||
lfs_mkdir(&lfs, "dirt/ground/earth") => LFS_ERR_NOENT;
|
# lfs_mkdir(&lfs, "dirt/ground/earth") => LFS_ERR_NOENT;
|
||||||
lfs_file_open(&lfs, &file, "dirt/ground/earth", LFS_O_WRONLY | LFS_O_CREAT)
|
# lfs_file_open(&lfs, &file, "dirt/ground/earth", LFS_O_WRONLY | LFS_O_CREAT)
|
||||||
=> LFS_ERR_NOENT;
|
# => LFS_ERR_NOENT;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# root operations
|
## root operations
|
||||||
[cases.test_paths_root]
|
#[cases.test_paths_root]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, "/", &info) => 0;
|
# lfs_stat(&lfs, "/", &info) => 0;
|
||||||
assert(strcmp(info.name, "/") == 0);
|
# assert(strcmp(info.name, "/") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
|
#
|
||||||
lfs_mkdir(&lfs, "/") => LFS_ERR_EXIST;
|
# lfs_mkdir(&lfs, "/") => LFS_ERR_EXIST;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "/", LFS_O_WRONLY | LFS_O_CREAT)
|
# lfs_file_open(&lfs, &file, "/", LFS_O_WRONLY | LFS_O_CREAT)
|
||||||
=> LFS_ERR_ISDIR;
|
# => LFS_ERR_ISDIR;
|
||||||
|
#
|
||||||
lfs_remove(&lfs, "/") => LFS_ERR_INVAL;
|
# lfs_remove(&lfs, "/") => LFS_ERR_INVAL;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# root representations
|
## root representations
|
||||||
[cases.test_paths_root_reprs]
|
#[cases.test_paths_root_reprs]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, "/", &info) => 0;
|
# lfs_stat(&lfs, "/", &info) => 0;
|
||||||
assert(strcmp(info.name, "/") == 0);
|
# assert(strcmp(info.name, "/") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
lfs_stat(&lfs, "", &info) => 0;
|
# lfs_stat(&lfs, "", &info) => 0;
|
||||||
assert(strcmp(info.name, "/") == 0);
|
# assert(strcmp(info.name, "/") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
lfs_stat(&lfs, ".", &info) => 0;
|
# lfs_stat(&lfs, ".", &info) => 0;
|
||||||
assert(strcmp(info.name, "/") == 0);
|
# assert(strcmp(info.name, "/") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
lfs_stat(&lfs, "..", &info) => 0;
|
# lfs_stat(&lfs, "..", &info) => 0;
|
||||||
assert(strcmp(info.name, "/") == 0);
|
# assert(strcmp(info.name, "/") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
lfs_stat(&lfs, "//", &info) => 0;
|
# lfs_stat(&lfs, "//", &info) => 0;
|
||||||
assert(strcmp(info.name, "/") == 0);
|
# assert(strcmp(info.name, "/") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
lfs_stat(&lfs, "./", &info) => 0;
|
# lfs_stat(&lfs, "./", &info) => 0;
|
||||||
assert(strcmp(info.name, "/") == 0);
|
# assert(strcmp(info.name, "/") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# superblock conflict test
|
## superblock conflict test
|
||||||
[cases.test_paths_superblock_conflict]
|
#[cases.test_paths_superblock_conflict]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT;
|
# lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT;
|
||||||
lfs_remove(&lfs, "littlefs") => LFS_ERR_NOENT;
|
# lfs_remove(&lfs, "littlefs") => LFS_ERR_NOENT;
|
||||||
|
#
|
||||||
lfs_mkdir(&lfs, "littlefs") => 0;
|
# lfs_mkdir(&lfs, "littlefs") => 0;
|
||||||
lfs_stat(&lfs, "littlefs", &info) => 0;
|
# lfs_stat(&lfs, "littlefs", &info) => 0;
|
||||||
assert(strcmp(info.name, "littlefs") == 0);
|
# assert(strcmp(info.name, "littlefs") == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
lfs_remove(&lfs, "littlefs") => 0;
|
# lfs_remove(&lfs, "littlefs") => 0;
|
||||||
lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT;
|
# lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# max path test
|
## max path test
|
||||||
[cases.test_paths_max]
|
#[cases.test_paths_max]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "coffee") => 0;
|
# lfs_mkdir(&lfs, "coffee") => 0;
|
||||||
lfs_mkdir(&lfs, "coffee/hotcoffee") => 0;
|
# lfs_mkdir(&lfs, "coffee/hotcoffee") => 0;
|
||||||
lfs_mkdir(&lfs, "coffee/warmcoffee") => 0;
|
# lfs_mkdir(&lfs, "coffee/warmcoffee") => 0;
|
||||||
lfs_mkdir(&lfs, "coffee/coldcoffee") => 0;
|
# lfs_mkdir(&lfs, "coffee/coldcoffee") => 0;
|
||||||
|
#
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
memset(path, 'w', LFS_NAME_MAX+1);
|
# memset(path, 'w', LFS_NAME_MAX+1);
|
||||||
path[LFS_NAME_MAX+1] = '\0';
|
# path[LFS_NAME_MAX+1] = '\0';
|
||||||
lfs_mkdir(&lfs, path) => LFS_ERR_NAMETOOLONG;
|
# lfs_mkdir(&lfs, path) => LFS_ERR_NAMETOOLONG;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, path, LFS_O_WRONLY | LFS_O_CREAT)
|
# lfs_file_open(&lfs, &file, path, LFS_O_WRONLY | LFS_O_CREAT)
|
||||||
=> LFS_ERR_NAMETOOLONG;
|
# => LFS_ERR_NAMETOOLONG;
|
||||||
|
#
|
||||||
memcpy(path, "coffee/", strlen("coffee/"));
|
# memcpy(path, "coffee/", strlen("coffee/"));
|
||||||
memset(path+strlen("coffee/"), 'w', LFS_NAME_MAX+1);
|
# memset(path+strlen("coffee/"), 'w', LFS_NAME_MAX+1);
|
||||||
path[strlen("coffee/")+LFS_NAME_MAX+1] = '\0';
|
# path[strlen("coffee/")+LFS_NAME_MAX+1] = '\0';
|
||||||
lfs_mkdir(&lfs, path) => LFS_ERR_NAMETOOLONG;
|
# lfs_mkdir(&lfs, path) => LFS_ERR_NAMETOOLONG;
|
||||||
lfs_file_open(&lfs, &file, path, LFS_O_WRONLY | LFS_O_CREAT)
|
# lfs_file_open(&lfs, &file, path, LFS_O_WRONLY | LFS_O_CREAT)
|
||||||
=> LFS_ERR_NAMETOOLONG;
|
# => LFS_ERR_NAMETOOLONG;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# really big path test
|
## really big path test
|
||||||
[cases.test_paths_really_big]
|
#[cases.test_paths_really_big]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "coffee") => 0;
|
# lfs_mkdir(&lfs, "coffee") => 0;
|
||||||
lfs_mkdir(&lfs, "coffee/hotcoffee") => 0;
|
# lfs_mkdir(&lfs, "coffee/hotcoffee") => 0;
|
||||||
lfs_mkdir(&lfs, "coffee/warmcoffee") => 0;
|
# lfs_mkdir(&lfs, "coffee/warmcoffee") => 0;
|
||||||
lfs_mkdir(&lfs, "coffee/coldcoffee") => 0;
|
# lfs_mkdir(&lfs, "coffee/coldcoffee") => 0;
|
||||||
|
#
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
memset(path, 'w', LFS_NAME_MAX);
|
# memset(path, 'w', LFS_NAME_MAX);
|
||||||
path[LFS_NAME_MAX] = '\0';
|
# path[LFS_NAME_MAX] = '\0';
|
||||||
lfs_mkdir(&lfs, path) => 0;
|
# lfs_mkdir(&lfs, path) => 0;
|
||||||
lfs_remove(&lfs, path) => 0;
|
# lfs_remove(&lfs, path) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, path,
|
# lfs_file_open(&lfs, &file, path,
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_remove(&lfs, path) => 0;
|
# lfs_remove(&lfs, path) => 0;
|
||||||
|
#
|
||||||
memcpy(path, "coffee/", strlen("coffee/"));
|
# memcpy(path, "coffee/", strlen("coffee/"));
|
||||||
memset(path+strlen("coffee/"), 'w', LFS_NAME_MAX);
|
# memset(path+strlen("coffee/"), 'w', LFS_NAME_MAX);
|
||||||
path[strlen("coffee/")+LFS_NAME_MAX] = '\0';
|
# path[strlen("coffee/")+LFS_NAME_MAX] = '\0';
|
||||||
lfs_mkdir(&lfs, path) => 0;
|
# lfs_mkdir(&lfs, path) => 0;
|
||||||
lfs_remove(&lfs, path) => 0;
|
# lfs_remove(&lfs, path) => 0;
|
||||||
lfs_file_open(&lfs, &file, path,
|
# lfs_file_open(&lfs, &file, path,
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_remove(&lfs, path) => 0;
|
# lfs_remove(&lfs, path) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
|
|||||||
+182
-182
@@ -1,182 +1,182 @@
|
|||||||
# There are already a number of tests that test general operations under
|
## There are already a number of tests that test general operations under
|
||||||
# power-loss (see the reentrant attribute). These tests are for explicitly
|
## power-loss (see the reentrant attribute). These tests are for explicitly
|
||||||
# testing specific corner cases.
|
## testing specific corner cases.
|
||||||
|
#
|
||||||
# only a revision count
|
## only a revision count
|
||||||
[cases.test_powerloss_only_rev]
|
#[cases.test_powerloss_only_rev]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "notebook") => 0;
|
# lfs_mkdir(&lfs, "notebook") => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "notebook/paper",
|
# lfs_file_open(&lfs, &file, "notebook/paper",
|
||||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
||||||
char buffer[256];
|
# char buffer[256];
|
||||||
strcpy(buffer, "hello");
|
# strcpy(buffer, "hello");
|
||||||
lfs_size_t size = strlen("hello");
|
# lfs_size_t size = strlen("hello");
|
||||||
for (int i = 0; i < 5; i++) {
|
# for (int i = 0; i < 5; i++) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
lfs_file_sync(&lfs, &file) => 0;
|
# lfs_file_sync(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
char rbuffer[256];
|
# char rbuffer[256];
|
||||||
lfs_file_open(&lfs, &file, "notebook/paper", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "notebook/paper", LFS_O_RDONLY) => 0;
|
||||||
for (int i = 0; i < 5; i++) {
|
# for (int i = 0; i < 5; i++) {
|
||||||
lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
# lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
||||||
assert(memcmp(rbuffer, buffer, size) == 0);
|
# assert(memcmp(rbuffer, buffer, size) == 0);
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
// get pair/rev count
|
# // get pair/rev count
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_dir_t dir;
|
# lfs_dir_t dir;
|
||||||
lfs_dir_open(&lfs, &dir, "notebook") => 0;
|
# lfs_dir_open(&lfs, &dir, "notebook") => 0;
|
||||||
lfs_block_t pair[2] = {dir.m.pair[0], dir.m.pair[1]};
|
# lfs_block_t pair[2] = {dir.m.pair[0], dir.m.pair[1]};
|
||||||
uint32_t rev = dir.m.rev;
|
# uint32_t rev = dir.m.rev;
|
||||||
lfs_dir_close(&lfs, &dir) => 0;
|
# lfs_dir_close(&lfs, &dir) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
// write just the revision count
|
# // write just the revision count
|
||||||
uint8_t bbuffer[BLOCK_SIZE];
|
# uint8_t bbuffer[BLOCK_SIZE];
|
||||||
cfg->read(cfg, pair[1], 0, bbuffer, BLOCK_SIZE) => 0;
|
# cfg->read(cfg, pair[1], 0, bbuffer, BLOCK_SIZE) => 0;
|
||||||
|
#
|
||||||
memcpy(bbuffer, &(uint32_t){lfs_tole32(rev+1)}, sizeof(uint32_t));
|
# memcpy(bbuffer, &(uint32_t){lfs_tole32(rev+1)}, sizeof(uint32_t));
|
||||||
|
#
|
||||||
cfg->erase(cfg, pair[1]) => 0;
|
# cfg->erase(cfg, pair[1]) => 0;
|
||||||
cfg->prog(cfg, pair[1], 0, bbuffer, BLOCK_SIZE) => 0;
|
# cfg->prog(cfg, pair[1], 0, bbuffer, BLOCK_SIZE) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
|
#
|
||||||
// can read?
|
# // can read?
|
||||||
lfs_file_open(&lfs, &file, "notebook/paper", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "notebook/paper", LFS_O_RDONLY) => 0;
|
||||||
for (int i = 0; i < 5; i++) {
|
# for (int i = 0; i < 5; i++) {
|
||||||
lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
# lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
||||||
assert(memcmp(rbuffer, buffer, size) == 0);
|
# assert(memcmp(rbuffer, buffer, size) == 0);
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
// can write?
|
# // can write?
|
||||||
lfs_file_open(&lfs, &file, "notebook/paper",
|
# lfs_file_open(&lfs, &file, "notebook/paper",
|
||||||
LFS_O_WRONLY | LFS_O_APPEND) => 0;
|
# LFS_O_WRONLY | LFS_O_APPEND) => 0;
|
||||||
strcpy(buffer, "goodbye");
|
# strcpy(buffer, "goodbye");
|
||||||
size = strlen("goodbye");
|
# size = strlen("goodbye");
|
||||||
for (int i = 0; i < 5; i++) {
|
# for (int i = 0; i < 5; i++) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
lfs_file_sync(&lfs, &file) => 0;
|
# lfs_file_sync(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
lfs_file_open(&lfs, &file, "notebook/paper", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "notebook/paper", LFS_O_RDONLY) => 0;
|
||||||
strcpy(buffer, "hello");
|
# strcpy(buffer, "hello");
|
||||||
size = strlen("hello");
|
# size = strlen("hello");
|
||||||
for (int i = 0; i < 5; i++) {
|
# for (int i = 0; i < 5; i++) {
|
||||||
lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
# lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
||||||
assert(memcmp(rbuffer, buffer, size) == 0);
|
# assert(memcmp(rbuffer, buffer, size) == 0);
|
||||||
}
|
# }
|
||||||
strcpy(buffer, "goodbye");
|
# strcpy(buffer, "goodbye");
|
||||||
size = strlen("goodbye");
|
# size = strlen("goodbye");
|
||||||
for (int i = 0; i < 5; i++) {
|
# for (int i = 0; i < 5; i++) {
|
||||||
lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
# lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
||||||
assert(memcmp(rbuffer, buffer, size) == 0);
|
# assert(memcmp(rbuffer, buffer, size) == 0);
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# partial prog, may not be byte in order!
|
## partial prog, may not be byte in order!
|
||||||
[cases.test_powerloss_partial_prog]
|
#[cases.test_powerloss_partial_prog]
|
||||||
if = "PROG_SIZE < BLOCK_SIZE"
|
#if = "PROG_SIZE < BLOCK_SIZE"
|
||||||
defines.BYTE_OFF = ["0", "PROG_SIZE-1", "PROG_SIZE/2"]
|
#defines.BYTE_OFF = ["0", "PROG_SIZE-1", "PROG_SIZE/2"]
|
||||||
defines.BYTE_VALUE = [0x33, 0xcc]
|
#defines.BYTE_VALUE = [0x33, 0xcc]
|
||||||
in = "lfs.c"
|
#in = "lfs.c"
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_mkdir(&lfs, "notebook") => 0;
|
# lfs_mkdir(&lfs, "notebook") => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "notebook/paper",
|
# lfs_file_open(&lfs, &file, "notebook/paper",
|
||||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
||||||
char buffer[256];
|
# char buffer[256];
|
||||||
strcpy(buffer, "hello");
|
# strcpy(buffer, "hello");
|
||||||
lfs_size_t size = strlen("hello");
|
# lfs_size_t size = strlen("hello");
|
||||||
for (int i = 0; i < 5; i++) {
|
# for (int i = 0; i < 5; i++) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
lfs_file_sync(&lfs, &file) => 0;
|
# lfs_file_sync(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
char rbuffer[256];
|
# char rbuffer[256];
|
||||||
lfs_file_open(&lfs, &file, "notebook/paper", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "notebook/paper", LFS_O_RDONLY) => 0;
|
||||||
for (int i = 0; i < 5; i++) {
|
# for (int i = 0; i < 5; i++) {
|
||||||
lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
# lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
||||||
assert(memcmp(rbuffer, buffer, size) == 0);
|
# assert(memcmp(rbuffer, buffer, size) == 0);
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
// imitate a partial prog, value should not matter, if littlefs
|
# // imitate a partial prog, value should not matter, if littlefs
|
||||||
// doesn't notice the partial prog testbd will assert
|
# // doesn't notice the partial prog testbd will assert
|
||||||
|
#
|
||||||
// get offset to next prog
|
# // get offset to next prog
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_dir_t dir;
|
# lfs_dir_t dir;
|
||||||
lfs_dir_open(&lfs, &dir, "notebook") => 0;
|
# lfs_dir_open(&lfs, &dir, "notebook") => 0;
|
||||||
lfs_block_t block = dir.m.pair[0];
|
# lfs_block_t block = dir.m.pair[0];
|
||||||
lfs_off_t off = dir.m.off;
|
# lfs_off_t off = dir.m.off;
|
||||||
lfs_dir_close(&lfs, &dir) => 0;
|
# lfs_dir_close(&lfs, &dir) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
// tweak byte
|
# // tweak byte
|
||||||
uint8_t bbuffer[BLOCK_SIZE];
|
# uint8_t bbuffer[BLOCK_SIZE];
|
||||||
cfg->read(cfg, block, 0, bbuffer, BLOCK_SIZE) => 0;
|
# cfg->read(cfg, block, 0, bbuffer, BLOCK_SIZE) => 0;
|
||||||
|
#
|
||||||
bbuffer[off + BYTE_OFF] = BYTE_VALUE;
|
# bbuffer[off + BYTE_OFF] = BYTE_VALUE;
|
||||||
|
#
|
||||||
cfg->erase(cfg, block) => 0;
|
# cfg->erase(cfg, block) => 0;
|
||||||
cfg->prog(cfg, block, 0, bbuffer, BLOCK_SIZE) => 0;
|
# cfg->prog(cfg, block, 0, bbuffer, BLOCK_SIZE) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
|
#
|
||||||
// can read?
|
# // can read?
|
||||||
lfs_file_open(&lfs, &file, "notebook/paper", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "notebook/paper", LFS_O_RDONLY) => 0;
|
||||||
for (int i = 0; i < 5; i++) {
|
# for (int i = 0; i < 5; i++) {
|
||||||
lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
# lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
||||||
assert(memcmp(rbuffer, buffer, size) == 0);
|
# assert(memcmp(rbuffer, buffer, size) == 0);
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
// can write?
|
# // can write?
|
||||||
lfs_file_open(&lfs, &file, "notebook/paper",
|
# lfs_file_open(&lfs, &file, "notebook/paper",
|
||||||
LFS_O_WRONLY | LFS_O_APPEND) => 0;
|
# LFS_O_WRONLY | LFS_O_APPEND) => 0;
|
||||||
strcpy(buffer, "goodbye");
|
# strcpy(buffer, "goodbye");
|
||||||
size = strlen("goodbye");
|
# size = strlen("goodbye");
|
||||||
for (int i = 0; i < 5; i++) {
|
# for (int i = 0; i < 5; i++) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
lfs_file_sync(&lfs, &file) => 0;
|
# lfs_file_sync(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
lfs_file_open(&lfs, &file, "notebook/paper", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "notebook/paper", LFS_O_RDONLY) => 0;
|
||||||
strcpy(buffer, "hello");
|
# strcpy(buffer, "hello");
|
||||||
size = strlen("hello");
|
# size = strlen("hello");
|
||||||
for (int i = 0; i < 5; i++) {
|
# for (int i = 0; i < 5; i++) {
|
||||||
lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
# lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
||||||
assert(memcmp(rbuffer, buffer, size) == 0);
|
# assert(memcmp(rbuffer, buffer, size) == 0);
|
||||||
}
|
# }
|
||||||
strcpy(buffer, "goodbye");
|
# strcpy(buffer, "goodbye");
|
||||||
size = strlen("goodbye");
|
# size = strlen("goodbye");
|
||||||
for (int i = 0; i < 5; i++) {
|
# for (int i = 0; i < 5; i++) {
|
||||||
lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
# lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
||||||
assert(memcmp(rbuffer, buffer, size) == 0);
|
# assert(memcmp(rbuffer, buffer, size) == 0);
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
|||||||
+343
-343
@@ -1,343 +1,343 @@
|
|||||||
# specific corner cases worth explicitly testing for
|
## specific corner cases worth explicitly testing for
|
||||||
[cases.test_relocations_dangling_split_dir]
|
#[cases.test_relocations_dangling_split_dir]
|
||||||
defines.ITERATIONS = 20
|
#defines.ITERATIONS = 20
|
||||||
defines.COUNT = 10
|
#defines.COUNT = 10
|
||||||
defines.BLOCK_CYCLES = [8, 1]
|
#defines.BLOCK_CYCLES = [8, 1]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
// fill up filesystem so only ~16 blocks are left
|
# // fill up filesystem so only ~16 blocks are left
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "padding", LFS_O_CREAT | LFS_O_WRONLY) => 0;
|
# lfs_file_open(&lfs, &file, "padding", LFS_O_CREAT | LFS_O_WRONLY) => 0;
|
||||||
uint8_t buffer[512];
|
# uint8_t buffer[512];
|
||||||
memset(buffer, 0, 512);
|
# memset(buffer, 0, 512);
|
||||||
while (BLOCK_COUNT - lfs_fs_size(&lfs) > 16) {
|
# while (BLOCK_COUNT - lfs_fs_size(&lfs) > 16) {
|
||||||
lfs_file_write(&lfs, &file, buffer, 512) => 512;
|
# lfs_file_write(&lfs, &file, buffer, 512) => 512;
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
// make a child dir to use in bounded space
|
# // make a child dir to use in bounded space
|
||||||
lfs_mkdir(&lfs, "child") => 0;
|
# lfs_mkdir(&lfs, "child") => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
for (unsigned j = 0; j < ITERATIONS; j++) {
|
# for (unsigned j = 0; j < ITERATIONS; j++) {
|
||||||
for (unsigned i = 0; i < COUNT; i++) {
|
# for (unsigned i = 0; i < COUNT; i++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
# sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
||||||
lfs_file_open(&lfs, &file, path, LFS_O_CREAT | LFS_O_WRONLY) => 0;
|
# lfs_file_open(&lfs, &file, path, LFS_O_CREAT | LFS_O_WRONLY) => 0;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_dir_t dir;
|
# lfs_dir_t dir;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_dir_open(&lfs, &dir, "child") => 0;
|
# lfs_dir_open(&lfs, &dir, "child") => 0;
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
for (unsigned i = 0; i < COUNT; i++) {
|
# for (unsigned i = 0; i < COUNT; i++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "test%03d_loooooooooooooooooong_name", i);
|
# sprintf(path, "test%03d_loooooooooooooooooong_name", i);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
strcmp(info.name, path) => 0;
|
# strcmp(info.name, path) => 0;
|
||||||
}
|
# }
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 0;
|
# lfs_dir_read(&lfs, &dir, &info) => 0;
|
||||||
lfs_dir_close(&lfs, &dir) => 0;
|
# lfs_dir_close(&lfs, &dir) => 0;
|
||||||
|
#
|
||||||
if (j == (unsigned)ITERATIONS-1) {
|
# if (j == (unsigned)ITERATIONS-1) {
|
||||||
break;
|
# break;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (unsigned i = 0; i < COUNT; i++) {
|
# for (unsigned i = 0; i < COUNT; i++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
# sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
||||||
lfs_remove(&lfs, path) => 0;
|
# lfs_remove(&lfs, path) => 0;
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_dir_t dir;
|
# lfs_dir_t dir;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_dir_open(&lfs, &dir, "child") => 0;
|
# lfs_dir_open(&lfs, &dir, "child") => 0;
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
for (unsigned i = 0; i < COUNT; i++) {
|
# for (unsigned i = 0; i < COUNT; i++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "test%03d_loooooooooooooooooong_name", i);
|
# sprintf(path, "test%03d_loooooooooooooooooong_name", i);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
strcmp(info.name, path) => 0;
|
# strcmp(info.name, path) => 0;
|
||||||
}
|
# }
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 0;
|
# lfs_dir_read(&lfs, &dir, &info) => 0;
|
||||||
lfs_dir_close(&lfs, &dir) => 0;
|
# lfs_dir_close(&lfs, &dir) => 0;
|
||||||
for (unsigned i = 0; i < COUNT; i++) {
|
# for (unsigned i = 0; i < COUNT; i++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
# sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
||||||
lfs_remove(&lfs, path) => 0;
|
# lfs_remove(&lfs, path) => 0;
|
||||||
}
|
# }
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
[cases.test_relocations_outdated_head]
|
#[cases.test_relocations_outdated_head]
|
||||||
defines.ITERATIONS = 20
|
#defines.ITERATIONS = 20
|
||||||
defines.COUNT = 10
|
#defines.COUNT = 10
|
||||||
defines.BLOCK_CYCLES = [8, 1]
|
#defines.BLOCK_CYCLES = [8, 1]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
// fill up filesystem so only ~16 blocks are left
|
# // fill up filesystem so only ~16 blocks are left
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "padding", LFS_O_CREAT | LFS_O_WRONLY) => 0;
|
# lfs_file_open(&lfs, &file, "padding", LFS_O_CREAT | LFS_O_WRONLY) => 0;
|
||||||
uint8_t buffer[512];
|
# uint8_t buffer[512];
|
||||||
memset(buffer, 0, 512);
|
# memset(buffer, 0, 512);
|
||||||
while (BLOCK_COUNT - lfs_fs_size(&lfs) > 16) {
|
# while (BLOCK_COUNT - lfs_fs_size(&lfs) > 16) {
|
||||||
lfs_file_write(&lfs, &file, buffer, 512) => 512;
|
# lfs_file_write(&lfs, &file, buffer, 512) => 512;
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
// make a child dir to use in bounded space
|
# // make a child dir to use in bounded space
|
||||||
lfs_mkdir(&lfs, "child") => 0;
|
# lfs_mkdir(&lfs, "child") => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
for (unsigned j = 0; j < ITERATIONS; j++) {
|
# for (unsigned j = 0; j < ITERATIONS; j++) {
|
||||||
for (unsigned i = 0; i < COUNT; i++) {
|
# for (unsigned i = 0; i < COUNT; i++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
# sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
||||||
lfs_file_open(&lfs, &file, path, LFS_O_CREAT | LFS_O_WRONLY) => 0;
|
# lfs_file_open(&lfs, &file, path, LFS_O_CREAT | LFS_O_WRONLY) => 0;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_dir_t dir;
|
# lfs_dir_t dir;
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
lfs_dir_open(&lfs, &dir, "child") => 0;
|
# lfs_dir_open(&lfs, &dir, "child") => 0;
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
for (unsigned i = 0; i < COUNT; i++) {
|
# for (unsigned i = 0; i < COUNT; i++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "test%03d_loooooooooooooooooong_name", i);
|
# sprintf(path, "test%03d_loooooooooooooooooong_name", i);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
strcmp(info.name, path) => 0;
|
# strcmp(info.name, path) => 0;
|
||||||
info.size => 0;
|
# info.size => 0;
|
||||||
|
#
|
||||||
sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
# sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
||||||
lfs_file_open(&lfs, &file, path, LFS_O_WRONLY) => 0;
|
# lfs_file_open(&lfs, &file, path, LFS_O_WRONLY) => 0;
|
||||||
lfs_file_write(&lfs, &file, "hi", 2) => 2;
|
# lfs_file_write(&lfs, &file, "hi", 2) => 2;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 0;
|
# lfs_dir_read(&lfs, &dir, &info) => 0;
|
||||||
|
#
|
||||||
lfs_dir_rewind(&lfs, &dir) => 0;
|
# lfs_dir_rewind(&lfs, &dir) => 0;
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
for (unsigned i = 0; i < COUNT; i++) {
|
# for (unsigned i = 0; i < COUNT; i++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "test%03d_loooooooooooooooooong_name", i);
|
# sprintf(path, "test%03d_loooooooooooooooooong_name", i);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
strcmp(info.name, path) => 0;
|
# strcmp(info.name, path) => 0;
|
||||||
info.size => 2;
|
# info.size => 2;
|
||||||
|
#
|
||||||
sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
# sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
||||||
lfs_file_open(&lfs, &file, path, LFS_O_WRONLY) => 0;
|
# lfs_file_open(&lfs, &file, path, LFS_O_WRONLY) => 0;
|
||||||
lfs_file_write(&lfs, &file, "hi", 2) => 2;
|
# lfs_file_write(&lfs, &file, "hi", 2) => 2;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 0;
|
# lfs_dir_read(&lfs, &dir, &info) => 0;
|
||||||
|
#
|
||||||
lfs_dir_rewind(&lfs, &dir) => 0;
|
# lfs_dir_rewind(&lfs, &dir) => 0;
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
for (unsigned i = 0; i < COUNT; i++) {
|
# for (unsigned i = 0; i < COUNT; i++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "test%03d_loooooooooooooooooong_name", i);
|
# sprintf(path, "test%03d_loooooooooooooooooong_name", i);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
# lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
strcmp(info.name, path) => 0;
|
# strcmp(info.name, path) => 0;
|
||||||
info.size => 2;
|
# info.size => 2;
|
||||||
}
|
# }
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 0;
|
# lfs_dir_read(&lfs, &dir, &info) => 0;
|
||||||
lfs_dir_close(&lfs, &dir) => 0;
|
# lfs_dir_close(&lfs, &dir) => 0;
|
||||||
|
#
|
||||||
for (unsigned i = 0; i < COUNT; i++) {
|
# for (unsigned i = 0; i < COUNT; i++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
# sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
||||||
lfs_remove(&lfs, path) => 0;
|
# lfs_remove(&lfs, path) => 0;
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# reentrant testing for relocations, this is the same as the
|
## reentrant testing for relocations, this is the same as the
|
||||||
# orphan testing, except here we also set block_cycles so that
|
## orphan testing, except here we also set block_cycles so that
|
||||||
# almost every tree operation needs a relocation
|
## almost every tree operation needs a relocation
|
||||||
[cases.test_relocations_reentrant]
|
#[cases.test_relocations_reentrant]
|
||||||
reentrant = true
|
#reentrant = true
|
||||||
# TODO fix this case, caused by non-DAG trees
|
## TODO fix this case, caused by non-DAG trees
|
||||||
# NOTE the second condition is required
|
## NOTE the second condition is required
|
||||||
if = '!(DEPTH == 3 && CACHE_SIZE != 64) && 2*FILES < BLOCK_COUNT'
|
#if = '!(DEPTH == 3 && CACHE_SIZE != 64) && 2*FILES < BLOCK_COUNT'
|
||||||
defines = [
|
#defines = [
|
||||||
{FILES=6, DEPTH=1, CYCLES=20, BLOCK_CYCLES=1},
|
# {FILES=6, DEPTH=1, CYCLES=20, BLOCK_CYCLES=1},
|
||||||
{FILES=26, DEPTH=1, CYCLES=20, BLOCK_CYCLES=1},
|
# {FILES=26, DEPTH=1, CYCLES=20, BLOCK_CYCLES=1},
|
||||||
{FILES=3, DEPTH=3, CYCLES=20, BLOCK_CYCLES=1},
|
# {FILES=3, DEPTH=3, CYCLES=20, BLOCK_CYCLES=1},
|
||||||
]
|
#]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
int err = lfs_mount(&lfs, cfg);
|
# int err = lfs_mount(&lfs, cfg);
|
||||||
if (err) {
|
# if (err) {
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
uint32_t prng = 1;
|
# uint32_t prng = 1;
|
||||||
const char alpha[] = "abcdefghijklmnopqrstuvwxyz";
|
# const char alpha[] = "abcdefghijklmnopqrstuvwxyz";
|
||||||
for (unsigned i = 0; i < CYCLES; i++) {
|
# for (unsigned i = 0; i < CYCLES; i++) {
|
||||||
// create random path
|
# // create random path
|
||||||
char full_path[256];
|
# char full_path[256];
|
||||||
for (unsigned d = 0; d < DEPTH; d++) {
|
# for (unsigned d = 0; d < DEPTH; d++) {
|
||||||
sprintf(&full_path[2*d], "/%c", alpha[TEST_PRNG(&prng) % FILES]);
|
# sprintf(&full_path[2*d], "/%c", alpha[TEST_PRNG(&prng) % FILES]);
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
// if it does not exist, we create it, else we destroy
|
# // if it does not exist, we create it, else we destroy
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
int res = lfs_stat(&lfs, full_path, &info);
|
# int res = lfs_stat(&lfs, full_path, &info);
|
||||||
if (res == LFS_ERR_NOENT) {
|
# if (res == LFS_ERR_NOENT) {
|
||||||
// create each directory in turn, ignore if dir already exists
|
# // create each directory in turn, ignore if dir already exists
|
||||||
for (unsigned d = 0; d < DEPTH; d++) {
|
# for (unsigned d = 0; d < DEPTH; d++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
strcpy(path, full_path);
|
# strcpy(path, full_path);
|
||||||
path[2*d+2] = '\0';
|
# path[2*d+2] = '\0';
|
||||||
err = lfs_mkdir(&lfs, path);
|
# err = lfs_mkdir(&lfs, path);
|
||||||
assert(!err || err == LFS_ERR_EXIST);
|
# assert(!err || err == LFS_ERR_EXIST);
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (unsigned d = 0; d < DEPTH; d++) {
|
# for (unsigned d = 0; d < DEPTH; d++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
strcpy(path, full_path);
|
# strcpy(path, full_path);
|
||||||
path[2*d+2] = '\0';
|
# path[2*d+2] = '\0';
|
||||||
lfs_stat(&lfs, path, &info) => 0;
|
# lfs_stat(&lfs, path, &info) => 0;
|
||||||
assert(strcmp(info.name, &path[2*d+1]) == 0);
|
# assert(strcmp(info.name, &path[2*d+1]) == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
}
|
# }
|
||||||
} else {
|
# } else {
|
||||||
// is valid dir?
|
# // is valid dir?
|
||||||
assert(strcmp(info.name, &full_path[2*(DEPTH-1)+1]) == 0);
|
# assert(strcmp(info.name, &full_path[2*(DEPTH-1)+1]) == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
|
#
|
||||||
// try to delete path in reverse order, ignore if dir is not empty
|
# // try to delete path in reverse order, ignore if dir is not empty
|
||||||
for (unsigned d = DEPTH-1; d+1 > 0; d--) {
|
# for (unsigned d = DEPTH-1; d+1 > 0; d--) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
strcpy(path, full_path);
|
# strcpy(path, full_path);
|
||||||
path[2*d+2] = '\0';
|
# path[2*d+2] = '\0';
|
||||||
err = lfs_remove(&lfs, path);
|
# err = lfs_remove(&lfs, path);
|
||||||
assert(!err || err == LFS_ERR_NOTEMPTY);
|
# assert(!err || err == LFS_ERR_NOTEMPTY);
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_stat(&lfs, full_path, &info) => LFS_ERR_NOENT;
|
# lfs_stat(&lfs, full_path, &info) => LFS_ERR_NOENT;
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# reentrant testing for relocations, but now with random renames!
|
## reentrant testing for relocations, but now with random renames!
|
||||||
[cases.test_relocations_reentrant_renames]
|
#[cases.test_relocations_reentrant_renames]
|
||||||
reentrant = true
|
#reentrant = true
|
||||||
# TODO fix this case, caused by non-DAG trees
|
## TODO fix this case, caused by non-DAG trees
|
||||||
# NOTE the second condition is required
|
## NOTE the second condition is required
|
||||||
if = '!(DEPTH == 3 && CACHE_SIZE != 64) && 2*FILES < BLOCK_COUNT'
|
#if = '!(DEPTH == 3 && CACHE_SIZE != 64) && 2*FILES < BLOCK_COUNT'
|
||||||
defines = [
|
#defines = [
|
||||||
{FILES=6, DEPTH=1, CYCLES=20, BLOCK_CYCLES=1},
|
# {FILES=6, DEPTH=1, CYCLES=20, BLOCK_CYCLES=1},
|
||||||
{FILES=26, DEPTH=1, CYCLES=20, BLOCK_CYCLES=1},
|
# {FILES=26, DEPTH=1, CYCLES=20, BLOCK_CYCLES=1},
|
||||||
{FILES=3, DEPTH=3, CYCLES=20, BLOCK_CYCLES=1},
|
# {FILES=3, DEPTH=3, CYCLES=20, BLOCK_CYCLES=1},
|
||||||
]
|
#]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
int err = lfs_mount(&lfs, cfg);
|
# int err = lfs_mount(&lfs, cfg);
|
||||||
if (err) {
|
# if (err) {
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
uint32_t prng = 1;
|
# uint32_t prng = 1;
|
||||||
const char alpha[] = "abcdefghijklmnopqrstuvwxyz";
|
# const char alpha[] = "abcdefghijklmnopqrstuvwxyz";
|
||||||
for (unsigned i = 0; i < CYCLES; i++) {
|
# for (unsigned i = 0; i < CYCLES; i++) {
|
||||||
// create random path
|
# // create random path
|
||||||
char full_path[256];
|
# char full_path[256];
|
||||||
for (unsigned d = 0; d < DEPTH; d++) {
|
# for (unsigned d = 0; d < DEPTH; d++) {
|
||||||
sprintf(&full_path[2*d], "/%c", alpha[TEST_PRNG(&prng) % FILES]);
|
# sprintf(&full_path[2*d], "/%c", alpha[TEST_PRNG(&prng) % FILES]);
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
// if it does not exist, we create it, else we destroy
|
# // if it does not exist, we create it, else we destroy
|
||||||
struct lfs_info info;
|
# struct lfs_info info;
|
||||||
int res = lfs_stat(&lfs, full_path, &info);
|
# int res = lfs_stat(&lfs, full_path, &info);
|
||||||
assert(!res || res == LFS_ERR_NOENT);
|
# assert(!res || res == LFS_ERR_NOENT);
|
||||||
if (res == LFS_ERR_NOENT) {
|
# if (res == LFS_ERR_NOENT) {
|
||||||
// create each directory in turn, ignore if dir already exists
|
# // create each directory in turn, ignore if dir already exists
|
||||||
for (unsigned d = 0; d < DEPTH; d++) {
|
# for (unsigned d = 0; d < DEPTH; d++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
strcpy(path, full_path);
|
# strcpy(path, full_path);
|
||||||
path[2*d+2] = '\0';
|
# path[2*d+2] = '\0';
|
||||||
err = lfs_mkdir(&lfs, path);
|
# err = lfs_mkdir(&lfs, path);
|
||||||
assert(!err || err == LFS_ERR_EXIST);
|
# assert(!err || err == LFS_ERR_EXIST);
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (unsigned d = 0; d < DEPTH; d++) {
|
# for (unsigned d = 0; d < DEPTH; d++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
strcpy(path, full_path);
|
# strcpy(path, full_path);
|
||||||
path[2*d+2] = '\0';
|
# path[2*d+2] = '\0';
|
||||||
lfs_stat(&lfs, path, &info) => 0;
|
# lfs_stat(&lfs, path, &info) => 0;
|
||||||
assert(strcmp(info.name, &path[2*d+1]) == 0);
|
# assert(strcmp(info.name, &path[2*d+1]) == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
}
|
# }
|
||||||
} else {
|
# } else {
|
||||||
assert(strcmp(info.name, &full_path[2*(DEPTH-1)+1]) == 0);
|
# assert(strcmp(info.name, &full_path[2*(DEPTH-1)+1]) == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
|
#
|
||||||
// create new random path
|
# // create new random path
|
||||||
char new_path[256];
|
# char new_path[256];
|
||||||
for (unsigned d = 0; d < DEPTH; d++) {
|
# for (unsigned d = 0; d < DEPTH; d++) {
|
||||||
sprintf(&new_path[2*d], "/%c", alpha[TEST_PRNG(&prng) % FILES]);
|
# sprintf(&new_path[2*d], "/%c", alpha[TEST_PRNG(&prng) % FILES]);
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
// if new path does not exist, rename, otherwise destroy
|
# // if new path does not exist, rename, otherwise destroy
|
||||||
res = lfs_stat(&lfs, new_path, &info);
|
# res = lfs_stat(&lfs, new_path, &info);
|
||||||
assert(!res || res == LFS_ERR_NOENT);
|
# assert(!res || res == LFS_ERR_NOENT);
|
||||||
if (res == LFS_ERR_NOENT) {
|
# if (res == LFS_ERR_NOENT) {
|
||||||
// stop once some dir is renamed
|
# // stop once some dir is renamed
|
||||||
for (unsigned d = 0; d < DEPTH; d++) {
|
# for (unsigned d = 0; d < DEPTH; d++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
strcpy(&path[2*d], &full_path[2*d]);
|
# strcpy(&path[2*d], &full_path[2*d]);
|
||||||
path[2*d+2] = '\0';
|
# path[2*d+2] = '\0';
|
||||||
strcpy(&path[128+2*d], &new_path[2*d]);
|
# strcpy(&path[128+2*d], &new_path[2*d]);
|
||||||
path[128+2*d+2] = '\0';
|
# path[128+2*d+2] = '\0';
|
||||||
err = lfs_rename(&lfs, path, path+128);
|
# err = lfs_rename(&lfs, path, path+128);
|
||||||
assert(!err || err == LFS_ERR_NOTEMPTY);
|
# assert(!err || err == LFS_ERR_NOTEMPTY);
|
||||||
if (!err) {
|
# if (!err) {
|
||||||
strcpy(path, path+128);
|
# strcpy(path, path+128);
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (unsigned d = 0; d < DEPTH; d++) {
|
# for (unsigned d = 0; d < DEPTH; d++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
strcpy(path, new_path);
|
# strcpy(path, new_path);
|
||||||
path[2*d+2] = '\0';
|
# path[2*d+2] = '\0';
|
||||||
lfs_stat(&lfs, path, &info) => 0;
|
# lfs_stat(&lfs, path, &info) => 0;
|
||||||
assert(strcmp(info.name, &path[2*d+1]) == 0);
|
# assert(strcmp(info.name, &path[2*d+1]) == 0);
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
# assert(info.type == LFS_TYPE_DIR);
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_stat(&lfs, full_path, &info) => LFS_ERR_NOENT;
|
# lfs_stat(&lfs, full_path, &info) => LFS_ERR_NOENT;
|
||||||
} else {
|
# } else {
|
||||||
// try to delete path in reverse order,
|
# // try to delete path in reverse order,
|
||||||
// ignore if dir is not empty
|
# // ignore if dir is not empty
|
||||||
for (unsigned d = DEPTH-1; d+1 > 0; d--) {
|
# for (unsigned d = DEPTH-1; d+1 > 0; d--) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
strcpy(path, full_path);
|
# strcpy(path, full_path);
|
||||||
path[2*d+2] = '\0';
|
# path[2*d+2] = '\0';
|
||||||
err = lfs_remove(&lfs, path);
|
# err = lfs_remove(&lfs, path);
|
||||||
assert(!err || err == LFS_ERR_NOTEMPTY);
|
# assert(!err || err == LFS_ERR_NOTEMPTY);
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_stat(&lfs, full_path, &info) => LFS_ERR_NOENT;
|
# lfs_stat(&lfs, full_path, &info) => LFS_ERR_NOENT;
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
|||||||
+403
-403
@@ -1,403 +1,403 @@
|
|||||||
|
#
|
||||||
# simple file seek
|
## simple file seek
|
||||||
[cases.test_seek_read]
|
#[cases.test_seek_read]
|
||||||
defines = [
|
#defines = [
|
||||||
{COUNT=132, SKIP=4},
|
# {COUNT=132, SKIP=4},
|
||||||
{COUNT=132, SKIP=128},
|
# {COUNT=132, SKIP=128},
|
||||||
{COUNT=200, SKIP=10},
|
# {COUNT=200, SKIP=10},
|
||||||
{COUNT=200, SKIP=100},
|
# {COUNT=200, SKIP=100},
|
||||||
{COUNT=4, SKIP=1},
|
# {COUNT=4, SKIP=1},
|
||||||
{COUNT=4, SKIP=2},
|
# {COUNT=4, SKIP=2},
|
||||||
]
|
#]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "kitty",
|
# lfs_file_open(&lfs, &file, "kitty",
|
||||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
||||||
size_t size = strlen("kittycatcat");
|
# size_t size = strlen("kittycatcat");
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
memcpy(buffer, "kittycatcat", size);
|
# memcpy(buffer, "kittycatcat", size);
|
||||||
for (int j = 0; j < COUNT; j++) {
|
# for (int j = 0; j < COUNT; j++) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size);
|
# lfs_file_write(&lfs, &file, buffer, size);
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_open(&lfs, &file, "kitty", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "kitty", LFS_O_RDONLY) => 0;
|
||||||
|
#
|
||||||
lfs_soff_t pos = -1;
|
# lfs_soff_t pos = -1;
|
||||||
size = strlen("kittycatcat");
|
# size = strlen("kittycatcat");
|
||||||
for (int i = 0; i < SKIP; i++) {
|
# for (int i = 0; i < SKIP; i++) {
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "kittycatcat", size) => 0;
|
# memcmp(buffer, "kittycatcat", size) => 0;
|
||||||
pos = lfs_file_tell(&lfs, &file);
|
# pos = lfs_file_tell(&lfs, &file);
|
||||||
}
|
# }
|
||||||
assert(pos >= 0);
|
# assert(pos >= 0);
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, pos, LFS_SEEK_SET) => pos;
|
# lfs_file_seek(&lfs, &file, pos, LFS_SEEK_SET) => pos;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "kittycatcat", size) => 0;
|
# memcmp(buffer, "kittycatcat", size) => 0;
|
||||||
|
#
|
||||||
lfs_file_rewind(&lfs, &file) => 0;
|
# lfs_file_rewind(&lfs, &file) => 0;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "kittycatcat", size) => 0;
|
# memcmp(buffer, "kittycatcat", size) => 0;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, 0, LFS_SEEK_CUR) => size;
|
# lfs_file_seek(&lfs, &file, 0, LFS_SEEK_CUR) => size;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "kittycatcat", size) => 0;
|
# memcmp(buffer, "kittycatcat", size) => 0;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, size, LFS_SEEK_CUR) => 3*size;
|
# lfs_file_seek(&lfs, &file, size, LFS_SEEK_CUR) => 3*size;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "kittycatcat", size) => 0;
|
# memcmp(buffer, "kittycatcat", size) => 0;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, pos, LFS_SEEK_SET) => pos;
|
# lfs_file_seek(&lfs, &file, pos, LFS_SEEK_SET) => pos;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "kittycatcat", size) => 0;
|
# memcmp(buffer, "kittycatcat", size) => 0;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, -size, LFS_SEEK_CUR) => pos;
|
# lfs_file_seek(&lfs, &file, -size, LFS_SEEK_CUR) => pos;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "kittycatcat", size) => 0;
|
# memcmp(buffer, "kittycatcat", size) => 0;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, -size, LFS_SEEK_END) >= 0 => 1;
|
# lfs_file_seek(&lfs, &file, -size, LFS_SEEK_END) >= 0 => 1;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "kittycatcat", size) => 0;
|
# memcmp(buffer, "kittycatcat", size) => 0;
|
||||||
|
#
|
||||||
size = lfs_file_size(&lfs, &file);
|
# size = lfs_file_size(&lfs, &file);
|
||||||
lfs_file_seek(&lfs, &file, 0, LFS_SEEK_CUR) => size;
|
# lfs_file_seek(&lfs, &file, 0, LFS_SEEK_CUR) => size;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# simple file seek and write
|
## simple file seek and write
|
||||||
[cases.test_seek_write]
|
#[cases.test_seek_write]
|
||||||
defines = [
|
#defines = [
|
||||||
{COUNT=132, SKIP=4},
|
# {COUNT=132, SKIP=4},
|
||||||
{COUNT=132, SKIP=128},
|
# {COUNT=132, SKIP=128},
|
||||||
{COUNT=200, SKIP=10},
|
# {COUNT=200, SKIP=10},
|
||||||
{COUNT=200, SKIP=100},
|
# {COUNT=200, SKIP=100},
|
||||||
{COUNT=4, SKIP=1},
|
# {COUNT=4, SKIP=1},
|
||||||
{COUNT=4, SKIP=2},
|
# {COUNT=4, SKIP=2},
|
||||||
]
|
#]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "kitty",
|
# lfs_file_open(&lfs, &file, "kitty",
|
||||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
||||||
size_t size = strlen("kittycatcat");
|
# size_t size = strlen("kittycatcat");
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
memcpy(buffer, "kittycatcat", size);
|
# memcpy(buffer, "kittycatcat", size);
|
||||||
for (int j = 0; j < COUNT; j++) {
|
# for (int j = 0; j < COUNT; j++) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size);
|
# lfs_file_write(&lfs, &file, buffer, size);
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
|
# lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
|
||||||
|
#
|
||||||
lfs_soff_t pos = -1;
|
# lfs_soff_t pos = -1;
|
||||||
size = strlen("kittycatcat");
|
# size = strlen("kittycatcat");
|
||||||
for (int i = 0; i < SKIP; i++) {
|
# for (int i = 0; i < SKIP; i++) {
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "kittycatcat", size) => 0;
|
# memcmp(buffer, "kittycatcat", size) => 0;
|
||||||
pos = lfs_file_tell(&lfs, &file);
|
# pos = lfs_file_tell(&lfs, &file);
|
||||||
}
|
# }
|
||||||
assert(pos >= 0);
|
# assert(pos >= 0);
|
||||||
|
#
|
||||||
memcpy(buffer, "doggodogdog", size);
|
# memcpy(buffer, "doggodogdog", size);
|
||||||
lfs_file_seek(&lfs, &file, pos, LFS_SEEK_SET) => pos;
|
# lfs_file_seek(&lfs, &file, pos, LFS_SEEK_SET) => pos;
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, pos, LFS_SEEK_SET) => pos;
|
# lfs_file_seek(&lfs, &file, pos, LFS_SEEK_SET) => pos;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "doggodogdog", size) => 0;
|
# memcmp(buffer, "doggodogdog", size) => 0;
|
||||||
|
#
|
||||||
lfs_file_rewind(&lfs, &file) => 0;
|
# lfs_file_rewind(&lfs, &file) => 0;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "kittycatcat", size) => 0;
|
# memcmp(buffer, "kittycatcat", size) => 0;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, pos, LFS_SEEK_SET) => pos;
|
# lfs_file_seek(&lfs, &file, pos, LFS_SEEK_SET) => pos;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "doggodogdog", size) => 0;
|
# memcmp(buffer, "doggodogdog", size) => 0;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, -size, LFS_SEEK_END) >= 0 => 1;
|
# lfs_file_seek(&lfs, &file, -size, LFS_SEEK_END) >= 0 => 1;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "kittycatcat", size) => 0;
|
# memcmp(buffer, "kittycatcat", size) => 0;
|
||||||
|
#
|
||||||
size = lfs_file_size(&lfs, &file);
|
# size = lfs_file_size(&lfs, &file);
|
||||||
lfs_file_seek(&lfs, &file, 0, LFS_SEEK_CUR) => size;
|
# lfs_file_seek(&lfs, &file, 0, LFS_SEEK_CUR) => size;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# boundary seek and writes
|
## boundary seek and writes
|
||||||
[cases.test_seek_boundary_write]
|
#[cases.test_seek_boundary_write]
|
||||||
defines.COUNT = 132
|
#defines.COUNT = 132
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "kitty",
|
# lfs_file_open(&lfs, &file, "kitty",
|
||||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
||||||
size_t size = strlen("kittycatcat");
|
# size_t size = strlen("kittycatcat");
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
memcpy(buffer, "kittycatcat", size);
|
# memcpy(buffer, "kittycatcat", size);
|
||||||
for (int j = 0; j < COUNT; j++) {
|
# for (int j = 0; j < COUNT; j++) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size);
|
# lfs_file_write(&lfs, &file, buffer, size);
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
|
# lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
|
||||||
|
#
|
||||||
size = strlen("hedgehoghog");
|
# size = strlen("hedgehoghog");
|
||||||
const lfs_soff_t offsets[] = {512, 1020, 513, 1021, 511, 1019, 1441};
|
# const lfs_soff_t offsets[] = {512, 1020, 513, 1021, 511, 1019, 1441};
|
||||||
|
#
|
||||||
for (unsigned i = 0; i < sizeof(offsets) / sizeof(offsets[0]); i++) {
|
# for (unsigned i = 0; i < sizeof(offsets) / sizeof(offsets[0]); i++) {
|
||||||
lfs_soff_t off = offsets[i];
|
# lfs_soff_t off = offsets[i];
|
||||||
memcpy(buffer, "hedgehoghog", size);
|
# memcpy(buffer, "hedgehoghog", size);
|
||||||
lfs_file_seek(&lfs, &file, off, LFS_SEEK_SET) => off;
|
# lfs_file_seek(&lfs, &file, off, LFS_SEEK_SET) => off;
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
lfs_file_seek(&lfs, &file, off, LFS_SEEK_SET) => off;
|
# lfs_file_seek(&lfs, &file, off, LFS_SEEK_SET) => off;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "hedgehoghog", size) => 0;
|
# memcmp(buffer, "hedgehoghog", size) => 0;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
|
# lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "kittycatcat", size) => 0;
|
# memcmp(buffer, "kittycatcat", size) => 0;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, off, LFS_SEEK_SET) => off;
|
# lfs_file_seek(&lfs, &file, off, LFS_SEEK_SET) => off;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "hedgehoghog", size) => 0;
|
# memcmp(buffer, "hedgehoghog", size) => 0;
|
||||||
|
#
|
||||||
lfs_file_sync(&lfs, &file) => 0;
|
# lfs_file_sync(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
|
# lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "kittycatcat", size) => 0;
|
# memcmp(buffer, "kittycatcat", size) => 0;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, off, LFS_SEEK_SET) => off;
|
# lfs_file_seek(&lfs, &file, off, LFS_SEEK_SET) => off;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "hedgehoghog", size) => 0;
|
# memcmp(buffer, "hedgehoghog", size) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# out of bounds seek
|
## out of bounds seek
|
||||||
[cases.test_seek_out_of_bounds]
|
#[cases.test_seek_out_of_bounds]
|
||||||
defines = [
|
#defines = [
|
||||||
{COUNT=132, SKIP=4},
|
# {COUNT=132, SKIP=4},
|
||||||
{COUNT=132, SKIP=128},
|
# {COUNT=132, SKIP=128},
|
||||||
{COUNT=200, SKIP=10},
|
# {COUNT=200, SKIP=10},
|
||||||
{COUNT=200, SKIP=100},
|
# {COUNT=200, SKIP=100},
|
||||||
{COUNT=4, SKIP=2},
|
# {COUNT=4, SKIP=2},
|
||||||
{COUNT=4, SKIP=3},
|
# {COUNT=4, SKIP=3},
|
||||||
]
|
#]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "kitty",
|
# lfs_file_open(&lfs, &file, "kitty",
|
||||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
||||||
size_t size = strlen("kittycatcat");
|
# size_t size = strlen("kittycatcat");
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
memcpy(buffer, "kittycatcat", size);
|
# memcpy(buffer, "kittycatcat", size);
|
||||||
for (int j = 0; j < COUNT; j++) {
|
# for (int j = 0; j < COUNT; j++) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size);
|
# lfs_file_write(&lfs, &file, buffer, size);
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
|
# lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
|
||||||
|
#
|
||||||
size = strlen("kittycatcat");
|
# size = strlen("kittycatcat");
|
||||||
lfs_file_size(&lfs, &file) => COUNT*size;
|
# lfs_file_size(&lfs, &file) => COUNT*size;
|
||||||
lfs_file_seek(&lfs, &file, (COUNT+SKIP)*size,
|
# lfs_file_seek(&lfs, &file, (COUNT+SKIP)*size,
|
||||||
LFS_SEEK_SET) => (COUNT+SKIP)*size;
|
# LFS_SEEK_SET) => (COUNT+SKIP)*size;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => 0;
|
# lfs_file_read(&lfs, &file, buffer, size) => 0;
|
||||||
|
#
|
||||||
memcpy(buffer, "porcupineee", size);
|
# memcpy(buffer, "porcupineee", size);
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, (COUNT+SKIP)*size,
|
# lfs_file_seek(&lfs, &file, (COUNT+SKIP)*size,
|
||||||
LFS_SEEK_SET) => (COUNT+SKIP)*size;
|
# LFS_SEEK_SET) => (COUNT+SKIP)*size;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "porcupineee", size) => 0;
|
# memcmp(buffer, "porcupineee", size) => 0;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, COUNT*size,
|
# lfs_file_seek(&lfs, &file, COUNT*size,
|
||||||
LFS_SEEK_SET) => COUNT*size;
|
# LFS_SEEK_SET) => COUNT*size;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "\0\0\0\0\0\0\0\0\0\0\0", size) => 0;
|
# memcmp(buffer, "\0\0\0\0\0\0\0\0\0\0\0", size) => 0;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, -((COUNT+SKIP)*size),
|
# lfs_file_seek(&lfs, &file, -((COUNT+SKIP)*size),
|
||||||
LFS_SEEK_CUR) => LFS_ERR_INVAL;
|
# LFS_SEEK_CUR) => LFS_ERR_INVAL;
|
||||||
lfs_file_tell(&lfs, &file) => (COUNT+1)*size;
|
# lfs_file_tell(&lfs, &file) => (COUNT+1)*size;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, -((COUNT+2*SKIP)*size),
|
# lfs_file_seek(&lfs, &file, -((COUNT+2*SKIP)*size),
|
||||||
LFS_SEEK_END) => LFS_ERR_INVAL;
|
# LFS_SEEK_END) => LFS_ERR_INVAL;
|
||||||
lfs_file_tell(&lfs, &file) => (COUNT+1)*size;
|
# lfs_file_tell(&lfs, &file) => (COUNT+1)*size;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# inline write and seek
|
## inline write and seek
|
||||||
[cases.test_seek_inline_write]
|
#[cases.test_seek_inline_write]
|
||||||
defines.SIZE = [2, 4, 128, 132]
|
#defines.SIZE = [2, 4, 128, 132]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "tinykitty",
|
# lfs_file_open(&lfs, &file, "tinykitty",
|
||||||
LFS_O_RDWR | LFS_O_CREAT) => 0;
|
# LFS_O_RDWR | LFS_O_CREAT) => 0;
|
||||||
int j = 0;
|
# int j = 0;
|
||||||
int k = 0;
|
# int k = 0;
|
||||||
|
#
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
memcpy(buffer, "abcdefghijklmnopqrstuvwxyz", 26);
|
# memcpy(buffer, "abcdefghijklmnopqrstuvwxyz", 26);
|
||||||
for (unsigned i = 0; i < SIZE; i++) {
|
# for (unsigned i = 0; i < SIZE; i++) {
|
||||||
lfs_file_write(&lfs, &file, &buffer[j++ % 26], 1) => 1;
|
# lfs_file_write(&lfs, &file, &buffer[j++ % 26], 1) => 1;
|
||||||
lfs_file_tell(&lfs, &file) => i+1;
|
# lfs_file_tell(&lfs, &file) => i+1;
|
||||||
lfs_file_size(&lfs, &file) => i+1;
|
# lfs_file_size(&lfs, &file) => i+1;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
|
# lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
|
||||||
lfs_file_tell(&lfs, &file) => 0;
|
# lfs_file_tell(&lfs, &file) => 0;
|
||||||
lfs_file_size(&lfs, &file) => SIZE;
|
# lfs_file_size(&lfs, &file) => SIZE;
|
||||||
for (unsigned i = 0; i < SIZE; i++) {
|
# for (unsigned i = 0; i < SIZE; i++) {
|
||||||
uint8_t c;
|
# uint8_t c;
|
||||||
lfs_file_read(&lfs, &file, &c, 1) => 1;
|
# lfs_file_read(&lfs, &file, &c, 1) => 1;
|
||||||
c => buffer[k++ % 26];
|
# c => buffer[k++ % 26];
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_sync(&lfs, &file) => 0;
|
# lfs_file_sync(&lfs, &file) => 0;
|
||||||
lfs_file_tell(&lfs, &file) => SIZE;
|
# lfs_file_tell(&lfs, &file) => SIZE;
|
||||||
lfs_file_size(&lfs, &file) => SIZE;
|
# lfs_file_size(&lfs, &file) => SIZE;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
|
# lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
|
||||||
for (unsigned i = 0; i < SIZE; i++) {
|
# for (unsigned i = 0; i < SIZE; i++) {
|
||||||
lfs_file_write(&lfs, &file, &buffer[j++ % 26], 1) => 1;
|
# lfs_file_write(&lfs, &file, &buffer[j++ % 26], 1) => 1;
|
||||||
lfs_file_tell(&lfs, &file) => i+1;
|
# lfs_file_tell(&lfs, &file) => i+1;
|
||||||
lfs_file_size(&lfs, &file) => SIZE;
|
# lfs_file_size(&lfs, &file) => SIZE;
|
||||||
lfs_file_sync(&lfs, &file) => 0;
|
# lfs_file_sync(&lfs, &file) => 0;
|
||||||
lfs_file_tell(&lfs, &file) => i+1;
|
# lfs_file_tell(&lfs, &file) => i+1;
|
||||||
lfs_file_size(&lfs, &file) => SIZE;
|
# lfs_file_size(&lfs, &file) => SIZE;
|
||||||
if (i < SIZE-2) {
|
# if (i < SIZE-2) {
|
||||||
uint8_t c[3];
|
# uint8_t c[3];
|
||||||
lfs_file_seek(&lfs, &file, -1, LFS_SEEK_CUR) => i;
|
# lfs_file_seek(&lfs, &file, -1, LFS_SEEK_CUR) => i;
|
||||||
lfs_file_read(&lfs, &file, &c, 3) => 3;
|
# lfs_file_read(&lfs, &file, &c, 3) => 3;
|
||||||
lfs_file_tell(&lfs, &file) => i+3;
|
# lfs_file_tell(&lfs, &file) => i+3;
|
||||||
lfs_file_size(&lfs, &file) => SIZE;
|
# lfs_file_size(&lfs, &file) => SIZE;
|
||||||
lfs_file_seek(&lfs, &file, i+1, LFS_SEEK_SET) => i+1;
|
# lfs_file_seek(&lfs, &file, i+1, LFS_SEEK_SET) => i+1;
|
||||||
lfs_file_tell(&lfs, &file) => i+1;
|
# lfs_file_tell(&lfs, &file) => i+1;
|
||||||
lfs_file_size(&lfs, &file) => SIZE;
|
# lfs_file_size(&lfs, &file) => SIZE;
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
|
# lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
|
||||||
lfs_file_tell(&lfs, &file) => 0;
|
# lfs_file_tell(&lfs, &file) => 0;
|
||||||
lfs_file_size(&lfs, &file) => SIZE;
|
# lfs_file_size(&lfs, &file) => SIZE;
|
||||||
for (unsigned i = 0; i < SIZE; i++) {
|
# for (unsigned i = 0; i < SIZE; i++) {
|
||||||
uint8_t c;
|
# uint8_t c;
|
||||||
lfs_file_read(&lfs, &file, &c, 1) => 1;
|
# lfs_file_read(&lfs, &file, &c, 1) => 1;
|
||||||
c => buffer[k++ % 26];
|
# c => buffer[k++ % 26];
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_sync(&lfs, &file) => 0;
|
# lfs_file_sync(&lfs, &file) => 0;
|
||||||
lfs_file_tell(&lfs, &file) => SIZE;
|
# lfs_file_tell(&lfs, &file) => SIZE;
|
||||||
lfs_file_size(&lfs, &file) => SIZE;
|
# lfs_file_size(&lfs, &file) => SIZE;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# file seek and write with power-loss
|
## file seek and write with power-loss
|
||||||
[cases.test_seek_reentrant_write]
|
#[cases.test_seek_reentrant_write]
|
||||||
# must be power-of-2 for quadratic probing to be exhaustive
|
## must be power-of-2 for quadratic probing to be exhaustive
|
||||||
defines.COUNT = [4, 64, 128]
|
#defines.COUNT = [4, 64, 128]
|
||||||
reentrant = true
|
#reentrant = true
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
int err = lfs_mount(&lfs, cfg);
|
# int err = lfs_mount(&lfs, cfg);
|
||||||
if (err) {
|
# if (err) {
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
}
|
# }
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
err = lfs_file_open(&lfs, &file, "kitty", LFS_O_RDONLY);
|
# err = lfs_file_open(&lfs, &file, "kitty", LFS_O_RDONLY);
|
||||||
assert(!err || err == LFS_ERR_NOENT);
|
# assert(!err || err == LFS_ERR_NOENT);
|
||||||
if (!err) {
|
# if (!err) {
|
||||||
if (lfs_file_size(&lfs, &file) != 0) {
|
# if (lfs_file_size(&lfs, &file) != 0) {
|
||||||
lfs_file_size(&lfs, &file) => 11*COUNT;
|
# lfs_file_size(&lfs, &file) => 11*COUNT;
|
||||||
for (int j = 0; j < COUNT; j++) {
|
# for (int j = 0; j < COUNT; j++) {
|
||||||
memset(buffer, 0, 11+1);
|
# memset(buffer, 0, 11+1);
|
||||||
lfs_file_read(&lfs, &file, buffer, 11) => 11;
|
# lfs_file_read(&lfs, &file, buffer, 11) => 11;
|
||||||
assert(memcmp(buffer, "kittycatcat", 11) == 0 ||
|
# assert(memcmp(buffer, "kittycatcat", 11) == 0 ||
|
||||||
memcmp(buffer, "doggodogdog", 11) == 0);
|
# memcmp(buffer, "doggodogdog", 11) == 0);
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_open(&lfs, &file, "kitty", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# lfs_file_open(&lfs, &file, "kitty", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
if (lfs_file_size(&lfs, &file) == 0) {
|
# if (lfs_file_size(&lfs, &file) == 0) {
|
||||||
for (int j = 0; j < COUNT; j++) {
|
# for (int j = 0; j < COUNT; j++) {
|
||||||
strcpy((char*)buffer, "kittycatcat");
|
# strcpy((char*)buffer, "kittycatcat");
|
||||||
size_t size = strlen((char*)buffer);
|
# size_t size = strlen((char*)buffer);
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
strcpy((char*)buffer, "doggodogdog");
|
# strcpy((char*)buffer, "doggodogdog");
|
||||||
size_t size = strlen((char*)buffer);
|
# size_t size = strlen((char*)buffer);
|
||||||
|
#
|
||||||
lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
|
# lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
|
||||||
lfs_file_size(&lfs, &file) => COUNT*size;
|
# lfs_file_size(&lfs, &file) => COUNT*size;
|
||||||
// seek and write using quadratic probing to touch all
|
# // seek and write using quadratic probing to touch all
|
||||||
// 11-byte words in the file
|
# // 11-byte words in the file
|
||||||
lfs_off_t off = 0;
|
# lfs_off_t off = 0;
|
||||||
for (int j = 0; j < COUNT; j++) {
|
# for (int j = 0; j < COUNT; j++) {
|
||||||
off = (5*off + 1) % COUNT;
|
# off = (5*off + 1) % COUNT;
|
||||||
lfs_file_seek(&lfs, &file, off*size, LFS_SEEK_SET) => off*size;
|
# lfs_file_seek(&lfs, &file, off*size, LFS_SEEK_SET) => off*size;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
assert(memcmp(buffer, "kittycatcat", size) == 0 ||
|
# assert(memcmp(buffer, "kittycatcat", size) == 0 ||
|
||||||
memcmp(buffer, "doggodogdog", size) == 0);
|
# memcmp(buffer, "doggodogdog", size) == 0);
|
||||||
if (memcmp(buffer, "doggodogdog", size) != 0) {
|
# if (memcmp(buffer, "doggodogdog", size) != 0) {
|
||||||
lfs_file_seek(&lfs, &file, off*size, LFS_SEEK_SET) => off*size;
|
# lfs_file_seek(&lfs, &file, off*size, LFS_SEEK_SET) => off*size;
|
||||||
strcpy((char*)buffer, "doggodogdog");
|
# strcpy((char*)buffer, "doggodogdog");
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
lfs_file_seek(&lfs, &file, off*size, LFS_SEEK_SET) => off*size;
|
# lfs_file_seek(&lfs, &file, off*size, LFS_SEEK_SET) => off*size;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
assert(memcmp(buffer, "doggodogdog", size) == 0);
|
# assert(memcmp(buffer, "doggodogdog", size) == 0);
|
||||||
lfs_file_sync(&lfs, &file) => 0;
|
# lfs_file_sync(&lfs, &file) => 0;
|
||||||
lfs_file_seek(&lfs, &file, off*size, LFS_SEEK_SET) => off*size;
|
# lfs_file_seek(&lfs, &file, off*size, LFS_SEEK_SET) => off*size;
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
assert(memcmp(buffer, "doggodogdog", size) == 0);
|
# assert(memcmp(buffer, "doggodogdog", size) == 0);
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
|
# lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
|
||||||
lfs_file_size(&lfs, &file) => COUNT*size;
|
# lfs_file_size(&lfs, &file) => COUNT*size;
|
||||||
for (int j = 0; j < COUNT; j++) {
|
# for (int j = 0; j < COUNT; j++) {
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
assert(memcmp(buffer, "doggodogdog", size) == 0);
|
# assert(memcmp(buffer, "doggodogdog", size) == 0);
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
|||||||
+178
-178
@@ -1,77 +1,17 @@
|
|||||||
# simple format test
|
## simple format test
|
||||||
[cases.test_superblocks_format]
|
|
||||||
code = '''
|
|
||||||
lfs_t lfs;
|
|
||||||
lfsr_format(&lfs, cfg) => 0;
|
|
||||||
'''
|
|
||||||
|
|
||||||
# simple mount/unmount test
|
|
||||||
[cases.test_superblocks_mount]
|
|
||||||
code = '''
|
|
||||||
lfs_t lfs;
|
|
||||||
lfsr_format(&lfs, cfg) => 0;
|
|
||||||
lfsr_mount(&lfs, cfg) => 0;
|
|
||||||
lfsr_unmount(&lfs) => 0;
|
|
||||||
'''
|
|
||||||
|
|
||||||
# reentrant format
|
|
||||||
[cases.test_superblocks_reentrant_format]
|
|
||||||
reentrant = true
|
|
||||||
code = '''
|
|
||||||
lfs_t lfs;
|
|
||||||
int err = lfsr_mount(&lfs, cfg);
|
|
||||||
if (err) {
|
|
||||||
lfsr_format(&lfs, cfg) => 0;
|
|
||||||
lfsr_mount(&lfs, cfg) => 0;
|
|
||||||
}
|
|
||||||
lfsr_unmount(&lfs) => 0;
|
|
||||||
'''
|
|
||||||
|
|
||||||
# invalid mount
|
|
||||||
[cases.test_superblocks_invalid]
|
|
||||||
code = '''
|
|
||||||
lfs_t lfs;
|
|
||||||
lfsr_mount(&lfs, cfg) => LFS_ERR_INVAL;
|
|
||||||
'''
|
|
||||||
|
|
||||||
# superblock cycle detection
|
|
||||||
[cases.test_superblocks_cycle]
|
|
||||||
in = 'lfs.c'
|
|
||||||
code = '''
|
|
||||||
// create a cycle
|
|
||||||
lfs_t lfs;
|
|
||||||
lfsr_format(&lfs, cfg) => 0;
|
|
||||||
lfsr_mount(&lfs, cfg) => 0;
|
|
||||||
uint8_t buf[LFSR_MPAIR_DSIZE];
|
|
||||||
lfs_ssize_t d = lfsr_mpair_todisk(&lfs,
|
|
||||||
lfsr_mdir_mpair(&lfs.mroot), buf);
|
|
||||||
assert(d >= 0);
|
|
||||||
lfsr_mdir_commit(&lfs, &lfs.mroot, &(lfs_ssize_t){-1}, LFSR_ATTRS(
|
|
||||||
LFSR_ATTR(-1, MROOT, 0, buf, d))) => 0;
|
|
||||||
lfsr_unmount(&lfs) => 0;
|
|
||||||
|
|
||||||
// now detect the cycle
|
|
||||||
lfsr_mount(&lfs, cfg) => LFS_ERR_CORRUPT;
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## simple formatting test
|
|
||||||
#[cases.test_superblocks_format]
|
#[cases.test_superblocks_format]
|
||||||
#code = '''
|
#code = '''
|
||||||
# lfs_t lfs;
|
# lfs_t lfs;
|
||||||
# lfs_format(&lfs, cfg) => 0;
|
# lfsr_format(&lfs, cfg) => 0;
|
||||||
#'''
|
#'''
|
||||||
#
|
#
|
||||||
## mount/unmount
|
## simple mount/unmount test
|
||||||
#[cases.test_superblocks_mount]
|
#[cases.test_superblocks_mount]
|
||||||
#code = '''
|
#code = '''
|
||||||
# lfs_t lfs;
|
# lfs_t lfs;
|
||||||
# lfs_format(&lfs, cfg) => 0;
|
# lfsr_format(&lfs, cfg) => 0;
|
||||||
# lfs_mount(&lfs, cfg) => 0;
|
# lfsr_mount(&lfs, cfg) => 0;
|
||||||
# lfs_unmount(&lfs) => 0;
|
# lfsr_unmount(&lfs) => 0;
|
||||||
#'''
|
#'''
|
||||||
#
|
#
|
||||||
## reentrant format
|
## reentrant format
|
||||||
@@ -79,133 +19,193 @@ code = '''
|
|||||||
#reentrant = true
|
#reentrant = true
|
||||||
#code = '''
|
#code = '''
|
||||||
# lfs_t lfs;
|
# lfs_t lfs;
|
||||||
# int err = lfs_mount(&lfs, cfg);
|
# int err = lfsr_mount(&lfs, cfg);
|
||||||
# if (err) {
|
# if (err) {
|
||||||
# lfs_format(&lfs, cfg) => 0;
|
# lfsr_format(&lfs, cfg) => 0;
|
||||||
# lfs_mount(&lfs, cfg) => 0;
|
# lfsr_mount(&lfs, cfg) => 0;
|
||||||
# }
|
# }
|
||||||
# lfs_unmount(&lfs) => 0;
|
# lfsr_unmount(&lfs) => 0;
|
||||||
#'''
|
#'''
|
||||||
#
|
#
|
||||||
## invalid mount
|
## invalid mount
|
||||||
#[cases.test_superblocks_invalid_mount]
|
#[cases.test_superblocks_invalid]
|
||||||
#code = '''
|
#code = '''
|
||||||
# lfs_t lfs;
|
# lfs_t lfs;
|
||||||
# lfs_mount(&lfs, cfg) => LFS_ERR_CORRUPT;
|
# lfsr_mount(&lfs, cfg) => LFS_ERR_INVAL;
|
||||||
#'''
|
#'''
|
||||||
#
|
#
|
||||||
## expanding superblock
|
## superblock cycle detection
|
||||||
#[cases.test_superblocks_expand]
|
#[cases.test_superblocks_cycle]
|
||||||
#defines.BLOCK_CYCLES = [32, 33, 1]
|
#in = 'lfs.c'
|
||||||
#defines.N = [10, 100, 1000]
|
|
||||||
#code = '''
|
#code = '''
|
||||||
|
# // create a cycle
|
||||||
# lfs_t lfs;
|
# lfs_t lfs;
|
||||||
# lfs_format(&lfs, cfg) => 0;
|
# lfsr_format(&lfs, cfg) => 0;
|
||||||
# lfs_mount(&lfs, cfg) => 0;
|
# lfsr_mount(&lfs, cfg) => 0;
|
||||||
# for (int i = 0; i < N; i++) {
|
# uint8_t buf[LFSR_MPAIR_DSIZE];
|
||||||
# lfs_file_t file;
|
# lfs_ssize_t d = lfsr_mpair_todisk(&lfs,
|
||||||
# lfs_file_open(&lfs, &file, "dummy",
|
# lfsr_mdir_mpair(&lfs.mroot), buf);
|
||||||
# LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
# assert(d >= 0);
|
||||||
# lfs_file_close(&lfs, &file) => 0;
|
# lfsr_mdir_commit(&lfs, &lfs.mroot, &(lfs_ssize_t){-1}, LFSR_ATTRS(
|
||||||
# struct lfs_info info;
|
# LFSR_ATTR(-1, MROOT, 0, buf, d))) => 0;
|
||||||
# lfs_stat(&lfs, "dummy", &info) => 0;
|
# lfsr_unmount(&lfs) => 0;
|
||||||
# assert(strcmp(info.name, "dummy") == 0);
|
|
||||||
# assert(info.type == LFS_TYPE_REG);
|
|
||||||
# lfs_remove(&lfs, "dummy") => 0;
|
|
||||||
# }
|
|
||||||
# lfs_unmount(&lfs) => 0;
|
|
||||||
#
|
#
|
||||||
# // one last check after power-cycle
|
# // now detect the cycle
|
||||||
# lfs_mount(&lfs, cfg) => 0;
|
# lfsr_mount(&lfs, cfg) => LFS_ERR_CORRUPT;
|
||||||
# lfs_file_t file;
|
|
||||||
# lfs_file_open(&lfs, &file, "dummy",
|
|
||||||
# LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
|
||||||
# lfs_file_close(&lfs, &file) => 0;
|
|
||||||
# struct lfs_info info;
|
|
||||||
# lfs_stat(&lfs, "dummy", &info) => 0;
|
|
||||||
# assert(strcmp(info.name, "dummy") == 0);
|
|
||||||
# assert(info.type == LFS_TYPE_REG);
|
|
||||||
# lfs_unmount(&lfs) => 0;
|
|
||||||
#'''
|
#'''
|
||||||
#
|
#
|
||||||
## expanding superblock with power cycle
|
|
||||||
#[cases.test_superblocks_expand_power_cycle]
|
|
||||||
#defines.BLOCK_CYCLES = [32, 33, 1]
|
|
||||||
#defines.N = [10, 100, 1000]
|
|
||||||
#code = '''
|
|
||||||
# lfs_t lfs;
|
|
||||||
# lfs_format(&lfs, cfg) => 0;
|
|
||||||
# for (int i = 0; i < N; i++) {
|
|
||||||
# lfs_mount(&lfs, cfg) => 0;
|
|
||||||
# // remove lingering dummy?
|
|
||||||
# struct lfs_info info;
|
|
||||||
# int err = lfs_stat(&lfs, "dummy", &info);
|
|
||||||
# assert(err == 0 || (err == LFS_ERR_NOENT && i == 0));
|
|
||||||
# if (!err) {
|
|
||||||
# assert(strcmp(info.name, "dummy") == 0);
|
|
||||||
# assert(info.type == LFS_TYPE_REG);
|
|
||||||
# lfs_remove(&lfs, "dummy") => 0;
|
|
||||||
# }
|
|
||||||
#
|
#
|
||||||
# lfs_file_t file;
|
|
||||||
# lfs_file_open(&lfs, &file, "dummy",
|
|
||||||
# LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
|
||||||
# lfs_file_close(&lfs, &file) => 0;
|
|
||||||
# lfs_stat(&lfs, "dummy", &info) => 0;
|
|
||||||
# assert(strcmp(info.name, "dummy") == 0);
|
|
||||||
# assert(info.type == LFS_TYPE_REG);
|
|
||||||
# lfs_unmount(&lfs) => 0;
|
|
||||||
# }
|
|
||||||
#
|
#
|
||||||
# // one last check after power-cycle
|
|
||||||
# lfs_mount(&lfs, cfg) => 0;
|
|
||||||
# struct lfs_info info;
|
|
||||||
# lfs_stat(&lfs, "dummy", &info) => 0;
|
|
||||||
# assert(strcmp(info.name, "dummy") == 0);
|
|
||||||
# assert(info.type == LFS_TYPE_REG);
|
|
||||||
# lfs_unmount(&lfs) => 0;
|
|
||||||
#'''
|
|
||||||
#
|
#
|
||||||
## reentrant expanding superblock
|
|
||||||
#[cases.test_superblocks_reentrant_expand]
|
|
||||||
#defines.BLOCK_CYCLES = [2, 1]
|
|
||||||
#defines.N = 24
|
|
||||||
#reentrant = true
|
|
||||||
#code = '''
|
|
||||||
# lfs_t lfs;
|
|
||||||
# int err = lfs_mount(&lfs, cfg);
|
|
||||||
# if (err) {
|
|
||||||
# lfs_format(&lfs, cfg) => 0;
|
|
||||||
# lfs_mount(&lfs, cfg) => 0;
|
|
||||||
# }
|
|
||||||
#
|
#
|
||||||
# for (int i = 0; i < N; i++) {
|
### simple formatting test
|
||||||
# // remove lingering dummy?
|
##[cases.test_superblocks_format]
|
||||||
# struct lfs_info info;
|
##code = '''
|
||||||
# err = lfs_stat(&lfs, "dummy", &info);
|
## lfs_t lfs;
|
||||||
# assert(err == 0 || (err == LFS_ERR_NOENT && i == 0));
|
## lfs_format(&lfs, cfg) => 0;
|
||||||
# if (!err) {
|
##'''
|
||||||
# assert(strcmp(info.name, "dummy") == 0);
|
##
|
||||||
# assert(info.type == LFS_TYPE_REG);
|
### mount/unmount
|
||||||
# lfs_remove(&lfs, "dummy") => 0;
|
##[cases.test_superblocks_mount]
|
||||||
# }
|
##code = '''
|
||||||
#
|
## lfs_t lfs;
|
||||||
# lfs_file_t file;
|
## lfs_format(&lfs, cfg) => 0;
|
||||||
# lfs_file_open(&lfs, &file, "dummy",
|
## lfs_mount(&lfs, cfg) => 0;
|
||||||
# LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
## lfs_unmount(&lfs) => 0;
|
||||||
# lfs_file_close(&lfs, &file) => 0;
|
##'''
|
||||||
# lfs_stat(&lfs, "dummy", &info) => 0;
|
##
|
||||||
# assert(strcmp(info.name, "dummy") == 0);
|
### reentrant format
|
||||||
# assert(info.type == LFS_TYPE_REG);
|
##[cases.test_superblocks_reentrant_format]
|
||||||
# }
|
##reentrant = true
|
||||||
#
|
##code = '''
|
||||||
# lfs_unmount(&lfs) => 0;
|
## lfs_t lfs;
|
||||||
#
|
## int err = lfs_mount(&lfs, cfg);
|
||||||
# // one last check after power-cycle
|
## if (err) {
|
||||||
# lfs_mount(&lfs, cfg) => 0;
|
## lfs_format(&lfs, cfg) => 0;
|
||||||
# struct lfs_info info;
|
## lfs_mount(&lfs, cfg) => 0;
|
||||||
# lfs_stat(&lfs, "dummy", &info) => 0;
|
## }
|
||||||
# assert(strcmp(info.name, "dummy") == 0);
|
## lfs_unmount(&lfs) => 0;
|
||||||
# assert(info.type == LFS_TYPE_REG);
|
##'''
|
||||||
# lfs_unmount(&lfs) => 0;
|
##
|
||||||
#'''
|
### invalid mount
|
||||||
|
##[cases.test_superblocks_invalid_mount]
|
||||||
|
##code = '''
|
||||||
|
## lfs_t lfs;
|
||||||
|
## lfs_mount(&lfs, cfg) => LFS_ERR_CORRUPT;
|
||||||
|
##'''
|
||||||
|
##
|
||||||
|
### expanding superblock
|
||||||
|
##[cases.test_superblocks_expand]
|
||||||
|
##defines.BLOCK_CYCLES = [32, 33, 1]
|
||||||
|
##defines.N = [10, 100, 1000]
|
||||||
|
##code = '''
|
||||||
|
## lfs_t lfs;
|
||||||
|
## lfs_format(&lfs, cfg) => 0;
|
||||||
|
## lfs_mount(&lfs, cfg) => 0;
|
||||||
|
## for (int i = 0; i < N; i++) {
|
||||||
|
## lfs_file_t file;
|
||||||
|
## lfs_file_open(&lfs, &file, "dummy",
|
||||||
|
## LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
||||||
|
## lfs_file_close(&lfs, &file) => 0;
|
||||||
|
## struct lfs_info info;
|
||||||
|
## lfs_stat(&lfs, "dummy", &info) => 0;
|
||||||
|
## assert(strcmp(info.name, "dummy") == 0);
|
||||||
|
## assert(info.type == LFS_TYPE_REG);
|
||||||
|
## lfs_remove(&lfs, "dummy") => 0;
|
||||||
|
## }
|
||||||
|
## lfs_unmount(&lfs) => 0;
|
||||||
|
##
|
||||||
|
## // one last check after power-cycle
|
||||||
|
## lfs_mount(&lfs, cfg) => 0;
|
||||||
|
## lfs_file_t file;
|
||||||
|
## lfs_file_open(&lfs, &file, "dummy",
|
||||||
|
## LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
||||||
|
## lfs_file_close(&lfs, &file) => 0;
|
||||||
|
## struct lfs_info info;
|
||||||
|
## lfs_stat(&lfs, "dummy", &info) => 0;
|
||||||
|
## assert(strcmp(info.name, "dummy") == 0);
|
||||||
|
## assert(info.type == LFS_TYPE_REG);
|
||||||
|
## lfs_unmount(&lfs) => 0;
|
||||||
|
##'''
|
||||||
|
##
|
||||||
|
### expanding superblock with power cycle
|
||||||
|
##[cases.test_superblocks_expand_power_cycle]
|
||||||
|
##defines.BLOCK_CYCLES = [32, 33, 1]
|
||||||
|
##defines.N = [10, 100, 1000]
|
||||||
|
##code = '''
|
||||||
|
## lfs_t lfs;
|
||||||
|
## lfs_format(&lfs, cfg) => 0;
|
||||||
|
## for (int i = 0; i < N; i++) {
|
||||||
|
## lfs_mount(&lfs, cfg) => 0;
|
||||||
|
## // remove lingering dummy?
|
||||||
|
## struct lfs_info info;
|
||||||
|
## int err = lfs_stat(&lfs, "dummy", &info);
|
||||||
|
## assert(err == 0 || (err == LFS_ERR_NOENT && i == 0));
|
||||||
|
## if (!err) {
|
||||||
|
## assert(strcmp(info.name, "dummy") == 0);
|
||||||
|
## assert(info.type == LFS_TYPE_REG);
|
||||||
|
## lfs_remove(&lfs, "dummy") => 0;
|
||||||
|
## }
|
||||||
|
##
|
||||||
|
## lfs_file_t file;
|
||||||
|
## lfs_file_open(&lfs, &file, "dummy",
|
||||||
|
## LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
||||||
|
## lfs_file_close(&lfs, &file) => 0;
|
||||||
|
## lfs_stat(&lfs, "dummy", &info) => 0;
|
||||||
|
## assert(strcmp(info.name, "dummy") == 0);
|
||||||
|
## assert(info.type == LFS_TYPE_REG);
|
||||||
|
## lfs_unmount(&lfs) => 0;
|
||||||
|
## }
|
||||||
|
##
|
||||||
|
## // one last check after power-cycle
|
||||||
|
## lfs_mount(&lfs, cfg) => 0;
|
||||||
|
## struct lfs_info info;
|
||||||
|
## lfs_stat(&lfs, "dummy", &info) => 0;
|
||||||
|
## assert(strcmp(info.name, "dummy") == 0);
|
||||||
|
## assert(info.type == LFS_TYPE_REG);
|
||||||
|
## lfs_unmount(&lfs) => 0;
|
||||||
|
##'''
|
||||||
|
##
|
||||||
|
### reentrant expanding superblock
|
||||||
|
##[cases.test_superblocks_reentrant_expand]
|
||||||
|
##defines.BLOCK_CYCLES = [2, 1]
|
||||||
|
##defines.N = 24
|
||||||
|
##reentrant = true
|
||||||
|
##code = '''
|
||||||
|
## lfs_t lfs;
|
||||||
|
## int err = lfs_mount(&lfs, cfg);
|
||||||
|
## if (err) {
|
||||||
|
## lfs_format(&lfs, cfg) => 0;
|
||||||
|
## lfs_mount(&lfs, cfg) => 0;
|
||||||
|
## }
|
||||||
|
##
|
||||||
|
## for (int i = 0; i < N; i++) {
|
||||||
|
## // remove lingering dummy?
|
||||||
|
## struct lfs_info info;
|
||||||
|
## err = lfs_stat(&lfs, "dummy", &info);
|
||||||
|
## assert(err == 0 || (err == LFS_ERR_NOENT && i == 0));
|
||||||
|
## if (!err) {
|
||||||
|
## assert(strcmp(info.name, "dummy") == 0);
|
||||||
|
## assert(info.type == LFS_TYPE_REG);
|
||||||
|
## lfs_remove(&lfs, "dummy") => 0;
|
||||||
|
## }
|
||||||
|
##
|
||||||
|
## lfs_file_t file;
|
||||||
|
## lfs_file_open(&lfs, &file, "dummy",
|
||||||
|
## LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
||||||
|
## lfs_file_close(&lfs, &file) => 0;
|
||||||
|
## lfs_stat(&lfs, "dummy", &info) => 0;
|
||||||
|
## assert(strcmp(info.name, "dummy") == 0);
|
||||||
|
## assert(info.type == LFS_TYPE_REG);
|
||||||
|
## }
|
||||||
|
##
|
||||||
|
## lfs_unmount(&lfs) => 0;
|
||||||
|
##
|
||||||
|
## // one last check after power-cycle
|
||||||
|
## lfs_mount(&lfs, cfg) => 0;
|
||||||
|
## struct lfs_info info;
|
||||||
|
## lfs_stat(&lfs, "dummy", &info) => 0;
|
||||||
|
## assert(strcmp(info.name, "dummy") == 0);
|
||||||
|
## assert(info.type == LFS_TYPE_REG);
|
||||||
|
## lfs_unmount(&lfs) => 0;
|
||||||
|
##'''
|
||||||
|
|||||||
+477
-477
@@ -1,477 +1,477 @@
|
|||||||
# simple truncate
|
## simple truncate
|
||||||
[cases.test_truncate_simple]
|
#[cases.test_truncate_simple]
|
||||||
defines.MEDIUMSIZE = [32, 2048]
|
#defines.MEDIUMSIZE = [32, 2048]
|
||||||
defines.LARGESIZE = 8192
|
#defines.LARGESIZE = 8192
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "baldynoop",
|
# lfs_file_open(&lfs, &file, "baldynoop",
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
|
#
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
strcpy((char*)buffer, "hair");
|
# strcpy((char*)buffer, "hair");
|
||||||
size_t size = strlen((char*)buffer);
|
# size_t size = strlen((char*)buffer);
|
||||||
for (lfs_off_t j = 0; j < LARGESIZE; j += size) {
|
# for (lfs_off_t j = 0; j < LARGESIZE; j += size) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
}
|
# }
|
||||||
lfs_file_size(&lfs, &file) => LARGESIZE;
|
# lfs_file_size(&lfs, &file) => LARGESIZE;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_open(&lfs, &file, "baldynoop", LFS_O_RDWR) => 0;
|
# lfs_file_open(&lfs, &file, "baldynoop", LFS_O_RDWR) => 0;
|
||||||
lfs_file_size(&lfs, &file) => LARGESIZE;
|
# lfs_file_size(&lfs, &file) => LARGESIZE;
|
||||||
|
#
|
||||||
lfs_file_truncate(&lfs, &file, MEDIUMSIZE) => 0;
|
# lfs_file_truncate(&lfs, &file, MEDIUMSIZE) => 0;
|
||||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
# lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_open(&lfs, &file, "baldynoop", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "baldynoop", LFS_O_RDONLY) => 0;
|
||||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
# lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||||
|
#
|
||||||
size = strlen("hair");
|
# size = strlen("hair");
|
||||||
for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
# for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "hair", size) => 0;
|
# memcmp(buffer, "hair", size) => 0;
|
||||||
}
|
# }
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => 0;
|
# lfs_file_read(&lfs, &file, buffer, size) => 0;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# truncate and read
|
## truncate and read
|
||||||
[cases.test_truncate_read]
|
#[cases.test_truncate_read]
|
||||||
defines.MEDIUMSIZE = [32, 2048]
|
#defines.MEDIUMSIZE = [32, 2048]
|
||||||
defines.LARGESIZE = 8192
|
#defines.LARGESIZE = 8192
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "baldyread",
|
# lfs_file_open(&lfs, &file, "baldyread",
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
|
#
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
strcpy((char*)buffer, "hair");
|
# strcpy((char*)buffer, "hair");
|
||||||
size_t size = strlen((char*)buffer);
|
# size_t size = strlen((char*)buffer);
|
||||||
for (lfs_off_t j = 0; j < LARGESIZE; j += size) {
|
# for (lfs_off_t j = 0; j < LARGESIZE; j += size) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
}
|
# }
|
||||||
lfs_file_size(&lfs, &file) => LARGESIZE;
|
# lfs_file_size(&lfs, &file) => LARGESIZE;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_open(&lfs, &file, "baldyread", LFS_O_RDWR) => 0;
|
# lfs_file_open(&lfs, &file, "baldyread", LFS_O_RDWR) => 0;
|
||||||
lfs_file_size(&lfs, &file) => LARGESIZE;
|
# lfs_file_size(&lfs, &file) => LARGESIZE;
|
||||||
|
#
|
||||||
lfs_file_truncate(&lfs, &file, MEDIUMSIZE) => 0;
|
# lfs_file_truncate(&lfs, &file, MEDIUMSIZE) => 0;
|
||||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
# lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||||
|
#
|
||||||
size = strlen("hair");
|
# size = strlen("hair");
|
||||||
for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
# for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "hair", size) => 0;
|
# memcmp(buffer, "hair", size) => 0;
|
||||||
}
|
# }
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => 0;
|
# lfs_file_read(&lfs, &file, buffer, size) => 0;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_open(&lfs, &file, "baldyread", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "baldyread", LFS_O_RDONLY) => 0;
|
||||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
# lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||||
|
#
|
||||||
size = strlen("hair");
|
# size = strlen("hair");
|
||||||
for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
# for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "hair", size) => 0;
|
# memcmp(buffer, "hair", size) => 0;
|
||||||
}
|
# }
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => 0;
|
# lfs_file_read(&lfs, &file, buffer, size) => 0;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# write, truncate, and read
|
## write, truncate, and read
|
||||||
[cases.test_truncate_write_read]
|
#[cases.test_truncate_write_read]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "sequence",
|
# lfs_file_open(&lfs, &file, "sequence",
|
||||||
LFS_O_RDWR | LFS_O_CREAT | LFS_O_TRUNC) => 0;
|
# LFS_O_RDWR | LFS_O_CREAT | LFS_O_TRUNC) => 0;
|
||||||
|
#
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
size_t size = lfs_min(lfs.cfg->cache_size, sizeof(buffer)/2);
|
# size_t size = lfs_min(lfs.cfg->cache_size, sizeof(buffer)/2);
|
||||||
lfs_size_t qsize = size / 4;
|
# lfs_size_t qsize = size / 4;
|
||||||
uint8_t *wb = buffer;
|
# uint8_t *wb = buffer;
|
||||||
uint8_t *rb = buffer + size;
|
# uint8_t *rb = buffer + size;
|
||||||
for (lfs_off_t j = 0; j < size; ++j) {
|
# for (lfs_off_t j = 0; j < size; ++j) {
|
||||||
wb[j] = j;
|
# wb[j] = j;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
/* Spread sequence over size */
|
# /* Spread sequence over size */
|
||||||
lfs_file_write(&lfs, &file, wb, size) => size;
|
# lfs_file_write(&lfs, &file, wb, size) => size;
|
||||||
lfs_file_size(&lfs, &file) => size;
|
# lfs_file_size(&lfs, &file) => size;
|
||||||
lfs_file_tell(&lfs, &file) => size;
|
# lfs_file_tell(&lfs, &file) => size;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
|
# lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
|
||||||
lfs_file_tell(&lfs, &file) => 0;
|
# lfs_file_tell(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
/* Chop off the last quarter */
|
# /* Chop off the last quarter */
|
||||||
lfs_size_t trunc = size - qsize;
|
# lfs_size_t trunc = size - qsize;
|
||||||
lfs_file_truncate(&lfs, &file, trunc) => 0;
|
# lfs_file_truncate(&lfs, &file, trunc) => 0;
|
||||||
lfs_file_tell(&lfs, &file) => 0;
|
# lfs_file_tell(&lfs, &file) => 0;
|
||||||
lfs_file_size(&lfs, &file) => trunc;
|
# lfs_file_size(&lfs, &file) => trunc;
|
||||||
|
#
|
||||||
/* Read should produce first 3/4 */
|
# /* Read should produce first 3/4 */
|
||||||
lfs_file_read(&lfs, &file, rb, size) => trunc;
|
# lfs_file_read(&lfs, &file, rb, size) => trunc;
|
||||||
memcmp(rb, wb, trunc) => 0;
|
# memcmp(rb, wb, trunc) => 0;
|
||||||
|
#
|
||||||
/* Move to 1/4 */
|
# /* Move to 1/4 */
|
||||||
lfs_file_size(&lfs, &file) => trunc;
|
# lfs_file_size(&lfs, &file) => trunc;
|
||||||
lfs_file_seek(&lfs, &file, qsize, LFS_SEEK_SET) => qsize;
|
# lfs_file_seek(&lfs, &file, qsize, LFS_SEEK_SET) => qsize;
|
||||||
lfs_file_tell(&lfs, &file) => qsize;
|
# lfs_file_tell(&lfs, &file) => qsize;
|
||||||
|
#
|
||||||
/* Chop to 1/2 */
|
# /* Chop to 1/2 */
|
||||||
trunc -= qsize;
|
# trunc -= qsize;
|
||||||
lfs_file_truncate(&lfs, &file, trunc) => 0;
|
# lfs_file_truncate(&lfs, &file, trunc) => 0;
|
||||||
lfs_file_tell(&lfs, &file) => qsize;
|
# lfs_file_tell(&lfs, &file) => qsize;
|
||||||
lfs_file_size(&lfs, &file) => trunc;
|
# lfs_file_size(&lfs, &file) => trunc;
|
||||||
|
#
|
||||||
/* Read should produce second quarter */
|
# /* Read should produce second quarter */
|
||||||
lfs_file_read(&lfs, &file, rb, size) => trunc - qsize;
|
# lfs_file_read(&lfs, &file, rb, size) => trunc - qsize;
|
||||||
memcmp(rb, wb + qsize, trunc - qsize) => 0;
|
# memcmp(rb, wb + qsize, trunc - qsize) => 0;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# truncate and write
|
## truncate and write
|
||||||
[cases.test_truncate_write]
|
#[cases.test_truncate_write]
|
||||||
defines.MEDIUMSIZE = [32, 2048]
|
#defines.MEDIUMSIZE = [32, 2048]
|
||||||
defines.LARGESIZE = 8192
|
#defines.LARGESIZE = 8192
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "baldywrite",
|
# lfs_file_open(&lfs, &file, "baldywrite",
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
|
#
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
strcpy((char*)buffer, "hair");
|
# strcpy((char*)buffer, "hair");
|
||||||
size_t size = strlen((char*)buffer);
|
# size_t size = strlen((char*)buffer);
|
||||||
for (lfs_off_t j = 0; j < LARGESIZE; j += size) {
|
# for (lfs_off_t j = 0; j < LARGESIZE; j += size) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
}
|
# }
|
||||||
lfs_file_size(&lfs, &file) => LARGESIZE;
|
# lfs_file_size(&lfs, &file) => LARGESIZE;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_open(&lfs, &file, "baldywrite", LFS_O_RDWR) => 0;
|
# lfs_file_open(&lfs, &file, "baldywrite", LFS_O_RDWR) => 0;
|
||||||
lfs_file_size(&lfs, &file) => LARGESIZE;
|
# lfs_file_size(&lfs, &file) => LARGESIZE;
|
||||||
|
#
|
||||||
lfs_file_truncate(&lfs, &file, MEDIUMSIZE) => 0;
|
# lfs_file_truncate(&lfs, &file, MEDIUMSIZE) => 0;
|
||||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
# lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||||
|
#
|
||||||
strcpy((char*)buffer, "bald");
|
# strcpy((char*)buffer, "bald");
|
||||||
size = strlen((char*)buffer);
|
# size = strlen((char*)buffer);
|
||||||
for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
# for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
}
|
# }
|
||||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
# lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_open(&lfs, &file, "baldywrite", LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, "baldywrite", LFS_O_RDONLY) => 0;
|
||||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
# lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||||
|
#
|
||||||
size = strlen("bald");
|
# size = strlen("bald");
|
||||||
for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
# for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "bald", size) => 0;
|
# memcmp(buffer, "bald", size) => 0;
|
||||||
}
|
# }
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => 0;
|
# lfs_file_read(&lfs, &file, buffer, size) => 0;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# truncate write under powerloss
|
## truncate write under powerloss
|
||||||
[cases.test_truncate_reentrant_write]
|
#[cases.test_truncate_reentrant_write]
|
||||||
defines.SMALLSIZE = [4, 512]
|
#defines.SMALLSIZE = [4, 512]
|
||||||
defines.MEDIUMSIZE = [32, 1024]
|
#defines.MEDIUMSIZE = [32, 1024]
|
||||||
defines.LARGESIZE = 2048
|
#defines.LARGESIZE = 2048
|
||||||
reentrant = true
|
#reentrant = true
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
int err = lfs_mount(&lfs, cfg);
|
# int err = lfs_mount(&lfs, cfg);
|
||||||
if (err) {
|
# if (err) {
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
}
|
# }
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
err = lfs_file_open(&lfs, &file, "baldy", LFS_O_RDONLY);
|
# err = lfs_file_open(&lfs, &file, "baldy", LFS_O_RDONLY);
|
||||||
assert(!err || err == LFS_ERR_NOENT);
|
# assert(!err || err == LFS_ERR_NOENT);
|
||||||
if (!err) {
|
# if (!err) {
|
||||||
size_t size = lfs_file_size(&lfs, &file);
|
# size_t size = lfs_file_size(&lfs, &file);
|
||||||
assert(size == 0 ||
|
# assert(size == 0 ||
|
||||||
size == (size_t)LARGESIZE ||
|
# size == (size_t)LARGESIZE ||
|
||||||
size == (size_t)MEDIUMSIZE ||
|
# size == (size_t)MEDIUMSIZE ||
|
||||||
size == (size_t)SMALLSIZE);
|
# size == (size_t)SMALLSIZE);
|
||||||
for (lfs_off_t j = 0; j < size; j += 4) {
|
# for (lfs_off_t j = 0; j < size; j += 4) {
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
lfs_file_read(&lfs, &file, buffer, 4) => 4;
|
# lfs_file_read(&lfs, &file, buffer, 4) => 4;
|
||||||
assert(memcmp(buffer, "hair", 4) == 0 ||
|
# assert(memcmp(buffer, "hair", 4) == 0 ||
|
||||||
memcmp(buffer, "bald", 4) == 0 ||
|
# memcmp(buffer, "bald", 4) == 0 ||
|
||||||
memcmp(buffer, "comb", 4) == 0);
|
# memcmp(buffer, "comb", 4) == 0);
|
||||||
}
|
# }
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_open(&lfs, &file, "baldy",
|
# lfs_file_open(&lfs, &file, "baldy",
|
||||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
|
||||||
lfs_file_size(&lfs, &file) => 0;
|
# lfs_file_size(&lfs, &file) => 0;
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
strcpy((char*)buffer, "hair");
|
# strcpy((char*)buffer, "hair");
|
||||||
size_t size = strlen((char*)buffer);
|
# size_t size = strlen((char*)buffer);
|
||||||
for (lfs_off_t j = 0; j < LARGESIZE; j += size) {
|
# for (lfs_off_t j = 0; j < LARGESIZE; j += size) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
}
|
# }
|
||||||
lfs_file_size(&lfs, &file) => LARGESIZE;
|
# lfs_file_size(&lfs, &file) => LARGESIZE;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
lfs_file_open(&lfs, &file, "baldy", LFS_O_RDWR) => 0;
|
# lfs_file_open(&lfs, &file, "baldy", LFS_O_RDWR) => 0;
|
||||||
lfs_file_size(&lfs, &file) => LARGESIZE;
|
# lfs_file_size(&lfs, &file) => LARGESIZE;
|
||||||
lfs_file_truncate(&lfs, &file, MEDIUMSIZE) => 0;
|
# lfs_file_truncate(&lfs, &file, MEDIUMSIZE) => 0;
|
||||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
# lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||||
strcpy((char*)buffer, "bald");
|
# strcpy((char*)buffer, "bald");
|
||||||
size = strlen((char*)buffer);
|
# size = strlen((char*)buffer);
|
||||||
for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
# for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
}
|
# }
|
||||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
# lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
lfs_file_open(&lfs, &file, "baldy", LFS_O_RDWR) => 0;
|
# lfs_file_open(&lfs, &file, "baldy", LFS_O_RDWR) => 0;
|
||||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
# lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||||
lfs_file_truncate(&lfs, &file, SMALLSIZE) => 0;
|
# lfs_file_truncate(&lfs, &file, SMALLSIZE) => 0;
|
||||||
lfs_file_size(&lfs, &file) => SMALLSIZE;
|
# lfs_file_size(&lfs, &file) => SMALLSIZE;
|
||||||
strcpy((char*)buffer, "comb");
|
# strcpy((char*)buffer, "comb");
|
||||||
size = strlen((char*)buffer);
|
# size = strlen((char*)buffer);
|
||||||
for (lfs_off_t j = 0; j < SMALLSIZE; j += size) {
|
# for (lfs_off_t j = 0; j < SMALLSIZE; j += size) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
}
|
# }
|
||||||
lfs_file_size(&lfs, &file) => SMALLSIZE;
|
# lfs_file_size(&lfs, &file) => SMALLSIZE;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
|
#
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# more aggressive general truncation tests
|
## more aggressive general truncation tests
|
||||||
[cases.test_truncate_aggressive]
|
#[cases.test_truncate_aggressive]
|
||||||
defines.CONFIG = 'range(6)'
|
#defines.CONFIG = 'range(6)'
|
||||||
defines.SMALLSIZE = 32
|
#defines.SMALLSIZE = 32
|
||||||
defines.MEDIUMSIZE = 2048
|
#defines.MEDIUMSIZE = 2048
|
||||||
defines.LARGESIZE = 8192
|
#defines.LARGESIZE = 8192
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
#define COUNT 5
|
# #define COUNT 5
|
||||||
const struct {
|
# const struct {
|
||||||
lfs_off_t startsizes[COUNT];
|
# lfs_off_t startsizes[COUNT];
|
||||||
lfs_off_t startseeks[COUNT];
|
# lfs_off_t startseeks[COUNT];
|
||||||
lfs_off_t hotsizes[COUNT];
|
# lfs_off_t hotsizes[COUNT];
|
||||||
lfs_off_t coldsizes[COUNT];
|
# lfs_off_t coldsizes[COUNT];
|
||||||
} configs[] = {
|
# } configs[] = {
|
||||||
// cold shrinking
|
# // cold shrinking
|
||||||
{{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
# {{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
||||||
{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
# {2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
||||||
{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
# {2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
||||||
{ 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE, 2*LARGESIZE}},
|
# { 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE, 2*LARGESIZE}},
|
||||||
// cold expanding
|
# // cold expanding
|
||||||
{{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
# {{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
||||||
{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
# {2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
||||||
{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
# {2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
||||||
{ 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE, 2*LARGESIZE}},
|
# { 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE, 2*LARGESIZE}},
|
||||||
// warm shrinking truncate
|
# // warm shrinking truncate
|
||||||
{{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
# {{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
||||||
{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
# {2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
||||||
{ 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE, 2*LARGESIZE},
|
# { 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE, 2*LARGESIZE},
|
||||||
{ 0, 0, 0, 0, 0}},
|
# { 0, 0, 0, 0, 0}},
|
||||||
// warm expanding truncate
|
# // warm expanding truncate
|
||||||
{{ 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE, 2*LARGESIZE},
|
# {{ 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE, 2*LARGESIZE},
|
||||||
{ 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE, 2*LARGESIZE},
|
# { 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE, 2*LARGESIZE},
|
||||||
{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
# {2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
||||||
{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE}},
|
# {2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE}},
|
||||||
// mid-file shrinking truncate
|
# // mid-file shrinking truncate
|
||||||
{{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
# {{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
||||||
{ LARGESIZE, LARGESIZE, LARGESIZE, LARGESIZE, LARGESIZE},
|
# { LARGESIZE, LARGESIZE, LARGESIZE, LARGESIZE, LARGESIZE},
|
||||||
{ 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE, 2*LARGESIZE},
|
# { 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE, 2*LARGESIZE},
|
||||||
{ 0, 0, 0, 0, 0}},
|
# { 0, 0, 0, 0, 0}},
|
||||||
// mid-file expanding truncate
|
# // mid-file expanding truncate
|
||||||
{{ 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE, 2*LARGESIZE},
|
# {{ 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE, 2*LARGESIZE},
|
||||||
{ 0, 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE},
|
# { 0, 0, SMALLSIZE, MEDIUMSIZE, LARGESIZE},
|
||||||
{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
# {2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE},
|
||||||
{2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE}},
|
# {2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE, 2*LARGESIZE}},
|
||||||
};
|
# };
|
||||||
|
#
|
||||||
const lfs_off_t *startsizes = configs[CONFIG].startsizes;
|
# const lfs_off_t *startsizes = configs[CONFIG].startsizes;
|
||||||
const lfs_off_t *startseeks = configs[CONFIG].startseeks;
|
# const lfs_off_t *startseeks = configs[CONFIG].startseeks;
|
||||||
const lfs_off_t *hotsizes = configs[CONFIG].hotsizes;
|
# const lfs_off_t *hotsizes = configs[CONFIG].hotsizes;
|
||||||
const lfs_off_t *coldsizes = configs[CONFIG].coldsizes;
|
# const lfs_off_t *coldsizes = configs[CONFIG].coldsizes;
|
||||||
|
#
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
|
#
|
||||||
for (unsigned i = 0; i < COUNT; i++) {
|
# for (unsigned i = 0; i < COUNT; i++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "hairyhead%d", i);
|
# sprintf(path, "hairyhead%d", i);
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, path,
|
# lfs_file_open(&lfs, &file, path,
|
||||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
|
# LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
|
||||||
|
#
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
strcpy((char*)buffer, "hair");
|
# strcpy((char*)buffer, "hair");
|
||||||
size_t size = strlen((char*)buffer);
|
# size_t size = strlen((char*)buffer);
|
||||||
for (lfs_off_t j = 0; j < startsizes[i]; j += size) {
|
# for (lfs_off_t j = 0; j < startsizes[i]; j += size) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
}
|
# }
|
||||||
lfs_file_size(&lfs, &file) => startsizes[i];
|
# lfs_file_size(&lfs, &file) => startsizes[i];
|
||||||
|
#
|
||||||
if (startseeks[i] != startsizes[i]) {
|
# if (startseeks[i] != startsizes[i]) {
|
||||||
lfs_file_seek(&lfs, &file,
|
# lfs_file_seek(&lfs, &file,
|
||||||
startseeks[i], LFS_SEEK_SET) => startseeks[i];
|
# startseeks[i], LFS_SEEK_SET) => startseeks[i];
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_truncate(&lfs, &file, hotsizes[i]) => 0;
|
# lfs_file_truncate(&lfs, &file, hotsizes[i]) => 0;
|
||||||
lfs_file_size(&lfs, &file) => hotsizes[i];
|
# lfs_file_size(&lfs, &file) => hotsizes[i];
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
|
#
|
||||||
for (unsigned i = 0; i < COUNT; i++) {
|
# for (unsigned i = 0; i < COUNT; i++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "hairyhead%d", i);
|
# sprintf(path, "hairyhead%d", i);
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, path, LFS_O_RDWR) => 0;
|
# lfs_file_open(&lfs, &file, path, LFS_O_RDWR) => 0;
|
||||||
lfs_file_size(&lfs, &file) => hotsizes[i];
|
# lfs_file_size(&lfs, &file) => hotsizes[i];
|
||||||
|
#
|
||||||
size_t size = strlen("hair");
|
# size_t size = strlen("hair");
|
||||||
lfs_off_t j = 0;
|
# lfs_off_t j = 0;
|
||||||
for (; j < startsizes[i] && j < hotsizes[i]; j += size) {
|
# for (; j < startsizes[i] && j < hotsizes[i]; j += size) {
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "hair", size) => 0;
|
# memcmp(buffer, "hair", size) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (; j < hotsizes[i]; j += size) {
|
# for (; j < hotsizes[i]; j += size) {
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "\0\0\0\0", size) => 0;
|
# memcmp(buffer, "\0\0\0\0", size) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_truncate(&lfs, &file, coldsizes[i]) => 0;
|
# lfs_file_truncate(&lfs, &file, coldsizes[i]) => 0;
|
||||||
lfs_file_size(&lfs, &file) => coldsizes[i];
|
# lfs_file_size(&lfs, &file) => coldsizes[i];
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
|
#
|
||||||
for (unsigned i = 0; i < COUNT; i++) {
|
# for (unsigned i = 0; i < COUNT; i++) {
|
||||||
char path[1024];
|
# char path[1024];
|
||||||
sprintf(path, "hairyhead%d", i);
|
# sprintf(path, "hairyhead%d", i);
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
|
# lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
|
||||||
lfs_file_size(&lfs, &file) => coldsizes[i];
|
# lfs_file_size(&lfs, &file) => coldsizes[i];
|
||||||
|
#
|
||||||
size_t size = strlen("hair");
|
# size_t size = strlen("hair");
|
||||||
lfs_off_t j = 0;
|
# lfs_off_t j = 0;
|
||||||
for (; j < startsizes[i] && j < hotsizes[i] && j < coldsizes[i];
|
# for (; j < startsizes[i] && j < hotsizes[i] && j < coldsizes[i];
|
||||||
j += size) {
|
# j += size) {
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "hair", size) => 0;
|
# memcmp(buffer, "hair", size) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
for (; j < coldsizes[i]; j += size) {
|
# for (; j < coldsizes[i]; j += size) {
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "\0\0\0\0", size) => 0;
|
# memcmp(buffer, "\0\0\0\0", size) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
#
|
||||||
# noop truncate
|
## noop truncate
|
||||||
[cases.test_truncate_nop]
|
#[cases.test_truncate_nop]
|
||||||
defines.MEDIUMSIZE = [32, 2048]
|
#defines.MEDIUMSIZE = [32, 2048]
|
||||||
code = '''
|
#code = '''
|
||||||
lfs_t lfs;
|
# lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
# lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_t file;
|
# lfs_file_t file;
|
||||||
lfs_file_open(&lfs, &file, "baldynoop",
|
# lfs_file_open(&lfs, &file, "baldynoop",
|
||||||
LFS_O_RDWR | LFS_O_CREAT) => 0;
|
# LFS_O_RDWR | LFS_O_CREAT) => 0;
|
||||||
|
#
|
||||||
uint8_t buffer[1024];
|
# uint8_t buffer[1024];
|
||||||
strcpy((char*)buffer, "hair");
|
# strcpy((char*)buffer, "hair");
|
||||||
size_t size = strlen((char*)buffer);
|
# size_t size = strlen((char*)buffer);
|
||||||
for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
# for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
||||||
lfs_file_write(&lfs, &file, buffer, size) => size;
|
# lfs_file_write(&lfs, &file, buffer, size) => size;
|
||||||
|
#
|
||||||
// this truncate should do nothing
|
# // this truncate should do nothing
|
||||||
lfs_file_truncate(&lfs, &file, j+size) => 0;
|
# lfs_file_truncate(&lfs, &file, j+size) => 0;
|
||||||
}
|
# }
|
||||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
# lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||||
|
#
|
||||||
lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
|
# lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
|
||||||
// should do nothing again
|
# // should do nothing again
|
||||||
lfs_file_truncate(&lfs, &file, MEDIUMSIZE) => 0;
|
# lfs_file_truncate(&lfs, &file, MEDIUMSIZE) => 0;
|
||||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
# lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||||
|
#
|
||||||
for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
# for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "hair", size) => 0;
|
# memcmp(buffer, "hair", size) => 0;
|
||||||
}
|
# }
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => 0;
|
# lfs_file_read(&lfs, &file, buffer, size) => 0;
|
||||||
|
#
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
|
#
|
||||||
// still there after reboot?
|
# // still there after reboot?
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
# lfs_mount(&lfs, cfg) => 0;
|
||||||
lfs_file_open(&lfs, &file, "baldynoop", LFS_O_RDWR) => 0;
|
# lfs_file_open(&lfs, &file, "baldynoop", LFS_O_RDWR) => 0;
|
||||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
# lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||||
for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
# for (lfs_off_t j = 0; j < MEDIUMSIZE; j += size) {
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
# lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||||
memcmp(buffer, "hair", size) => 0;
|
# memcmp(buffer, "hair", size) => 0;
|
||||||
}
|
# }
|
||||||
lfs_file_read(&lfs, &file, buffer, size) => 0;
|
# lfs_file_read(&lfs, &file, buffer, size) => 0;
|
||||||
lfs_file_close(&lfs, &file) => 0;
|
# lfs_file_close(&lfs, &file) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
# lfs_unmount(&lfs) => 0;
|
||||||
'''
|
#'''
|
||||||
|
|||||||
Reference in New Issue
Block a user