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:
Christopher Haster
2020-11-23 00:53:07 -06:00
parent ef9ba2d912
commit c44427f9ec
18 changed files with 873 additions and 627 deletions

489
lfs.c

File diff suppressed because it is too large Load Diff

175
lfs.h
View File

@@ -125,6 +125,7 @@ enum lfs_whence_flags {
}; };
#if !defined(LFS_STATICCFG)
// Configuration provided during initialization of the littlefs // Configuration provided during initialization of the littlefs
struct lfs_config { struct lfs_config {
// Opaque user provided context that can be used to pass // Opaque user provided context that can be used to pass
@@ -219,6 +220,99 @@ struct lfs_config {
// LFS_ATTR_MAX when zero. // LFS_ATTR_MAX when zero.
lfs_size_t attr_max; lfs_size_t attr_max;
}; };
#else
// Static configuration if LFS_STATICCFG is defined, there are defaults
// for some of these, but some are required. For full documentation, see
// the lfs_config struct above.
// Block device operations
int lfs_read(lfs_block_t block,
lfs_off_t off, void *buffer, lfs_size_t size);
int lfs_prog(lfs_block_t block,
lfs_off_t off, const void *buffer, lfs_size_t size);
int lfs_erase(lfs_block_t block);
int lfs_sync(void);
// Required configuration
#ifndef LFS_READ_SIZE
#error "LFS_STATICCFG requires LFS_READ_SIZE"
#endif
#ifndef LFS_PROG_SIZE
#error "LFS_STATICCFG requires LFS_PROG_SIZE"
#endif
#ifndef LFS_BLOCK_SIZE
#error "LFS_STATICCFG requires LFS_BLOCK_SIZE"
#endif
#ifndef LFS_BLOCK_COUNT
#error "LFS_STATICCFG requires LFS_BLOCK_COUNT"
#endif
#ifndef LFS_BLOCK_CYCLES
#error "LFS_STATICCFG requires LFS_BLOCK_CYCLES"
#endif
#ifndef LFS_CACHE_SIZE
#error "LFS_STATICCFG requires LFS_CACHE_SIZE"
#endif
#ifndef LFS_LOOKAHEAD_SIZE
#error "LFS_STATICCFG requires LFS_LOOKAHEAD_SIZE"
#endif
// Optional configuration
#ifndef LFS_READ_BUFFER
#define LFS_READ_BUFFER NULL
#endif
#ifndef LFS_PROG_BUFFER
#define LFS_PROG_BUFFER NULL
#endif
#ifndef LFS_LOOKAHEAD_BUFFER
#define LFS_LOOKAHEAD_BUFFER NULL
#endif
#ifndef LFS_NAME_MAX
#define LFS_NAME_MAX 0
#endif
#ifndef LFS_FILE_MAX
#define LFS_FILE_MAX 0
#endif
#ifndef LFS_ATTR_MAX
#define LFS_ATTR_MAX 0
#endif
#endif
#if !defined(LFS_FILE_STATICCFG)
// Optional configuration provided during lfs_file_opencfg
struct lfs_file_config {
// Optional statically allocated file buffer. Must be cache_size.
// By default lfs_malloc is used to allocate this buffer.
void *buffer;
// Optional list of custom attributes related to the file. If the file
// is opened with read access, these attributes will be read from disk
// during the open call. If the file is opened with write access, the
// attributes will be written to disk every file sync or close. This
// write occurs atomically with update to the file's contents.
//
// Custom attributes are uniquely identified by an 8-bit type and limited
// to LFS_ATTR_MAX bytes. When read, if the stored attribute is smaller
// than the buffer, it will be padded with zeros. If the stored attribute
// is larger, then it will be silently truncated. If the attribute is not
// found, it will be created implicitly.
struct lfs_attr *attrs;
// Number of custom attributes in the list
lfs_size_t attr_count;
};
#else
// Static configuration if LFS_FILE_STATICCFG is defined. For full
// documentation, see the lfs_file_config struct above.
#ifndef LFS_FILE_BUFFER
#define LFS_FILE_BUFFER NULL
#endif
#ifndef LFS_FILE_ATTRS
#define LFS_FILE_ATTRS ((struct lfs_attr*)NULL)
#endif
#ifndef LFS_FILE_ATTR_COUNT
#define LFS_FILE_ATTR_COUNT 0
#endif
#endif
// File info structure // File info structure
struct lfs_info { struct lfs_info {
@@ -249,29 +343,6 @@ struct lfs_attr {
lfs_size_t size; lfs_size_t size;
}; };
// Optional configuration provided during lfs_file_opencfg
struct lfs_file_config {
// Optional statically allocated file buffer. Must be cache_size.
// By default lfs_malloc is used to allocate this buffer.
void *buffer;
// Optional list of custom attributes related to the file. If the file
// is opened with read access, these attributes will be read from disk
// during the open call. If the file is opened with write access, the
// attributes will be written to disk every file sync or close. This
// write occurs atomically with update to the file's contents.
//
// Custom attributes are uniquely identified by an 8-bit type and limited
// to LFS_ATTR_MAX bytes. When read, if the stored attribute is smaller
// than the buffer, it will be padded with zeros. If the stored attribute
// is larger, then it will be silently truncated. If the attribute is not
// found, it will be created implicitly.
struct lfs_attr *attrs;
// Number of custom attributes in the list
lfs_size_t attr_count;
};
/// internal littlefs data structures /// /// internal littlefs data structures ///
typedef struct lfs_cache { typedef struct lfs_cache {
@@ -321,7 +392,9 @@ typedef struct lfs_file {
lfs_off_t off; lfs_off_t off;
lfs_cache_t cache; lfs_cache_t cache;
#ifndef LFS_FILE_STATICCFG
const struct lfs_file_config *cfg; const struct lfs_file_config *cfg;
#endif
} lfs_file_t; } lfs_file_t;
typedef struct lfs_superblock { typedef struct lfs_superblock {
@@ -364,7 +437,9 @@ typedef struct lfs {
uint32_t *buffer; uint32_t *buffer;
} free; } free;
#ifndef LFS_STATICCFG
const struct lfs_config *cfg; const struct lfs_config *cfg;
#endif
lfs_size_t name_max; lfs_size_t name_max;
lfs_size_t file_max; lfs_size_t file_max;
lfs_size_t attr_max; lfs_size_t attr_max;
@@ -377,16 +452,38 @@ typedef struct lfs {
/// Filesystem functions /// /// Filesystem functions ///
// Format a block device with the littlefs #if defined(LFS_STATICCFG)
// Format a block device with littlefs
//
// Requires a littlefs object. This clobbers the littlefs object, and does
// not leave the filesystem mounted.
//
// Returns a negative error code on failure.
int lfs_format(lfs_t *lfs);
#endif
#if !defined(LFS_STATICCFG)
// Format a block device with littlefs with per-filesystem configuration
// //
// Requires a littlefs object and config struct. This clobbers the littlefs // Requires a littlefs object and config struct. This clobbers the littlefs
// object, and does not leave the filesystem mounted. The config struct must // object, and does not leave the filesystem mounted. The config struct must
// be zeroed for defaults and backwards compatibility. // be zeroed for defaults and backwards compatibility.
// //
// Returns a negative error code on failure. // Returns a negative error code on failure.
int lfs_format(lfs_t *lfs, const struct lfs_config *config); int lfs_formatcfg(lfs_t *lfs, const struct lfs_config *config);
#endif
// Mounts a littlefs #if defined(LFS_STATICCFG)
// Mounts littlefs
//
// Requires a littlefs object and static configuration.
//
// Returns a negative error code on failure.
int lfs_mount(lfs_t *lfs);
#endif
#if !defined(LFS_STATICCFG)
// Mounts a littlefs with per-filesystem configuration
// //
// Requires a littlefs object and config struct. Multiple filesystems // Requires a littlefs object and config struct. Multiple filesystems
// may be mounted simultaneously with multiple littlefs objects. Both // may be mounted simultaneously with multiple littlefs objects. Both
@@ -394,7 +491,8 @@ int lfs_format(lfs_t *lfs, const struct lfs_config *config);
// be zeroed for defaults and backwards compatibility. // be zeroed for defaults and backwards compatibility.
// //
// Returns a negative error code on failure. // Returns a negative error code on failure.
int lfs_mount(lfs_t *lfs, const struct lfs_config *config); int lfs_mountcfg(lfs_t *lfs, const struct lfs_config *config);
#endif
// Unmounts a littlefs // Unmounts a littlefs
// //
@@ -468,7 +566,8 @@ int lfs_removeattr(lfs_t *lfs, const char *path, uint8_t type);
int lfs_file_open(lfs_t *lfs, lfs_file_t *file, int lfs_file_open(lfs_t *lfs, lfs_file_t *file,
const char *path, int flags); const char *path, int flags);
// Open a file with extra configuration #if !defined(LFS_FILE_STATICCFG)
// Open a file with per-file configuration
// //
// The mode that the file is opened in is determined by the flags, which // The mode that the file is opened in is determined by the flags, which
// are values from the enum lfs_open_flags that are bitwise-ored together. // are values from the enum lfs_open_flags that are bitwise-ored together.
@@ -481,6 +580,7 @@ int lfs_file_open(lfs_t *lfs, lfs_file_t *file,
int lfs_file_opencfg(lfs_t *lfs, lfs_file_t *file, int lfs_file_opencfg(lfs_t *lfs, lfs_file_t *file,
const char *path, int flags, const char *path, int flags,
const struct lfs_file_config *config); const struct lfs_file_config *config);
#endif
// Close a file // Close a file
// //
@@ -610,19 +710,34 @@ lfs_ssize_t lfs_fs_size(lfs_t *lfs);
// Returns a negative error code on failure. // Returns a negative error code on failure.
int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data); int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data);
#ifdef LFS_MIGRATE #if defined(LFS_MIGRATE) && defined(LFS_STATICCFG)
// Attempts to migrate a previous version of littlefs // Attempts to migrate a previous version of littlefs
// //
// Behaves similarly to the lfs_format function. Attempts to mount // Behaves similarly to the lfs_format function. Attempts to mount
// the previous version of littlefs and update the filesystem so it can be // the previous version of littlefs and update the filesystem so it can be
// mounted with the current version of littlefs. // mounted with the current version of littlefs.
// //
// Requires a littlefs object. This clobbers the littlefs object, and does
// not leave the filesystem mounted.
//
// Returns a negative error code on failure.
int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg);
#endif
#if defined(LFS_MIGRATE) && !defined(LFS_STATICCFG)
// Attempts to migrate a previous version of littlefs with per-filesystem
// configuration
//
// Behaves similarly to the lfs_format function. Attempts to mount
// the previous version of littlefs and update the filesystem so it can be
// mounted with the current version of littlefs.
//
// Requires a littlefs object and config struct. This clobbers the littlefs // Requires a littlefs object and config struct. This clobbers the littlefs
// object, and does not leave the filesystem mounted. The config struct must // object, and does not leave the filesystem mounted. The config struct must
// be zeroed for defaults and backwards compatibility. // be zeroed for defaults and backwards compatibility.
// //
// Returns a negative error code on failure. // Returns a negative error code on failure.
int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg); int lfs_migratecfg(lfs_t *lfs, const struct lfs_config *cfg);
#endif #endif

View File

@@ -9,12 +9,12 @@ code = '''
const char *names[FILES] = {"bacon", "eggs", "pancakes"}; const char *names[FILES] = {"bacon", "eggs", "pancakes"};
lfs_file_t files[FILES]; lfs_file_t files[FILES];
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "breakfast") => 0; lfs_mkdir(&lfs, "breakfast") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int n = 0; n < FILES; n++) { for (int n = 0; n < FILES; n++) {
sprintf(path, "breakfast/%s", names[n]); sprintf(path, "breakfast/%s", names[n]);
lfs_file_open(&lfs, &files[n], path, lfs_file_open(&lfs, &files[n], path,
@@ -31,7 +31,7 @@ code = '''
} }
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int n = 0; n < FILES; n++) { for (int n = 0; n < FILES; n++) {
sprintf(path, "breakfast/%s", names[n]); sprintf(path, "breakfast/%s", names[n]);
lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0; 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 = ''' code = '''
const char *names[FILES] = {"bacon", "eggs", "pancakes"}; const char *names[FILES] = {"bacon", "eggs", "pancakes"};
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "breakfast") => 0; lfs_mkdir(&lfs, "breakfast") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
for (int n = 0; n < FILES; n++) { for (int n = 0; n < FILES; n++) {
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
sprintf(path, "breakfast/%s", names[n]); sprintf(path, "breakfast/%s", names[n]);
lfs_file_open(&lfs, &file, path, lfs_file_open(&lfs, &file, path,
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0; LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
@@ -70,7 +70,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
} }
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int n = 0; n < FILES; n++) { for (int n = 0; n < FILES; n++) {
sprintf(path, "breakfast/%s", names[n]); sprintf(path, "breakfast/%s", names[n]);
lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0; lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
@@ -92,14 +92,14 @@ code = '''
const char *names[FILES] = {"bacon", "eggs", "pancakes"}; const char *names[FILES] = {"bacon", "eggs", "pancakes"};
lfs_file_t files[FILES]; lfs_file_t files[FILES];
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
for (int c = 0; c < CYCLES; c++) { for (int c = 0; c < CYCLES; c++) {
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "breakfast") => 0; lfs_mkdir(&lfs, "breakfast") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int n = 0; n < FILES; n++) { for (int n = 0; n < FILES; n++) {
sprintf(path, "breakfast/%s", names[n]); sprintf(path, "breakfast/%s", names[n]);
lfs_file_open(&lfs, &files[n], path, lfs_file_open(&lfs, &files[n], path,
@@ -116,7 +116,7 @@ code = '''
} }
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int n = 0; n < FILES; n++) { for (int n = 0; n < FILES; n++) {
sprintf(path, "breakfast/%s", names[n]); sprintf(path, "breakfast/%s", names[n]);
lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0; lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
@@ -129,7 +129,7 @@ code = '''
} }
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int n = 0; n < FILES; n++) { for (int n = 0; n < FILES; n++) {
sprintf(path, "breakfast/%s", names[n]); sprintf(path, "breakfast/%s", names[n]);
lfs_remove(&lfs, path) => 0; lfs_remove(&lfs, path) => 0;
@@ -146,15 +146,15 @@ define.CYCLES = [1, 10]
code = ''' code = '''
const char *names[FILES] = {"bacon", "eggs", "pancakes"}; const char *names[FILES] = {"bacon", "eggs", "pancakes"};
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
for (int c = 0; c < CYCLES; c++) { for (int c = 0; c < CYCLES; c++) {
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "breakfast") => 0; lfs_mkdir(&lfs, "breakfast") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
for (int n = 0; n < FILES; n++) { for (int n = 0; n < FILES; n++) {
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
sprintf(path, "breakfast/%s", names[n]); sprintf(path, "breakfast/%s", names[n]);
lfs_file_open(&lfs, &file, path, lfs_file_open(&lfs, &file, path,
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0; LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
@@ -167,7 +167,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
} }
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int n = 0; n < FILES; n++) { for (int n = 0; n < FILES; n++) {
sprintf(path, "breakfast/%s", names[n]); sprintf(path, "breakfast/%s", names[n]);
lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0; lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
@@ -180,7 +180,7 @@ code = '''
} }
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int n = 0; n < FILES; n++) { for (int n = 0; n < FILES; n++) {
sprintf(path, "breakfast/%s", names[n]); sprintf(path, "breakfast/%s", names[n]);
lfs_remove(&lfs, path) => 0; lfs_remove(&lfs, path) => 0;
@@ -192,8 +192,8 @@ code = '''
[[case]] # exhaustion test [[case]] # exhaustion test
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "exhaustion", LFS_O_WRONLY | LFS_O_CREAT); lfs_file_open(&lfs, &file, "exhaustion", LFS_O_WRONLY | LFS_O_CREAT);
size = strlen("exhaustion"); size = strlen("exhaustion");
memcpy(buffer, "exhaustion", size); memcpy(buffer, "exhaustion", size);
@@ -216,7 +216,7 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "exhaustion", LFS_O_RDONLY); lfs_file_open(&lfs, &file, "exhaustion", LFS_O_RDONLY);
size = strlen("exhaustion"); size = strlen("exhaustion");
lfs_file_size(&lfs, &file) => size; lfs_file_size(&lfs, &file) => size;
@@ -229,8 +229,8 @@ code = '''
[[case]] # exhaustion wraparound test [[case]] # exhaustion wraparound test
define.SIZE = '(((LFS_BLOCK_SIZE-8)*(LFS_BLOCK_COUNT-4)) / 3)' define.SIZE = '(((LFS_BLOCK_SIZE-8)*(LFS_BLOCK_COUNT-4)) / 3)'
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "padding", LFS_O_WRONLY | LFS_O_CREAT); lfs_file_open(&lfs, &file, "padding", LFS_O_WRONLY | LFS_O_CREAT);
size = strlen("buffering"); size = strlen("buffering");
@@ -263,7 +263,7 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "exhaustion", LFS_O_RDONLY); lfs_file_open(&lfs, &file, "exhaustion", LFS_O_RDONLY);
size = strlen("exhaustion"); size = strlen("exhaustion");
lfs_file_size(&lfs, &file) => size; lfs_file_size(&lfs, &file) => size;
@@ -276,8 +276,8 @@ code = '''
[[case]] # dir exhaustion test [[case]] # dir exhaustion test
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// find out max file size // find out max file size
lfs_mkdir(&lfs, "exhaustiondir") => 0; lfs_mkdir(&lfs, "exhaustiondir") => 0;
@@ -328,8 +328,8 @@ in = "lfs.c"
define.LFS_ERASE_CYCLES = 0xffffffff define.LFS_ERASE_CYCLES = 0xffffffff
define.LFS_BADBLOCK_BEHAVIOR = 'LFS_TESTBD_BADBLOCK_READERROR' define.LFS_BADBLOCK_BEHAVIOR = 'LFS_TESTBD_BADBLOCK_READERROR'
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// first fill to exhaustion to find available space // first fill to exhaustion to find available space
lfs_file_open(&lfs, &file, "pacman", LFS_O_WRONLY | LFS_O_CREAT) => 0; lfs_file_open(&lfs, &file, "pacman", LFS_O_WRONLY | LFS_O_CREAT) => 0;
strcpy((char*)buffer, "waka"); strcpy((char*)buffer, "waka");
@@ -358,7 +358,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// remount to force an alloc scan // 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 // but mark the head of our file as a "bad block", this is force our
// scan to bail early // scan to bail early
@@ -393,7 +393,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// check that the disk isn't hurt // 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; lfs_file_open(&lfs, &file, "pacman", LFS_O_RDONLY) => 0;
strcpy((char*)buffer, "waka"); strcpy((char*)buffer, "waka");
size = strlen("waka"); size = strlen("waka");
@@ -416,8 +416,8 @@ define.LFS_BLOCK_SIZE = 512
define.LFS_BLOCK_COUNT = 1024 define.LFS_BLOCK_COUNT = 1024
if = 'LFS_BLOCK_SIZE == 512 && LFS_BLOCK_COUNT == 1024' if = 'LFS_BLOCK_SIZE == 512 && LFS_BLOCK_COUNT == 1024'
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// find out max file size // find out max file size
lfs_mkdir(&lfs, "exhaustiondir") => 0; lfs_mkdir(&lfs, "exhaustiondir") => 0;
@@ -487,8 +487,8 @@ define.LFS_BLOCK_SIZE = 512
define.LFS_BLOCK_COUNT = 1024 define.LFS_BLOCK_COUNT = 1024
if = 'LFS_BLOCK_SIZE == 512 && LFS_BLOCK_COUNT == 1024' if = 'LFS_BLOCK_SIZE == 512 && LFS_BLOCK_COUNT == 1024'
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// create one block hole for half a directory // create one block hole for half a directory
lfs_file_open(&lfs, &file, "bump", LFS_O_WRONLY | LFS_O_CREAT) => 0; lfs_file_open(&lfs, &file, "bump", LFS_O_WRONLY | LFS_O_CREAT) => 0;
@@ -510,7 +510,7 @@ code = '''
// remount to force reset of lookahead // remount to force reset of lookahead
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// open hole // open hole
lfs_remove(&lfs, "bump") => 0; lfs_remove(&lfs, "bump") => 0;
@@ -532,8 +532,8 @@ define.LFS_BLOCK_SIZE = 512
define.LFS_BLOCK_COUNT = 1024 define.LFS_BLOCK_COUNT = 1024
if = 'LFS_BLOCK_SIZE == 512 && LFS_BLOCK_COUNT == 1024' if = 'LFS_BLOCK_SIZE == 512 && LFS_BLOCK_COUNT == 1024'
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// fill completely with two files // fill completely with two files
lfs_file_open(&lfs, &file, "exhaustion1", lfs_file_open(&lfs, &file, "exhaustion1",
@@ -560,7 +560,7 @@ code = '''
// remount to force reset of lookahead // remount to force reset of lookahead
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// rewrite one file // rewrite one file
lfs_file_open(&lfs, &file, "exhaustion1", lfs_file_open(&lfs, &file, "exhaustion1",
@@ -597,8 +597,8 @@ define.LFS_BLOCK_SIZE = 512
define.LFS_BLOCK_COUNT = 1024 define.LFS_BLOCK_COUNT = 1024
if = 'LFS_BLOCK_SIZE == 512 && LFS_BLOCK_COUNT == 1024' if = 'LFS_BLOCK_SIZE == 512 && LFS_BLOCK_COUNT == 1024'
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// fill completely with two files // fill completely with two files
lfs_file_open(&lfs, &file, "exhaustion1", lfs_file_open(&lfs, &file, "exhaustion1",
@@ -625,7 +625,7 @@ code = '''
// remount to force reset of lookahead // remount to force reset of lookahead
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// rewrite one file with a hole of one block // rewrite one file with a hole of one block
lfs_file_open(&lfs, &file, "exhaustion1", lfs_file_open(&lfs, &file, "exhaustion1",

View File

@@ -1,14 +1,14 @@
[[case]] # set/get attribute [[case]] # set/get attribute
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "hello") => 0; lfs_mkdir(&lfs, "hello") => 0;
lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0; lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello"); lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
lfs_file_close(&lfs, &file); lfs_file_close(&lfs, &file);
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
lfs_setattr(&lfs, "hello", 'A', "aaaa", 4) => 0; lfs_setattr(&lfs, "hello", 'A', "aaaa", 4) => 0;
lfs_setattr(&lfs, "hello", 'B', "bbbbbb", 6) => 0; lfs_setattr(&lfs, "hello", 'B', "bbbbbb", 6) => 0;
@@ -60,7 +60,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4; lfs_getattr(&lfs, "hello", 'A', buffer, 4) => 4;
lfs_getattr(&lfs, "hello", 'B', buffer+4, 9) => 9; lfs_getattr(&lfs, "hello", 'B', buffer+4, 9) => 9;
@@ -78,15 +78,15 @@ code = '''
[[case]] # set/get root attribute [[case]] # set/get root attribute
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "hello") => 0; lfs_mkdir(&lfs, "hello") => 0;
lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0; lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello"); lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
lfs_file_close(&lfs, &file); lfs_file_close(&lfs, &file);
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
lfs_setattr(&lfs, "/", 'A', "aaaa", 4) => 0; lfs_setattr(&lfs, "/", 'A', "aaaa", 4) => 0;
lfs_setattr(&lfs, "/", 'B', "bbbbbb", 6) => 0; lfs_setattr(&lfs, "/", 'B', "bbbbbb", 6) => 0;
@@ -137,7 +137,7 @@ code = '''
lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5; lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4; lfs_getattr(&lfs, "/", 'A', buffer, 4) => 4;
lfs_getattr(&lfs, "/", 'B', buffer+4, 9) => 9; lfs_getattr(&lfs, "/", 'B', buffer+4, 9) => 9;
@@ -155,15 +155,15 @@ code = '''
[[case]] # set/get file attribute [[case]] # set/get file attribute
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "hello") => 0; lfs_mkdir(&lfs, "hello") => 0;
lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0; lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello"); lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
lfs_file_close(&lfs, &file); lfs_file_close(&lfs, &file);
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
struct lfs_attr attrs1[] = { struct lfs_attr attrs1[] = {
{'A', buffer, 4}, {'A', buffer, 4},
@@ -238,7 +238,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
struct lfs_attr attrs3[] = { struct lfs_attr attrs3[] = {
{'A', buffer, 4}, {'A', buffer, 4},
@@ -262,15 +262,15 @@ code = '''
[[case]] # deferred file attributes [[case]] # deferred file attributes
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "hello") => 0; lfs_mkdir(&lfs, "hello") => 0;
lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0; lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello"); lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
lfs_file_close(&lfs, &file); lfs_file_close(&lfs, &file);
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_setattr(&lfs, "hello/hello", 'B', "fffffffff", 9) => 0; lfs_setattr(&lfs, "hello/hello", 'B', "fffffffff", 9) => 0;
lfs_setattr(&lfs, "hello/hello", 'C', "ccccc", 5) => 0; lfs_setattr(&lfs, "hello/hello", 'C', "ccccc", 5) => 0;

View File

@@ -19,9 +19,9 @@ code = '''
lfs_testbd_setwear(&cfg, badblock-1, 0) => 0; lfs_testbd_setwear(&cfg, badblock-1, 0) => 0;
lfs_testbd_setwear(&cfg, badblock, 0xffffffff) => 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 i = 1; i < 10; i++) {
for (int j = 0; j < NAMEMULT; j++) { for (int j = 0; j < NAMEMULT; j++) {
buffer[j] = '0'+i; buffer[j] = '0'+i;
@@ -46,7 +46,7 @@ code = '''
} }
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int i = 1; i < 10; i++) { for (int i = 1; i < 10; i++) {
for (int j = 0; j < NAMEMULT; j++) { for (int j = 0; j < NAMEMULT; j++) {
buffer[j] = '0'+i; buffer[j] = '0'+i;
@@ -93,9 +93,9 @@ code = '''
lfs_testbd_setwear(&cfg, i+2, 0xffffffff) => 0; 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 i = 1; i < 10; i++) {
for (int j = 0; j < NAMEMULT; j++) { for (int j = 0; j < NAMEMULT; j++) {
buffer[j] = '0'+i; buffer[j] = '0'+i;
@@ -120,7 +120,7 @@ code = '''
} }
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int i = 1; i < 10; i++) { for (int i = 1; i < 10; i++) {
for (int j = 0; j < NAMEMULT; j++) { for (int j = 0; j < NAMEMULT; j++) {
buffer[j] = '0'+i; buffer[j] = '0'+i;
@@ -166,9 +166,9 @@ code = '''
lfs_testbd_setwear(&cfg, (2*i) + 2, 0xffffffff) => 0; 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 i = 1; i < 10; i++) {
for (int j = 0; j < NAMEMULT; j++) { for (int j = 0; j < NAMEMULT; j++) {
buffer[j] = '0'+i; buffer[j] = '0'+i;
@@ -193,7 +193,7 @@ code = '''
} }
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int i = 1; i < 10; i++) { for (int i = 1; i < 10; i++) {
for (int j = 0; j < NAMEMULT; j++) { for (int j = 0; j < NAMEMULT; j++) {
buffer[j] = '0'+i; buffer[j] = '0'+i;
@@ -236,6 +236,6 @@ code = '''
lfs_testbd_setwear(&cfg, 0, 0xffffffff) => 0; lfs_testbd_setwear(&cfg, 0, 0xffffffff) => 0;
lfs_testbd_setwear(&cfg, 1, 0xffffffff) => 0; lfs_testbd_setwear(&cfg, 1, 0xffffffff) => 0;
lfs_format(&lfs, &cfg) => LFS_ERR_NOSPC; lfs_formatcfg(&lfs, &cfg) => LFS_ERR_NOSPC;
lfs_mount(&lfs, &cfg) => LFS_ERR_CORRUPT; lfs_mountcfg(&lfs, &cfg) => LFS_ERR_CORRUPT;
''' '''

View File

@@ -1,7 +1,7 @@
[[case]] # root [[case]] # root
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "/") => 0; lfs_dir_open(&lfs, &dir, "/") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(info.type == LFS_TYPE_DIR); assert(info.type == LFS_TYPE_DIR);
@@ -17,16 +17,16 @@ code = '''
[[case]] # many directory creation [[case]] # many directory creation
define.N = 'range(0, 100, 3)' define.N = 'range(0, 100, 3)'
code = ''' 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++) { for (int i = 0; i < N; i++) {
sprintf(path, "dir%03d", i); sprintf(path, "dir%03d", i);
lfs_mkdir(&lfs, path) => 0; lfs_mkdir(&lfs, path) => 0;
} }
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "/") => 0; lfs_dir_open(&lfs, &dir, "/") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(info.type == LFS_TYPE_DIR); assert(info.type == LFS_TYPE_DIR);
@@ -48,16 +48,16 @@ code = '''
[[case]] # many directory removal [[case]] # many directory removal
define.N = 'range(3, 100, 11)' define.N = 'range(3, 100, 11)'
code = ''' 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++) { for (int i = 0; i < N; i++) {
sprintf(path, "removeme%03d", i); sprintf(path, "removeme%03d", i);
lfs_mkdir(&lfs, path) => 0; lfs_mkdir(&lfs, path) => 0;
} }
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "/") => 0; lfs_dir_open(&lfs, &dir, "/") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(info.type == LFS_TYPE_DIR); assert(info.type == LFS_TYPE_DIR);
@@ -75,14 +75,14 @@ code = '''
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
lfs_unmount(&lfs); lfs_unmount(&lfs);
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
sprintf(path, "removeme%03d", i); sprintf(path, "removeme%03d", i);
lfs_remove(&lfs, path) => 0; lfs_remove(&lfs, path) => 0;
} }
lfs_unmount(&lfs); lfs_unmount(&lfs);
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "/") => 0; lfs_dir_open(&lfs, &dir, "/") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(info.type == LFS_TYPE_DIR); assert(info.type == LFS_TYPE_DIR);
@@ -98,16 +98,16 @@ code = '''
[[case]] # many directory rename [[case]] # many directory rename
define.N = 'range(3, 100, 11)' define.N = 'range(3, 100, 11)'
code = ''' 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++) { for (int i = 0; i < N; i++) {
sprintf(path, "test%03d", i); sprintf(path, "test%03d", i);
lfs_mkdir(&lfs, path) => 0; lfs_mkdir(&lfs, path) => 0;
} }
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "/") => 0; lfs_dir_open(&lfs, &dir, "/") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(info.type == LFS_TYPE_DIR); assert(info.type == LFS_TYPE_DIR);
@@ -125,7 +125,7 @@ code = '''
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
lfs_unmount(&lfs); lfs_unmount(&lfs);
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
char oldpath[128]; char oldpath[128];
char newpath[128]; char newpath[128];
@@ -135,7 +135,7 @@ code = '''
} }
lfs_unmount(&lfs); lfs_unmount(&lfs);
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "/") => 0; lfs_dir_open(&lfs, &dir, "/") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(info.type == LFS_TYPE_DIR); assert(info.type == LFS_TYPE_DIR);
@@ -158,10 +158,10 @@ code = '''
define.N = [5, 11] define.N = [5, 11]
reentrant = true reentrant = true
code = ''' code = '''
err = lfs_mount(&lfs, &cfg); err = lfs_mountcfg(&lfs, &cfg);
if (err) { if (err) {
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++) { for (int i = 0; i < N; i++) {
@@ -237,9 +237,9 @@ code = '''
[[case]] # file creation [[case]] # file creation
define.N = 'range(3, 100, 11)' define.N = 'range(3, 100, 11)'
code = ''' 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++) { for (int i = 0; i < N; i++) {
sprintf(path, "file%03d", i); sprintf(path, "file%03d", i);
lfs_file_open(&lfs, &file, path, lfs_file_open(&lfs, &file, path,
@@ -248,7 +248,7 @@ code = '''
} }
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "/") => 0; lfs_dir_open(&lfs, &dir, "/") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(info.type == LFS_TYPE_DIR); assert(info.type == LFS_TYPE_DIR);
@@ -270,9 +270,9 @@ code = '''
[[case]] # file removal [[case]] # file removal
define.N = 'range(0, 100, 3)' define.N = 'range(0, 100, 3)'
code = ''' 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++) { for (int i = 0; i < N; i++) {
sprintf(path, "removeme%03d", i); sprintf(path, "removeme%03d", i);
lfs_file_open(&lfs, &file, path, lfs_file_open(&lfs, &file, path,
@@ -281,7 +281,7 @@ code = '''
} }
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "/") => 0; lfs_dir_open(&lfs, &dir, "/") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(info.type == LFS_TYPE_DIR); assert(info.type == LFS_TYPE_DIR);
@@ -299,14 +299,14 @@ code = '''
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
lfs_unmount(&lfs); lfs_unmount(&lfs);
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
sprintf(path, "removeme%03d", i); sprintf(path, "removeme%03d", i);
lfs_remove(&lfs, path) => 0; lfs_remove(&lfs, path) => 0;
} }
lfs_unmount(&lfs); lfs_unmount(&lfs);
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "/") => 0; lfs_dir_open(&lfs, &dir, "/") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(info.type == LFS_TYPE_DIR); assert(info.type == LFS_TYPE_DIR);
@@ -322,9 +322,9 @@ code = '''
[[case]] # file rename [[case]] # file rename
define.N = 'range(0, 100, 3)' define.N = 'range(0, 100, 3)'
code = ''' 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++) { for (int i = 0; i < N; i++) {
sprintf(path, "test%03d", i); sprintf(path, "test%03d", i);
lfs_file_open(&lfs, &file, path, lfs_file_open(&lfs, &file, path,
@@ -333,7 +333,7 @@ code = '''
} }
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "/") => 0; lfs_dir_open(&lfs, &dir, "/") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(info.type == LFS_TYPE_DIR); assert(info.type == LFS_TYPE_DIR);
@@ -351,7 +351,7 @@ code = '''
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
lfs_unmount(&lfs); lfs_unmount(&lfs);
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
char oldpath[128]; char oldpath[128];
char newpath[128]; char newpath[128];
@@ -361,7 +361,7 @@ code = '''
} }
lfs_unmount(&lfs); lfs_unmount(&lfs);
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "/") => 0; lfs_dir_open(&lfs, &dir, "/") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(info.type == LFS_TYPE_DIR); assert(info.type == LFS_TYPE_DIR);
@@ -384,10 +384,10 @@ code = '''
define.N = [5, 25] define.N = [5, 25]
reentrant = true reentrant = true
code = ''' code = '''
err = lfs_mount(&lfs, &cfg); err = lfs_mountcfg(&lfs, &cfg);
if (err) { if (err) {
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++) { for (int i = 0; i < N; i++) {
@@ -462,21 +462,21 @@ code = '''
[[case]] # nested directories [[case]] # nested directories
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "potato") => 0; lfs_mkdir(&lfs, "potato") => 0;
lfs_file_open(&lfs, &file, "burito", lfs_file_open(&lfs, &file, "burito",
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0; LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "potato/baked") => 0; lfs_mkdir(&lfs, "potato/baked") => 0;
lfs_mkdir(&lfs, "potato/sweet") => 0; lfs_mkdir(&lfs, "potato/sweet") => 0;
lfs_mkdir(&lfs, "potato/fried") => 0; lfs_mkdir(&lfs, "potato/fried") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "potato") => 0; lfs_dir_open(&lfs, &dir, "potato") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(strcmp(info.name, ".") == 0); assert(strcmp(info.name, ".") == 0);
@@ -498,21 +498,21 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// try removing? // try removing?
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_remove(&lfs, "potato") => LFS_ERR_NOTEMPTY; lfs_remove(&lfs, "potato") => LFS_ERR_NOTEMPTY;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// try renaming? // try renaming?
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_rename(&lfs, "potato", "coldpotato") => 0; lfs_rename(&lfs, "potato", "coldpotato") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_rename(&lfs, "coldpotato", "warmpotato") => 0; lfs_rename(&lfs, "coldpotato", "warmpotato") => 0;
lfs_rename(&lfs, "warmpotato", "hotpotato") => 0; lfs_rename(&lfs, "warmpotato", "hotpotato") => 0;
lfs_unmount(&lfs) => 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, "potato") => LFS_ERR_NOENT;
lfs_remove(&lfs, "coldpotato") => LFS_ERR_NOENT; lfs_remove(&lfs, "coldpotato") => LFS_ERR_NOENT;
lfs_remove(&lfs, "warmpotato") => LFS_ERR_NOENT; lfs_remove(&lfs, "warmpotato") => LFS_ERR_NOENT;
@@ -520,7 +520,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// try cross-directory renaming // try cross-directory renaming
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "coldpotato") => 0; lfs_mkdir(&lfs, "coldpotato") => 0;
lfs_rename(&lfs, "hotpotato/baked", "coldpotato/baked") => 0; lfs_rename(&lfs, "hotpotato/baked", "coldpotato/baked") => 0;
lfs_rename(&lfs, "coldpotato", "hotpotato") => LFS_ERR_NOTEMPTY; lfs_rename(&lfs, "coldpotato", "hotpotato") => LFS_ERR_NOTEMPTY;
@@ -536,7 +536,7 @@ code = '''
lfs_remove(&lfs, "hotpotato") => LFS_ERR_NOTEMPTY; lfs_remove(&lfs, "hotpotato") => LFS_ERR_NOTEMPTY;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "hotpotato") => 0; lfs_dir_open(&lfs, &dir, "hotpotato") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(strcmp(info.name, ".") == 0); assert(strcmp(info.name, ".") == 0);
@@ -558,7 +558,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// final remove // final remove
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_remove(&lfs, "hotpotato") => LFS_ERR_NOTEMPTY; lfs_remove(&lfs, "hotpotato") => LFS_ERR_NOTEMPTY;
lfs_remove(&lfs, "hotpotato/baked") => 0; lfs_remove(&lfs, "hotpotato/baked") => 0;
lfs_remove(&lfs, "hotpotato") => LFS_ERR_NOTEMPTY; lfs_remove(&lfs, "hotpotato") => LFS_ERR_NOTEMPTY;
@@ -568,7 +568,7 @@ code = '''
lfs_remove(&lfs, "hotpotato") => 0; lfs_remove(&lfs, "hotpotato") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "/") => 0; lfs_dir_open(&lfs, &dir, "/") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(strcmp(info.name, ".") == 0); assert(strcmp(info.name, ".") == 0);
@@ -587,8 +587,8 @@ code = '''
[[case]] # recursive remove [[case]] # recursive remove
define.N = [10, 100] define.N = [10, 100]
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "prickly-pear") => 0; lfs_mkdir(&lfs, "prickly-pear") => 0;
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
sprintf(path, "prickly-pear/cactus%03d", i); sprintf(path, "prickly-pear/cactus%03d", i);
@@ -611,7 +611,7 @@ code = '''
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
lfs_unmount(&lfs); lfs_unmount(&lfs);
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_remove(&lfs, "prickly-pear") => LFS_ERR_NOTEMPTY; lfs_remove(&lfs, "prickly-pear") => LFS_ERR_NOTEMPTY;
lfs_dir_open(&lfs, &dir, "prickly-pear") => 0; lfs_dir_open(&lfs, &dir, "prickly-pear") => 0;
@@ -636,22 +636,22 @@ code = '''
lfs_remove(&lfs, "prickly-pear") => LFS_ERR_NOENT; lfs_remove(&lfs, "prickly-pear") => LFS_ERR_NOENT;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_remove(&lfs, "prickly-pear") => LFS_ERR_NOENT; lfs_remove(&lfs, "prickly-pear") => LFS_ERR_NOENT;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
''' '''
[[case]] # other error cases [[case]] # other error cases
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "potato") => 0; lfs_mkdir(&lfs, "potato") => 0;
lfs_file_open(&lfs, &file, "burito", lfs_file_open(&lfs, &file, "burito",
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0; LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "potato") => LFS_ERR_EXIST; lfs_mkdir(&lfs, "potato") => LFS_ERR_EXIST;
lfs_mkdir(&lfs, "burito") => LFS_ERR_EXIST; lfs_mkdir(&lfs, "burito") => LFS_ERR_EXIST;
@@ -696,7 +696,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// or on disk // or on disk
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "/") => 0; lfs_dir_open(&lfs, &dir, "/") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(info.type == LFS_TYPE_DIR); assert(info.type == LFS_TYPE_DIR);
@@ -718,8 +718,8 @@ code = '''
[[case]] # directory seek [[case]] # directory seek
define.COUNT = [4, 128, 132] define.COUNT = [4, 128, 132]
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "hello") => 0; lfs_mkdir(&lfs, "hello") => 0;
for (int i = 0; i < COUNT; i++) { for (int i = 0; i < COUNT; i++) {
sprintf(path, "hello/kitty%03d", i); sprintf(path, "hello/kitty%03d", i);
@@ -728,7 +728,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
for (int j = 2; j < COUNT; j++) { 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_open(&lfs, &dir, "hello") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(strcmp(info.name, ".") == 0); assert(strcmp(info.name, ".") == 0);
@@ -779,8 +779,8 @@ code = '''
[[case]] # root seek [[case]] # root seek
define.COUNT = [4, 128, 132] define.COUNT = [4, 128, 132]
code = ''' 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 < COUNT; i++) { for (int i = 0; i < COUNT; i++) {
sprintf(path, "hi%03d", i); sprintf(path, "hi%03d", i);
lfs_mkdir(&lfs, path) => 0; lfs_mkdir(&lfs, path) => 0;
@@ -788,7 +788,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
for (int j = 2; j < COUNT; j++) { 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_open(&lfs, &dir, "/") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(strcmp(info.name, ".") == 0); assert(strcmp(info.name, ".") == 0);

View File

@@ -10,8 +10,8 @@ code = '''
uint8_t wbuffer[1024]; uint8_t wbuffer[1024];
uint8_t rbuffer[1024]; uint8_t rbuffer[1024];
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// write hi0 20 // write hi0 20
sprintf(path, "hi0"); size = 20; sprintf(path, "hi0"); size = 20;
@@ -99,8 +99,8 @@ code = '''
uint8_t wbuffer[1024]; uint8_t wbuffer[1024];
uint8_t rbuffer[1024]; uint8_t rbuffer[1024];
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// write hi0 20 // write hi0 20
sprintf(path, "hi0"); size = 20; sprintf(path, "hi0"); size = 20;
@@ -188,8 +188,8 @@ code = '''
uint8_t wbuffer[1024]; uint8_t wbuffer[1024];
uint8_t rbuffer[1024]; uint8_t rbuffer[1024];
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// write hi0 200 // write hi0 200
sprintf(path, "hi0"); size = 200; sprintf(path, "hi0"); size = 200;
@@ -261,8 +261,8 @@ code = '''
uint8_t wbuffer[1024]; uint8_t wbuffer[1024];
uint8_t rbuffer[1024]; uint8_t rbuffer[1024];
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// write hi0 200 // write hi0 200
sprintf(path, "hi0"); size = 200; sprintf(path, "hi0"); size = 200;
@@ -350,8 +350,8 @@ code = '''
uint8_t wbuffer[1024]; uint8_t wbuffer[1024];
uint8_t rbuffer[1024]; uint8_t rbuffer[1024];
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// write hi0 200 // write hi0 200
sprintf(path, "hi0"); size = 200; sprintf(path, "hi0"); size = 200;
@@ -454,8 +454,8 @@ code = '''
uint8_t wbuffer[1024]; uint8_t wbuffer[1024];
uint8_t rbuffer[1024]; uint8_t rbuffer[1024];
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// write hi0 200 // write hi0 200
sprintf(path, "hi0"); size = 200; sprintf(path, "hi0"); size = 200;
@@ -549,9 +549,9 @@ code = '''
[[case]] # create too big [[case]] # create too big
code = ''' 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); memset(path, 'm', 200);
path[200] = '\0'; path[200] = '\0';
@@ -574,9 +574,9 @@ code = '''
[[case]] # resize too big [[case]] # resize too big
code = ''' 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); memset(path, 'm', 200);
path[200] = '\0'; path[200] = '\0';

View File

@@ -9,10 +9,11 @@ define.INVALSET = [0x3, 0x1, 0x2]
in = "lfs.c" in = "lfs.c"
code = ''' code = '''
// create littlefs // create littlefs
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
// change tail-pointer to invalid pointers // change tail-pointer to invalid pointers
lfs_init(&lfs, &cfg) => 0; lfs.cfg = &cfg;
lfs_initcommon(&lfs) => 0;
lfs_mdir_t mdir; lfs_mdir_t mdir;
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0; lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS( lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
@@ -23,7 +24,7 @@ code = '''
lfs_deinit(&lfs) => 0; lfs_deinit(&lfs) => 0;
// test that mount fails gracefully // test that mount fails gracefully
lfs_mount(&lfs, &cfg) => LFS_ERR_CORRUPT; lfs_mountcfg(&lfs, &cfg) => LFS_ERR_CORRUPT;
''' '''
[[case]] # invalid dir pointer test [[case]] # invalid dir pointer test
@@ -31,14 +32,15 @@ define.INVALSET = [0x3, 0x1, 0x2]
in = "lfs.c" in = "lfs.c"
code = ''' code = '''
// create littlefs // create littlefs
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
// make a dir // make a dir
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "dir_here") => 0; lfs_mkdir(&lfs, "dir_here") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// change the dir pointer to be invalid // change the dir pointer to be invalid
lfs_init(&lfs, &cfg) => 0; lfs.cfg = &cfg;
lfs_initcommon(&lfs) => 0;
lfs_mdir_t mdir; lfs_mdir_t mdir;
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0; lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
// make sure id 1 == our directory // make sure id 1 == our directory
@@ -57,7 +59,7 @@ code = '''
// test that accessing our bad dir fails, note there's a number // test that accessing our bad dir fails, note there's a number
// of ways to access the dir, some can fail, but some don't // of ways to access the dir, some can fail, but some don't
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_stat(&lfs, "dir_here", &info) => 0; lfs_stat(&lfs, "dir_here", &info) => 0;
assert(strcmp(info.name, "dir_here") == 0); assert(strcmp(info.name, "dir_here") == 0);
assert(info.type == LFS_TYPE_DIR); assert(info.type == LFS_TYPE_DIR);
@@ -77,16 +79,17 @@ in = "lfs.c"
define.SIZE = [10, 1000, 100000] # faked file size define.SIZE = [10, 1000, 100000] # faked file size
code = ''' code = '''
// create littlefs // create littlefs
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
// make a file // make a file
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "file_here", lfs_file_open(&lfs, &file, "file_here",
LFS_O_WRONLY | LFS_O_CREAT) => 0; LFS_O_WRONLY | LFS_O_CREAT) => 0;
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// change the file pointer to be invalid // change the file pointer to be invalid
lfs_init(&lfs, &cfg) => 0; lfs.cfg = &cfg;
lfs_initcommon(&lfs) => 0;
lfs_mdir_t mdir; lfs_mdir_t mdir;
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0; lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
// make sure id 1 == our file // make sure id 1 == our file
@@ -103,7 +106,7 @@ code = '''
// test that accessing our bad file fails, note there's a number // test that accessing our bad file fails, note there's a number
// of ways to access the dir, some can fail, but some don't // of ways to access the dir, some can fail, but some don't
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_stat(&lfs, "file_here", &info) => 0; lfs_stat(&lfs, "file_here", &info) => 0;
assert(strcmp(info.name, "file_here") == 0); assert(strcmp(info.name, "file_here") == 0);
assert(info.type == LFS_TYPE_REG); assert(info.type == LFS_TYPE_REG);
@@ -125,9 +128,9 @@ define.SIZE = ['2*LFS_BLOCK_SIZE', '3*LFS_BLOCK_SIZE', '4*LFS_BLOCK_SIZE']
in = "lfs.c" in = "lfs.c"
code = ''' code = '''
// create littlefs // create littlefs
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
// make a file // make a file
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "file_here", lfs_file_open(&lfs, &file, "file_here",
LFS_O_WRONLY | LFS_O_CREAT) => 0; LFS_O_WRONLY | LFS_O_CREAT) => 0;
for (int i = 0; i < SIZE; i++) { for (int i = 0; i < SIZE; i++) {
@@ -137,7 +140,8 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// change pointer in CTZ skip-list to be invalid // change pointer in CTZ skip-list to be invalid
lfs_init(&lfs, &cfg) => 0; lfs.cfg = &cfg;
lfs_initcommon(&lfs) => 0;
lfs_mdir_t mdir; lfs_mdir_t mdir;
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0; lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
// make sure id 1 == our file and get our CTZ structure // make sure id 1 == our file and get our CTZ structure
@@ -164,7 +168,7 @@ code = '''
// test that accessing our bad file fails, note there's a number // test that accessing our bad file fails, note there's a number
// of ways to access the dir, some can fail, but some don't // of ways to access the dir, some can fail, but some don't
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_stat(&lfs, "file_here", &info) => 0; lfs_stat(&lfs, "file_here", &info) => 0;
assert(strcmp(info.name, "file_here") == 0); assert(strcmp(info.name, "file_here") == 0);
assert(info.type == LFS_TYPE_REG); assert(info.type == LFS_TYPE_REG);
@@ -187,10 +191,11 @@ define.INVALSET = [0x3, 0x1, 0x2]
in = "lfs.c" in = "lfs.c"
code = ''' code = '''
// create littlefs // create littlefs
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
// create an invalid gstate // create an invalid gstate
lfs_init(&lfs, &cfg) => 0; lfs.cfg = &cfg;
lfs_initcommon(&lfs) => 0;
lfs_mdir_t mdir; lfs_mdir_t mdir;
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0; lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
lfs_fs_prepmove(&lfs, 1, (lfs_block_t [2]){ lfs_fs_prepmove(&lfs, 1, (lfs_block_t [2]){
@@ -202,7 +207,7 @@ code = '''
// test that mount fails gracefully // test that mount fails gracefully
// mount may not fail, but our first alloc should fail when // mount may not fail, but our first alloc should fail when
// we try to fix the gstate // we try to fix the gstate
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "should_fail") => LFS_ERR_CORRUPT; lfs_mkdir(&lfs, "should_fail") => LFS_ERR_CORRUPT;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
''' '''
@@ -213,10 +218,11 @@ code = '''
in = "lfs.c" in = "lfs.c"
code = ''' code = '''
// create littlefs // create littlefs
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
// change tail-pointer to point to ourself // change tail-pointer to point to ourself
lfs_init(&lfs, &cfg) => 0; lfs.cfg = &cfg;
lfs_initcommon(&lfs) => 0;
lfs_mdir_t mdir; lfs_mdir_t mdir;
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0; lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS( lfs_dir_commit(&lfs, &mdir, LFS_MKATTRS(
@@ -225,20 +231,21 @@ code = '''
lfs_deinit(&lfs) => 0; lfs_deinit(&lfs) => 0;
// test that mount fails gracefully // test that mount fails gracefully
lfs_mount(&lfs, &cfg) => LFS_ERR_CORRUPT; lfs_mountcfg(&lfs, &cfg) => LFS_ERR_CORRUPT;
''' '''
[[case]] # metadata-pair threaded-list 2-length loop test [[case]] # metadata-pair threaded-list 2-length loop test
in = "lfs.c" in = "lfs.c"
code = ''' code = '''
// create littlefs with child dir // create littlefs with child dir
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "child") => 0; lfs_mkdir(&lfs, "child") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// find child // find child
lfs_init(&lfs, &cfg) => 0; lfs.cfg = &cfg;
lfs_initcommon(&lfs) => 0;
lfs_mdir_t mdir; lfs_mdir_t mdir;
lfs_block_t pair[2]; lfs_block_t pair[2];
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0; lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
@@ -255,20 +262,21 @@ code = '''
lfs_deinit(&lfs) => 0; lfs_deinit(&lfs) => 0;
// test that mount fails gracefully // test that mount fails gracefully
lfs_mount(&lfs, &cfg) => LFS_ERR_CORRUPT; lfs_mountcfg(&lfs, &cfg) => LFS_ERR_CORRUPT;
''' '''
[[case]] # metadata-pair threaded-list 1-length child loop test [[case]] # metadata-pair threaded-list 1-length child loop test
in = "lfs.c" in = "lfs.c"
code = ''' code = '''
// create littlefs with child dir // create littlefs with child dir
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "child") => 0; lfs_mkdir(&lfs, "child") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// find child // find child
lfs_init(&lfs, &cfg) => 0; lfs.cfg = &cfg;
lfs_initcommon(&lfs) => 0;
lfs_mdir_t mdir; lfs_mdir_t mdir;
lfs_block_t pair[2]; lfs_block_t pair[2];
lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0; lfs_dir_fetch(&lfs, &mdir, (lfs_block_t[2]){0, 1}) => 0;
@@ -284,5 +292,5 @@ code = '''
lfs_deinit(&lfs) => 0; lfs_deinit(&lfs) => 0;
// test that mount fails gracefully // test that mount fails gracefully
lfs_mount(&lfs, &cfg) => LFS_ERR_CORRUPT; lfs_mountcfg(&lfs, &cfg) => LFS_ERR_CORRUPT;
''' '''

View File

@@ -11,14 +11,14 @@ define.LFS_BADBLOCK_BEHAVIOR = [
] ]
define.FILES = 10 define.FILES = 10
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "roadrunner") => 0; lfs_mkdir(&lfs, "roadrunner") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
uint32_t cycle = 0; uint32_t cycle = 0;
while (true) { while (true) {
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (uint32_t i = 0; i < FILES; i++) { for (uint32_t i = 0; i < FILES; i++) {
// chose name, roughly random seed, and random 2^n size // chose name, roughly random seed, and random 2^n size
sprintf(path, "roadrunner/test%d", i); sprintf(path, "roadrunner/test%d", i);
@@ -71,7 +71,7 @@ code = '''
exhausted: exhausted:
// should still be readable // should still be readable
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (uint32_t i = 0; i < FILES; i++) { for (uint32_t i = 0; i < FILES; i++) {
// check for errors // check for errors
sprintf(path, "roadrunner/test%d", i); sprintf(path, "roadrunner/test%d", i);
@@ -96,11 +96,11 @@ define.LFS_BADBLOCK_BEHAVIOR = [
] ]
define.FILES = 10 define.FILES = 10
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
uint32_t cycle = 0; uint32_t cycle = 0;
while (true) { while (true) {
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (uint32_t i = 0; i < FILES; i++) { for (uint32_t i = 0; i < FILES; i++) {
// chose name, roughly random seed, and random 2^n size // chose name, roughly random seed, and random 2^n size
sprintf(path, "test%d", i); sprintf(path, "test%d", i);
@@ -153,7 +153,7 @@ code = '''
exhausted: exhausted:
// should still be readable // should still be readable
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (uint32_t i = 0; i < FILES; i++) { for (uint32_t i = 0; i < FILES; i++) {
// check for errors // check for errors
sprintf(path, "test%d", i); sprintf(path, "test%d", i);
@@ -184,14 +184,14 @@ code = '''
(b < run_block_count[run]) ? 0 : LFS_ERASE_CYCLES) => 0; (b < run_block_count[run]) ? 0 : LFS_ERASE_CYCLES) => 0;
} }
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "roadrunner") => 0; lfs_mkdir(&lfs, "roadrunner") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
uint32_t cycle = 0; uint32_t cycle = 0;
while (true) { while (true) {
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (uint32_t i = 0; i < FILES; i++) { for (uint32_t i = 0; i < FILES; i++) {
// chose name, roughly random seed, and random 2^n size // chose name, roughly random seed, and random 2^n size
sprintf(path, "roadrunner/test%d", i); sprintf(path, "roadrunner/test%d", i);
@@ -244,7 +244,7 @@ code = '''
exhausted: exhausted:
// should still be readable // should still be readable
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (uint32_t i = 0; i < FILES; i++) { for (uint32_t i = 0; i < FILES; i++) {
// check for errors // check for errors
sprintf(path, "roadrunner/test%d", i); sprintf(path, "roadrunner/test%d", i);
@@ -276,11 +276,11 @@ code = '''
(b < run_block_count[run]) ? 0 : LFS_ERASE_CYCLES) => 0; (b < run_block_count[run]) ? 0 : LFS_ERASE_CYCLES) => 0;
} }
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
uint32_t cycle = 0; uint32_t cycle = 0;
while (true) { while (true) {
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (uint32_t i = 0; i < FILES; i++) { for (uint32_t i = 0; i < FILES; i++) {
// chose name, roughly random seed, and random 2^n size // chose name, roughly random seed, and random 2^n size
sprintf(path, "test%d", i); sprintf(path, "test%d", i);
@@ -333,7 +333,7 @@ code = '''
exhausted: exhausted:
// should still be readable // should still be readable
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (uint32_t i = 0; i < FILES; i++) { for (uint32_t i = 0; i < FILES; i++) {
// check for errors // check for errors
sprintf(path, "test%d", i); sprintf(path, "test%d", i);
@@ -358,14 +358,14 @@ define.CYCLES = 100
define.FILES = 10 define.FILES = 10
if = 'LFS_BLOCK_CYCLES < CYCLES/10' if = 'LFS_BLOCK_CYCLES < CYCLES/10'
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "roadrunner") => 0; lfs_mkdir(&lfs, "roadrunner") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
uint32_t cycle = 0; uint32_t cycle = 0;
while (cycle < CYCLES) { while (cycle < CYCLES) {
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (uint32_t i = 0; i < FILES; i++) { for (uint32_t i = 0; i < FILES; i++) {
// chose name, roughly random seed, and random 2^n size // chose name, roughly random seed, and random 2^n size
sprintf(path, "roadrunner/test%d", i); sprintf(path, "roadrunner/test%d", i);
@@ -418,7 +418,7 @@ code = '''
exhausted: exhausted:
// should still be readable // should still be readable
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (uint32_t i = 0; i < FILES; i++) { for (uint32_t i = 0; i < FILES; i++) {
// check for errors // check for errors
sprintf(path, "roadrunner/test%d", i); sprintf(path, "roadrunner/test%d", i);

View File

@@ -1,8 +1,8 @@
[[case]] # simple file test [[case]] # simple file test
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "hello", lfs_file_open(&lfs, &file, "hello",
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0; LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
size = strlen("Hello World!")+1; size = strlen("Hello World!")+1;
@@ -11,7 +11,7 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "hello", LFS_O_RDONLY) => 0; lfs_file_open(&lfs, &file, "hello", LFS_O_RDONLY) => 0;
lfs_file_read(&lfs, &file, buffer, size) => size; lfs_file_read(&lfs, &file, buffer, size) => size;
assert(strcmp((char*)buffer, "Hello World!") == 0); assert(strcmp((char*)buffer, "Hello World!") == 0);
@@ -23,10 +23,10 @@ code = '''
define.SIZE = [32, 8192, 262144, 0, 7, 8193] define.SIZE = [32, 8192, 262144, 0, 7, 8193]
define.CHUNKSIZE = [31, 16, 33, 1, 1023] define.CHUNKSIZE = [31, 16, 33, 1, 1023]
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
// write // write
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "avacado", lfs_file_open(&lfs, &file, "avacado",
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0; LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
srand(1); srand(1);
@@ -41,7 +41,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// read // read
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0; lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0;
lfs_file_size(&lfs, &file) => SIZE; lfs_file_size(&lfs, &file) => SIZE;
srand(1); srand(1);
@@ -62,10 +62,10 @@ define.SIZE1 = [32, 8192, 131072, 0, 7, 8193]
define.SIZE2 = [32, 8192, 131072, 0, 7, 8193] define.SIZE2 = [32, 8192, 131072, 0, 7, 8193]
define.CHUNKSIZE = [31, 16, 1] define.CHUNKSIZE = [31, 16, 1]
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
// write // write
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "avacado", lfs_file_open(&lfs, &file, "avacado",
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0; LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
srand(1); srand(1);
@@ -80,7 +80,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// read // read
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0; lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0;
lfs_file_size(&lfs, &file) => SIZE1; lfs_file_size(&lfs, &file) => SIZE1;
srand(1); srand(1);
@@ -96,7 +96,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// rewrite // rewrite
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "avacado", LFS_O_WRONLY) => 0; lfs_file_open(&lfs, &file, "avacado", LFS_O_WRONLY) => 0;
srand(2); srand(2);
for (lfs_size_t i = 0; i < SIZE2; i += CHUNKSIZE) { for (lfs_size_t i = 0; i < SIZE2; i += CHUNKSIZE) {
@@ -110,7 +110,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// read // read
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0; lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0;
lfs_file_size(&lfs, &file) => lfs_max(SIZE1, SIZE2); lfs_file_size(&lfs, &file) => lfs_max(SIZE1, SIZE2);
srand(2); srand(2);
@@ -144,10 +144,10 @@ define.SIZE1 = [32, 8192, 131072, 0, 7, 8193]
define.SIZE2 = [32, 8192, 131072, 0, 7, 8193] define.SIZE2 = [32, 8192, 131072, 0, 7, 8193]
define.CHUNKSIZE = [31, 16, 1] define.CHUNKSIZE = [31, 16, 1]
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
// write // write
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "avacado", lfs_file_open(&lfs, &file, "avacado",
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0; LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
srand(1); srand(1);
@@ -162,7 +162,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// read // read
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0; lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0;
lfs_file_size(&lfs, &file) => SIZE1; lfs_file_size(&lfs, &file) => SIZE1;
srand(1); srand(1);
@@ -178,7 +178,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// append // append
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "avacado", LFS_O_WRONLY | LFS_O_APPEND) => 0; lfs_file_open(&lfs, &file, "avacado", LFS_O_WRONLY | LFS_O_APPEND) => 0;
srand(2); srand(2);
for (lfs_size_t i = 0; i < SIZE2; i += CHUNKSIZE) { for (lfs_size_t i = 0; i < SIZE2; i += CHUNKSIZE) {
@@ -192,7 +192,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// read // read
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0; lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0;
lfs_file_size(&lfs, &file) => SIZE1 + SIZE2; lfs_file_size(&lfs, &file) => SIZE1 + SIZE2;
srand(1); srand(1);
@@ -221,10 +221,10 @@ define.SIZE1 = [32, 8192, 131072, 0, 7, 8193]
define.SIZE2 = [32, 8192, 131072, 0, 7, 8193] define.SIZE2 = [32, 8192, 131072, 0, 7, 8193]
define.CHUNKSIZE = [31, 16, 1] define.CHUNKSIZE = [31, 16, 1]
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
// write // write
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "avacado", lfs_file_open(&lfs, &file, "avacado",
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0; LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
srand(1); srand(1);
@@ -239,7 +239,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// read // read
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0; lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0;
lfs_file_size(&lfs, &file) => SIZE1; lfs_file_size(&lfs, &file) => SIZE1;
srand(1); srand(1);
@@ -255,7 +255,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// truncate // truncate
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "avacado", LFS_O_WRONLY | LFS_O_TRUNC) => 0; lfs_file_open(&lfs, &file, "avacado", LFS_O_WRONLY | LFS_O_TRUNC) => 0;
srand(2); srand(2);
for (lfs_size_t i = 0; i < SIZE2; i += CHUNKSIZE) { for (lfs_size_t i = 0; i < SIZE2; i += CHUNKSIZE) {
@@ -269,7 +269,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// read // read
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0; lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY) => 0;
lfs_file_size(&lfs, &file) => SIZE2; lfs_file_size(&lfs, &file) => SIZE2;
srand(2); srand(2);
@@ -290,10 +290,10 @@ define.SIZE = [32, 0, 7, 2049]
define.CHUNKSIZE = [31, 16, 65] define.CHUNKSIZE = [31, 16, 65]
reentrant = true reentrant = true
code = ''' code = '''
err = lfs_mount(&lfs, &cfg); err = lfs_mountcfg(&lfs, &cfg);
if (err) { if (err) {
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
} }
err = lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY); err = lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY);
@@ -344,10 +344,10 @@ define = [
] ]
reentrant = true reentrant = true
code = ''' code = '''
err = lfs_mount(&lfs, &cfg); err = lfs_mountcfg(&lfs, &cfg);
if (err) { if (err) {
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
} }
err = lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY); err = lfs_file_open(&lfs, &file, "avacado", LFS_O_RDONLY);
@@ -406,9 +406,9 @@ code = '''
[[case]] # many files [[case]] # many files
define.N = 300 define.N = 300
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
// create N files of 7 bytes // create N files of 7 bytes
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
sprintf(path, "file_%03d", i); sprintf(path, "file_%03d", i);
lfs_file_open(&lfs, &file, path, lfs_file_open(&lfs, &file, path,
@@ -431,9 +431,9 @@ code = '''
[[case]] # many files with power cycle [[case]] # many files with power cycle
define.N = 300 define.N = 300
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
// create N files of 7 bytes // create N files of 7 bytes
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
sprintf(path, "file_%03d", i); sprintf(path, "file_%03d", i);
lfs_file_open(&lfs, &file, path, lfs_file_open(&lfs, &file, path,
@@ -446,7 +446,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
char rbuffer[1024]; 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_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
lfs_file_read(&lfs, &file, rbuffer, size) => size; lfs_file_read(&lfs, &file, rbuffer, size) => size;
assert(strcmp(rbuffer, wbuffer) == 0); assert(strcmp(rbuffer, wbuffer) == 0);
@@ -459,10 +459,10 @@ code = '''
define.N = 300 define.N = 300
reentrant = true reentrant = true
code = ''' code = '''
err = lfs_mount(&lfs, &cfg); err = lfs_mountcfg(&lfs, &cfg);
if (err) { if (err) {
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
} }
// create N files of 7 bytes // create N files of 7 bytes
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {

View File

@@ -5,8 +5,8 @@ define.FILES = [4, 10, 26]
code = ''' code = '''
lfs_file_t files[FILES]; lfs_file_t files[FILES];
const char alphas[] = "abcdefghijklmnopqrstuvwxyz"; const char alphas[] = "abcdefghijklmnopqrstuvwxyz";
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int j = 0; j < FILES; j++) { for (int j = 0; j < FILES; j++) {
sprintf(path, "%c", alphas[j]); sprintf(path, "%c", alphas[j]);
lfs_file_open(&lfs, &files[j], path, lfs_file_open(&lfs, &files[j], path,
@@ -64,8 +64,8 @@ define.SIZE = [10, 100]
define.FILES = [4, 10, 26] define.FILES = [4, 10, 26]
code = ''' code = '''
const char alphas[] = "abcdefghijklmnopqrstuvwxyz"; const char alphas[] = "abcdefghijklmnopqrstuvwxyz";
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int j = 0; j < FILES; j++) { for (int j = 0; j < FILES; j++) {
sprintf(path, "%c", alphas[j]); sprintf(path, "%c", alphas[j]);
lfs_file_open(&lfs, &file, path, lfs_file_open(&lfs, &file, path,
@@ -77,7 +77,7 @@ code = '''
} }
lfs_unmount(&lfs) => 0; 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; lfs_file_open(&lfs, &file, "zzz", LFS_O_WRONLY | LFS_O_CREAT) => 0;
for (int j = 0; j < FILES; j++) { for (int j = 0; j < FILES; j++) {
lfs_file_write(&lfs, &file, (const void*)"~", 1) => 1; lfs_file_write(&lfs, &file, (const void*)"~", 1) => 1;
@@ -115,8 +115,8 @@ code = '''
[[case]] # remove inconveniently test [[case]] # remove inconveniently test
define.SIZE = [10, 100] define.SIZE = [10, 100]
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_t files[3]; lfs_file_t files[3];
lfs_file_open(&lfs, &files[0], "e", LFS_O_WRONLY | LFS_O_CREAT) => 0; lfs_file_open(&lfs, &files[0], "e", LFS_O_WRONLY | LFS_O_CREAT) => 0;
lfs_file_open(&lfs, &files[1], "f", LFS_O_WRONLY | LFS_O_CREAT) => 0; lfs_file_open(&lfs, &files[1], "f", LFS_O_WRONLY | LFS_O_CREAT) => 0;
@@ -180,10 +180,10 @@ code = '''
lfs_file_t files[FILES]; lfs_file_t files[FILES];
const char alphas[] = "abcdefghijklmnopqrstuvwxyz"; const char alphas[] = "abcdefghijklmnopqrstuvwxyz";
err = lfs_mount(&lfs, &cfg); err = lfs_mountcfg(&lfs, &cfg);
if (err) { if (err) {
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
} }
for (int j = 0; j < FILES; j++) { for (int j = 0; j < FILES; j++) {

View File

@@ -1,7 +1,7 @@
[[case]] # move file [[case]] # move file
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "a") => 0; lfs_mkdir(&lfs, "a") => 0;
lfs_mkdir(&lfs, "b") => 0; lfs_mkdir(&lfs, "b") => 0;
lfs_mkdir(&lfs, "c") => 0; lfs_mkdir(&lfs, "c") => 0;
@@ -13,11 +13,11 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_rename(&lfs, "a/hello", "c/hello") => 0; lfs_rename(&lfs, "a/hello", "c/hello") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(strcmp(info.name, ".") == 0); assert(strcmp(info.name, ".") == 0);
@@ -57,8 +57,8 @@ code = '''
[[case]] # noop move, yes this is legal [[case]] # noop move, yes this is legal
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "hi") => 0; lfs_mkdir(&lfs, "hi") => 0;
lfs_rename(&lfs, "hi", "hi") => 0; lfs_rename(&lfs, "hi", "hi") => 0;
lfs_mkdir(&lfs, "hi/hi") => 0; lfs_mkdir(&lfs, "hi/hi") => 0;
@@ -74,8 +74,8 @@ code = '''
[[case]] # move file corrupt source [[case]] # move file corrupt source
in = "lfs.c" in = "lfs.c"
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "a") => 0; lfs_mkdir(&lfs, "a") => 0;
lfs_mkdir(&lfs, "b") => 0; lfs_mkdir(&lfs, "b") => 0;
lfs_mkdir(&lfs, "c") => 0; lfs_mkdir(&lfs, "c") => 0;
@@ -87,12 +87,12 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_rename(&lfs, "a/hello", "c/hello") => 0; lfs_rename(&lfs, "a/hello", "c/hello") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// corrupt the source // corrupt the source
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_block_t block = dir.m.pair[0]; lfs_block_t block = dir.m.pair[0];
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
@@ -108,7 +108,7 @@ code = '''
cfg.prog(&cfg, block, 0, bbuffer, LFS_BLOCK_SIZE) => 0; cfg.prog(&cfg, block, 0, bbuffer, LFS_BLOCK_SIZE) => 0;
cfg.sync(&cfg) => 0; cfg.sync(&cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(strcmp(info.name, ".") == 0); assert(strcmp(info.name, ".") == 0);
@@ -150,8 +150,8 @@ code = '''
in = "lfs.c" in = "lfs.c"
if = 'LFS_PROG_SIZE <= 0x3fe' # only works with one crc per commit if = 'LFS_PROG_SIZE <= 0x3fe' # only works with one crc per commit
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "a") => 0; lfs_mkdir(&lfs, "a") => 0;
lfs_mkdir(&lfs, "b") => 0; lfs_mkdir(&lfs, "b") => 0;
lfs_mkdir(&lfs, "c") => 0; lfs_mkdir(&lfs, "c") => 0;
@@ -163,12 +163,12 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_rename(&lfs, "a/hello", "c/hello") => 0; lfs_rename(&lfs, "a/hello", "c/hello") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// corrupt the source // corrupt the source
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_block_t block = dir.m.pair[0]; lfs_block_t block = dir.m.pair[0];
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
@@ -185,7 +185,7 @@ code = '''
cfg.sync(&cfg) => 0; cfg.sync(&cfg) => 0;
// corrupt the destination // corrupt the destination
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "c") => 0; lfs_dir_open(&lfs, &dir, "c") => 0;
block = dir.m.pair[0]; block = dir.m.pair[0];
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
@@ -200,7 +200,7 @@ code = '''
cfg.prog(&cfg, block, 0, bbuffer, LFS_BLOCK_SIZE) => 0; cfg.prog(&cfg, block, 0, bbuffer, LFS_BLOCK_SIZE) => 0;
cfg.sync(&cfg) => 0; cfg.sync(&cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(strcmp(info.name, ".") == 0); assert(strcmp(info.name, ".") == 0);
@@ -242,8 +242,8 @@ code = '''
in = "lfs.c" in = "lfs.c"
if = 'LFS_PROG_SIZE <= 0x3fe' # only works with one crc per commit if = 'LFS_PROG_SIZE <= 0x3fe' # only works with one crc per commit
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "a") => 0; lfs_mkdir(&lfs, "a") => 0;
lfs_mkdir(&lfs, "b") => 0; lfs_mkdir(&lfs, "b") => 0;
lfs_mkdir(&lfs, "c") => 0; lfs_mkdir(&lfs, "c") => 0;
@@ -255,12 +255,12 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_rename(&lfs, "a/hello", "c/hello") => 0; lfs_rename(&lfs, "a/hello", "c/hello") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// corrupt the source // corrupt the source
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_block_t block = dir.m.pair[0]; lfs_block_t block = dir.m.pair[0];
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
@@ -277,7 +277,7 @@ code = '''
cfg.sync(&cfg) => 0; cfg.sync(&cfg) => 0;
// corrupt the destination // corrupt the destination
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "c") => 0; lfs_dir_open(&lfs, &dir, "c") => 0;
block = dir.m.pair[0]; block = dir.m.pair[0];
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
@@ -293,11 +293,11 @@ code = '''
cfg.sync(&cfg) => 0; cfg.sync(&cfg) => 0;
// continue move // continue move
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_rename(&lfs, "a/hello", "c/hello") => 0; lfs_rename(&lfs, "a/hello", "c/hello") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(strcmp(info.name, ".") == 0); assert(strcmp(info.name, ".") == 0);
@@ -338,10 +338,10 @@ code = '''
[[case]] # simple reentrant move file [[case]] # simple reentrant move file
reentrant = true reentrant = true
code = ''' code = '''
err = lfs_mount(&lfs, &cfg); err = lfs_mountcfg(&lfs, &cfg);
if (err) { if (err) {
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
} }
err = lfs_mkdir(&lfs, "a"); err = lfs_mkdir(&lfs, "a");
assert(!err || err == LFS_ERR_EXIST); assert(!err || err == LFS_ERR_EXIST);
@@ -354,7 +354,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
while (true) { while (true) {
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// there should never exist _2_ hello files // there should never exist _2_ hello files
int count = 0; int count = 0;
if (lfs_stat(&lfs, "a/hello", &info) == 0) { if (lfs_stat(&lfs, "a/hello", &info) == 0) {
@@ -384,7 +384,7 @@ code = '''
assert(count <= 1); assert(count <= 1);
lfs_unmount(&lfs) => 0; 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) { if (lfs_stat(&lfs, "a/hello", &info) == 0 && info.size > 0) {
lfs_rename(&lfs, "a/hello", "b/hello") => 0; lfs_rename(&lfs, "a/hello", "b/hello") => 0;
} else if (lfs_stat(&lfs, "b/hello", &info) == 0) { } else if (lfs_stat(&lfs, "b/hello", &info) == 0) {
@@ -407,7 +407,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
} }
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(strcmp(info.name, ".") == 0); assert(strcmp(info.name, ".") == 0);
@@ -447,8 +447,8 @@ code = '''
[[case]] # move dir [[case]] # move dir
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "a") => 0; lfs_mkdir(&lfs, "a") => 0;
lfs_mkdir(&lfs, "b") => 0; lfs_mkdir(&lfs, "b") => 0;
lfs_mkdir(&lfs, "c") => 0; lfs_mkdir(&lfs, "c") => 0;
@@ -459,11 +459,11 @@ code = '''
lfs_mkdir(&lfs, "a/hi/ohayo") => 0; lfs_mkdir(&lfs, "a/hi/ohayo") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_rename(&lfs, "a/hi", "c/hi") => 0; lfs_rename(&lfs, "a/hi", "c/hi") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(strcmp(info.name, ".") == 0); assert(strcmp(info.name, ".") == 0);
@@ -513,8 +513,8 @@ code = '''
[[case]] # move dir corrupt source [[case]] # move dir corrupt source
in = "lfs.c" in = "lfs.c"
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "a") => 0; lfs_mkdir(&lfs, "a") => 0;
lfs_mkdir(&lfs, "b") => 0; lfs_mkdir(&lfs, "b") => 0;
lfs_mkdir(&lfs, "c") => 0; lfs_mkdir(&lfs, "c") => 0;
@@ -525,12 +525,12 @@ code = '''
lfs_mkdir(&lfs, "a/hi/ohayo") => 0; lfs_mkdir(&lfs, "a/hi/ohayo") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_rename(&lfs, "a/hi", "c/hi") => 0; lfs_rename(&lfs, "a/hi", "c/hi") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// corrupt the source // corrupt the source
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_block_t block = dir.m.pair[0]; lfs_block_t block = dir.m.pair[0];
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
@@ -546,7 +546,7 @@ code = '''
cfg.prog(&cfg, block, 0, bbuffer, LFS_BLOCK_SIZE) => 0; cfg.prog(&cfg, block, 0, bbuffer, LFS_BLOCK_SIZE) => 0;
cfg.sync(&cfg) => 0; cfg.sync(&cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(strcmp(info.name, ".") == 0); assert(strcmp(info.name, ".") == 0);
@@ -597,8 +597,8 @@ code = '''
in = "lfs.c" in = "lfs.c"
if = 'LFS_PROG_SIZE <= 0x3fe' # only works with one crc per commit if = 'LFS_PROG_SIZE <= 0x3fe' # only works with one crc per commit
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "a") => 0; lfs_mkdir(&lfs, "a") => 0;
lfs_mkdir(&lfs, "b") => 0; lfs_mkdir(&lfs, "b") => 0;
lfs_mkdir(&lfs, "c") => 0; lfs_mkdir(&lfs, "c") => 0;
@@ -609,12 +609,12 @@ code = '''
lfs_mkdir(&lfs, "a/hi/ohayo") => 0; lfs_mkdir(&lfs, "a/hi/ohayo") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_rename(&lfs, "a/hi", "c/hi") => 0; lfs_rename(&lfs, "a/hi", "c/hi") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// corrupt the source // corrupt the source
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_block_t block = dir.m.pair[0]; lfs_block_t block = dir.m.pair[0];
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
@@ -631,7 +631,7 @@ code = '''
cfg.sync(&cfg) => 0; cfg.sync(&cfg) => 0;
// corrupt the destination // corrupt the destination
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "c") => 0; lfs_dir_open(&lfs, &dir, "c") => 0;
block = dir.m.pair[0]; block = dir.m.pair[0];
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
@@ -646,7 +646,7 @@ code = '''
cfg.prog(&cfg, block, 0, bbuffer, LFS_BLOCK_SIZE) => 0; cfg.prog(&cfg, block, 0, bbuffer, LFS_BLOCK_SIZE) => 0;
cfg.sync(&cfg) => 0; cfg.sync(&cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(strcmp(info.name, ".") == 0); assert(strcmp(info.name, ".") == 0);
@@ -697,8 +697,8 @@ code = '''
in = "lfs.c" in = "lfs.c"
if = 'LFS_PROG_SIZE <= 0x3fe' # only works with one crc per commit if = 'LFS_PROG_SIZE <= 0x3fe' # only works with one crc per commit
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "a") => 0; lfs_mkdir(&lfs, "a") => 0;
lfs_mkdir(&lfs, "b") => 0; lfs_mkdir(&lfs, "b") => 0;
lfs_mkdir(&lfs, "c") => 0; lfs_mkdir(&lfs, "c") => 0;
@@ -709,12 +709,12 @@ code = '''
lfs_mkdir(&lfs, "a/hi/ohayo") => 0; lfs_mkdir(&lfs, "a/hi/ohayo") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_rename(&lfs, "a/hi", "c/hi") => 0; lfs_rename(&lfs, "a/hi", "c/hi") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// corrupt the source // corrupt the source
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_block_t block = dir.m.pair[0]; lfs_block_t block = dir.m.pair[0];
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
@@ -731,7 +731,7 @@ code = '''
cfg.sync(&cfg) => 0; cfg.sync(&cfg) => 0;
// corrupt the destination // corrupt the destination
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "c") => 0; lfs_dir_open(&lfs, &dir, "c") => 0;
block = dir.m.pair[0]; block = dir.m.pair[0];
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
@@ -747,11 +747,11 @@ code = '''
cfg.sync(&cfg) => 0; cfg.sync(&cfg) => 0;
// continue move // continue move
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_rename(&lfs, "a/hi", "c/hi") => 0; lfs_rename(&lfs, "a/hi", "c/hi") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(strcmp(info.name, ".") == 0); assert(strcmp(info.name, ".") == 0);
@@ -801,10 +801,10 @@ code = '''
[[case]] # simple reentrant move dir [[case]] # simple reentrant move dir
reentrant = true reentrant = true
code = ''' code = '''
err = lfs_mount(&lfs, &cfg); err = lfs_mountcfg(&lfs, &cfg);
if (err) { if (err) {
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
} }
err = lfs_mkdir(&lfs, "a"); err = lfs_mkdir(&lfs, "a");
assert(!err || err == LFS_ERR_EXIST); assert(!err || err == LFS_ERR_EXIST);
@@ -817,7 +817,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
while (true) { while (true) {
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// there should never exist _2_ hi directories // there should never exist _2_ hi directories
int count = 0; int count = 0;
if (lfs_stat(&lfs, "a/hi", &info) == 0) { if (lfs_stat(&lfs, "a/hi", &info) == 0) {
@@ -843,7 +843,7 @@ code = '''
assert(count <= 1); assert(count <= 1);
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
if (lfs_stat(&lfs, "a/hi", &info) == 0) { if (lfs_stat(&lfs, "a/hi", &info) == 0) {
lfs_rename(&lfs, "a/hi", "b/hi") => 0; lfs_rename(&lfs, "a/hi", "b/hi") => 0;
} else if (lfs_stat(&lfs, "b/hi", &info) == 0) { } else if (lfs_stat(&lfs, "b/hi", &info) == 0) {
@@ -868,7 +868,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
} }
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "a") => 0; lfs_dir_open(&lfs, &dir, "a") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
assert(strcmp(info.name, ".") == 0); assert(strcmp(info.name, ".") == 0);
@@ -917,8 +917,8 @@ code = '''
[[case]] # move state stealing [[case]] # move state stealing
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "a") => 0; lfs_mkdir(&lfs, "a") => 0;
lfs_mkdir(&lfs, "b") => 0; lfs_mkdir(&lfs, "b") => 0;
lfs_mkdir(&lfs, "c") => 0; lfs_mkdir(&lfs, "c") => 0;
@@ -930,17 +930,17 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_rename(&lfs, "a/hello", "b/hello") => 0; lfs_rename(&lfs, "a/hello", "b/hello") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_rename(&lfs, "b/hello", "c/hello") => 0; lfs_rename(&lfs, "b/hello", "c/hello") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_rename(&lfs, "c/hello", "d/hello") => 0; lfs_rename(&lfs, "c/hello", "d/hello") => 0;
lfs_unmount(&lfs) => 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, "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, "b/hello", LFS_O_RDONLY) => LFS_ERR_NOENT;
lfs_file_open(&lfs, &file, "c/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_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_remove(&lfs, "b") => 0; lfs_remove(&lfs, "b") => 0;
lfs_remove(&lfs, "c") => 0; lfs_remove(&lfs, "c") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_stat(&lfs, "a", &info) => 0; lfs_stat(&lfs, "a", &info) => 0;
lfs_stat(&lfs, "b", &info) => LFS_ERR_NOENT; lfs_stat(&lfs, "b", &info) => LFS_ERR_NOENT;
lfs_stat(&lfs, "c", &info) => LFS_ERR_NOENT; lfs_stat(&lfs, "c", &info) => LFS_ERR_NOENT;
@@ -981,8 +981,8 @@ code = '''
# Other specific corner cases # Other specific corner cases
[[case]] # create + delete in same commit with neighbors [[case]] # create + delete in same commit with neighbors
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// littlefs keeps files sorted, so we know the order these will be in // littlefs keeps files sorted, so we know the order these will be in
lfs_file_open(&lfs, &file, "/1.move_me", lfs_file_open(&lfs, &file, "/1.move_me",
@@ -1127,8 +1127,8 @@ code = '''
# Other specific corner cases # Other specific corner cases
[[case]] # create + delete + delete in same commit with neighbors [[case]] # create + delete + delete in same commit with neighbors
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// littlefs keeps files sorted, so we know the order these will be in // littlefs keeps files sorted, so we know the order these will be in
lfs_file_open(&lfs, &file, "/1.move_me", lfs_file_open(&lfs, &file, "/1.move_me",
@@ -1283,8 +1283,8 @@ code = '''
[[case]] # create + delete in different dirs with neighbors [[case]] # create + delete in different dirs with neighbors
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// littlefs keeps files sorted, so we know the order these will be in // littlefs keeps files sorted, so we know the order these will be in
lfs_mkdir(&lfs, "/dir.1") => 0; lfs_mkdir(&lfs, "/dir.1") => 0;
@@ -1523,8 +1523,8 @@ in = "lfs.c"
define.RELOCATIONS = 'range(0x3+1)' define.RELOCATIONS = 'range(0x3+1)'
define.LFS_ERASE_CYCLES = 0xffffffff define.LFS_ERASE_CYCLES = 0xffffffff
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "/parent") => 0; lfs_mkdir(&lfs, "/parent") => 0;
lfs_mkdir(&lfs, "/parent/child") => 0; lfs_mkdir(&lfs, "/parent/child") => 0;
@@ -1660,8 +1660,8 @@ in = "lfs.c"
define.RELOCATIONS = 'range(0x7+1)' define.RELOCATIONS = 'range(0x7+1)'
define.LFS_ERASE_CYCLES = 0xffffffff define.LFS_ERASE_CYCLES = 0xffffffff
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "/parent") => 0; lfs_mkdir(&lfs, "/parent") => 0;
lfs_mkdir(&lfs, "/parent/child") => 0; lfs_mkdir(&lfs, "/parent/child") => 0;

View File

@@ -2,8 +2,8 @@
in = "lfs.c" in = "lfs.c"
if = 'LFS_PROG_SIZE <= 0x3fe' # only works with one crc per commit if = 'LFS_PROG_SIZE <= 0x3fe' # only works with one crc per commit
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "parent") => 0; lfs_mkdir(&lfs, "parent") => 0;
lfs_mkdir(&lfs, "parent/orphan") => 0; lfs_mkdir(&lfs, "parent/orphan") => 0;
lfs_mkdir(&lfs, "parent/child") => 0; lfs_mkdir(&lfs, "parent/child") => 0;
@@ -13,7 +13,7 @@ code = '''
// corrupt the child's most recent commit, this should be the update // corrupt the child's most recent commit, this should be the update
// to the linked-list entry, which should orphan the orphan. Note this // to the linked-list entry, which should orphan the orphan. Note this
// makes a lot of assumptions about the remove operation. // makes a lot of assumptions about the remove operation.
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "parent/child") => 0; lfs_dir_open(&lfs, &dir, "parent/child") => 0;
lfs_block_t block = dir.m.pair[0]; lfs_block_t block = dir.m.pair[0];
lfs_dir_close(&lfs, &dir) => 0; lfs_dir_close(&lfs, &dir) => 0;
@@ -29,13 +29,13 @@ code = '''
cfg.prog(&cfg, block, 0, bbuffer, LFS_BLOCK_SIZE) => 0; cfg.prog(&cfg, block, 0, bbuffer, LFS_BLOCK_SIZE) => 0;
cfg.sync(&cfg) => 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/orphan", &info) => LFS_ERR_NOENT;
lfs_stat(&lfs, "parent/child", &info) => 0; lfs_stat(&lfs, "parent/child", &info) => 0;
lfs_fs_size(&lfs) => 8; lfs_fs_size(&lfs) => 8;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT; lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
lfs_stat(&lfs, "parent/child", &info) => 0; lfs_stat(&lfs, "parent/child", &info) => 0;
lfs_fs_size(&lfs) => 8; lfs_fs_size(&lfs) => 8;
@@ -48,7 +48,7 @@ code = '''
lfs_fs_size(&lfs) => 8; lfs_fs_size(&lfs) => 8;
lfs_unmount(&lfs) => 0; 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/orphan", &info) => LFS_ERR_NOENT;
lfs_stat(&lfs, "parent/child", &info) => 0; lfs_stat(&lfs, "parent/child", &info) => 0;
lfs_stat(&lfs, "parent/otherchild", &info) => 0; lfs_stat(&lfs, "parent/otherchild", &info) => 0;
@@ -66,10 +66,10 @@ define = [
{FILES=3, DEPTH=3, CYCLES=20}, {FILES=3, DEPTH=3, CYCLES=20},
] ]
code = ''' code = '''
err = lfs_mount(&lfs, &cfg); err = lfs_mountcfg(&lfs, &cfg);
if (err) { if (err) {
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
} }
srand(1); srand(1);

View File

@@ -1,8 +1,8 @@
[[case]] # simple path test [[case]] # simple path test
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "tea") => 0; lfs_mkdir(&lfs, "tea") => 0;
lfs_mkdir(&lfs, "tea/hottea") => 0; lfs_mkdir(&lfs, "tea/hottea") => 0;
lfs_mkdir(&lfs, "tea/warmtea") => 0; lfs_mkdir(&lfs, "tea/warmtea") => 0;
@@ -23,8 +23,8 @@ code = '''
[[case]] # redundant slashes [[case]] # redundant slashes
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "tea") => 0; lfs_mkdir(&lfs, "tea") => 0;
lfs_mkdir(&lfs, "tea/hottea") => 0; lfs_mkdir(&lfs, "tea/hottea") => 0;
lfs_mkdir(&lfs, "tea/warmtea") => 0; lfs_mkdir(&lfs, "tea/warmtea") => 0;
@@ -47,8 +47,8 @@ code = '''
[[case]] # dot path test [[case]] # dot path test
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "tea") => 0; lfs_mkdir(&lfs, "tea") => 0;
lfs_mkdir(&lfs, "tea/hottea") => 0; lfs_mkdir(&lfs, "tea/hottea") => 0;
lfs_mkdir(&lfs, "tea/warmtea") => 0; lfs_mkdir(&lfs, "tea/warmtea") => 0;
@@ -73,8 +73,8 @@ code = '''
[[case]] # dot dot path test [[case]] # dot dot path test
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "tea") => 0; lfs_mkdir(&lfs, "tea") => 0;
lfs_mkdir(&lfs, "tea/hottea") => 0; lfs_mkdir(&lfs, "tea/hottea") => 0;
lfs_mkdir(&lfs, "tea/warmtea") => 0; lfs_mkdir(&lfs, "tea/warmtea") => 0;
@@ -103,8 +103,8 @@ code = '''
[[case]] # trailing dot path test [[case]] # trailing dot path test
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "tea") => 0; lfs_mkdir(&lfs, "tea") => 0;
lfs_mkdir(&lfs, "tea/hottea") => 0; lfs_mkdir(&lfs, "tea/hottea") => 0;
lfs_mkdir(&lfs, "tea/warmtea") => 0; lfs_mkdir(&lfs, "tea/warmtea") => 0;
@@ -125,8 +125,8 @@ code = '''
[[case]] # leading dot path test [[case]] # leading dot path test
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, ".milk") => 0; lfs_mkdir(&lfs, ".milk") => 0;
lfs_stat(&lfs, ".milk", &info) => 0; lfs_stat(&lfs, ".milk", &info) => 0;
strcmp(info.name, ".milk") => 0; strcmp(info.name, ".milk") => 0;
@@ -137,8 +137,8 @@ code = '''
[[case]] # root dot dot path test [[case]] # root dot dot path test
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "tea") => 0; lfs_mkdir(&lfs, "tea") => 0;
lfs_mkdir(&lfs, "tea/hottea") => 0; lfs_mkdir(&lfs, "tea/hottea") => 0;
lfs_mkdir(&lfs, "tea/warmtea") => 0; lfs_mkdir(&lfs, "tea/warmtea") => 0;
@@ -161,8 +161,8 @@ code = '''
[[case]] # invalid path tests [[case]] # invalid path tests
code = ''' code = '''
lfs_format(&lfs, &cfg); lfs_formatcfg(&lfs, &cfg);
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_stat(&lfs, "dirt", &info) => LFS_ERR_NOENT; lfs_stat(&lfs, "dirt", &info) => LFS_ERR_NOENT;
lfs_stat(&lfs, "dirt/ground", &info) => LFS_ERR_NOENT; lfs_stat(&lfs, "dirt/ground", &info) => LFS_ERR_NOENT;
lfs_stat(&lfs, "dirt/ground/earth", &info) => LFS_ERR_NOENT; lfs_stat(&lfs, "dirt/ground/earth", &info) => LFS_ERR_NOENT;
@@ -182,8 +182,8 @@ code = '''
[[case]] # root operations [[case]] # root operations
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_stat(&lfs, "/", &info) => 0; lfs_stat(&lfs, "/", &info) => 0;
assert(strcmp(info.name, "/") == 0); assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS_TYPE_DIR); assert(info.type == LFS_TYPE_DIR);
@@ -198,8 +198,8 @@ code = '''
[[case]] # root representations [[case]] # root representations
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_stat(&lfs, "/", &info) => 0; lfs_stat(&lfs, "/", &info) => 0;
assert(strcmp(info.name, "/") == 0); assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS_TYPE_DIR); assert(info.type == LFS_TYPE_DIR);
@@ -223,8 +223,8 @@ code = '''
[[case]] # superblock conflict test [[case]] # superblock conflict test
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT; lfs_stat(&lfs, "littlefs", &info) => LFS_ERR_NOENT;
lfs_remove(&lfs, "littlefs") => LFS_ERR_NOENT; lfs_remove(&lfs, "littlefs") => LFS_ERR_NOENT;
@@ -239,8 +239,8 @@ code = '''
[[case]] # max path test [[case]] # max path test
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "coffee") => 0; lfs_mkdir(&lfs, "coffee") => 0;
lfs_mkdir(&lfs, "coffee/hotcoffee") => 0; lfs_mkdir(&lfs, "coffee/hotcoffee") => 0;
lfs_mkdir(&lfs, "coffee/warmcoffee") => 0; lfs_mkdir(&lfs, "coffee/warmcoffee") => 0;
@@ -263,8 +263,8 @@ code = '''
[[case]] # really big path test [[case]] # really big path test
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_mkdir(&lfs, "coffee") => 0; lfs_mkdir(&lfs, "coffee") => 0;
lfs_mkdir(&lfs, "coffee/hotcoffee") => 0; lfs_mkdir(&lfs, "coffee/hotcoffee") => 0;
lfs_mkdir(&lfs, "coffee/warmcoffee") => 0; lfs_mkdir(&lfs, "coffee/warmcoffee") => 0;

View File

@@ -4,9 +4,9 @@ define.ITERATIONS = 20
define.COUNT = 10 define.COUNT = 10
define.LFS_BLOCK_CYCLES = [8, 1] define.LFS_BLOCK_CYCLES = [8, 1]
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
// fill up filesystem so only ~16 blocks are left // fill up filesystem so only ~16 blocks are left
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "padding", LFS_O_CREAT | LFS_O_WRONLY) => 0; lfs_file_open(&lfs, &file, "padding", LFS_O_CREAT | LFS_O_WRONLY) => 0;
memset(buffer, 0, 512); memset(buffer, 0, 512);
while (LFS_BLOCK_COUNT - lfs_fs_size(&lfs) > 16) { while (LFS_BLOCK_COUNT - lfs_fs_size(&lfs) > 16) {
@@ -17,7 +17,7 @@ code = '''
lfs_mkdir(&lfs, "child") => 0; lfs_mkdir(&lfs, "child") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int j = 0; j < ITERATIONS; j++) { for (int j = 0; j < ITERATIONS; j++) {
for (int i = 0; i < COUNT; i++) { for (int i = 0; i < COUNT; i++) {
sprintf(path, "child/test%03d_loooooooooooooooooong_name", i); sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
@@ -47,7 +47,7 @@ code = '''
} }
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_dir_open(&lfs, &dir, "child") => 0; lfs_dir_open(&lfs, &dir, "child") => 0;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
lfs_dir_read(&lfs, &dir, &info) => 1; lfs_dir_read(&lfs, &dir, &info) => 1;
@@ -70,9 +70,9 @@ define.ITERATIONS = 20
define.COUNT = 10 define.COUNT = 10
define.LFS_BLOCK_CYCLES = [8, 1] define.LFS_BLOCK_CYCLES = [8, 1]
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
// fill up filesystem so only ~16 blocks are left // fill up filesystem so only ~16 blocks are left
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "padding", LFS_O_CREAT | LFS_O_WRONLY) => 0; lfs_file_open(&lfs, &file, "padding", LFS_O_CREAT | LFS_O_WRONLY) => 0;
memset(buffer, 0, 512); memset(buffer, 0, 512);
while (LFS_BLOCK_COUNT - lfs_fs_size(&lfs) > 16) { while (LFS_BLOCK_COUNT - lfs_fs_size(&lfs) > 16) {
@@ -83,7 +83,7 @@ code = '''
lfs_mkdir(&lfs, "child") => 0; lfs_mkdir(&lfs, "child") => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (int j = 0; j < ITERATIONS; j++) { for (int j = 0; j < ITERATIONS; j++) {
for (int i = 0; i < COUNT; i++) { for (int i = 0; i < COUNT; i++) {
sprintf(path, "child/test%03d_loooooooooooooooooong_name", i); sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
@@ -155,10 +155,10 @@ define = [
{FILES=3, DEPTH=3, CYCLES=20, LFS_BLOCK_CYCLES=1}, {FILES=3, DEPTH=3, CYCLES=20, LFS_BLOCK_CYCLES=1},
] ]
code = ''' code = '''
err = lfs_mount(&lfs, &cfg); err = lfs_mountcfg(&lfs, &cfg);
if (err) { if (err) {
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
} }
srand(1); srand(1);
@@ -217,10 +217,10 @@ define = [
{FILES=3, DEPTH=3, CYCLES=20, LFS_BLOCK_CYCLES=1}, {FILES=3, DEPTH=3, CYCLES=20, LFS_BLOCK_CYCLES=1},
] ]
code = ''' code = '''
err = lfs_mount(&lfs, &cfg); err = lfs_mountcfg(&lfs, &cfg);
if (err) { if (err) {
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
} }
srand(1); srand(1);

View File

@@ -9,8 +9,8 @@ define = [
{COUNT=4, SKIP=2}, {COUNT=4, SKIP=2},
] ]
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "kitty", lfs_file_open(&lfs, &file, "kitty",
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0; LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
size = strlen("kittycatcat"); size = strlen("kittycatcat");
@@ -21,7 +21,7 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "kitty", LFS_O_RDONLY) => 0; lfs_file_open(&lfs, &file, "kitty", LFS_O_RDONLY) => 0;
lfs_soff_t pos = -1; lfs_soff_t pos = -1;
@@ -78,8 +78,8 @@ define = [
{COUNT=4, SKIP=2}, {COUNT=4, SKIP=2},
] ]
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "kitty", lfs_file_open(&lfs, &file, "kitty",
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0; LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
size = strlen("kittycatcat"); size = strlen("kittycatcat");
@@ -90,7 +90,7 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0; lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
lfs_soff_t pos = -1; lfs_soff_t pos = -1;
@@ -133,8 +133,8 @@ code = '''
define.COUNT = 132 define.COUNT = 132
define.OFFSETS = '"{512, 1020, 513, 1021, 511, 1019, 1441}"' define.OFFSETS = '"{512, 1020, 513, 1021, 511, 1019, 1441}"'
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "kitty", lfs_file_open(&lfs, &file, "kitty",
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0; LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
size = strlen("kittycatcat"); size = strlen("kittycatcat");
@@ -145,7 +145,7 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0; lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
size = strlen("hedgehoghog"); size = strlen("hedgehoghog");
@@ -193,8 +193,8 @@ define = [
{COUNT=4, SKIP=3}, {COUNT=4, SKIP=3},
] ]
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "kitty", lfs_file_open(&lfs, &file, "kitty",
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0; LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
size = strlen("kittycatcat"); size = strlen("kittycatcat");
@@ -204,7 +204,7 @@ code = '''
} }
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0; lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
size = strlen("kittycatcat"); size = strlen("kittycatcat");
@@ -241,8 +241,8 @@ code = '''
[[case]] # inline write and seek [[case]] # inline write and seek
define.SIZE = [2, 4, 128, 132] define.SIZE = [2, 4, 128, 132]
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "tinykitty", lfs_file_open(&lfs, &file, "tinykitty",
LFS_O_RDWR | LFS_O_CREAT) => 0; LFS_O_RDWR | LFS_O_CREAT) => 0;
int j = 0; int j = 0;
@@ -310,10 +310,10 @@ code = '''
define.COUNT = [4, 64, 128] define.COUNT = [4, 64, 128]
reentrant = true reentrant = true
code = ''' code = '''
err = lfs_mount(&lfs, &cfg); err = lfs_mountcfg(&lfs, &cfg);
if (err) { if (err) {
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
} }
err = lfs_file_open(&lfs, &file, "kitty", LFS_O_RDONLY); err = lfs_file_open(&lfs, &file, "kitty", LFS_O_RDONLY);
assert(!err || err == LFS_ERR_NOENT); assert(!err || err == LFS_ERR_NOENT);

View File

@@ -1,37 +1,37 @@
[[case]] # simple formatting test [[case]] # simple formatting test
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
''' '''
[[case]] # mount/unmount [[case]] # mount/unmount
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
''' '''
[[case]] # reentrant format [[case]] # reentrant format
reentrant = true reentrant = true
code = ''' code = '''
err = lfs_mount(&lfs, &cfg); err = lfs_mountcfg(&lfs, &cfg);
if (err) { if (err) {
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
} }
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
''' '''
[[case]] # invalid mount [[case]] # invalid mount
code = ''' code = '''
lfs_mount(&lfs, &cfg) => LFS_ERR_CORRUPT; lfs_mountcfg(&lfs, &cfg) => LFS_ERR_CORRUPT;
''' '''
[[case]] # expanding superblock [[case]] # expanding superblock
define.LFS_BLOCK_CYCLES = [32, 33, 1] define.LFS_BLOCK_CYCLES = [32, 33, 1]
define.N = [10, 100, 1000] define.N = [10, 100, 1000]
code = ''' 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++) { for (int i = 0; i < N; i++) {
lfs_file_open(&lfs, &file, "dummy", lfs_file_open(&lfs, &file, "dummy",
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0; LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
@@ -44,7 +44,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// one last check after power-cycle // one last check after power-cycle
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "dummy", lfs_file_open(&lfs, &file, "dummy",
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0; LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
@@ -58,9 +58,9 @@ code = '''
define.LFS_BLOCK_CYCLES = [32, 33, 1] define.LFS_BLOCK_CYCLES = [32, 33, 1]
define.N = [10, 100, 1000] define.N = [10, 100, 1000]
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
// remove lingering dummy? // remove lingering dummy?
err = lfs_stat(&lfs, "dummy", &info); err = lfs_stat(&lfs, "dummy", &info);
assert(err == 0 || (err == LFS_ERR_NOENT && i == 0)); assert(err == 0 || (err == LFS_ERR_NOENT && i == 0));
@@ -80,7 +80,7 @@ code = '''
} }
// one last check after power-cycle // one last check after power-cycle
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_stat(&lfs, "dummy", &info) => 0; lfs_stat(&lfs, "dummy", &info) => 0;
assert(strcmp(info.name, "dummy") == 0); assert(strcmp(info.name, "dummy") == 0);
assert(info.type == LFS_TYPE_REG); assert(info.type == LFS_TYPE_REG);
@@ -92,10 +92,10 @@ define.LFS_BLOCK_CYCLES = [2, 1]
define.N = 24 define.N = 24
reentrant = true reentrant = true
code = ''' code = '''
err = lfs_mount(&lfs, &cfg); err = lfs_mountcfg(&lfs, &cfg);
if (err) { if (err) {
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++) { for (int i = 0; i < N; i++) {
@@ -119,7 +119,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
// one last check after power-cycle // one last check after power-cycle
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_stat(&lfs, "dummy", &info) => 0; lfs_stat(&lfs, "dummy", &info) => 0;
assert(strcmp(info.name, "dummy") == 0); assert(strcmp(info.name, "dummy") == 0);
assert(info.type == LFS_TYPE_REG); assert(info.type == LFS_TYPE_REG);

View File

@@ -2,8 +2,8 @@
define.MEDIUMSIZE = [32, 2048] define.MEDIUMSIZE = [32, 2048]
define.LARGESIZE = 8192 define.LARGESIZE = 8192
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "baldynoop", lfs_file_open(&lfs, &file, "baldynoop",
LFS_O_WRONLY | LFS_O_CREAT) => 0; LFS_O_WRONLY | LFS_O_CREAT) => 0;
@@ -17,7 +17,7 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "baldynoop", LFS_O_RDWR) => 0; lfs_file_open(&lfs, &file, "baldynoop", LFS_O_RDWR) => 0;
lfs_file_size(&lfs, &file) => LARGESIZE; lfs_file_size(&lfs, &file) => LARGESIZE;
@@ -27,7 +27,7 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "baldynoop", LFS_O_RDONLY) => 0; lfs_file_open(&lfs, &file, "baldynoop", LFS_O_RDONLY) => 0;
lfs_file_size(&lfs, &file) => MEDIUMSIZE; lfs_file_size(&lfs, &file) => MEDIUMSIZE;
@@ -46,8 +46,8 @@ code = '''
define.MEDIUMSIZE = [32, 2048] define.MEDIUMSIZE = [32, 2048]
define.LARGESIZE = 8192 define.LARGESIZE = 8192
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "baldyread", lfs_file_open(&lfs, &file, "baldyread",
LFS_O_WRONLY | LFS_O_CREAT) => 0; LFS_O_WRONLY | LFS_O_CREAT) => 0;
@@ -61,7 +61,7 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "baldyread", LFS_O_RDWR) => 0; lfs_file_open(&lfs, &file, "baldyread", LFS_O_RDWR) => 0;
lfs_file_size(&lfs, &file) => LARGESIZE; lfs_file_size(&lfs, &file) => LARGESIZE;
@@ -78,7 +78,7 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "baldyread", LFS_O_RDONLY) => 0; lfs_file_open(&lfs, &file, "baldyread", LFS_O_RDONLY) => 0;
lfs_file_size(&lfs, &file) => MEDIUMSIZE; lfs_file_size(&lfs, &file) => MEDIUMSIZE;
@@ -95,8 +95,8 @@ code = '''
[[case]] # write, truncate, and read [[case]] # write, truncate, and read
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "sequence", lfs_file_open(&lfs, &file, "sequence",
LFS_O_RDWR | LFS_O_CREAT | LFS_O_TRUNC) => 0; LFS_O_RDWR | LFS_O_CREAT | LFS_O_TRUNC) => 0;
@@ -149,8 +149,8 @@ code = '''
define.MEDIUMSIZE = [32, 2048] define.MEDIUMSIZE = [32, 2048]
define.LARGESIZE = 8192 define.LARGESIZE = 8192
code = ''' code = '''
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "baldywrite", lfs_file_open(&lfs, &file, "baldywrite",
LFS_O_WRONLY | LFS_O_CREAT) => 0; LFS_O_WRONLY | LFS_O_CREAT) => 0;
@@ -164,7 +164,7 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "baldywrite", LFS_O_RDWR) => 0; lfs_file_open(&lfs, &file, "baldywrite", LFS_O_RDWR) => 0;
lfs_file_size(&lfs, &file) => LARGESIZE; lfs_file_size(&lfs, &file) => LARGESIZE;
@@ -181,7 +181,7 @@ code = '''
lfs_file_close(&lfs, &file) => 0; lfs_file_close(&lfs, &file) => 0;
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
lfs_file_open(&lfs, &file, "baldywrite", LFS_O_RDONLY) => 0; lfs_file_open(&lfs, &file, "baldywrite", LFS_O_RDONLY) => 0;
lfs_file_size(&lfs, &file) => MEDIUMSIZE; lfs_file_size(&lfs, &file) => MEDIUMSIZE;
@@ -202,10 +202,10 @@ define.MEDIUMSIZE = [32, 1024]
define.LARGESIZE = 2048 define.LARGESIZE = 2048
reentrant = true reentrant = true
code = ''' code = '''
err = lfs_mount(&lfs, &cfg); err = lfs_mountcfg(&lfs, &cfg);
if (err) { if (err) {
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
} }
err = lfs_file_open(&lfs, &file, "baldy", LFS_O_RDONLY); err = lfs_file_open(&lfs, &file, "baldy", LFS_O_RDONLY);
assert(!err || err == LFS_ERR_NOENT); assert(!err || err == LFS_ERR_NOENT);
@@ -312,8 +312,8 @@ code = '''
const lfs_off_t *hotsizes = configs[CONFIG].hotsizes; const lfs_off_t *hotsizes = configs[CONFIG].hotsizes;
const lfs_off_t *coldsizes = configs[CONFIG].coldsizes; const lfs_off_t *coldsizes = configs[CONFIG].coldsizes;
lfs_format(&lfs, &cfg) => 0; lfs_formatcfg(&lfs, &cfg) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (unsigned i = 0; i < COUNT; i++) { for (unsigned i = 0; i < COUNT; i++) {
sprintf(path, "hairyhead%d", i); sprintf(path, "hairyhead%d", i);
@@ -340,7 +340,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (unsigned i = 0; i < COUNT; i++) { for (unsigned i = 0; i < COUNT; i++) {
sprintf(path, "hairyhead%d", i); sprintf(path, "hairyhead%d", i);
@@ -367,7 +367,7 @@ code = '''
lfs_unmount(&lfs) => 0; lfs_unmount(&lfs) => 0;
lfs_mount(&lfs, &cfg) => 0; lfs_mountcfg(&lfs, &cfg) => 0;
for (unsigned i = 0; i < COUNT; i++) { for (unsigned i = 0; i < COUNT; i++) {
sprintf(path, "hairyhead%d", i); sprintf(path, "hairyhead%d", i);