Exploring ideas for static configuration
As an embedded library, littlefs's configuration straddles two worlds.
In most cases the configuration is usually constant at build time, but
when integrated into OSs, the configuration needs to be dynamically
configurable.
To help with this, littlefs has a separate lfs_config struct that can be
placed into ROM when possible.
But you know what's better than ROM configuration? Truely inlinable
static configuration known at compile-time. In addition to avoiding the
RAM cost, compile-time configuration allows for additional compiler
optimizations, such as constexpr-elimination and removal of unused
code-paths.
So how to enable static configuration?
1. define LFS_STATICCFG
2. implement callbacks as global functions:
- lfs_read
- lfs_prog
- lfs_erase
- lfs_sync
2. define the now-required constants that configure littlefs:
- LFS_READ_SIZE
- LFS_PROG_SIZE
- LFS_BLOCK_SIZE
- LFS_BLOCK_COUNT
- LFS_BLOCK_CYCLES
- LFS_CACHE_SIZE
- LFS_LOOKAHEAD_SIZE
- LFS_READ_BUFFER (optional)
- LFS_PROG_BUFFER (optional)
- LFS_LOOKAHEAD_BUFFER (optional)
- LFS_NAME_MAX (optional)
- LFS_FILE_MAX (optional)
- LFS_ATTR_MAX (optional)
Note, there is a separate configuration for the file configuration, this
can be enabled/disabled independently of LFS_STATICCFG. You will likely
want to define this as well if you are looking for the smallest code
size.
In order to avoid a mess of #ifdefs, the internals of littlefs use a
simple macro that redirects to either the dynamic or static config at
compile time:
#ifdef LFS_STATICCFG
#define LFS_CFG_READ_SIZE(lfs) ((void)lfs, LFS_READ_SIZE)
#else
#define LFS_CFG_READ_SIZE(lfs) lfs->cfg->read_size
#endif
Unfortunately it does look like there still may be a lot of issues
related to warnings of comparisons against constants... If only C had
a way to ignore warnings on individual statements...
Original idea by apmorton
This commit is contained in:
+41
-41
@@ -9,12 +9,12 @@ code = '''
|
||||
const char *names[FILES] = {"bacon", "eggs", "pancakes"};
|
||||
lfs_file_t files[FILES];
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "breakfast") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int n = 0; n < FILES; n++) {
|
||||
sprintf(path, "breakfast/%s", names[n]);
|
||||
lfs_file_open(&lfs, &files[n], path,
|
||||
@@ -31,7 +31,7 @@ code = '''
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int n = 0; n < FILES; n++) {
|
||||
sprintf(path, "breakfast/%s", names[n]);
|
||||
lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
|
||||
@@ -51,13 +51,13 @@ define.SIZE = '(((LFS_BLOCK_SIZE-8)*(LFS_BLOCK_COUNT-6)) / FILES)'
|
||||
code = '''
|
||||
const char *names[FILES] = {"bacon", "eggs", "pancakes"};
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "breakfast") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
for (int n = 0; n < FILES; n++) {
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
sprintf(path, "breakfast/%s", names[n]);
|
||||
lfs_file_open(&lfs, &file, path,
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
||||
@@ -70,7 +70,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
}
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int n = 0; n < FILES; n++) {
|
||||
sprintf(path, "breakfast/%s", names[n]);
|
||||
lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
|
||||
@@ -92,14 +92,14 @@ code = '''
|
||||
const char *names[FILES] = {"bacon", "eggs", "pancakes"};
|
||||
lfs_file_t files[FILES];
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "breakfast") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int n = 0; n < FILES; n++) {
|
||||
sprintf(path, "breakfast/%s", names[n]);
|
||||
lfs_file_open(&lfs, &files[n], path,
|
||||
@@ -116,7 +116,7 @@ code = '''
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int n = 0; n < FILES; n++) {
|
||||
sprintf(path, "breakfast/%s", names[n]);
|
||||
lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
|
||||
@@ -129,7 +129,7 @@ code = '''
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int n = 0; n < FILES; n++) {
|
||||
sprintf(path, "breakfast/%s", names[n]);
|
||||
lfs_remove(&lfs, path) => 0;
|
||||
@@ -146,15 +146,15 @@ define.CYCLES = [1, 10]
|
||||
code = '''
|
||||
const char *names[FILES] = {"bacon", "eggs", "pancakes"};
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "breakfast") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
for (int n = 0; n < FILES; n++) {
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
sprintf(path, "breakfast/%s", names[n]);
|
||||
lfs_file_open(&lfs, &file, path,
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
||||
@@ -167,7 +167,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
}
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int n = 0; n < FILES; n++) {
|
||||
sprintf(path, "breakfast/%s", names[n]);
|
||||
lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
|
||||
@@ -180,7 +180,7 @@ code = '''
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int n = 0; n < FILES; n++) {
|
||||
sprintf(path, "breakfast/%s", names[n]);
|
||||
lfs_remove(&lfs, path) => 0;
|
||||
@@ -192,8 +192,8 @@ code = '''
|
||||
|
||||
[[case]] # exhaustion test
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "exhaustion", LFS_O_WRONLY | LFS_O_CREAT);
|
||||
size = strlen("exhaustion");
|
||||
memcpy(buffer, "exhaustion", size);
|
||||
@@ -216,7 +216,7 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "exhaustion", LFS_O_RDONLY);
|
||||
size = strlen("exhaustion");
|
||||
lfs_file_size(&lfs, &file) => size;
|
||||
@@ -229,8 +229,8 @@ code = '''
|
||||
[[case]] # exhaustion wraparound test
|
||||
define.SIZE = '(((LFS_BLOCK_SIZE-8)*(LFS_BLOCK_COUNT-4)) / 3)'
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
lfs_file_open(&lfs, &file, "padding", LFS_O_WRONLY | LFS_O_CREAT);
|
||||
size = strlen("buffering");
|
||||
@@ -263,7 +263,7 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "exhaustion", LFS_O_RDONLY);
|
||||
size = strlen("exhaustion");
|
||||
lfs_file_size(&lfs, &file) => size;
|
||||
@@ -276,8 +276,8 @@ code = '''
|
||||
|
||||
[[case]] # dir exhaustion test
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// find out max file size
|
||||
lfs_mkdir(&lfs, "exhaustiondir") => 0;
|
||||
@@ -328,8 +328,8 @@ in = "lfs.c"
|
||||
define.LFS_ERASE_CYCLES = 0xffffffff
|
||||
define.LFS_BADBLOCK_BEHAVIOR = 'LFS_TESTBD_BADBLOCK_READERROR'
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
// first fill to exhaustion to find available space
|
||||
lfs_file_open(&lfs, &file, "pacman", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||
strcpy((char*)buffer, "waka");
|
||||
@@ -358,7 +358,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// remount to force an alloc scan
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// but mark the head of our file as a "bad block", this is force our
|
||||
// scan to bail early
|
||||
@@ -393,7 +393,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// check that the disk isn't hurt
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "pacman", LFS_O_RDONLY) => 0;
|
||||
strcpy((char*)buffer, "waka");
|
||||
size = strlen("waka");
|
||||
@@ -416,8 +416,8 @@ define.LFS_BLOCK_SIZE = 512
|
||||
define.LFS_BLOCK_COUNT = 1024
|
||||
if = 'LFS_BLOCK_SIZE == 512 && LFS_BLOCK_COUNT == 1024'
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// find out max file size
|
||||
lfs_mkdir(&lfs, "exhaustiondir") => 0;
|
||||
@@ -487,8 +487,8 @@ define.LFS_BLOCK_SIZE = 512
|
||||
define.LFS_BLOCK_COUNT = 1024
|
||||
if = 'LFS_BLOCK_SIZE == 512 && LFS_BLOCK_COUNT == 1024'
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// create one block hole for half a directory
|
||||
lfs_file_open(&lfs, &file, "bump", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||
@@ -510,7 +510,7 @@ code = '''
|
||||
|
||||
// remount to force reset of lookahead
|
||||
lfs_unmount(&lfs) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// open hole
|
||||
lfs_remove(&lfs, "bump") => 0;
|
||||
@@ -532,8 +532,8 @@ define.LFS_BLOCK_SIZE = 512
|
||||
define.LFS_BLOCK_COUNT = 1024
|
||||
if = 'LFS_BLOCK_SIZE == 512 && LFS_BLOCK_COUNT == 1024'
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// fill completely with two files
|
||||
lfs_file_open(&lfs, &file, "exhaustion1",
|
||||
@@ -560,7 +560,7 @@ code = '''
|
||||
|
||||
// remount to force reset of lookahead
|
||||
lfs_unmount(&lfs) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// rewrite one file
|
||||
lfs_file_open(&lfs, &file, "exhaustion1",
|
||||
@@ -597,8 +597,8 @@ define.LFS_BLOCK_SIZE = 512
|
||||
define.LFS_BLOCK_COUNT = 1024
|
||||
if = 'LFS_BLOCK_SIZE == 512 && LFS_BLOCK_COUNT == 1024'
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// fill completely with two files
|
||||
lfs_file_open(&lfs, &file, "exhaustion1",
|
||||
@@ -625,7 +625,7 @@ code = '''
|
||||
|
||||
// remount to force reset of lookahead
|
||||
lfs_unmount(&lfs) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// rewrite one file with a hole of one block
|
||||
lfs_file_open(&lfs, &file, "exhaustion1",
|
||||
|
||||
+15
-15
@@ -1,14 +1,14 @@
|
||||
[[case]] # set/get attribute
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "hello") => 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_close(&lfs, &file);
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
lfs_setattr(&lfs, "hello", 'A', "aaaa", 4) => 0;
|
||||
lfs_setattr(&lfs, "hello", 'B', "bbbbbb", 6) => 0;
|
||||
@@ -60,7 +60,7 @@ code = '''
|
||||
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
|
||||
lfs_getattr(&lfs, "hello", 'B', buffer+4, 9) => 9;
|
||||
@@ -78,15 +78,15 @@ code = '''
|
||||
|
||||
[[case]] # set/get root attribute
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "hello") => 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_close(&lfs, &file);
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
lfs_setattr(&lfs, "/", 'A', "aaaa", 4) => 0;
|
||||
lfs_setattr(&lfs, "/", 'B', "bbbbbb", 6) => 0;
|
||||
@@ -137,7 +137,7 @@ code = '''
|
||||
lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
|
||||
lfs_getattr(&lfs, "/", 'B', buffer+4, 9) => 9;
|
||||
@@ -155,15 +155,15 @@ code = '''
|
||||
|
||||
[[case]] # set/get file attribute
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "hello") => 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_close(&lfs, &file);
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
struct lfs_attr attrs1[] = {
|
||||
{'A', buffer, 4},
|
||||
@@ -238,7 +238,7 @@ code = '''
|
||||
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
struct lfs_attr attrs3[] = {
|
||||
{'A', buffer, 4},
|
||||
@@ -262,15 +262,15 @@ code = '''
|
||||
|
||||
[[case]] # deferred file attributes
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "hello") => 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_close(&lfs, &file);
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_setattr(&lfs, "hello/hello", 'B', "fffffffff", 9) => 0;
|
||||
lfs_setattr(&lfs, "hello/hello", 'C', "ccccc", 5) => 0;
|
||||
|
||||
|
||||
+11
-11
@@ -19,9 +19,9 @@ code = '''
|
||||
lfs_testbd_setwear(&cfg, badblock-1, 0) => 0;
|
||||
lfs_testbd_setwear(&cfg, badblock, 0xffffffff) => 0;
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 1; i < 10; i++) {
|
||||
for (int j = 0; j < NAMEMULT; j++) {
|
||||
buffer[j] = '0'+i;
|
||||
@@ -46,7 +46,7 @@ code = '''
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 1; i < 10; i++) {
|
||||
for (int j = 0; j < NAMEMULT; j++) {
|
||||
buffer[j] = '0'+i;
|
||||
@@ -93,9 +93,9 @@ code = '''
|
||||
lfs_testbd_setwear(&cfg, i+2, 0xffffffff) => 0;
|
||||
}
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 1; i < 10; i++) {
|
||||
for (int j = 0; j < NAMEMULT; j++) {
|
||||
buffer[j] = '0'+i;
|
||||
@@ -120,7 +120,7 @@ code = '''
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 1; i < 10; i++) {
|
||||
for (int j = 0; j < NAMEMULT; j++) {
|
||||
buffer[j] = '0'+i;
|
||||
@@ -166,9 +166,9 @@ code = '''
|
||||
lfs_testbd_setwear(&cfg, (2*i) + 2, 0xffffffff) => 0;
|
||||
}
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 1; i < 10; i++) {
|
||||
for (int j = 0; j < NAMEMULT; j++) {
|
||||
buffer[j] = '0'+i;
|
||||
@@ -193,7 +193,7 @@ code = '''
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 1; i < 10; i++) {
|
||||
for (int j = 0; j < NAMEMULT; j++) {
|
||||
buffer[j] = '0'+i;
|
||||
@@ -236,6 +236,6 @@ code = '''
|
||||
lfs_testbd_setwear(&cfg, 0, 0xffffffff) => 0;
|
||||
lfs_testbd_setwear(&cfg, 1, 0xffffffff) => 0;
|
||||
|
||||
lfs_format(&lfs, &cfg) => LFS_ERR_NOSPC;
|
||||
lfs_mount(&lfs, &cfg) => LFS_ERR_CORRUPT;
|
||||
lfs_formatcfg(&lfs, &cfg) => LFS_ERR_NOSPC;
|
||||
lfs_mountcfg(&lfs, &cfg) => LFS_ERR_CORRUPT;
|
||||
'''
|
||||
|
||||
+60
-60
@@ -1,7 +1,7 @@
|
||||
[[case]] # root
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(info.type == LFS_TYPE_DIR);
|
||||
@@ -17,16 +17,16 @@ code = '''
|
||||
[[case]] # many directory creation
|
||||
define.N = 'range(0, 100, 3)'
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
sprintf(path, "dir%03d", i);
|
||||
lfs_mkdir(&lfs, path) => 0;
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(info.type == LFS_TYPE_DIR);
|
||||
@@ -48,16 +48,16 @@ code = '''
|
||||
[[case]] # many directory removal
|
||||
define.N = 'range(3, 100, 11)'
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
sprintf(path, "removeme%03d", i);
|
||||
lfs_mkdir(&lfs, path) => 0;
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(info.type == LFS_TYPE_DIR);
|
||||
@@ -75,14 +75,14 @@ code = '''
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
lfs_unmount(&lfs);
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
sprintf(path, "removeme%03d", i);
|
||||
lfs_remove(&lfs, path) => 0;
|
||||
}
|
||||
lfs_unmount(&lfs);
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(info.type == LFS_TYPE_DIR);
|
||||
@@ -98,16 +98,16 @@ code = '''
|
||||
[[case]] # many directory rename
|
||||
define.N = 'range(3, 100, 11)'
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
sprintf(path, "test%03d", i);
|
||||
lfs_mkdir(&lfs, path) => 0;
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(info.type == LFS_TYPE_DIR);
|
||||
@@ -125,7 +125,7 @@ code = '''
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
lfs_unmount(&lfs);
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
char oldpath[128];
|
||||
char newpath[128];
|
||||
@@ -135,7 +135,7 @@ code = '''
|
||||
}
|
||||
lfs_unmount(&lfs);
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(info.type == LFS_TYPE_DIR);
|
||||
@@ -158,10 +158,10 @@ code = '''
|
||||
define.N = [5, 11]
|
||||
reentrant = true
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
err = lfs_mountcfg(&lfs, &cfg);
|
||||
if (err) {
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
@@ -237,9 +237,9 @@ code = '''
|
||||
[[case]] # file creation
|
||||
define.N = 'range(3, 100, 11)'
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
sprintf(path, "file%03d", i);
|
||||
lfs_file_open(&lfs, &file, path,
|
||||
@@ -248,7 +248,7 @@ code = '''
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(info.type == LFS_TYPE_DIR);
|
||||
@@ -270,9 +270,9 @@ code = '''
|
||||
[[case]] # file removal
|
||||
define.N = 'range(0, 100, 3)'
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
sprintf(path, "removeme%03d", i);
|
||||
lfs_file_open(&lfs, &file, path,
|
||||
@@ -281,7 +281,7 @@ code = '''
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(info.type == LFS_TYPE_DIR);
|
||||
@@ -299,14 +299,14 @@ code = '''
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
lfs_unmount(&lfs);
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
sprintf(path, "removeme%03d", i);
|
||||
lfs_remove(&lfs, path) => 0;
|
||||
}
|
||||
lfs_unmount(&lfs);
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(info.type == LFS_TYPE_DIR);
|
||||
@@ -322,9 +322,9 @@ code = '''
|
||||
[[case]] # file rename
|
||||
define.N = 'range(0, 100, 3)'
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
sprintf(path, "test%03d", i);
|
||||
lfs_file_open(&lfs, &file, path,
|
||||
@@ -333,7 +333,7 @@ code = '''
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(info.type == LFS_TYPE_DIR);
|
||||
@@ -351,7 +351,7 @@ code = '''
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
lfs_unmount(&lfs);
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
char oldpath[128];
|
||||
char newpath[128];
|
||||
@@ -361,7 +361,7 @@ code = '''
|
||||
}
|
||||
lfs_unmount(&lfs);
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(info.type == LFS_TYPE_DIR);
|
||||
@@ -384,10 +384,10 @@ code = '''
|
||||
define.N = [5, 25]
|
||||
reentrant = true
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
err = lfs_mountcfg(&lfs, &cfg);
|
||||
if (err) {
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
@@ -462,21 +462,21 @@ code = '''
|
||||
|
||||
[[case]] # nested directories
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "potato") => 0;
|
||||
lfs_file_open(&lfs, &file, "burito",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "potato/baked") => 0;
|
||||
lfs_mkdir(&lfs, "potato/sweet") => 0;
|
||||
lfs_mkdir(&lfs, "potato/fried") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "potato") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(strcmp(info.name, ".") == 0);
|
||||
@@ -498,21 +498,21 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// try removing?
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_remove(&lfs, "potato") => LFS_ERR_NOTEMPTY;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// try renaming?
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_rename(&lfs, "potato", "coldpotato") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_rename(&lfs, "coldpotato", "warmpotato") => 0;
|
||||
lfs_rename(&lfs, "warmpotato", "hotpotato") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_remove(&lfs, "potato") => LFS_ERR_NOENT;
|
||||
lfs_remove(&lfs, "coldpotato") => LFS_ERR_NOENT;
|
||||
lfs_remove(&lfs, "warmpotato") => LFS_ERR_NOENT;
|
||||
@@ -520,7 +520,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// try cross-directory renaming
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "coldpotato") => 0;
|
||||
lfs_rename(&lfs, "hotpotato/baked", "coldpotato/baked") => 0;
|
||||
lfs_rename(&lfs, "coldpotato", "hotpotato") => LFS_ERR_NOTEMPTY;
|
||||
@@ -536,7 +536,7 @@ code = '''
|
||||
lfs_remove(&lfs, "hotpotato") => LFS_ERR_NOTEMPTY;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "hotpotato") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(strcmp(info.name, ".") == 0);
|
||||
@@ -558,7 +558,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// final remove
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_remove(&lfs, "hotpotato") => LFS_ERR_NOTEMPTY;
|
||||
lfs_remove(&lfs, "hotpotato/baked") => 0;
|
||||
lfs_remove(&lfs, "hotpotato") => LFS_ERR_NOTEMPTY;
|
||||
@@ -568,7 +568,7 @@ code = '''
|
||||
lfs_remove(&lfs, "hotpotato") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(strcmp(info.name, ".") == 0);
|
||||
@@ -587,8 +587,8 @@ code = '''
|
||||
[[case]] # recursive remove
|
||||
define.N = [10, 100]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "prickly-pear") => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
sprintf(path, "prickly-pear/cactus%03d", i);
|
||||
@@ -611,7 +611,7 @@ code = '''
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
lfs_unmount(&lfs);
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_remove(&lfs, "prickly-pear") => LFS_ERR_NOTEMPTY;
|
||||
|
||||
lfs_dir_open(&lfs, &dir, "prickly-pear") => 0;
|
||||
@@ -636,22 +636,22 @@ code = '''
|
||||
lfs_remove(&lfs, "prickly-pear") => LFS_ERR_NOENT;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_remove(&lfs, "prickly-pear") => LFS_ERR_NOENT;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
'''
|
||||
|
||||
[[case]] # other error cases
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "potato") => 0;
|
||||
lfs_file_open(&lfs, &file, "burito",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
lfs_mkdir(&lfs, "potato") => LFS_ERR_EXIST;
|
||||
lfs_mkdir(&lfs, "burito") => LFS_ERR_EXIST;
|
||||
@@ -696,7 +696,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// or on disk
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(info.type == LFS_TYPE_DIR);
|
||||
@@ -718,8 +718,8 @@ code = '''
|
||||
[[case]] # directory seek
|
||||
define.COUNT = [4, 128, 132]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "hello") => 0;
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
sprintf(path, "hello/kitty%03d", i);
|
||||
@@ -728,7 +728,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
for (int j = 2; j < COUNT; j++) {
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "hello") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(strcmp(info.name, ".") == 0);
|
||||
@@ -779,8 +779,8 @@ code = '''
|
||||
[[case]] # root seek
|
||||
define.COUNT = [4, 128, 132]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
sprintf(path, "hi%03d", i);
|
||||
lfs_mkdir(&lfs, path) => 0;
|
||||
@@ -788,7 +788,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
for (int j = 2; j < COUNT; j++) {
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(strcmp(info.name, ".") == 0);
|
||||
|
||||
+16
-16
@@ -10,8 +10,8 @@ code = '''
|
||||
uint8_t wbuffer[1024];
|
||||
uint8_t rbuffer[1024];
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// write hi0 20
|
||||
sprintf(path, "hi0"); size = 20;
|
||||
@@ -99,8 +99,8 @@ code = '''
|
||||
uint8_t wbuffer[1024];
|
||||
uint8_t rbuffer[1024];
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// write hi0 20
|
||||
sprintf(path, "hi0"); size = 20;
|
||||
@@ -188,8 +188,8 @@ code = '''
|
||||
uint8_t wbuffer[1024];
|
||||
uint8_t rbuffer[1024];
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// write hi0 200
|
||||
sprintf(path, "hi0"); size = 200;
|
||||
@@ -261,8 +261,8 @@ code = '''
|
||||
uint8_t wbuffer[1024];
|
||||
uint8_t rbuffer[1024];
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// write hi0 200
|
||||
sprintf(path, "hi0"); size = 200;
|
||||
@@ -350,8 +350,8 @@ code = '''
|
||||
uint8_t wbuffer[1024];
|
||||
uint8_t rbuffer[1024];
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// write hi0 200
|
||||
sprintf(path, "hi0"); size = 200;
|
||||
@@ -454,8 +454,8 @@ code = '''
|
||||
uint8_t wbuffer[1024];
|
||||
uint8_t rbuffer[1024];
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// write hi0 200
|
||||
sprintf(path, "hi0"); size = 200;
|
||||
@@ -549,9 +549,9 @@ code = '''
|
||||
|
||||
[[case]] # create too big
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
memset(path, 'm', 200);
|
||||
path[200] = '\0';
|
||||
|
||||
@@ -574,9 +574,9 @@ code = '''
|
||||
|
||||
[[case]] # resize too big
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
memset(path, 'm', 200);
|
||||
path[200] = '\0';
|
||||
|
||||
|
||||
+37
-29
@@ -9,10 +9,11 @@ define.INVALSET = [0x3, 0x1, 0x2]
|
||||
in = "lfs.c"
|
||||
code = '''
|
||||
// create littlefs
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// change tail-pointer to invalid pointers
|
||||
lfs_init(&lfs, &cfg) => 0;
|
||||
lfs.cfg = &cfg;
|
||||
lfs_initcommon(&lfs) => 0;
|
||||
lfs_mdir_t mdir;
|
||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||
lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
|
||||
@@ -23,7 +24,7 @@ code = '''
|
||||
lfs_deinit(&lfs) => 0;
|
||||
|
||||
// test that mount fails gracefully
|
||||
lfs_mount(&lfs, &cfg) => LFS_ERR_CORRUPT;
|
||||
lfs_mountcfg(&lfs, &cfg) => LFS_ERR_CORRUPT;
|
||||
'''
|
||||
|
||||
[[case]] # invalid dir pointer test
|
||||
@@ -31,14 +32,15 @@ define.INVALSET = [0x3, 0x1, 0x2]
|
||||
in = "lfs.c"
|
||||
code = '''
|
||||
// create littlefs
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
// make a dir
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "dir_here") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// change the dir pointer to be invalid
|
||||
lfs_init(&lfs, &cfg) => 0;
|
||||
lfs.cfg = &cfg;
|
||||
lfs_initcommon(&lfs) => 0;
|
||||
lfs_mdir_t mdir;
|
||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||
// make sure id 1 == our directory
|
||||
@@ -57,7 +59,7 @@ code = '''
|
||||
|
||||
// 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
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_stat(&lfs, "dir_here", &info) => 0;
|
||||
assert(strcmp(info.name, "dir_here") == 0);
|
||||
assert(info.type == LFS_TYPE_DIR);
|
||||
@@ -77,16 +79,17 @@ in = "lfs.c"
|
||||
define.SIZE = [10, 1000, 100000] # faked file size
|
||||
code = '''
|
||||
// create littlefs
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
// make a file
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "file_here",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// change the file pointer to be invalid
|
||||
lfs_init(&lfs, &cfg) => 0;
|
||||
lfs.cfg = &cfg;
|
||||
lfs_initcommon(&lfs) => 0;
|
||||
lfs_mdir_t mdir;
|
||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||
// make sure id 1 == our file
|
||||
@@ -103,7 +106,7 @@ code = '''
|
||||
|
||||
// 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
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_stat(&lfs, "file_here", &info) => 0;
|
||||
assert(strcmp(info.name, "file_here") == 0);
|
||||
assert(info.type == LFS_TYPE_REG);
|
||||
@@ -125,9 +128,9 @@ define.SIZE = ['2*LFS_BLOCK_SIZE', '3*LFS_BLOCK_SIZE', '4*LFS_BLOCK_SIZE']
|
||||
in = "lfs.c"
|
||||
code = '''
|
||||
// create littlefs
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
// make a file
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "file_here",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@@ -137,7 +140,8 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
// change pointer in CTZ skip-list to be invalid
|
||||
lfs_init(&lfs, &cfg) => 0;
|
||||
lfs.cfg = &cfg;
|
||||
lfs_initcommon(&lfs) => 0;
|
||||
lfs_mdir_t mdir;
|
||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||
// make sure id 1 == our file and get our CTZ structure
|
||||
@@ -164,7 +168,7 @@ code = '''
|
||||
|
||||
// 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
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_stat(&lfs, "file_here", &info) => 0;
|
||||
assert(strcmp(info.name, "file_here") == 0);
|
||||
assert(info.type == LFS_TYPE_REG);
|
||||
@@ -187,10 +191,11 @@ define.INVALSET = [0x3, 0x1, 0x2]
|
||||
in = "lfs.c"
|
||||
code = '''
|
||||
// create littlefs
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// create an invalid gstate
|
||||
lfs_init(&lfs, &cfg) => 0;
|
||||
lfs.cfg = &cfg;
|
||||
lfs_initcommon(&lfs) => 0;
|
||||
lfs_mdir_t mdir;
|
||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||
lfs_fs_prepmove(&lfs, 1, (lfs_block_t [2]){
|
||||
@@ -202,7 +207,7 @@ code = '''
|
||||
// test that mount fails gracefully
|
||||
// mount may not fail, but our first alloc should fail when
|
||||
// we try to fix the gstate
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "should_fail") => LFS_ERR_CORRUPT;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
'''
|
||||
@@ -213,10 +218,11 @@ code = '''
|
||||
in = "lfs.c"
|
||||
code = '''
|
||||
// create littlefs
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// change tail-pointer to point to ourself
|
||||
lfs_init(&lfs, &cfg) => 0;
|
||||
lfs.cfg = &cfg;
|
||||
lfs_initcommon(&lfs) => 0;
|
||||
lfs_mdir_t mdir;
|
||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||
lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
|
||||
@@ -225,20 +231,21 @@ code = '''
|
||||
lfs_deinit(&lfs) => 0;
|
||||
|
||||
// test that mount fails gracefully
|
||||
lfs_mount(&lfs, &cfg) => LFS_ERR_CORRUPT;
|
||||
lfs_mountcfg(&lfs, &cfg) => LFS_ERR_CORRUPT;
|
||||
'''
|
||||
|
||||
[[case]] # metadata-pair threaded-list 2-length loop test
|
||||
in = "lfs.c"
|
||||
code = '''
|
||||
// create littlefs with child dir
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "child") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// find child
|
||||
lfs_init(&lfs, &cfg) => 0;
|
||||
lfs.cfg = &cfg;
|
||||
lfs_initcommon(&lfs) => 0;
|
||||
lfs_mdir_t mdir;
|
||||
lfs_block_t pair[2];
|
||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||
@@ -255,20 +262,21 @@ code = '''
|
||||
lfs_deinit(&lfs) => 0;
|
||||
|
||||
// test that mount fails gracefully
|
||||
lfs_mount(&lfs, &cfg) => LFS_ERR_CORRUPT;
|
||||
lfs_mountcfg(&lfs, &cfg) => LFS_ERR_CORRUPT;
|
||||
'''
|
||||
|
||||
[[case]] # metadata-pair threaded-list 1-length child loop test
|
||||
in = "lfs.c"
|
||||
code = '''
|
||||
// create littlefs with child dir
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "child") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// find child
|
||||
lfs_init(&lfs, &cfg) => 0;
|
||||
lfs.cfg = &cfg;
|
||||
lfs_initcommon(&lfs) => 0;
|
||||
lfs_mdir_t mdir;
|
||||
lfs_block_t pair[2];
|
||||
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
|
||||
@@ -284,5 +292,5 @@ code = '''
|
||||
lfs_deinit(&lfs) => 0;
|
||||
|
||||
// test that mount fails gracefully
|
||||
lfs_mount(&lfs, &cfg) => LFS_ERR_CORRUPT;
|
||||
lfs_mountcfg(&lfs, &cfg) => LFS_ERR_CORRUPT;
|
||||
'''
|
||||
|
||||
+18
-18
@@ -11,14 +11,14 @@ define.LFS_BADBLOCK_BEHAVIOR = [
|
||||
]
|
||||
define.FILES = 10
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "roadrunner") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
uint32_t cycle = 0;
|
||||
while (true) {
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (uint32_t i = 0; i < FILES; i++) {
|
||||
// chose name, roughly random seed, and random 2^n size
|
||||
sprintf(path, "roadrunner/test%d", i);
|
||||
@@ -71,7 +71,7 @@ code = '''
|
||||
|
||||
exhausted:
|
||||
// should still be readable
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (uint32_t i = 0; i < FILES; i++) {
|
||||
// check for errors
|
||||
sprintf(path, "roadrunner/test%d", i);
|
||||
@@ -96,11 +96,11 @@ define.LFS_BADBLOCK_BEHAVIOR = [
|
||||
]
|
||||
define.FILES = 10
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
uint32_t cycle = 0;
|
||||
while (true) {
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (uint32_t i = 0; i < FILES; i++) {
|
||||
// chose name, roughly random seed, and random 2^n size
|
||||
sprintf(path, "test%d", i);
|
||||
@@ -153,7 +153,7 @@ code = '''
|
||||
|
||||
exhausted:
|
||||
// should still be readable
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (uint32_t i = 0; i < FILES; i++) {
|
||||
// check for errors
|
||||
sprintf(path, "test%d", i);
|
||||
@@ -184,14 +184,14 @@ code = '''
|
||||
(b < run_block_count[run]) ? 0 : LFS_ERASE_CYCLES) => 0;
|
||||
}
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "roadrunner") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
uint32_t cycle = 0;
|
||||
while (true) {
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (uint32_t i = 0; i < FILES; i++) {
|
||||
// chose name, roughly random seed, and random 2^n size
|
||||
sprintf(path, "roadrunner/test%d", i);
|
||||
@@ -244,7 +244,7 @@ code = '''
|
||||
|
||||
exhausted:
|
||||
// should still be readable
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (uint32_t i = 0; i < FILES; i++) {
|
||||
// check for errors
|
||||
sprintf(path, "roadrunner/test%d", i);
|
||||
@@ -276,11 +276,11 @@ code = '''
|
||||
(b < run_block_count[run]) ? 0 : LFS_ERASE_CYCLES) => 0;
|
||||
}
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
uint32_t cycle = 0;
|
||||
while (true) {
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (uint32_t i = 0; i < FILES; i++) {
|
||||
// chose name, roughly random seed, and random 2^n size
|
||||
sprintf(path, "test%d", i);
|
||||
@@ -333,7 +333,7 @@ code = '''
|
||||
|
||||
exhausted:
|
||||
// should still be readable
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (uint32_t i = 0; i < FILES; i++) {
|
||||
// check for errors
|
||||
sprintf(path, "test%d", i);
|
||||
@@ -358,14 +358,14 @@ define.CYCLES = 100
|
||||
define.FILES = 10
|
||||
if = 'LFS_BLOCK_CYCLES < CYCLES/10'
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "roadrunner") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
uint32_t cycle = 0;
|
||||
while (cycle < CYCLES) {
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (uint32_t i = 0; i < FILES; i++) {
|
||||
// chose name, roughly random seed, and random 2^n size
|
||||
sprintf(path, "roadrunner/test%d", i);
|
||||
@@ -418,7 +418,7 @@ code = '''
|
||||
|
||||
exhausted:
|
||||
// should still be readable
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (uint32_t i = 0; i < FILES; i++) {
|
||||
// check for errors
|
||||
sprintf(path, "roadrunner/test%d", i);
|
||||
|
||||
+35
-35
@@ -1,8 +1,8 @@
|
||||
|
||||
[[case]] # simple file test
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "hello",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
||||
size = strlen("Hello World!")+1;
|
||||
@@ -11,7 +11,7 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "hello", LFS_O_RDONLY) => 0;
|
||||
lfs_file_read(&lfs, &file, buffer, size) => size;
|
||||
assert(strcmp((char*)buffer, "Hello World!") == 0);
|
||||
@@ -23,10 +23,10 @@ code = '''
|
||||
define.SIZE = [32, 8192, 262144, 0, 7, 8193]
|
||||
define.CHUNKSIZE = [31, 16, 33, 1, 1023]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// write
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "avacado",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
||||
srand(1);
|
||||
@@ -41,7 +41,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// read
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0;
|
||||
lfs_file_size(&lfs, &file) => SIZE;
|
||||
srand(1);
|
||||
@@ -62,10 +62,10 @@ define.SIZE1 = [32, 8192, 131072, 0, 7, 8193]
|
||||
define.SIZE2 = [32, 8192, 131072, 0, 7, 8193]
|
||||
define.CHUNKSIZE = [31, 16, 1]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// write
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "avacado",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
||||
srand(1);
|
||||
@@ -80,7 +80,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// read
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0;
|
||||
lfs_file_size(&lfs, &file) => SIZE1;
|
||||
srand(1);
|
||||
@@ -96,7 +96,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// rewrite
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "avacado", LFS_O_WRONLY) => 0;
|
||||
srand(2);
|
||||
for (lfs_size_t i = 0; i < SIZE2; i += CHUNKSIZE) {
|
||||
@@ -110,7 +110,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// read
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0;
|
||||
lfs_file_size(&lfs, &file) => lfs_max(SIZE1, SIZE2);
|
||||
srand(2);
|
||||
@@ -144,10 +144,10 @@ define.SIZE1 = [32, 8192, 131072, 0, 7, 8193]
|
||||
define.SIZE2 = [32, 8192, 131072, 0, 7, 8193]
|
||||
define.CHUNKSIZE = [31, 16, 1]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// write
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "avacado",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
||||
srand(1);
|
||||
@@ -162,7 +162,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// read
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0;
|
||||
lfs_file_size(&lfs, &file) => SIZE1;
|
||||
srand(1);
|
||||
@@ -178,7 +178,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// append
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "avacado", LFS_O_WRONLY | LFS_O_APPEND) => 0;
|
||||
srand(2);
|
||||
for (lfs_size_t i = 0; i < SIZE2; i += CHUNKSIZE) {
|
||||
@@ -192,7 +192,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// read
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0;
|
||||
lfs_file_size(&lfs, &file) => SIZE1 + SIZE2;
|
||||
srand(1);
|
||||
@@ -221,10 +221,10 @@ define.SIZE1 = [32, 8192, 131072, 0, 7, 8193]
|
||||
define.SIZE2 = [32, 8192, 131072, 0, 7, 8193]
|
||||
define.CHUNKSIZE = [31, 16, 1]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// write
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "avacado",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
||||
srand(1);
|
||||
@@ -239,7 +239,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// read
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0;
|
||||
lfs_file_size(&lfs, &file) => SIZE1;
|
||||
srand(1);
|
||||
@@ -255,7 +255,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// truncate
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "avacado", LFS_O_WRONLY | LFS_O_TRUNC) => 0;
|
||||
srand(2);
|
||||
for (lfs_size_t i = 0; i < SIZE2; i += CHUNKSIZE) {
|
||||
@@ -269,7 +269,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// read
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0;
|
||||
lfs_file_size(&lfs, &file) => SIZE2;
|
||||
srand(2);
|
||||
@@ -290,10 +290,10 @@ define.SIZE = [32, 0, 7, 2049]
|
||||
define.CHUNKSIZE = [31, 16, 65]
|
||||
reentrant = true
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
err = lfs_mountcfg(&lfs, &cfg);
|
||||
if (err) {
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
}
|
||||
|
||||
err = lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY);
|
||||
@@ -344,10 +344,10 @@ define = [
|
||||
]
|
||||
reentrant = true
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
err = lfs_mountcfg(&lfs, &cfg);
|
||||
if (err) {
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
}
|
||||
|
||||
err = lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY);
|
||||
@@ -406,9 +406,9 @@ code = '''
|
||||
[[case]] # many files
|
||||
define.N = 300
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
// create N files of 7 bytes
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
sprintf(path, "file_%03d", i);
|
||||
lfs_file_open(&lfs, &file, path,
|
||||
@@ -431,9 +431,9 @@ code = '''
|
||||
[[case]] # many files with power cycle
|
||||
define.N = 300
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
// create N files of 7 bytes
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
sprintf(path, "file_%03d", i);
|
||||
lfs_file_open(&lfs, &file, path,
|
||||
@@ -446,7 +446,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
char rbuffer[1024];
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
|
||||
lfs_file_read(&lfs, &file, rbuffer, size) => size;
|
||||
assert(strcmp(rbuffer, wbuffer) == 0);
|
||||
@@ -459,10 +459,10 @@ code = '''
|
||||
define.N = 300
|
||||
reentrant = true
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
err = lfs_mountcfg(&lfs, &cfg);
|
||||
if (err) {
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
}
|
||||
// create N files of 7 bytes
|
||||
for (int i = 0; i < N; i++) {
|
||||
|
||||
@@ -5,8 +5,8 @@ define.FILES = [4, 10, 26]
|
||||
code = '''
|
||||
lfs_file_t files[FILES];
|
||||
const char alphas[] = "abcdefghijklmnopqrstuvwxyz";
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int j = 0; j < FILES; j++) {
|
||||
sprintf(path, "%c", alphas[j]);
|
||||
lfs_file_open(&lfs, &files[j], path,
|
||||
@@ -64,8 +64,8 @@ define.SIZE = [10, 100]
|
||||
define.FILES = [4, 10, 26]
|
||||
code = '''
|
||||
const char alphas[] = "abcdefghijklmnopqrstuvwxyz";
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int j = 0; j < FILES; j++) {
|
||||
sprintf(path, "%c", alphas[j]);
|
||||
lfs_file_open(&lfs, &file, path,
|
||||
@@ -77,7 +77,7 @@ code = '''
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "zzz", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||
for (int j = 0; j < FILES; j++) {
|
||||
lfs_file_write(&lfs, &file, (const void*)"~", 1) => 1;
|
||||
@@ -115,8 +115,8 @@ code = '''
|
||||
[[case]] # remove inconveniently test
|
||||
define.SIZE = [10, 100]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_t files[3];
|
||||
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;
|
||||
@@ -180,10 +180,10 @@ code = '''
|
||||
lfs_file_t files[FILES];
|
||||
const char alphas[] = "abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
err = lfs_mountcfg(&lfs, &cfg);
|
||||
if (err) {
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
}
|
||||
|
||||
for (int j = 0; j < FILES; j++) {
|
||||
|
||||
+76
-76
@@ -1,7 +1,7 @@
|
||||
[[case]] # move file
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "a") => 0;
|
||||
lfs_mkdir(&lfs, "b") => 0;
|
||||
lfs_mkdir(&lfs, "c") => 0;
|
||||
@@ -13,11 +13,11 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_rename(&lfs, "a/hello", "c/hello") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(strcmp(info.name, ".") == 0);
|
||||
@@ -57,8 +57,8 @@ code = '''
|
||||
|
||||
[[case]] # noop move, yes this is legal
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "hi") => 0;
|
||||
lfs_rename(&lfs, "hi", "hi") => 0;
|
||||
lfs_mkdir(&lfs, "hi/hi") => 0;
|
||||
@@ -74,8 +74,8 @@ code = '''
|
||||
[[case]] # move file corrupt source
|
||||
in = "lfs.c"
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "a") => 0;
|
||||
lfs_mkdir(&lfs, "b") => 0;
|
||||
lfs_mkdir(&lfs, "c") => 0;
|
||||
@@ -87,12 +87,12 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_rename(&lfs, "a/hello", "c/hello") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// corrupt the source
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_block_t block = dir.m.pair[0];
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
@@ -108,7 +108,7 @@ code = '''
|
||||
cfg.prog(&cfg, block, 0, bbuffer, LFS_BLOCK_SIZE) => 0;
|
||||
cfg.sync(&cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(strcmp(info.name, ".") == 0);
|
||||
@@ -150,8 +150,8 @@ code = '''
|
||||
in = "lfs.c"
|
||||
if = 'LFS_PROG_SIZE <= 0x3fe' # only works with one crc per commit
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "a") => 0;
|
||||
lfs_mkdir(&lfs, "b") => 0;
|
||||
lfs_mkdir(&lfs, "c") => 0;
|
||||
@@ -163,12 +163,12 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_rename(&lfs, "a/hello", "c/hello") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// corrupt the source
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_block_t block = dir.m.pair[0];
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
@@ -185,7 +185,7 @@ code = '''
|
||||
cfg.sync(&cfg) => 0;
|
||||
|
||||
// corrupt the destination
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "c") => 0;
|
||||
block = dir.m.pair[0];
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
@@ -200,7 +200,7 @@ code = '''
|
||||
cfg.prog(&cfg, block, 0, bbuffer, LFS_BLOCK_SIZE) => 0;
|
||||
cfg.sync(&cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(strcmp(info.name, ".") == 0);
|
||||
@@ -242,8 +242,8 @@ code = '''
|
||||
in = "lfs.c"
|
||||
if = 'LFS_PROG_SIZE <= 0x3fe' # only works with one crc per commit
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "a") => 0;
|
||||
lfs_mkdir(&lfs, "b") => 0;
|
||||
lfs_mkdir(&lfs, "c") => 0;
|
||||
@@ -255,12 +255,12 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_rename(&lfs, "a/hello", "c/hello") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// corrupt the source
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_block_t block = dir.m.pair[0];
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
@@ -277,7 +277,7 @@ code = '''
|
||||
cfg.sync(&cfg) => 0;
|
||||
|
||||
// corrupt the destination
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "c") => 0;
|
||||
block = dir.m.pair[0];
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
@@ -293,11 +293,11 @@ code = '''
|
||||
cfg.sync(&cfg) => 0;
|
||||
|
||||
// continue move
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_rename(&lfs, "a/hello", "c/hello") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(strcmp(info.name, ".") == 0);
|
||||
@@ -338,10 +338,10 @@ code = '''
|
||||
[[case]] # simple reentrant move file
|
||||
reentrant = true
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
err = lfs_mountcfg(&lfs, &cfg);
|
||||
if (err) {
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
}
|
||||
err = lfs_mkdir(&lfs, "a");
|
||||
assert(!err || err == LFS_ERR_EXIST);
|
||||
@@ -354,7 +354,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
while (true) {
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
// there should never exist _2_ hello files
|
||||
int count = 0;
|
||||
if (lfs_stat(&lfs, "a/hello", &info) == 0) {
|
||||
@@ -384,7 +384,7 @@ code = '''
|
||||
assert(count <= 1);
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
if (lfs_stat(&lfs, "a/hello", &info) == 0 && info.size > 0) {
|
||||
lfs_rename(&lfs, "a/hello", "b/hello") => 0;
|
||||
} else if (lfs_stat(&lfs, "b/hello", &info) == 0) {
|
||||
@@ -407,7 +407,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
}
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(strcmp(info.name, ".") == 0);
|
||||
@@ -447,8 +447,8 @@ code = '''
|
||||
|
||||
[[case]] # move dir
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "a") => 0;
|
||||
lfs_mkdir(&lfs, "b") => 0;
|
||||
lfs_mkdir(&lfs, "c") => 0;
|
||||
@@ -459,11 +459,11 @@ code = '''
|
||||
lfs_mkdir(&lfs, "a/hi/ohayo") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_rename(&lfs, "a/hi", "c/hi") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(strcmp(info.name, ".") == 0);
|
||||
@@ -513,8 +513,8 @@ code = '''
|
||||
[[case]] # move dir corrupt source
|
||||
in = "lfs.c"
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "a") => 0;
|
||||
lfs_mkdir(&lfs, "b") => 0;
|
||||
lfs_mkdir(&lfs, "c") => 0;
|
||||
@@ -525,12 +525,12 @@ code = '''
|
||||
lfs_mkdir(&lfs, "a/hi/ohayo") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_rename(&lfs, "a/hi", "c/hi") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// corrupt the source
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_block_t block = dir.m.pair[0];
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
@@ -546,7 +546,7 @@ code = '''
|
||||
cfg.prog(&cfg, block, 0, bbuffer, LFS_BLOCK_SIZE) => 0;
|
||||
cfg.sync(&cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(strcmp(info.name, ".") == 0);
|
||||
@@ -597,8 +597,8 @@ code = '''
|
||||
in = "lfs.c"
|
||||
if = 'LFS_PROG_SIZE <= 0x3fe' # only works with one crc per commit
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "a") => 0;
|
||||
lfs_mkdir(&lfs, "b") => 0;
|
||||
lfs_mkdir(&lfs, "c") => 0;
|
||||
@@ -609,12 +609,12 @@ code = '''
|
||||
lfs_mkdir(&lfs, "a/hi/ohayo") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_rename(&lfs, "a/hi", "c/hi") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// corrupt the source
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_block_t block = dir.m.pair[0];
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
@@ -631,7 +631,7 @@ code = '''
|
||||
cfg.sync(&cfg) => 0;
|
||||
|
||||
// corrupt the destination
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "c") => 0;
|
||||
block = dir.m.pair[0];
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
@@ -646,7 +646,7 @@ code = '''
|
||||
cfg.prog(&cfg, block, 0, bbuffer, LFS_BLOCK_SIZE) => 0;
|
||||
cfg.sync(&cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(strcmp(info.name, ".") == 0);
|
||||
@@ -697,8 +697,8 @@ code = '''
|
||||
in = "lfs.c"
|
||||
if = 'LFS_PROG_SIZE <= 0x3fe' # only works with one crc per commit
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "a") => 0;
|
||||
lfs_mkdir(&lfs, "b") => 0;
|
||||
lfs_mkdir(&lfs, "c") => 0;
|
||||
@@ -709,12 +709,12 @@ code = '''
|
||||
lfs_mkdir(&lfs, "a/hi/ohayo") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_rename(&lfs, "a/hi", "c/hi") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// corrupt the source
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_block_t block = dir.m.pair[0];
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
@@ -731,7 +731,7 @@ code = '''
|
||||
cfg.sync(&cfg) => 0;
|
||||
|
||||
// corrupt the destination
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "c") => 0;
|
||||
block = dir.m.pair[0];
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
@@ -747,11 +747,11 @@ code = '''
|
||||
cfg.sync(&cfg) => 0;
|
||||
|
||||
// continue move
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_rename(&lfs, "a/hi", "c/hi") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(strcmp(info.name, ".") == 0);
|
||||
@@ -801,10 +801,10 @@ code = '''
|
||||
[[case]] # simple reentrant move dir
|
||||
reentrant = true
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
err = lfs_mountcfg(&lfs, &cfg);
|
||||
if (err) {
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
}
|
||||
err = lfs_mkdir(&lfs, "a");
|
||||
assert(!err || err == LFS_ERR_EXIST);
|
||||
@@ -817,7 +817,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
while (true) {
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
// there should never exist _2_ hi directories
|
||||
int count = 0;
|
||||
if (lfs_stat(&lfs, "a/hi", &info) == 0) {
|
||||
@@ -843,7 +843,7 @@ code = '''
|
||||
assert(count <= 1);
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
if (lfs_stat(&lfs, "a/hi", &info) == 0) {
|
||||
lfs_rename(&lfs, "a/hi", "b/hi") => 0;
|
||||
} else if (lfs_stat(&lfs, "b/hi", &info) == 0) {
|
||||
@@ -868,7 +868,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
}
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "a") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
assert(strcmp(info.name, ".") == 0);
|
||||
@@ -917,8 +917,8 @@ code = '''
|
||||
|
||||
[[case]] # move state stealing
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "a") => 0;
|
||||
lfs_mkdir(&lfs, "b") => 0;
|
||||
lfs_mkdir(&lfs, "c") => 0;
|
||||
@@ -930,17 +930,17 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_rename(&lfs, "a/hello", "b/hello") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_rename(&lfs, "b/hello", "c/hello") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_rename(&lfs, "c/hello", "d/hello") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "a/hello", LFS_O_RDONLY) => LFS_ERR_NOENT;
|
||||
lfs_file_open(&lfs, &file, "b/hello", LFS_O_RDONLY) => LFS_ERR_NOENT;
|
||||
lfs_file_open(&lfs, &file, "c/hello", LFS_O_RDONLY) => LFS_ERR_NOENT;
|
||||
@@ -954,12 +954,12 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_remove(&lfs, "b") => 0;
|
||||
lfs_remove(&lfs, "c") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_stat(&lfs, "a", &info) => 0;
|
||||
lfs_stat(&lfs, "b", &info) => LFS_ERR_NOENT;
|
||||
lfs_stat(&lfs, "c", &info) => LFS_ERR_NOENT;
|
||||
@@ -981,8 +981,8 @@ code = '''
|
||||
# Other specific corner cases
|
||||
[[case]] # create + delete in same commit with neighbors
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// littlefs keeps files sorted, so we know the order these will be in
|
||||
lfs_file_open(&lfs, &file, "/1.move_me",
|
||||
@@ -1127,8 +1127,8 @@ code = '''
|
||||
# Other specific corner cases
|
||||
[[case]] # create + delete + delete in same commit with neighbors
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// littlefs keeps files sorted, so we know the order these will be in
|
||||
lfs_file_open(&lfs, &file, "/1.move_me",
|
||||
@@ -1283,8 +1283,8 @@ code = '''
|
||||
|
||||
[[case]] # create + delete in different dirs with neighbors
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
// littlefs keeps files sorted, so we know the order these will be in
|
||||
lfs_mkdir(&lfs, "/dir.1") => 0;
|
||||
@@ -1523,8 +1523,8 @@ in = "lfs.c"
|
||||
define.RELOCATIONS = 'range(0x3+1)'
|
||||
define.LFS_ERASE_CYCLES = 0xffffffff
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
lfs_mkdir(&lfs, "/parent") => 0;
|
||||
lfs_mkdir(&lfs, "/parent/child") => 0;
|
||||
@@ -1660,8 +1660,8 @@ in = "lfs.c"
|
||||
define.RELOCATIONS = 'range(0x7+1)'
|
||||
define.LFS_ERASE_CYCLES = 0xffffffff
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
lfs_mkdir(&lfs, "/parent") => 0;
|
||||
lfs_mkdir(&lfs, "/parent/child") => 0;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
in = "lfs.c"
|
||||
if = 'LFS_PROG_SIZE <= 0x3fe' # only works with one crc per commit
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "parent") => 0;
|
||||
lfs_mkdir(&lfs, "parent/orphan") => 0;
|
||||
lfs_mkdir(&lfs, "parent/child") => 0;
|
||||
@@ -13,7 +13,7 @@ code = '''
|
||||
// corrupt the child's most recent commit, this should be the update
|
||||
// to the linked-list entry, which should orphan the orphan. Note this
|
||||
// makes a lot of assumptions about the remove operation.
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "parent/child") => 0;
|
||||
lfs_block_t block = dir.m.pair[0];
|
||||
lfs_dir_close(&lfs, &dir) => 0;
|
||||
@@ -29,13 +29,13 @@ code = '''
|
||||
cfg.prog(&cfg, block, 0, bbuffer, LFS_BLOCK_SIZE) => 0;
|
||||
cfg.sync(&cfg) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
|
||||
lfs_stat(&lfs, "parent/child", &info) => 0;
|
||||
lfs_fs_size(&lfs) => 8;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
|
||||
lfs_stat(&lfs, "parent/child", &info) => 0;
|
||||
lfs_fs_size(&lfs) => 8;
|
||||
@@ -48,7 +48,7 @@ code = '''
|
||||
lfs_fs_size(&lfs) => 8;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
|
||||
lfs_stat(&lfs, "parent/child", &info) => 0;
|
||||
lfs_stat(&lfs, "parent/otherchild", &info) => 0;
|
||||
@@ -66,10 +66,10 @@ define = [
|
||||
{FILES=3, DEPTH=3, CYCLES=20},
|
||||
]
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
err = lfs_mountcfg(&lfs, &cfg);
|
||||
if (err) {
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
}
|
||||
|
||||
srand(1);
|
||||
|
||||
+26
-26
@@ -1,8 +1,8 @@
|
||||
|
||||
[[case]] # simple path test
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "tea") => 0;
|
||||
lfs_mkdir(&lfs, "tea/hottea") => 0;
|
||||
lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
||||
@@ -23,8 +23,8 @@ code = '''
|
||||
|
||||
[[case]] # redundant slashes
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "tea") => 0;
|
||||
lfs_mkdir(&lfs, "tea/hottea") => 0;
|
||||
lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
||||
@@ -47,8 +47,8 @@ code = '''
|
||||
|
||||
[[case]] # dot path test
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "tea") => 0;
|
||||
lfs_mkdir(&lfs, "tea/hottea") => 0;
|
||||
lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
||||
@@ -73,8 +73,8 @@ code = '''
|
||||
|
||||
[[case]] # dot dot path test
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "tea") => 0;
|
||||
lfs_mkdir(&lfs, "tea/hottea") => 0;
|
||||
lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
||||
@@ -103,8 +103,8 @@ code = '''
|
||||
|
||||
[[case]] # trailing dot path test
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "tea") => 0;
|
||||
lfs_mkdir(&lfs, "tea/hottea") => 0;
|
||||
lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
||||
@@ -125,8 +125,8 @@ code = '''
|
||||
|
||||
[[case]] # leading dot path test
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, ".milk") => 0;
|
||||
lfs_stat(&lfs, ".milk", &info) => 0;
|
||||
strcmp(info.name, ".milk") => 0;
|
||||
@@ -137,8 +137,8 @@ code = '''
|
||||
|
||||
[[case]] # root dot dot path test
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "tea") => 0;
|
||||
lfs_mkdir(&lfs, "tea/hottea") => 0;
|
||||
lfs_mkdir(&lfs, "tea/warmtea") => 0;
|
||||
@@ -161,8 +161,8 @@ code = '''
|
||||
|
||||
[[case]] # invalid path tests
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg);
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg);
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_stat(&lfs, "dirt", &info) => LFS_ERR_NOENT;
|
||||
lfs_stat(&lfs, "dirt/ground", &info) => LFS_ERR_NOENT;
|
||||
lfs_stat(&lfs, "dirt/ground/earth", &info) => LFS_ERR_NOENT;
|
||||
@@ -182,8 +182,8 @@ code = '''
|
||||
|
||||
[[case]] # root operations
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_stat(&lfs, "/", &info) => 0;
|
||||
assert(strcmp(info.name, "/") == 0);
|
||||
assert(info.type == LFS_TYPE_DIR);
|
||||
@@ -198,8 +198,8 @@ code = '''
|
||||
|
||||
[[case]] # root representations
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_stat(&lfs, "/", &info) => 0;
|
||||
assert(strcmp(info.name, "/") == 0);
|
||||
assert(info.type == LFS_TYPE_DIR);
|
||||
@@ -223,8 +223,8 @@ code = '''
|
||||
|
||||
[[case]] # superblock conflict test
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT;
|
||||
lfs_remove(&lfs, "littlefs") => LFS_ERR_NOENT;
|
||||
|
||||
@@ -239,8 +239,8 @@ code = '''
|
||||
|
||||
[[case]] # max path test
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "coffee") => 0;
|
||||
lfs_mkdir(&lfs, "coffee/hotcoffee") => 0;
|
||||
lfs_mkdir(&lfs, "coffee/warmcoffee") => 0;
|
||||
@@ -263,8 +263,8 @@ code = '''
|
||||
|
||||
[[case]] # really big path test
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_mkdir(&lfs, "coffee") => 0;
|
||||
lfs_mkdir(&lfs, "coffee/hotcoffee") => 0;
|
||||
lfs_mkdir(&lfs, "coffee/warmcoffee") => 0;
|
||||
|
||||
+13
-13
@@ -4,9 +4,9 @@ define.ITERATIONS = 20
|
||||
define.COUNT = 10
|
||||
define.LFS_BLOCK_CYCLES = [8, 1]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
// fill up filesystem so only ~16 blocks are left
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "padding", LFS_O_CREAT | LFS_O_WRONLY) => 0;
|
||||
memset(buffer, 0, 512);
|
||||
while (LFS_BLOCK_COUNT - lfs_fs_size(&lfs) > 16) {
|
||||
@@ -17,7 +17,7 @@ code = '''
|
||||
lfs_mkdir(&lfs, "child") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int j = 0; j < ITERATIONS; j++) {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
||||
@@ -47,7 +47,7 @@ code = '''
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_dir_open(&lfs, &dir, "child") => 0;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||
@@ -70,9 +70,9 @@ define.ITERATIONS = 20
|
||||
define.COUNT = 10
|
||||
define.LFS_BLOCK_CYCLES = [8, 1]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
// fill up filesystem so only ~16 blocks are left
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "padding", LFS_O_CREAT | LFS_O_WRONLY) => 0;
|
||||
memset(buffer, 0, 512);
|
||||
while (LFS_BLOCK_COUNT - lfs_fs_size(&lfs) > 16) {
|
||||
@@ -83,7 +83,7 @@ code = '''
|
||||
lfs_mkdir(&lfs, "child") => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int j = 0; j < ITERATIONS; j++) {
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
|
||||
@@ -155,10 +155,10 @@ define = [
|
||||
{FILES=3, DEPTH=3, CYCLES=20, LFS_BLOCK_CYCLES=1},
|
||||
]
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
err = lfs_mountcfg(&lfs, &cfg);
|
||||
if (err) {
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
}
|
||||
|
||||
srand(1);
|
||||
@@ -217,10 +217,10 @@ define = [
|
||||
{FILES=3, DEPTH=3, CYCLES=20, LFS_BLOCK_CYCLES=1},
|
||||
]
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
err = lfs_mountcfg(&lfs, &cfg);
|
||||
if (err) {
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
}
|
||||
|
||||
srand(1);
|
||||
|
||||
+17
-17
@@ -9,8 +9,8 @@ define = [
|
||||
{COUNT=4, SKIP=2},
|
||||
]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "kitty",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
||||
size = strlen("kittycatcat");
|
||||
@@ -21,7 +21,7 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "kitty", LFS_O_RDONLY) => 0;
|
||||
|
||||
lfs_soff_t pos = -1;
|
||||
@@ -78,8 +78,8 @@ define = [
|
||||
{COUNT=4, SKIP=2},
|
||||
]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "kitty",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
||||
size = strlen("kittycatcat");
|
||||
@@ -90,7 +90,7 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
|
||||
|
||||
lfs_soff_t pos = -1;
|
||||
@@ -133,8 +133,8 @@ code = '''
|
||||
define.COUNT = 132
|
||||
define.OFFSETS = '"{512, 1020, 513, 1021, 511, 1019, 1441}"'
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "kitty",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
||||
size = strlen("kittycatcat");
|
||||
@@ -145,7 +145,7 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
|
||||
|
||||
size = strlen("hedgehoghog");
|
||||
@@ -193,8 +193,8 @@ define = [
|
||||
{COUNT=4, SKIP=3},
|
||||
]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "kitty",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
||||
size = strlen("kittycatcat");
|
||||
@@ -204,7 +204,7 @@ code = '''
|
||||
}
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
|
||||
|
||||
size = strlen("kittycatcat");
|
||||
@@ -241,8 +241,8 @@ code = '''
|
||||
[[case]] # inline write and seek
|
||||
define.SIZE = [2, 4, 128, 132]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "tinykitty",
|
||||
LFS_O_RDWR | LFS_O_CREAT) => 0;
|
||||
int j = 0;
|
||||
@@ -310,10 +310,10 @@ code = '''
|
||||
define.COUNT = [4, 64, 128]
|
||||
reentrant = true
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
err = lfs_mountcfg(&lfs, &cfg);
|
||||
if (err) {
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
}
|
||||
err = lfs_file_open(&lfs, &file, "kitty", LFS_O_RDONLY);
|
||||
assert(!err || err == LFS_ERR_NOENT);
|
||||
|
||||
+17
-17
@@ -1,37 +1,37 @@
|
||||
[[case]] # simple formatting test
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
'''
|
||||
|
||||
[[case]] # mount/unmount
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
'''
|
||||
|
||||
[[case]] # reentrant format
|
||||
reentrant = true
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
err = lfs_mountcfg(&lfs, &cfg);
|
||||
if (err) {
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
}
|
||||
lfs_unmount(&lfs) => 0;
|
||||
'''
|
||||
|
||||
[[case]] # invalid mount
|
||||
code = '''
|
||||
lfs_mount(&lfs, &cfg) => LFS_ERR_CORRUPT;
|
||||
lfs_mountcfg(&lfs, &cfg) => LFS_ERR_CORRUPT;
|
||||
'''
|
||||
|
||||
[[case]] # expanding superblock
|
||||
define.LFS_BLOCK_CYCLES = [32, 33, 1]
|
||||
define.N = [10, 100, 1000]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
lfs_file_open(&lfs, &file, "dummy",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
||||
@@ -44,7 +44,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// one last check after power-cycle
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "dummy",
|
||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
@@ -58,9 +58,9 @@ code = '''
|
||||
define.LFS_BLOCK_CYCLES = [32, 33, 1]
|
||||
define.N = [10, 100, 1000]
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
// remove lingering dummy?
|
||||
err = lfs_stat(&lfs, "dummy", &info);
|
||||
assert(err == 0 || (err == LFS_ERR_NOENT && i == 0));
|
||||
@@ -80,7 +80,7 @@ code = '''
|
||||
}
|
||||
|
||||
// one last check after power-cycle
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_stat(&lfs, "dummy", &info) => 0;
|
||||
assert(strcmp(info.name, "dummy") == 0);
|
||||
assert(info.type == LFS_TYPE_REG);
|
||||
@@ -92,10 +92,10 @@ define.LFS_BLOCK_CYCLES = [2, 1]
|
||||
define.N = 24
|
||||
reentrant = true
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
err = lfs_mountcfg(&lfs, &cfg);
|
||||
if (err) {
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
@@ -119,7 +119,7 @@ code = '''
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
// one last check after power-cycle
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_stat(&lfs, "dummy", &info) => 0;
|
||||
assert(strcmp(info.name, "dummy") == 0);
|
||||
assert(info.type == LFS_TYPE_REG);
|
||||
|
||||
+21
-21
@@ -2,8 +2,8 @@
|
||||
define.MEDIUMSIZE = [32, 2048]
|
||||
define.LARGESIZE = 8192
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "baldynoop",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||
|
||||
@@ -17,7 +17,7 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "baldynoop", LFS_O_RDWR) => 0;
|
||||
lfs_file_size(&lfs, &file) => LARGESIZE;
|
||||
|
||||
@@ -27,7 +27,7 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "baldynoop", LFS_O_RDONLY) => 0;
|
||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||
|
||||
@@ -46,8 +46,8 @@ code = '''
|
||||
define.MEDIUMSIZE = [32, 2048]
|
||||
define.LARGESIZE = 8192
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "baldyread",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||
|
||||
@@ -61,7 +61,7 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "baldyread", LFS_O_RDWR) => 0;
|
||||
lfs_file_size(&lfs, &file) => LARGESIZE;
|
||||
|
||||
@@ -78,7 +78,7 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "baldyread", LFS_O_RDONLY) => 0;
|
||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||
|
||||
@@ -95,8 +95,8 @@ code = '''
|
||||
|
||||
[[case]] # write, truncate, and read
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "sequence",
|
||||
LFS_O_RDWR | LFS_O_CREAT | LFS_O_TRUNC) => 0;
|
||||
|
||||
@@ -149,8 +149,8 @@ code = '''
|
||||
define.MEDIUMSIZE = [32, 2048]
|
||||
define.LARGESIZE = 8192
|
||||
code = '''
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "baldywrite",
|
||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||
|
||||
@@ -164,7 +164,7 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "baldywrite", LFS_O_RDWR) => 0;
|
||||
lfs_file_size(&lfs, &file) => LARGESIZE;
|
||||
|
||||
@@ -181,7 +181,7 @@ code = '''
|
||||
lfs_file_close(&lfs, &file) => 0;
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
lfs_file_open(&lfs, &file, "baldywrite", LFS_O_RDONLY) => 0;
|
||||
lfs_file_size(&lfs, &file) => MEDIUMSIZE;
|
||||
|
||||
@@ -202,10 +202,10 @@ define.MEDIUMSIZE = [32, 1024]
|
||||
define.LARGESIZE = 2048
|
||||
reentrant = true
|
||||
code = '''
|
||||
err = lfs_mount(&lfs, &cfg);
|
||||
err = lfs_mountcfg(&lfs, &cfg);
|
||||
if (err) {
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
}
|
||||
err = lfs_file_open(&lfs, &file, "baldy", LFS_O_RDONLY);
|
||||
assert(!err || err == LFS_ERR_NOENT);
|
||||
@@ -312,8 +312,8 @@ code = '''
|
||||
const lfs_off_t *hotsizes = configs[CONFIG].hotsizes;
|
||||
const lfs_off_t *coldsizes = configs[CONFIG].coldsizes;
|
||||
|
||||
lfs_format(&lfs, &cfg) => 0;
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_formatcfg(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
for (unsigned i = 0; i < COUNT; i++) {
|
||||
sprintf(path, "hairyhead%d", i);
|
||||
@@ -340,7 +340,7 @@ code = '''
|
||||
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
for (unsigned i = 0; i < COUNT; i++) {
|
||||
sprintf(path, "hairyhead%d", i);
|
||||
@@ -367,7 +367,7 @@ code = '''
|
||||
|
||||
lfs_unmount(&lfs) => 0;
|
||||
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
lfs_mountcfg(&lfs, &cfg) => 0;
|
||||
|
||||
for (unsigned i = 0; i < COUNT; i++) {
|
||||
sprintf(path, "hairyhead%d", i);
|
||||
|
||||
Reference in New Issue
Block a user