Files
littlefs/tests/test_paths.toml
Christopher Haster e196be53df Adopted LFS3_ERR_BUSY for root-related errors
Now that we use LFS3_ERR_BUSY for traversals, we no longer have an
excuse for not returning LFS3_ERR_BUSY on root-related errors:

- lfs3_remove(&lfs3, "/") => LFS3_ERR_BUSY
- lfs3_rename(&lfs3, "/", *) => LFS3_ERR_BUSY
- lfs3_rename(&lfs3, *, "/") => LFS3_ERR_BUSY

This better aligns with POSIX. Arguably we should have defined
LFS3_ERR_BUSY for this case anyways, it's not like additional error
codes cost much.

No code changes.
2025-11-12 13:40:59 -06:00

8580 lines
381 KiB
TOML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Test various path-related corner cases
after = 'test_dirs'
# simple path test
[cases.test_paths_simple]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "coffee/drip") => 0;
lfs3_mkdir(&lfs3, "coffee/coldbrew") => 0;
lfs3_mkdir(&lfs3, "coffee/turkish") => 0;
lfs3_mkdir(&lfs3, "coffee/tubruk") => 0;
lfs3_mkdir(&lfs3, "coffee/vietnamese") => 0;
lfs3_mkdir(&lfs3, "coffee/thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/drip") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/coldbrew") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/turkish") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/tubruk") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/vietnamese") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/thai") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/drip") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/coldbrew") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/turkish") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/tubruk") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/vietnamese") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/thai") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
lfs3_rename(&lfs3,
"coffee/drip",
"espresso/espresso") => 0;
lfs3_rename(&lfs3,
"coffee/coldbrew",
"espresso/americano") => 0;
lfs3_rename(&lfs3,
"coffee/turkish",
"espresso/macchiato") => 0;
lfs3_rename(&lfs3,
"coffee/tubruk",
"espresso/latte") => 0;
lfs3_rename(&lfs3,
"coffee/vietnamese",
"espresso/cappuccino") => 0;
lfs3_rename(&lfs3,
"coffee/thai",
"espresso/mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => 0;
assert(strcmp(info.name, "espresso") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "espresso/americano", &info) => 0;
assert(strcmp(info.name, "americano") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "espresso/macchiato", &info) => 0;
assert(strcmp(info.name, "macchiato") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "espresso/latte", &info) => 0;
assert(strcmp(info.name, "latte") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => 0;
assert(strcmp(info.name, "cappuccino") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "espresso/mocha", &info) => 0;
assert(strcmp(info.name, "mocha") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/drip", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/turkish", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/tubruk", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/thai", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "espresso/espresso") => 0;
lfs3_remove(&lfs3, "espresso/americano") => 0;
lfs3_remove(&lfs3, "espresso/macchiato") => 0;
lfs3_remove(&lfs3, "espresso/latte") => 0;
lfs3_remove(&lfs3, "espresso/cappuccino") => 0;
lfs3_remove(&lfs3, "espresso/mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# absolute path test
#
# littlefs does not provide cd, so these are the same as relative paths
[cases.test_paths_absolute]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "/coffee/drip") => 0;
lfs3_mkdir(&lfs3, "/coffee/coldbrew") => 0;
lfs3_mkdir(&lfs3, "/coffee/turkish") => 0;
lfs3_mkdir(&lfs3, "/coffee/tubruk") => 0;
lfs3_mkdir(&lfs3, "/coffee/vietnamese") => 0;
lfs3_mkdir(&lfs3, "/coffee/thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "/coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/coldbrew",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/turkish",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/tubruk",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/vietnamese",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/thai",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/coldbrew",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/turkish",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/tubruk",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/vietnamese",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/thai",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/coffee/drip") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/coldbrew") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/turkish") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/tubruk") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/vietnamese") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/thai") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/coffee/drip") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/coldbrew") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/turkish") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/tubruk") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/vietnamese") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/thai") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
lfs3_rename(&lfs3,
"coffee/drip",
"/espresso/espresso") => 0;
lfs3_rename(&lfs3,
"coffee/coldbrew",
"/espresso/americano") => 0;
lfs3_rename(&lfs3,
"/coffee/turkish",
"espresso/macchiato") => 0;
lfs3_rename(&lfs3,
"/coffee/tubruk",
"espresso/latte") => 0;
lfs3_rename(&lfs3,
"/coffee/vietnamese",
"/espresso/cappuccino") => 0;
lfs3_rename(&lfs3,
"/coffee/thai",
"/espresso/mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "/espresso/espresso", &info) => 0;
assert(strcmp(info.name, "espresso") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "espresso/americano", &info) => 0;
assert(strcmp(info.name, "americano") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/macchiato", &info) => 0;
assert(strcmp(info.name, "macchiato") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "espresso/latte", &info) => 0;
assert(strcmp(info.name, "latte") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/cappuccino", &info) => 0;
assert(strcmp(info.name, "cappuccino") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "espresso/mocha", &info) => 0;
assert(strcmp(info.name, "mocha") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/drip", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/coffee/coldbrew", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/coffee/turkish", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/coffee/tubruk", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/coffee/vietnamese", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/coffee/thai", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "/espresso/espresso") => 0;
lfs3_remove(&lfs3, "/espresso/americano") => 0;
lfs3_remove(&lfs3, "/espresso/macchiato") => 0;
lfs3_remove(&lfs3, "/espresso/latte") => 0;
lfs3_remove(&lfs3, "/espresso/cappuccino") => 0;
lfs3_remove(&lfs3, "/espresso/mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "/espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# redundant slashes
[cases.test_paths_redundant_slashes]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "/coffee/drip") => 0;
lfs3_mkdir(&lfs3, "//coffee//coldbrew") => 0;
lfs3_mkdir(&lfs3, "///coffee///turkish") => 0;
lfs3_mkdir(&lfs3, "////coffee////tubruk") => 0;
lfs3_mkdir(&lfs3, "/////coffee/////vietnamese") => 0;
lfs3_mkdir(&lfs3, "//////coffee//////thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "//coffee//coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "///coffee///turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "////coffee////tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/////coffee/////vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "//////coffee//////thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "//////coffee//////drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/////coffee/////coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "////coffee////turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "///coffee///tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "//coffee//vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "//coffee//coldbrew",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "///coffee///turkish",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "////coffee////tubruk",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/////coffee/////vietnamese",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "//////coffee//////thai",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "//coffee//coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "///coffee///turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "////coffee////tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/////coffee/////vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "//////coffee//////thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "//coffee//coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "///coffee///turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "////coffee////tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/////coffee/////vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "//////coffee//////thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "//coffee//coldbrew",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "///coffee///turkish",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "////coffee////tubruk",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/////coffee/////vietnamese",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "//////coffee//////thai",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "//coffee//coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "///coffee///turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "////coffee////tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/////coffee/////vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "//////coffee//////thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "//coffee//coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "///coffee///turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "////coffee////tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/////coffee/////vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "//////coffee//////thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/coffee/drip") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "//coffee//coldbrew") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "///coffee///turkish") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "////coffee////tubruk") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/////coffee/////vietnamese") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "//////coffee//////thai") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/coffee/drip") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "//coffee//coldbrew") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "///coffee///turkish") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "////coffee////tubruk") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/////coffee/////vietnamese") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "//////coffee//////thai") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
lfs3_rename(&lfs3,
"//////coffee//////drip",
"/espresso/espresso") => 0;
lfs3_rename(&lfs3,
"/////coffee/////coldbrew",
"//espresso//americano") => 0;
lfs3_rename(&lfs3,
"////coffee////turkish",
"///espresso///macchiato") => 0;
lfs3_rename(&lfs3,
"///coffee///tubruk",
"////espresso////latte") => 0;
lfs3_rename(&lfs3,
"//coffee//vietnamese",
"/////espresso/////cappuccino") => 0;
lfs3_rename(&lfs3,
"/coffee/thai",
"//////espresso//////mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "//////espresso//////espresso", &info) => 0;
assert(strcmp(info.name, "espresso") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/////espresso/////americano", &info) => 0;
assert(strcmp(info.name, "americano") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "////espresso////macchiato", &info) => 0;
assert(strcmp(info.name, "macchiato") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "///espresso///latte", &info) => 0;
assert(strcmp(info.name, "latte") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "//espresso//cappuccino", &info) => 0;
assert(strcmp(info.name, "cappuccino") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/mocha", &info) => 0;
assert(strcmp(info.name, "mocha") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "//////coffee//////drip", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/////coffee/////coldbrew", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "////coffee////turkish", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "///coffee///tubruk", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "//coffee//vietnamese", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/coffee/thai", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "/espresso/espresso") => 0;
lfs3_remove(&lfs3, "//espresso//americano") => 0;
lfs3_remove(&lfs3, "///espresso///macchiato") => 0;
lfs3_remove(&lfs3, "////espresso////latte") => 0;
lfs3_remove(&lfs3, "/////espresso/////cappuccino") => 0;
lfs3_remove(&lfs3, "//////espresso//////mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "//////espresso//////espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/////espresso/////americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "////espresso////macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "///espresso///latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "//espresso//cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# test trailing slashes
#
# trailing slashes are only allowed on directories
[cases.test_paths_trailing_slashes]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "coffee/drip/") => 0;
lfs3_mkdir(&lfs3, "coffee/coldbrew//") => 0;
lfs3_mkdir(&lfs3, "coffee/turkish///") => 0;
lfs3_mkdir(&lfs3, "coffee/tubruk////") => 0;
lfs3_mkdir(&lfs3, "coffee/vietnamese/////") => 0;
lfs3_mkdir(&lfs3, "coffee/thai//////") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip/",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew//",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish///",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk////",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/////",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai//////",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
// still create so we have something to test
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
if (DIR) {
lfs3_stat(&lfs3, "coffee/drip//////", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "coffee/coldbrew/////", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "coffee/turkish////", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "coffee/tubruk///", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "coffee/vietnamese//", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "coffee/thai/", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == LFS3_TYPE_DIR);
} else {
lfs3_stat(&lfs3, "coffee/drip//////", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/coldbrew/////", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/turkish////", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/tubruk///", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/vietnamese//", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/thai/", &info) => LFS3_ERR_NOTDIR;
}
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip/",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew//",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish///",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk////",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/////",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai//////",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/drip/",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew//",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish///",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk////",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/////",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai//////",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/drip/",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew//",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/turkish///",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/tubruk////",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/////",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/thai//////",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip/",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew//",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish///",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk////",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/////",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai//////",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/drip/",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew//",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish///",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk////",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/////",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai//////",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/drip/",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew//",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish///",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk////",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/////",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai//////",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/drip/") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/coldbrew//") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/turkish///") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/tubruk////") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/vietnamese/////") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/thai//////") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/drip/") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/coldbrew//") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/turkish///") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/tubruk////") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/vietnamese/////") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/thai//////") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
if (DIR) {
lfs3_rename(&lfs3,
"coffee/drip//////",
"espresso/espresso/") => 0;
lfs3_rename(&lfs3,
"coffee/coldbrew/////",
"espresso/americano//") => 0;
lfs3_rename(&lfs3,
"coffee/turkish////",
"espresso/macchiato///") => 0;
lfs3_rename(&lfs3,
"coffee/tubruk///",
"espresso/latte////") => 0;
lfs3_rename(&lfs3,
"coffee/vietnamese//",
"espresso/cappuccino/////") => 0;
lfs3_rename(&lfs3,
"coffee/thai/",
"espresso/mocha//////") => 0;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso//////", &info) => 0;
assert(strcmp(info.name, "espresso") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "espresso/americano/////", &info) => 0;
assert(strcmp(info.name, "americano") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "espresso/macchiato////", &info) => 0;
assert(strcmp(info.name, "macchiato") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "espresso/latte///", &info) => 0;
assert(strcmp(info.name, "latte") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "espresso/cappuccino//", &info) => 0;
assert(strcmp(info.name, "cappuccino") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "espresso/mocha/", &info) => 0;
assert(strcmp(info.name, "mocha") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "coffee/drip//////", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/coldbrew/////", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/turkish////", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/tubruk///", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/vietnamese//", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/thai/", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "espresso/espresso/") => 0;
lfs3_remove(&lfs3, "espresso/americano//") => 0;
lfs3_remove(&lfs3, "espresso/macchiato///") => 0;
lfs3_remove(&lfs3, "espresso/latte////") => 0;
lfs3_remove(&lfs3, "espresso/cappuccino/////") => 0;
lfs3_remove(&lfs3, "espresso/mocha//////") => 0;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso//////", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano/////", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato////", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte///", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino//", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha/", &info) => LFS3_ERR_NOENT;
} else {
// bad source
lfs3_rename(&lfs3,
"coffee/drip//////",
"espresso/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/coldbrew/////",
"espresso/americano") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/turkish////",
"espresso/macchiato") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/tubruk///",
"espresso/latte") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/vietnamese//",
"espresso/cappuccino") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/thai/",
"espresso/mocha") => LFS3_ERR_NOTDIR;
// bad destination
lfs3_rename(&lfs3,
"coffee/drip",
"espresso/espresso/") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/coldbrew",
"espresso/americano//") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/turkish",
"espresso/macchiato///") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/tubruk",
"espresso/latte////") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/vietnamese",
"espresso/cappuccino/////") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/thai",
"espresso/mocha//////") => LFS3_ERR_NOTDIR;
// bad source and bad destination
lfs3_rename(&lfs3,
"coffee/drip//////",
"espresso/espresso/") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/coldbrew/////",
"espresso/americano//") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/turkish////",
"espresso/macchiato///") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/tubruk///",
"espresso/latte////") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/vietnamese//",
"espresso/cappuccino/////") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/thai/",
"espresso/mocha//////") => LFS3_ERR_NOTDIR;
// remove paths
lfs3_remove(&lfs3, "coffee/drip/") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/coldbrew//") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/turkish///") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/tubruk////") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/vietnamese/////") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/thai//////") => LFS3_ERR_NOTDIR;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == LFS3_TYPE_REG);
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == LFS3_TYPE_REG);
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == LFS3_TYPE_REG);
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == LFS3_TYPE_REG);
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == LFS3_TYPE_REG);
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == LFS3_TYPE_REG);
}
lfs3_unmount(&lfs3) => 0;
'''
# dot path tests
[cases.test_paths_dots]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "/coffee/drip") => 0;
lfs3_mkdir(&lfs3, "/./coffee/./coldbrew") => 0;
lfs3_mkdir(&lfs3, "/././coffee/././turkish") => 0;
lfs3_mkdir(&lfs3, "/./././coffee/./././tubruk") => 0;
lfs3_mkdir(&lfs3, "/././././coffee/././././vietnamese") => 0;
lfs3_mkdir(&lfs3, "/./././././coffee/./././././thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/./coffee/./coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/././coffee/././turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/./././coffee/./././tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/././././coffee/././././vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/./././././coffee/./././././thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "/./././././coffee/./././././drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/././././coffee/././././coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/./././coffee/./././turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/././coffee/././tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/./coffee/./vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/./coffee/./coldbrew",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/././coffee/././turkish",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/./././coffee/./././tubruk",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/././././coffee/././././vietnamese",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/./././././coffee/./././././thai",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/./coffee/./coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/././coffee/././turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/./././coffee/./././tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/././././coffee/././././vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/./././././coffee/./././././thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/./coffee/./coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/././coffee/././turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/./././coffee/./././tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/././././coffee/././././vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/./././././coffee/./././././thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/./coffee/./coldbrew",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/././coffee/././turkish",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/./././coffee/./././tubruk",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/././././coffee/././././vietnamese",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/./././././coffee/./././././thai",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/./coffee/./coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/././coffee/././turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/./././coffee/./././tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/././././coffee/././././vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/./././././coffee/./././././thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/./coffee/./coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/././coffee/././turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/./././coffee/./././tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/././././coffee/././././vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/./././././coffee/./././././thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/coffee/drip") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/./coffee/./coldbrew") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/././coffee/././turkish") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/./././coffee/./././tubruk") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/././././coffee/././././vietnamese") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/./././././coffee/./././././thai") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/coffee/drip") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/./coffee/./coldbrew") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/././coffee/././turkish") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/./././coffee/./././tubruk") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/././././coffee/././././vietnamese") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/./././././coffee/./././././thai") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
lfs3_rename(&lfs3,
"/./././././coffee/./././././drip",
"/espresso/espresso") => 0;
lfs3_rename(&lfs3,
"/././././coffee/././././coldbrew",
"/./espresso/./americano") => 0;
lfs3_rename(&lfs3,
"/./././coffee/./././turkish",
"/././espresso/././macchiato") => 0;
lfs3_rename(&lfs3,
"/././coffee/././tubruk",
"/./././espresso/./././latte") => 0;
lfs3_rename(&lfs3,
"/./coffee/./vietnamese",
"/././././espresso/././././cappuccino") => 0;
lfs3_rename(&lfs3,
"/coffee/thai",
"/./././././espresso/./././././mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "/./././././espresso/./././././espresso", &info) => 0;
assert(strcmp(info.name, "espresso") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/././././espresso/././././americano", &info) => 0;
assert(strcmp(info.name, "americano") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/./././espresso/./././macchiato", &info) => 0;
assert(strcmp(info.name, "macchiato") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/././espresso/././latte", &info) => 0;
assert(strcmp(info.name, "latte") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/./espresso/./cappuccino", &info) => 0;
assert(strcmp(info.name, "cappuccino") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/mocha", &info) => 0;
assert(strcmp(info.name, "mocha") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/./././././coffee/./././././drip", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/././././coffee/././././coldbrew", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/./././coffee/./././turkish", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/././coffee/././tubruk", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/./coffee/./vietnamese", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/coffee/thai", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "/espresso/espresso") => 0;
lfs3_remove(&lfs3, "/./espresso/./americano") => 0;
lfs3_remove(&lfs3, "/././espresso/././macchiato") => 0;
lfs3_remove(&lfs3, "/./././espresso/./././latte") => 0;
lfs3_remove(&lfs3, "/././././espresso/././././cappuccino") => 0;
lfs3_remove(&lfs3, "/./././././espresso/./././././mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "/./././././espresso/./././././espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/././././espresso/././././americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/./././espresso/./././macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/././espresso/././latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/./espresso/./cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# test trailing dots, these get a bit weird
#
# POSIX deviations:
#
# - We accept modifications of directories with trailing dots:
# - littlefs: remove("a/.") => 0
# - POSIX: remove("a/.") => EBUSY
# Reason: Not worth implementing.
#
[cases.test_paths_trailing_dots]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "coffee/drip/.") => LFS3_ERR_NOENT;
lfs3_mkdir(&lfs3, "coffee/coldbrew/./.") => LFS3_ERR_NOENT;
lfs3_mkdir(&lfs3, "coffee/turkish/././.") => LFS3_ERR_NOENT;
lfs3_mkdir(&lfs3, "coffee/tubruk/./././.") => LFS3_ERR_NOENT;
lfs3_mkdir(&lfs3, "coffee/vietnamese/././././.") => LFS3_ERR_NOENT;
lfs3_mkdir(&lfs3, "coffee/thai/./././././.") => LFS3_ERR_NOENT;
// still create so we have something to test
lfs3_mkdir(&lfs3, "coffee/drip") => 0;
lfs3_mkdir(&lfs3, "coffee/coldbrew") => 0;
lfs3_mkdir(&lfs3, "coffee/turkish") => 0;
lfs3_mkdir(&lfs3, "coffee/tubruk") => 0;
lfs3_mkdir(&lfs3, "coffee/vietnamese") => 0;
lfs3_mkdir(&lfs3, "coffee/thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip/.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew/./.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/turkish/././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/tubruk/./././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/././././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/thai/./././././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
// still create so we have something to test
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
if (DIR) {
lfs3_stat(&lfs3, "coffee/drip/./././././.", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "coffee/coldbrew/././././.", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "coffee/turkish/./././.", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "coffee/tubruk/././.", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "coffee/vietnamese/./.", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "coffee/thai/.", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == LFS3_TYPE_DIR);
} else {
lfs3_stat(&lfs3, "coffee/drip/./././././.", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/coldbrew/././././.", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/turkish/./././.", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/tubruk/././.", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/vietnamese/./.", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/thai/.", &info) => LFS3_ERR_NOTDIR;
}
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip/.",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew/./.",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish/././.",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk/./././.",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/././././.",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai/./././././.",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/drip/.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew/./.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish/././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk/./././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/././././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai/./././././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/drip/.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew/./.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/turkish/././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/tubruk/./././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/././././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/thai/./././././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip/.",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew/./.",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish/././.",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk/./././.",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/././././.",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai/./././././.",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/drip/.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew/./.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish/././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk/./././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/././././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai/./././././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/drip/.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew/./.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish/././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk/./././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/././././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai/./././././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/drip/.") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/coldbrew/./.") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/turkish/././.") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/tubruk/./././.") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/vietnamese/././././.") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/thai/./././././.") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/drip/.") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/coldbrew/./.") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/turkish/././.") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/tubruk/./././.") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/vietnamese/././././.") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/thai/./././././.") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
if (DIR) {
// bad destination
lfs3_rename(&lfs3,
"coffee/drip",
"espresso/espresso/.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/coldbrew",
"espresso/americano/./.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/turkish",
"espresso/macchiato/././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tubruk",
"espresso/latte/./././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/vietnamese",
"espresso/cappuccino/././././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai",
"espresso/mocha/./././././.") => LFS3_ERR_NOENT;
// bad source and bad destination
lfs3_rename(&lfs3,
"coffee/drip/./././././.",
"espresso/espresso/.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/coldbrew/././././.",
"espresso/americano/./.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/turkish/./././.",
"espresso/macchiato/././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tubruk/././.",
"espresso/latte/./././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/vietnamese/./.",
"espresso/cappuccino/././././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai/.",
"espresso/mocha/./././././.") => LFS3_ERR_NOENT;
// this one works
lfs3_rename(&lfs3,
"coffee/drip/./././././.",
"espresso/espresso") => 0;
lfs3_rename(&lfs3,
"coffee/coldbrew/././././.",
"espresso/americano") => 0;
lfs3_rename(&lfs3,
"coffee/turkish/./././.",
"espresso/macchiato") => 0;
lfs3_rename(&lfs3,
"coffee/tubruk/././.",
"espresso/latte") => 0;
lfs3_rename(&lfs3,
"coffee/vietnamese/./.",
"espresso/cappuccino") => 0;
lfs3_rename(&lfs3,
"coffee/thai/.",
"espresso/mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso/./././././.", &info) => 0;
assert(strcmp(info.name, "espresso") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "espresso/americano/././././.", &info) => 0;
assert(strcmp(info.name, "americano") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "espresso/macchiato/./././.", &info) => 0;
assert(strcmp(info.name, "macchiato") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "espresso/latte/././.", &info) => 0;
assert(strcmp(info.name, "latte") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "espresso/cappuccino/./.", &info) => 0;
assert(strcmp(info.name, "cappuccino") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "espresso/mocha/.", &info) => 0;
assert(strcmp(info.name, "mocha") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "coffee/drip/./././././.", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/coldbrew/././././.", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/turkish/./././.", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/tubruk/././.", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/vietnamese/./.", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/thai/.", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "espresso/espresso/.") => 0;
lfs3_remove(&lfs3, "espresso/americano/./.") => 0;
lfs3_remove(&lfs3, "espresso/macchiato/././.") => 0;
lfs3_remove(&lfs3, "espresso/latte/./././.") => 0;
lfs3_remove(&lfs3, "espresso/cappuccino/././././.") => 0;
lfs3_remove(&lfs3, "espresso/mocha/./././././.") => 0;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso/./././././.", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano/././././.", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato/./././.", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte/././.", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino/./.", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha/.", &info) => LFS3_ERR_NOENT;
} else {
// bad source
lfs3_rename(&lfs3,
"coffee/drip/./././././.",
"espresso/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/coldbrew/././././.",
"espresso/americano") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/turkish/./././.",
"espresso/macchiato") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/tubruk/././.",
"espresso/latte") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/vietnamese/./.",
"espresso/cappuccino") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/thai/.",
"espresso/mocha") => LFS3_ERR_NOTDIR;
// bad destination
lfs3_rename(&lfs3,
"coffee/drip",
"espresso/espresso/.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/coldbrew",
"espresso/americano/./.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/turkish",
"espresso/macchiato/././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tubruk",
"espresso/latte/./././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/vietnamese",
"espresso/cappuccino/././././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai",
"espresso/mocha/./././././.") => LFS3_ERR_NOENT;
// bad source and bad destination
lfs3_rename(&lfs3,
"coffee/drip/./././././.",
"espresso/espresso/.") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/coldbrew/././././.",
"espresso/americano/./.") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/turkish/./././.",
"espresso/macchiato/././.") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/tubruk/././.",
"espresso/latte/./././.") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/vietnamese/./.",
"espresso/cappuccino/././././.") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/thai/.",
"espresso/mocha/./././././.") => LFS3_ERR_NOTDIR;
// remove paths
lfs3_remove(&lfs3, "coffee/drip/.") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/coldbrew/./.") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/turkish/././.") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/tubruk/./././.") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/vietnamese/././././.") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/thai/./././././.") => LFS3_ERR_NOTDIR;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == LFS3_TYPE_REG);
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == LFS3_TYPE_REG);
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == LFS3_TYPE_REG);
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == LFS3_TYPE_REG);
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == LFS3_TYPE_REG);
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == LFS3_TYPE_REG);
}
lfs3_unmount(&lfs3) => 0;
'''
# dot dot path tests
[cases.test_paths_dotdots]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "no") => 0;
lfs3_mkdir(&lfs3, "no/no") => 0;
lfs3_mkdir(&lfs3, "coffee") => 0;
lfs3_mkdir(&lfs3, "coffee/no") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "/coffee/drip") => 0;
lfs3_mkdir(&lfs3, "/no/../coffee/coldbrew") => 0;
lfs3_mkdir(&lfs3, "/coffee/no/../turkish") => 0;
lfs3_mkdir(&lfs3, "/no/no/../../coffee/tubruk") => 0;
lfs3_mkdir(&lfs3, "/no/no/../../coffee/no/../vietnamese") => 0;
lfs3_mkdir(&lfs3, "/no/no/../../no/no/../../coffee/thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/../coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/no/../turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/../../coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/../../coffee/no/../vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/../../no/no/../../coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "/no/no/../../no/no/../../coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/no/no/../../coffee/no/../coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/no/no/../../coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/no/../tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/no/../coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/../coffee/coldbrew",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/no/../turkish",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/no/../../coffee/tubruk",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/no/../../coffee/no/../vietnamese",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/no/../../no/no/../../coffee/thai",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/../coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/no/../turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/no/../../coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/no/../../coffee/no/../vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/no/../../no/no/../../coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/../coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/no/../turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/no/../../coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/no/../../coffee/no/../vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/no/../../no/no/../../coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/../coffee/coldbrew",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/no/../turkish",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/../../coffee/tubruk",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/../../coffee/no/../vietnamese",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/../../no/no/../../coffee/thai",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/../coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/no/../turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/../../coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/../../coffee/no/../vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/../../no/no/../../coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/../coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/no/../turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/no/../../coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/no/../../coffee/no/../vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/no/../../no/no/../../coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/coffee/drip") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/no/../coffee/coldbrew") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/no/../turkish") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/no/no/../../coffee/tubruk") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/no/no/../../coffee/no/../vietnamese") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/no/no/../../no/no/../../coffee/thai") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/coffee/drip") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/no/../coffee/coldbrew") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/no/../turkish") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/no/no/../../coffee/tubruk") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/no/no/../../coffee/no/../vietnamese") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/no/no/../../no/no/../../coffee/thai") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
lfs3_rename(&lfs3,
"/no/no/../../no/no/../../coffee/drip",
"/espresso/espresso") => 0;
lfs3_rename(&lfs3,
"/no/no/../../coffee/no/../coldbrew",
"/no/../espresso/americano") => 0;
lfs3_rename(&lfs3,
"/no/no/../../coffee/turkish",
"/espresso/no/../macchiato") => 0;
lfs3_rename(&lfs3,
"/coffee/no/../tubruk",
"/no/no/../../espresso/latte") => 0;
lfs3_rename(&lfs3,
"/no/../coffee/vietnamese",
"/no/no/../../espresso/no/../cappuccino") => 0;
lfs3_rename(&lfs3,
"/coffee/thai",
"/no/no/../../no/no/../../espresso/mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "/no/no/../../no/no/../../espresso/espresso", &info) => 0;
assert(strcmp(info.name, "espresso") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/no/no/../../espresso/no/../americano", &info) => 0;
assert(strcmp(info.name, "americano") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/no/no/../../espresso/macchiato", &info) => 0;
assert(strcmp(info.name, "macchiato") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/no/../latte", &info) => 0;
assert(strcmp(info.name, "latte") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/no/../espresso/cappuccino", &info) => 0;
assert(strcmp(info.name, "cappuccino") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/mocha", &info) => 0;
assert(strcmp(info.name, "mocha") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/no/no/../../no/no/../../coffee/drip", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/no/no/../../coffee/no/../coldbrew", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/no/no/../../coffee/turkish", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/coffee/no/../tubruk", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/no/../coffee/vietnamese", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/coffee/thai", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "/espresso/espresso") => 0;
lfs3_remove(&lfs3, "/no/../espresso/americano") => 0;
lfs3_remove(&lfs3, "/espresso/no/../macchiato") => 0;
lfs3_remove(&lfs3, "/no/no/../../espresso/latte") => 0;
lfs3_remove(&lfs3, "/no/no/../../espresso/no/../cappuccino") => 0;
lfs3_remove(&lfs3, "/no/no/../../no/no/../../espresso/mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "/no/no/../../no/no/../../espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/no/no/../../espresso/no/../americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/no/no/../../espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/no/../latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/no/../espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# test trailing dot dots, these get really weird
#
# POSIX deviations:
#
# - We do not check for existance of directories followed by dotdots:
# - littlefs: stat("a/missing/..") => 0
# - POSIX: stat("a/missing/..") => ENOENT
# Reason: Difficult to implement non-recursively.
#
# - We accept modifications of directories with trailing dotdots:
# - littlefs: rename("a/b/..", "c") => 0
# - POSIX: rename("a/b/..", "c") => EBUSY
# Reason: Not worth implementing.
#
[cases.test_paths_trailing_dotdots]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "coffee/drip/..") => LFS3_ERR_EXIST;
lfs3_mkdir(&lfs3, "coffee/coldbrew/../..") => LFS3_ERR_EXIST;
lfs3_mkdir(&lfs3, "coffee/turkish/../../..") => LFS3_ERR_INVAL;
lfs3_mkdir(&lfs3, "coffee/tubruk/../../../..") => LFS3_ERR_INVAL;
lfs3_mkdir(&lfs3, "coffee/vietnamese/../../../../..") => LFS3_ERR_INVAL;
lfs3_mkdir(&lfs3, "coffee/thai/../../../../../..") => LFS3_ERR_INVAL;
// still create so we have something to test
lfs3_mkdir(&lfs3, "coffee/drip") => 0;
lfs3_mkdir(&lfs3, "coffee/coldbrew") => 0;
lfs3_mkdir(&lfs3, "coffee/turkish") => 0;
lfs3_mkdir(&lfs3, "coffee/tubruk") => 0;
lfs3_mkdir(&lfs3, "coffee/vietnamese") => 0;
lfs3_mkdir(&lfs3, "coffee/thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip/..",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew/../..",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/turkish/../../..",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/tubruk/../../../..",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/../../../../..",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/thai/../../../../../..",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
// still create so we have something to test
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "coffee/drip/../../../../../..", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "coffee/coldbrew/../../../../..", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "coffee/turkish/../../../..", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "coffee/tubruk/../../..", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "coffee/vietnamese/../..", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "coffee/thai/..", &info) => 0;
assert(strcmp(info.name, "coffee") == 0);
assert(info.type == LFS3_TYPE_DIR);
// file open paths, only works on files!
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip/..",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew/../..",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish/../../..",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/tubruk/../../../..",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/../../../../..",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/thai/../../../../../..",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/drip/..",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew/../..",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish/../../..",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/tubruk/../../../..",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/../../../../..",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/thai/../../../../../..",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/drip/..",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew/../..",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/turkish/../../..",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/tubruk/../../../..",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/../../../../..",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/thai/../../../../../..",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
// dir open paths, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/drip/..") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/coldbrew/../..") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/turkish/../../..") => LFS3_ERR_INVAL;
lfs3_dir_open(&lfs3, &dir, "coffee/tubruk/../../../..") => LFS3_ERR_INVAL;
lfs3_dir_open(&lfs3, &dir, "coffee/vietnamese/../../../../..") => LFS3_ERR_INVAL;
lfs3_dir_open(&lfs3, &dir, "coffee/thai/../../../../../..") => LFS3_ERR_INVAL;
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
// bad source
lfs3_rename(&lfs3,
"coffee/drip/../../../../../..",
"espresso/espresso") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/coldbrew/../../../../..",
"espresso/americano") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/turkish/../../../..",
"espresso/macchiato") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/tubruk/../../..",
"espresso/latte") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/vietnamese/../..",
"espresso/cappuccino") => LFS3_ERR_BUSY;
// this one works
lfs3_rename(&lfs3,
"coffee/thai/..",
"espresso/mocha") => 0;
lfs3_rename(&lfs3,
"espresso/mocha",
"coffee") => 0;
// bad destination
if (DIR) {
// this one works
lfs3_rename(&lfs3,
"coffee/drip",
"espresso/espresso/..") => 0;
lfs3_rename(&lfs3,
"espresso",
"coffee/drip") => 0;
} else {
lfs3_rename(&lfs3,
"coffee/drip",
"espresso/espresso/..") => LFS3_ERR_ISDIR;
}
lfs3_rename(&lfs3,
"coffee/coldbrew",
"espresso/americano/../..") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3,
"coffee/turkish",
"espresso/macchiato/../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/tubruk",
"espresso/latte/../../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/vietnamese",
"espresso/cappuccino/../../../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/thai",
"espresso/mocha/../../../../../..") => LFS3_ERR_INVAL;
// bad source and bad destination
lfs3_rename(&lfs3,
"coffee/drip/../../../../../..",
"espresso/espresso/..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/coldbrew/../../../../..",
"espresso/americano/../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/turkish/../../../..",
"espresso/macchiato/../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/tubruk/../../..",
"espresso/latte/../../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/vietnamese/../..",
"espresso/cappuccino/../../../../..") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3,
"coffee/thai/..",
"espresso/mocha/../../../../../..") => LFS3_ERR_INVAL;
// remove paths
lfs3_remove(&lfs3, "coffee/drip/..") => LFS3_ERR_NOTEMPTY;
lfs3_remove(&lfs3, "coffee/coldbrew/../..") => LFS3_ERR_BUSY;
lfs3_remove(&lfs3, "coffee/turkish/../../..") => LFS3_ERR_INVAL;
lfs3_remove(&lfs3, "coffee/tubruk/../../../..") => LFS3_ERR_INVAL;
lfs3_remove(&lfs3, "coffee/vietnamese/../../../../..") => LFS3_ERR_INVAL;
lfs3_remove(&lfs3, "coffee/thai/../../../../../..") => LFS3_ERR_INVAL;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_unmount(&lfs3) => 0;
'''
# dot dot dot path tests
[cases.test_paths_dot_dotdots]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "no") => 0;
lfs3_mkdir(&lfs3, "no/no") => 0;
lfs3_mkdir(&lfs3, "coffee") => 0;
lfs3_mkdir(&lfs3, "coffee/no") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "/coffee/drip") => 0;
lfs3_mkdir(&lfs3, "/no/./../coffee/coldbrew") => 0;
lfs3_mkdir(&lfs3, "/coffee/no/./../turkish") => 0;
lfs3_mkdir(&lfs3, "/no/no/./.././../coffee/tubruk") => 0;
lfs3_mkdir(&lfs3, "/no/no/./.././../coffee/no/./../vietnamese") => 0;
lfs3_mkdir(&lfs3, "/no/no/./.././../no/no/./.././../coffee/thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/./../coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/no/./../turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../coffee/no/./../vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "/no/no/./.././../no/no/./.././../coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/no/no/./.././../coffee/no/./../coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/no/no/./.././../coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/no/./../tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/no/./../coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/./../coffee/coldbrew",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/no/./../turkish",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../coffee/tubruk",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../coffee/no/./../vietnamese",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/./../coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/no/./../turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../coffee/no/./../vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/./../coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/no/./../turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../coffee/no/./../vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/./../coffee/coldbrew",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/no/./../turkish",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../coffee/tubruk",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../coffee/no/./../vietnamese",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/./../coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/no/./../turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../coffee/no/./../vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/./../coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/no/./../turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../coffee/no/./../vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/no/no/./.././../no/no/./.././../coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/coffee/drip") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/no/./../coffee/coldbrew") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/no/./../turkish") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/no/no/./.././../coffee/tubruk") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/no/no/./.././../coffee/no/./../vietnamese") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/no/no/./.././../no/no/./.././../coffee/thai") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/coffee/drip") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/no/./../coffee/coldbrew") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/no/./../turkish") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/no/no/./.././../coffee/tubruk") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/no/no/./.././../coffee/no/./../vietnamese") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/no/no/./.././../no/no/./.././../coffee/thai") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
lfs3_rename(&lfs3,
"/no/no/./.././../no/no/./.././../coffee/drip",
"/espresso/espresso") => 0;
lfs3_rename(&lfs3,
"/no/no/./.././../coffee/no/./../coldbrew",
"/no/./../espresso/americano") => 0;
lfs3_rename(&lfs3,
"/no/no/./.././../coffee/turkish",
"/espresso/no/./../macchiato") => 0;
lfs3_rename(&lfs3,
"/coffee/no/./../tubruk",
"/no/no/./.././../espresso/latte") => 0;
lfs3_rename(&lfs3,
"/no/./../coffee/vietnamese",
"/no/no/./.././../espresso/no/./../cappuccino") => 0;
lfs3_rename(&lfs3,
"/coffee/thai",
"/no/no/./.././../no/no/./.././../espresso/mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "/no/no/./.././../no/no/./.././../espresso/espresso", &info) => 0;
assert(strcmp(info.name, "espresso") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/no/no/./.././../espresso/no/./../americano", &info) => 0;
assert(strcmp(info.name, "americano") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/no/no/./.././../espresso/macchiato", &info) => 0;
assert(strcmp(info.name, "macchiato") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/no/./../latte", &info) => 0;
assert(strcmp(info.name, "latte") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/no/./../espresso/cappuccino", &info) => 0;
assert(strcmp(info.name, "cappuccino") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/mocha", &info) => 0;
assert(strcmp(info.name, "mocha") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/no/no/./.././../no/no/./.././../coffee/drip", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/no/no/./.././../coffee/no/./../coldbrew", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/no/no/./.././../coffee/turkish", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/coffee/no/./../tubruk", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/no/./../coffee/vietnamese", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/coffee/thai", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "/espresso/espresso") => 0;
lfs3_remove(&lfs3, "/no/./../espresso/americano") => 0;
lfs3_remove(&lfs3, "/espresso/no/./../macchiato") => 0;
lfs3_remove(&lfs3, "/no/no/./.././../espresso/latte") => 0;
lfs3_remove(&lfs3, "/no/no/./.././../espresso/no/./../cappuccino") => 0;
lfs3_remove(&lfs3, "/no/no/./.././../no/no/./.././../espresso/mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "/no/no/./.././../no/no/./.././../espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/no/no/./.././../espresso/no/./../americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/no/no/./.././../espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/no/./../latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/no/./../espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# dot dot dot path tests
[cases.test_paths_dotdotdots]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
lfs3_mkdir(&lfs3, "coffee/...") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "/coffee/.../drip") => 0;
lfs3_mkdir(&lfs3, "/coffee/.../coldbrew") => 0;
lfs3_mkdir(&lfs3, "/coffee/.../turkish") => 0;
lfs3_mkdir(&lfs3, "/coffee/.../tubruk") => 0;
lfs3_mkdir(&lfs3, "/coffee/.../vietnamese") => 0;
lfs3_mkdir(&lfs3, "/coffee/.../thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/.../drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "/coffee/.../drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/.../coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/.../turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/.../tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/.../vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/.../thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/.../drip",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.../coldbrew",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.../turkish",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.../tubruk",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.../vietnamese",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.../thai",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.../drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.../coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.../turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.../tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.../vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.../thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.../drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/.../coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/.../turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/.../tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/.../vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/.../thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/.../drip",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../coldbrew",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../turkish",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../tubruk",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../vietnamese",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../thai",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.../drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/.../coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/.../turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/.../tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/.../vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/.../thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/coffee/.../drip") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/.../coldbrew") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/.../turkish") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/.../tubruk") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/.../vietnamese") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/.../thai") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/coffee/.../drip") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/.../coldbrew") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/.../turkish") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/.../tubruk") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/.../vietnamese") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/.../thai") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
lfs3_mkdir(&lfs3, "espresso/...") => 0;
lfs3_rename(&lfs3,
"/coffee/.../drip",
"/espresso/.../espresso") => 0;
lfs3_rename(&lfs3,
"/coffee/.../coldbrew",
"/espresso/.../americano") => 0;
lfs3_rename(&lfs3,
"/coffee/.../turkish",
"/espresso/.../macchiato") => 0;
lfs3_rename(&lfs3,
"/coffee/.../tubruk",
"/espresso/.../latte") => 0;
lfs3_rename(&lfs3,
"/coffee/.../vietnamese",
"/espresso/.../cappuccino") => 0;
lfs3_rename(&lfs3,
"/coffee/.../thai",
"/espresso/.../mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "/espresso/.../espresso", &info) => 0;
assert(strcmp(info.name, "espresso") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/.../americano", &info) => 0;
assert(strcmp(info.name, "americano") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/.../macchiato", &info) => 0;
assert(strcmp(info.name, "macchiato") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/.../latte", &info) => 0;
assert(strcmp(info.name, "latte") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/.../cappuccino", &info) => 0;
assert(strcmp(info.name, "cappuccino") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/.../mocha", &info) => 0;
assert(strcmp(info.name, "mocha") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/.../drip", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/.../coldbrew", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/.../turkish", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/.../tubruk", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/.../vietnamese", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/.../thai", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "/espresso/.../espresso") => 0;
lfs3_remove(&lfs3, "/espresso/.../americano") => 0;
lfs3_remove(&lfs3, "/espresso/.../macchiato") => 0;
lfs3_remove(&lfs3, "/espresso/.../latte") => 0;
lfs3_remove(&lfs3, "/espresso/.../cappuccino") => 0;
lfs3_remove(&lfs3, "/espresso/.../mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "/espresso/.../espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/.../americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/.../macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/.../latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/.../cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/.../mocha", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# leading dot path test
[cases.test_paths_leading_dots]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "/coffee/.drip") => 0;
lfs3_mkdir(&lfs3, "/coffee/..coldbrew") => 0;
lfs3_mkdir(&lfs3, "/coffee/...turkish") => 0;
lfs3_mkdir(&lfs3, "/coffee/....tubruk") => 0;
lfs3_mkdir(&lfs3, "/coffee/.....vietnamese") => 0;
lfs3_mkdir(&lfs3, "/coffee/......thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/.drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/..coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/...turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/....tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.....vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/......thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "/coffee/.drip", &info) => 0;
assert(strcmp(info.name, ".drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/..coldbrew", &info) => 0;
assert(strcmp(info.name, "..coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/...turkish", &info) => 0;
assert(strcmp(info.name, "...turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/....tubruk", &info) => 0;
assert(strcmp(info.name, "....tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/.....vietnamese", &info) => 0;
assert(strcmp(info.name, ".....vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/coffee/......thai", &info) => 0;
assert(strcmp(info.name, "......thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/.drip",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/..coldbrew",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/...turkish",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/....tubruk",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.....vietnamese",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/......thai",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/..coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/...turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/....tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.....vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/......thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/coffee/.drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/..coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/...turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/....tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/.....vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/......thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/coffee/.drip",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/..coldbrew",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/...turkish",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/....tubruk",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.....vietnamese",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/......thai",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/..coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/...turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/....tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.....vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/......thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "/coffee/.drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/..coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/...turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/....tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/.....vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/coffee/......thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/coffee/.drip") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/..coldbrew") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/...turkish") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/....tubruk") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/.....vietnamese") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/coffee/......thai") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/coffee/.drip") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/..coldbrew") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/...turkish") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/....tubruk") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/.....vietnamese") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "/coffee/......thai") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
lfs3_rename(&lfs3,
"/coffee/.drip",
"/espresso/.espresso") => 0;
lfs3_rename(&lfs3,
"/coffee/..coldbrew",
"/espresso/..americano") => 0;
lfs3_rename(&lfs3,
"/coffee/...turkish",
"/espresso/...macchiato") => 0;
lfs3_rename(&lfs3,
"/coffee/....tubruk",
"/espresso/....latte") => 0;
lfs3_rename(&lfs3,
"/coffee/.....vietnamese",
"/espresso/.....cappuccino") => 0;
lfs3_rename(&lfs3,
"/coffee/......thai",
"/espresso/......mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "/espresso/.espresso", &info) => 0;
assert(strcmp(info.name, ".espresso") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/..americano", &info) => 0;
assert(strcmp(info.name, "..americano") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/...macchiato", &info) => 0;
assert(strcmp(info.name, "...macchiato") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/....latte", &info) => 0;
assert(strcmp(info.name, "....latte") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/.....cappuccino", &info) => 0;
assert(strcmp(info.name, ".....cappuccino") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "/espresso/......mocha", &info) => 0;
assert(strcmp(info.name, "......mocha") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/.drip", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/..coldbrew", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/...turkish", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/....tubruk", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/.....vietnamese", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/......thai", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "/espresso/.espresso") => 0;
lfs3_remove(&lfs3, "/espresso/..americano") => 0;
lfs3_remove(&lfs3, "/espresso/...macchiato") => 0;
lfs3_remove(&lfs3, "/espresso/....latte") => 0;
lfs3_remove(&lfs3, "/espresso/.....cappuccino") => 0;
lfs3_remove(&lfs3, "/espresso/......mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "/espresso/.espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/..americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/...macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/....latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/.....cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "/espresso/......mocha", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# root dot dot path test
[cases.test_paths_root_dotdots]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "no") => 0;
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "/../coffee/drip") => LFS3_ERR_INVAL;
lfs3_mkdir(&lfs3, "/../../coffee/coldbrew") => LFS3_ERR_INVAL;
lfs3_mkdir(&lfs3, "/../../../coffee/turkish") => LFS3_ERR_INVAL;
lfs3_mkdir(&lfs3, "/no/../../coffee/tubruk") => LFS3_ERR_INVAL;
lfs3_mkdir(&lfs3, "/no/../../../coffee/vietnamese") => LFS3_ERR_INVAL;
lfs3_mkdir(&lfs3, "/no/../../../../coffee/thai") => LFS3_ERR_INVAL;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/../coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/../../coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/../../../coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/no/../../coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/no/../../../coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/no/../../../../coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
}
// ok, actually create paths
if (DIR) {
lfs3_mkdir(&lfs3, "coffee/drip") => 0;
lfs3_mkdir(&lfs3, "coffee/coldbrew") => 0;
lfs3_mkdir(&lfs3, "coffee/turkish") => 0;
lfs3_mkdir(&lfs3, "coffee/tubruk") => 0;
lfs3_mkdir(&lfs3, "coffee/vietnamese") => 0;
lfs3_mkdir(&lfs3, "coffee/thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "/no/../../../../coffee/drip", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "/no/../../../coffee/coldbrew", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "/no/../../coffee/turkish", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "/../../../coffee/tubruk", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "/../../coffee/vietnamese", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "/../coffee/thai", &info) => LFS3_ERR_INVAL;
// file open paths, only works on files!
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/../coffee/drip",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/../../coffee/coldbrew",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/../../../coffee/turkish",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/no/../../coffee/tubruk",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/no/../../../coffee/vietnamese",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/no/../../../../coffee/thai",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/../coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/../../coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/../../../coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/no/../../coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/no/../../../coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/no/../../../../coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/../coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/../../coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/../../../coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/no/../../coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/no/../../../coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "/no/../../../../coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
// dir open paths, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/../coffee/drip") => LFS3_ERR_INVAL;
lfs3_dir_open(&lfs3, &dir, "/../../coffee/coldbrew") => LFS3_ERR_INVAL;
lfs3_dir_open(&lfs3, &dir, "/../../../coffee/turkish") => LFS3_ERR_INVAL;
lfs3_dir_open(&lfs3, &dir, "/no/../../coffee/tubruk") => LFS3_ERR_INVAL;
lfs3_dir_open(&lfs3, &dir, "/no/../../../coffee/vietnamese") => LFS3_ERR_INVAL;
lfs3_dir_open(&lfs3, &dir, "/no/../../../../coffee/thai") => LFS3_ERR_INVAL;
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
// bad source
lfs3_rename(&lfs3,
"/no/../../../../coffee/drip",
"espresso/espresso") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"/no/../../../coffee/coldbrew",
"espresso/americano") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"/no/../../coffee/turkish",
"espresso/macchiato") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"/../../../coffee/tubruk",
"espresso/latte") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"/../../coffee/vietnamese",
"espresso/cappuccino") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"/../coffee/thai",
"espresso/mocha") => LFS3_ERR_INVAL;
// bad destination
lfs3_rename(&lfs3,
"coffee/drip",
"/../espresso/espresso") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/coldbrew",
"/../../espresso/americano") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/turkish",
"/../../../espresso/macchiato") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/tubruk",
"/no/../../espresso/latte") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/vietnamese",
"/no/../../../espresso/cappuccino") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/thai",
"/no/../../../../espresso/mocha") => LFS3_ERR_INVAL;
// bad source and bad destination
lfs3_rename(&lfs3,
"/no/../../../../coffee/drip",
"/../espresso/espresso") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"/no/../../../coffee/coldbrew",
"/../../espresso/americano") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"/no/../../coffee/turkish",
"/../../../espresso/macchiato") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"/../../../coffee/tubruk",
"/no/../../espresso/latte") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"/../../coffee/vietnamese",
"/no/../../../espresso/cappuccino") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"/../coffee/thai",
"/no/../../../../espresso/mocha") => LFS3_ERR_INVAL;
// here's a weird one, what happens if our rename is also a noop?
lfs3_rename(&lfs3,
"/no/../../../../coffee/drip",
"/no/../../../../coffee/drip") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"/no/../../../coffee/coldbrew",
"/no/../../../coffee/coldbrew") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"/no/../../coffee/turkish",
"/no/../../coffee/turkish") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"/../../../coffee/tubruk",
"/../../../coffee/tubruk") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"/../../coffee/vietnamese",
"/../../coffee/vietnamese") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"/../coffee/thai",
"/../coffee/thai") => LFS3_ERR_INVAL;
// remove paths
lfs3_remove(&lfs3, "/../espresso/espresso") => LFS3_ERR_INVAL;
lfs3_remove(&lfs3, "/../../espresso/americano") => LFS3_ERR_INVAL;
lfs3_remove(&lfs3, "/../../../espresso/macchiato") => LFS3_ERR_INVAL;
lfs3_remove(&lfs3, "/no/../../espresso/latte") => LFS3_ERR_INVAL;
lfs3_remove(&lfs3, "/no/../../../espresso/cappuccino") => LFS3_ERR_INVAL;
lfs3_remove(&lfs3, "/no/../../../../espresso/mocha") => LFS3_ERR_INVAL;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_unmount(&lfs3) => 0;
'''
# trailing noent tests
[cases.test_paths_noent]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "coffee/drip") => 0;
lfs3_mkdir(&lfs3, "coffee/coldbrew") => 0;
lfs3_mkdir(&lfs3, "coffee/turkish") => 0;
lfs3_mkdir(&lfs3, "coffee/tubruk") => 0;
lfs3_mkdir(&lfs3, "coffee/vietnamese") => 0;
lfs3_mkdir(&lfs3, "coffee/thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "coffee/_rip", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/c_ldbrew", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/tu_kish", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/tub_uk", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/_vietnamese", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/thai_", &info) => LFS3_ERR_NOENT;
// file open paths, only works on files!
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/_rip",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/c_ldbrew",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/tu_kish",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/tub_uk",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/_vietnamese",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/thai_",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
// dir open paths, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/_rip") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee/c_ldbrew") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee/tu_kish") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee/tub_uk") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee/_vietnamese") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee/thai_") => LFS3_ERR_NOENT;
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
lfs3_rename(&lfs3,
"coffee/_rip",
"espresso/espresso") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/c_ldbrew",
"espresso/americano") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tu_kish",
"espresso/macchiato") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tub_uk",
"espresso/latte") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/_vietnamese",
"espresso/cappuccino") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai_",
"espresso/mocha") => LFS3_ERR_NOENT;
// here's a weird one, what happens if our rename is also a noop?
lfs3_rename(&lfs3,
"coffee/_rip",
"coffee/_rip") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/c_ldbrew",
"coffee/c_ldbrew") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tu_kish",
"coffee/tu_kish") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tub_uk",
"coffee/tub_uk") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/_vietnamese",
"coffee/_vietnamese") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai_",
"coffee/thai_") => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "coffee/_rip") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee/c_ldbrew") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee/tu_kish") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee/tub_uk") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee/_vietnamese") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee/thai_") => LFS3_ERR_NOENT;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_unmount(&lfs3) => 0;
'''
# parent noent tests
[cases.test_paths_noent_parent]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "_offee/drip") => LFS3_ERR_NOENT;
lfs3_mkdir(&lfs3, "c_ffee/coldbrew") => LFS3_ERR_NOENT;
lfs3_mkdir(&lfs3, "co_fee/turkish") => LFS3_ERR_NOENT;
lfs3_mkdir(&lfs3, "cof_ee/tubruk") => LFS3_ERR_NOENT;
lfs3_mkdir(&lfs3, "_coffee/vietnamese") => LFS3_ERR_NOENT;
lfs3_mkdir(&lfs3, "coffee_/thai") => LFS3_ERR_NOENT;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "_offee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "c_ffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "co_fee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "cof_ee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "_coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee_/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
}
// ok, actually create paths
if (DIR) {
lfs3_mkdir(&lfs3, "coffee/drip") => 0;
lfs3_mkdir(&lfs3, "coffee/coldbrew") => 0;
lfs3_mkdir(&lfs3, "coffee/turkish") => 0;
lfs3_mkdir(&lfs3, "coffee/tubruk") => 0;
lfs3_mkdir(&lfs3, "coffee/vietnamese") => 0;
lfs3_mkdir(&lfs3, "coffee/thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "_offee/drip", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "c_ffee/coldbrew", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "co_fee/turkish", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "cof_ee/tubruk", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "_coffee/vietnamese", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee_/thai", &info) => LFS3_ERR_NOENT;
// file open paths, only works on files!
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "_offee/drip",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "c_ffee/coldbrew",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "co_fee/turkish",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "cof_ee/tubruk",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "_coffee/vietnamese",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee_/thai",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "_offee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "c_ffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "co_fee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "cof_ee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "_coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee_/thai",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "_offee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "c_ffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "co_fee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "cof_ee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "_coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee_/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
// dir open paths, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "_offee/drip") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "c_ffee/coldbrew") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "co_fee/turkish") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "cof_ee/tubruk") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "_coffee/vietnamese") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee_/thai") => LFS3_ERR_NOENT;
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
// bad source
lfs3_rename(&lfs3,
"_offee/drip",
"espresso/espresso") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"c_ffee/coldbrew",
"espresso/americano") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"co_fee/turkish",
"espresso/macchiato") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"cof_ee/tubruk",
"espresso/latte") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"_coffee/vietnamese",
"espresso/cappuccino") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee_/thai",
"espresso/mocha") => LFS3_ERR_NOENT;
// bad destination
lfs3_rename(&lfs3,
"coffee/drip",
"_spresso/espresso") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/coldbrew",
"e_presso/americano") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/turkish",
"es_resso/macchiato") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tubruk",
"esp_esso/latte") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/vietnamese",
"_espresso/cappuccino") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai",
"espresso_/mocha") => LFS3_ERR_NOENT;
// bad source and bad destination
lfs3_rename(&lfs3,
"_offee/drip",
"_spresso/espresso") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"c_ffee/coldbrew",
"e_presso/americano") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"co_fee/turkish",
"es_resso/macchiato") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"cof_ee/tubruk",
"esp_esso/latte") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"_coffee/vietnamese",
"_espresso/cappuccino") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee_/thai",
"espresso_/mocha") => LFS3_ERR_NOENT;
// here's a weird one, what happens if our rename is also a noop?
lfs3_rename(&lfs3,
"_offee/drip",
"_offee/drip") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"c_ffee/coldbrew",
"c_ffee/coldbrew") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"co_fee/turkish",
"co_fee/turkish") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"cof_ee/tubruk",
"cof_ee/tubruk") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"_coffee/vietnamese",
"_coffee/vietnamese") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee_/thai",
"coffee_/thai") => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "_offee/drip") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "c_ffee/coldbrew") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "co_fee/turkish") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "cof_ee/tubruk") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "_coffee/vietnamese") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee_/thai") => LFS3_ERR_NOENT;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_unmount(&lfs3) => 0;
'''
# parent notdir tests
[cases.test_paths_notdir_parent]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "drip/coffee") => LFS3_ERR_NOTDIR;
lfs3_mkdir(&lfs3, "coldbrew/coffee") => LFS3_ERR_NOTDIR;
lfs3_mkdir(&lfs3, "turkish/coffee") => LFS3_ERR_NOTDIR;
lfs3_mkdir(&lfs3, "tubruk/coffee") => LFS3_ERR_NOTDIR;
lfs3_mkdir(&lfs3, "vietnamese/coffee") => LFS3_ERR_NOTDIR;
lfs3_mkdir(&lfs3, "thai/coffee") => LFS3_ERR_NOTDIR;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "drip/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coldbrew/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "turkish/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "tubruk/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "vietnamese/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "thai/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "drip/coffee", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coldbrew/coffee", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "turkish/coffee", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "tubruk/coffee", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "vietnamese/coffee", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "thai/coffee", &info) => LFS3_ERR_NOTDIR;
// file open paths, only works on files!
lfs3_file_open(&lfs3, &file, "drip/coffee",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coldbrew/coffee",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "turkish/coffee",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "tubruk/coffee",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "vietnamese/coffee",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "thai/coffee",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "drip/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coldbrew/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "turkish/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "tubruk/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "vietnamese/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "thai/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "drip/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coldbrew/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "turkish/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "tubruk/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "vietnamese/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "thai/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
// dir open paths, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "drip/coffee") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coldbrew/coffee") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "turkish/coffee") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "tubruk/coffee") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "vietnamese/coffee") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "thai/coffee") => LFS3_ERR_NOTDIR;
// make some normal paths so we have something to rename
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "coffee/drip") => 0;
lfs3_mkdir(&lfs3, "coffee/coldbrew") => 0;
lfs3_mkdir(&lfs3, "coffee/turkish") => 0;
lfs3_mkdir(&lfs3, "coffee/tubruk") => 0;
lfs3_mkdir(&lfs3, "coffee/vietnamese") => 0;
lfs3_mkdir(&lfs3, "coffee/thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
// bad source
lfs3_rename(&lfs3,
"drip/coffee",
"espresso/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coldbrew/coffee",
"espresso/americano") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"turkish/coffee",
"espresso/macchiato") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"tubruk/coffee",
"espresso/latte") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"vietnamese/coffee",
"espresso/cappuccino") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"thai/coffee",
"espresso/mocha") => LFS3_ERR_NOTDIR;
// bad destination
lfs3_rename(&lfs3,
"coffee/drip",
"drip/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/coldbrew",
"coldbrew/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/turkish",
"turkish/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/tubruk",
"tubruk/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/vietnamese",
"vietnamese/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/thai",
"thai/espresso") => LFS3_ERR_NOTDIR;
// bad source and bad destination
lfs3_rename(&lfs3,
"drip/coffee",
"drip/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coldbrew/coffee",
"coldbrew/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"turkish/coffee",
"turkish/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"tubruk/coffee",
"tubruk/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"vietnamese/coffee",
"vietnamese/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"thai/coffee",
"thai/espresso") => LFS3_ERR_NOTDIR;
// here's a weird one, what happens if our rename is also a noop?
lfs3_rename(&lfs3,
"drip/coffee",
"drip/coffee") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coldbrew/coffee",
"coldbrew/coffee") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"turkish/coffee",
"turkish/coffee") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"tubruk/coffee",
"tubruk/coffee") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"vietnamese/coffee",
"vietnamese/coffee") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"thai/coffee",
"thai/coffee") => LFS3_ERR_NOTDIR;
// remove paths
lfs3_stat(&lfs3, "drip/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coldbrew/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "turkish/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "tubruk/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "vietnamese/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "thai/espresso", &info) => LFS3_ERR_NOTDIR;
// stat paths
lfs3_stat(&lfs3, "drip/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coldbrew/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "turkish/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "tubruk/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "vietnamese/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "thai/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_unmount(&lfs3) => 0;
'''
# noent tests with trailing slashes
[cases.test_paths_noent_trailing_slashes]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "coffee/drip") => 0;
lfs3_mkdir(&lfs3, "coffee/coldbrew") => 0;
lfs3_mkdir(&lfs3, "coffee/turkish") => 0;
lfs3_mkdir(&lfs3, "coffee/tubruk") => 0;
lfs3_mkdir(&lfs3, "coffee/vietnamese") => 0;
lfs3_mkdir(&lfs3, "coffee/thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "coffee/_rip//////", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/c_ldbrew/////", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/tu_kish////", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/tub_uk///", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/_vietnamese//", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/thai_/", &info) => LFS3_ERR_NOENT;
// file open paths, only works on files!
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/_rip/",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/c_ldbrew//",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/tu_kish///",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/tub_uk////",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/_vietnamese/////",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/thai_//////",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/_rip/",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/c_ldbrew//",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tu_kish///",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tub_uk////",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/_vietnamese/////",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai_//////",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/_rip/",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/c_ldbrew//",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tu_kish///",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tub_uk////",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/_vietnamese/////",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai_//////",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
// dir open paths, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/_rip/") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee/c_ldbrew//") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee/tu_kish///") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee/tub_uk////") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee/_vietnamese/////") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee/thai_//////") => LFS3_ERR_NOENT;
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
// bad source
lfs3_rename(&lfs3,
"coffee/_rip//////",
"espresso/espresso") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/c_ldbrew/////",
"espresso/americano") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tu_kish////",
"espresso/macchiato") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tub_uk///",
"espresso/latte") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/_vietnamese//",
"espresso/cappuccino") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai_/",
"espresso/mocha") => LFS3_ERR_NOENT;
// bad destination
lfs3_rename(&lfs3,
"coffee/_rip",
"espresso/espresso/") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/c_ldbrew",
"espresso/americano//") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tu_kish",
"espresso/macchiato///") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tub_uk",
"espresso/latte////") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/_vietnamese",
"espresso/cappuccino/////") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai_",
"espresso/mocha//////") => LFS3_ERR_NOENT;
// bad source and bad destination
lfs3_rename(&lfs3,
"coffee/_rip//////",
"espresso/espresso/") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/c_ldbrew/////",
"espresso/americano//") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tu_kish////",
"espresso/macchiato///") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tub_uk///",
"espresso/latte////") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/_vietnamese//",
"espresso/cappuccino/////") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai_/",
"espresso/mocha//////") => LFS3_ERR_NOENT;
// here's a weird one, what happens if our rename is also a noop?
lfs3_rename(&lfs3,
"coffee/_rip//////",
"coffee/_rip//////") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/c_ldbrew/////",
"coffee/c_ldbrew/////") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tu_kish////",
"coffee/tu_kish////") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tub_uk///",
"coffee/tub_uk///") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/_vietnamese//",
"coffee/_vietnamese//") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai_/",
"coffee/thai_/") => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "coffee/_rip/") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee/c_ldbrew//") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee/tu_kish///") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee/tub_uk////") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee/_vietnamese/////") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee/thai_//////") => LFS3_ERR_NOENT;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_unmount(&lfs3) => 0;
'''
# noent tests with trailing dots
[cases.test_paths_noent_trailing_dots]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "coffee/drip") => 0;
lfs3_mkdir(&lfs3, "coffee/coldbrew") => 0;
lfs3_mkdir(&lfs3, "coffee/turkish") => 0;
lfs3_mkdir(&lfs3, "coffee/tubruk") => 0;
lfs3_mkdir(&lfs3, "coffee/vietnamese") => 0;
lfs3_mkdir(&lfs3, "coffee/thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "coffee/_rip/./././././.", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/c_ldbrew/././././.", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/tu_kish/./././.", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/tub_uk/././.", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/_vietnamese/./.", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/thai_/.", &info) => LFS3_ERR_NOENT;
// file open paths, only works on files!
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/_rip/.",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/c_ldbrew/./.",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/tu_kish/././.",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/tub_uk/./././.",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/_vietnamese/././././.",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/thai_/./././././.",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/_rip/.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/c_ldbrew/./.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/tu_kish/././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/tub_uk/./././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/_vietnamese/././././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/thai_/./././././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/_rip/.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/c_ldbrew/./.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/tu_kish/././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/tub_uk/./././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/_vietnamese/././././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
lfs3_file_open(&lfs3, &file, "coffee/thai_/./././././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOENT;
// dir open paths, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/_rip/.") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee/c_ldbrew/./.") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee/tu_kish/././.") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee/tub_uk/./././.") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee/_vietnamese/././././.") => LFS3_ERR_NOENT;
lfs3_dir_open(&lfs3, &dir, "coffee/thai_/./././././.") => LFS3_ERR_NOENT;
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
// bad source
lfs3_rename(&lfs3,
"coffee/_rip/./././././.",
"espresso/espresso") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/c_ldbrew/././././.",
"espresso/americano") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tu_kish/./././.",
"espresso/macchiato") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tub_uk/././.",
"espresso/latte") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/_vietnamese/./.",
"espresso/cappuccino") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai_/.",
"espresso/mocha") => LFS3_ERR_NOENT;
// bad destination
lfs3_rename(&lfs3,
"coffee/_rip",
"espresso/espresso/.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/c_ldbrew",
"espresso/americano/./.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tu_kish",
"espresso/macchiato/././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tub_uk",
"espresso/latte/./././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/_vietnamese",
"espresso/cappuccino/././././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai_",
"espresso/mocha/./././././.") => LFS3_ERR_NOENT;
// bad source and bad destination
lfs3_rename(&lfs3,
"coffee/_rip/./././././.",
"espresso/espresso/.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/c_ldbrew/././././.",
"espresso/americano/./.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tu_kish/./././.",
"espresso/macchiato/././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tub_uk/././.",
"espresso/latte/./././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/_vietnamese/./.",
"espresso/cappuccino/././././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai_/.",
"espresso/mocha/./././././.") => LFS3_ERR_NOENT;
// here's a weird one, what happens if our rename is also a noop?
lfs3_rename(&lfs3,
"coffee/_rip/./././././.",
"coffee/_rip/./././././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/c_ldbrew/././././.",
"coffee/c_ldbrew/././././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tu_kish/./././.",
"coffee/tu_kish/./././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tub_uk/././.",
"coffee/tub_uk/././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/_vietnamese/./.",
"coffee/_vietnamese/./.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai_/.",
"coffee/thai_/.") => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "coffee/_rip/.") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee/c_ldbrew/./.") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee/tu_kish/././.") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee/tub_uk/./././.") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee/_vietnamese/././././.") => LFS3_ERR_NOENT;
lfs3_remove(&lfs3, "coffee/thai_/./././././.") => LFS3_ERR_NOENT;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_unmount(&lfs3) => 0;
'''
# noent tests with trailing dotdots
[cases.test_paths_noent_trailing_dotdots]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "coffee/drip") => 0;
lfs3_mkdir(&lfs3, "coffee/coldbrew") => 0;
lfs3_mkdir(&lfs3, "coffee/turkish") => 0;
lfs3_mkdir(&lfs3, "coffee/tubruk") => 0;
lfs3_mkdir(&lfs3, "coffee/vietnamese") => 0;
lfs3_mkdir(&lfs3, "coffee/thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "coffee/_rip/../../../../../..", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "coffee/c_ldbrew/../../../../..", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "coffee/tu_kish/../../../..", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "coffee/tub_uk/../../..", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "coffee/_vietnamese/../..", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "coffee/thai_/..", &info) => 0;
assert(strcmp(info.name, "coffee") == 0);
assert(info.type == LFS3_TYPE_DIR);
// file open paths, only works on files!
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/_rip/..",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/c_ldbrew/../..",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/tu_kish/../../..",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/tub_uk/../../../..",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/_vietnamese/../../../../..",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/thai_/../../../../../..",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
// dir open paths, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/_rip/..") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/c_ldbrew/../..") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/tu_kish/../../..") => LFS3_ERR_INVAL;
lfs3_dir_open(&lfs3, &dir, "coffee/tub_uk/../../../..") => LFS3_ERR_INVAL;
lfs3_dir_open(&lfs3, &dir, "coffee/_vietnamese/../../../../..") => LFS3_ERR_INVAL;
lfs3_dir_open(&lfs3, &dir, "coffee/thai_/../../../../../..") => LFS3_ERR_INVAL;
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
// bad source
lfs3_rename(&lfs3,
"coffee/_rip/../../../../../..",
"espresso/espresso") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/c_ldbrew/../../../../..",
"espresso/americano") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/tu_kish/../../../..",
"espresso/macchiato") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/tub_uk/../../..",
"espresso/latte") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/_vietnamese/../..",
"espresso/cappuccino") => LFS3_ERR_BUSY;
// this one works
lfs3_rename(&lfs3,
"coffee/thai_/..",
"espresso/mocha") => 0;
lfs3_rename(&lfs3,
"espresso/mocha",
"coffee") => 0;
// bad destination
lfs3_rename(&lfs3,
"coffee/_rip",
"espresso/espresso/..") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/c_ldbrew",
"espresso/americano/../..") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tu_kish",
"espresso/macchiato/../../..") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tub_uk",
"espresso/latte/../../../..") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/_vietnamese",
"espresso/cappuccino/../../../../..") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai_",
"espresso/mocha/../../../../../..") => LFS3_ERR_NOENT;
// bad source and bad destination
lfs3_rename(&lfs3,
"coffee/_rip/../../../../../..",
"espresso/espresso/..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/c_ldbrew/../../../../..",
"espresso/americano/../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/tu_kish/../../../..",
"espresso/macchiato/../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/tub_uk/../../..",
"espresso/latte/../../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/_vietnamese/../..",
"espresso/cappuccino/../../../../..") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3,
"coffee/thai_/..",
"espresso/mocha/../../../../../..") => LFS3_ERR_INVAL;
// here's a weird one, what happens if our rename is also a noop?
lfs3_rename(&lfs3,
"coffee/_rip/../../../../../..",
"coffee/_rip/../../../../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/c_ldbrew/../../../../..",
"coffee/c_ldbrew/../../../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/tu_kish/../../../..",
"coffee/tu_kish/../../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/tub_uk/../../..",
"coffee/tub_uk/../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/_vietnamese/../..",
"coffee/_vietnamese/../..") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3,
"coffee/thai_/..",
"coffee/thai_/..") => 0;
// remove paths
lfs3_remove(&lfs3, "coffee/_rip/..") => LFS3_ERR_NOTEMPTY;
lfs3_remove(&lfs3, "coffee/c_ldbrew/../..") => LFS3_ERR_BUSY;
lfs3_remove(&lfs3, "coffee/tu_kish/../../..") => LFS3_ERR_INVAL;
lfs3_remove(&lfs3, "coffee/tub_uk/../../../..") => LFS3_ERR_INVAL;
lfs3_remove(&lfs3, "coffee/_vietnamese/../../../../..") => LFS3_ERR_INVAL;
lfs3_remove(&lfs3, "coffee/thai_/../../../../../..") => LFS3_ERR_INVAL;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_unmount(&lfs3) => 0;
'''
# trailing notsup tests
[cases.test_paths_notsup]
in = 'lfs3.c'
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
// create paths with unknown file types
const char *path;
lfs3_mdir_t mdir;
lfs3_did_t did;
path = "coffee/drip";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/coldbrew";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/turkish";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/tubruk";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/vietnamese";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/thai";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
// file open paths, only works on files!
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_RDONLY) => LFS3_ERR_NOTSUP;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_RDONLY) => LFS3_ERR_NOTSUP;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_RDONLY) => LFS3_ERR_NOTSUP;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_RDONLY) => LFS3_ERR_NOTSUP;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_RDONLY) => LFS3_ERR_NOTSUP;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_RDONLY) => LFS3_ERR_NOTSUP;
// dir open paths, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/drip") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/coldbrew") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/turkish") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/tubruk") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/vietnamese") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/thai") => LFS3_ERR_NOTDIR;
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
lfs3_rename(&lfs3,
"coffee/drip",
"espresso/espresso") => 0;
lfs3_rename(&lfs3,
"coffee/coldbrew",
"espresso/americano") => 0;
lfs3_rename(&lfs3,
"coffee/turkish",
"espresso/macchiato") => 0;
lfs3_rename(&lfs3,
"coffee/tubruk",
"espresso/latte") => 0;
lfs3_rename(&lfs3,
"coffee/vietnamese",
"espresso/cappuccino") => 0;
lfs3_rename(&lfs3,
"coffee/thai",
"espresso/mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => 0;
assert(strcmp(info.name, "espresso") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "espresso/americano", &info) => 0;
assert(strcmp(info.name, "americano") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "espresso/macchiato", &info) => 0;
assert(strcmp(info.name, "macchiato") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "espresso/latte", &info) => 0;
assert(strcmp(info.name, "latte") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => 0;
assert(strcmp(info.name, "cappuccino") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "espresso/mocha", &info) => 0;
assert(strcmp(info.name, "mocha") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/drip", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/turkish", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/tubruk", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/thai", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "espresso/espresso") => 0;
lfs3_remove(&lfs3, "espresso/americano") => 0;
lfs3_remove(&lfs3, "espresso/macchiato") => 0;
lfs3_remove(&lfs3, "espresso/latte") => 0;
lfs3_remove(&lfs3, "espresso/cappuccino") => 0;
lfs3_remove(&lfs3, "espresso/mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# parent notsup tests
[cases.test_paths_notsup_parent]
defines.DIR = [false, true]
in = 'lfs3.c'
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths with unknown file types
const char *path;
lfs3_mdir_t mdir;
lfs3_did_t did;
path = "drip";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coldbrew";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "turkish";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "tubruk";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "vietnamese";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "thai";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "drip/coffee") => LFS3_ERR_NOTDIR;
lfs3_mkdir(&lfs3, "coldbrew/coffee") => LFS3_ERR_NOTDIR;
lfs3_mkdir(&lfs3, "turkish/coffee") => LFS3_ERR_NOTDIR;
lfs3_mkdir(&lfs3, "tubruk/coffee") => LFS3_ERR_NOTDIR;
lfs3_mkdir(&lfs3, "vietnamese/coffee") => LFS3_ERR_NOTDIR;
lfs3_mkdir(&lfs3, "thai/coffee") => LFS3_ERR_NOTDIR;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "drip/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coldbrew/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "turkish/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "tubruk/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "vietnamese/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "thai/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "drip/coffee", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coldbrew/coffee", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "turkish/coffee", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "tubruk/coffee", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "vietnamese/coffee", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "thai/coffee", &info) => LFS3_ERR_NOTDIR;
// file open paths, only works on files!
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "drip/coffee",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coldbrew/coffee",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "turkish/coffee",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "tubruk/coffee",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "vietnamese/coffee",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "thai/coffee",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "drip/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coldbrew/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "turkish/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "tubruk/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "vietnamese/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "thai/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "drip/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coldbrew/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "turkish/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "tubruk/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "vietnamese/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "thai/coffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
// dir open paths, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "drip/coffee") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coldbrew/coffee") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "turkish/coffee") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "tubruk/coffee") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "vietnamese/coffee") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "thai/coffee") => LFS3_ERR_NOTDIR;
// make some normal paths so we have something to rename
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "coffee/drip") => 0;
lfs3_mkdir(&lfs3, "coffee/coldbrew") => 0;
lfs3_mkdir(&lfs3, "coffee/turkish") => 0;
lfs3_mkdir(&lfs3, "coffee/tubruk") => 0;
lfs3_mkdir(&lfs3, "coffee/vietnamese") => 0;
lfs3_mkdir(&lfs3, "coffee/thai") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/turkish",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/tubruk",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/thai",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
// bad source
lfs3_rename(&lfs3,
"drip/coffee",
"espresso/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coldbrew/coffee",
"espresso/americano") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"turkish/coffee",
"espresso/macchiato") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"tubruk/coffee",
"espresso/latte") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"vietnamese/coffee",
"espresso/cappuccino") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"thai/coffee",
"espresso/mocha") => LFS3_ERR_NOTDIR;
// bad destination
lfs3_rename(&lfs3,
"coffee/drip",
"drip/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/coldbrew",
"coldbrew/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/turkish",
"turkish/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/tubruk",
"tubruk/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/vietnamese",
"vietnamese/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/thai",
"thai/espresso") => LFS3_ERR_NOTDIR;
// bad source and bad destination
lfs3_rename(&lfs3,
"drip/coffee",
"drip/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coldbrew/coffee",
"coldbrew/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"turkish/coffee",
"turkish/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"tubruk/coffee",
"tubruk/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"vietnamese/coffee",
"vietnamese/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"thai/coffee",
"thai/espresso") => LFS3_ERR_NOTDIR;
// here's a weird one, what happens if our rename is also a noop?
lfs3_rename(&lfs3,
"drip/coffee",
"drip/coffee") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coldbrew/coffee",
"coldbrew/coffee") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"turkish/coffee",
"turkish/coffee") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"tubruk/coffee",
"tubruk/coffee") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"vietnamese/coffee",
"vietnamese/coffee") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"thai/coffee",
"thai/coffee") => LFS3_ERR_NOTDIR;
// remove paths
lfs3_stat(&lfs3, "drip/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coldbrew/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "turkish/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "tubruk/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "vietnamese/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "thai/espresso", &info) => LFS3_ERR_NOTDIR;
// stat paths
lfs3_stat(&lfs3, "drip/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coldbrew/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "turkish/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "tubruk/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "vietnamese/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "thai/espresso", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_unmount(&lfs3) => 0;
'''
# notsup tests with trailing slashes
[cases.test_paths_notsup_trailing_slashes]
in = 'lfs3.c'
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
// create paths with unknown file types
const char *path;
lfs3_mdir_t mdir;
lfs3_did_t did;
path = "coffee/drip";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/coldbrew";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/turkish";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/tubruk";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/vietnamese";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/thai";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "coffee/drip//////", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/coldbrew/////", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/turkish////", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/tubruk///", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/vietnamese//", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/thai/", &info) => LFS3_ERR_NOTDIR;
// file open paths, only works on files!
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip/",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew//",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish///",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk////",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/////",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai//////",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/drip/",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew//",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish///",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk////",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/////",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai//////",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/drip/",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew//",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish///",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk////",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/////",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai//////",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
// dir open paths, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/drip/") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/coldbrew//") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/turkish///") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/tubruk////") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/vietnamese/////") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/thai//////") => LFS3_ERR_NOTDIR;
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
// bad source
lfs3_rename(&lfs3,
"coffee/drip//////",
"espresso/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/coldbrew/////",
"espresso/americano") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/turkish////",
"espresso/macchiato") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/tubruk///",
"espresso/latte") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/vietnamese//",
"espresso/cappuccino") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/thai/",
"espresso/mocha") => LFS3_ERR_NOTDIR;
// bad destination
lfs3_rename(&lfs3,
"coffee/drip",
"espresso/espresso/") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/coldbrew",
"espresso/americano//") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/turkish",
"espresso/macchiato///") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/tubruk",
"espresso/latte////") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/vietnamese",
"espresso/cappuccino/////") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/thai",
"espresso/mocha//////") => LFS3_ERR_NOTDIR;
// bad source and bad destination
lfs3_rename(&lfs3,
"coffee/drip//////",
"espresso/espresso/") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/coldbrew/////",
"espresso/americano//") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/turkish////",
"espresso/macchiato///") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/tubruk///",
"espresso/latte////") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/vietnamese//",
"espresso/cappuccino/////") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/thai/",
"espresso/mocha//////") => LFS3_ERR_NOTDIR;
// here's a weird one, what happens if our rename is also a noop?
lfs3_rename(&lfs3,
"coffee/drip//////",
"coffee/drip//////") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/coldbrew/////",
"coffee/coldbrew/////") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/turkish////",
"coffee/turkish////") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/tubruk///",
"coffee/tubruk///") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/vietnamese//",
"coffee/vietnamese//") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/thai/",
"coffee/thai/") => LFS3_ERR_NOTDIR;
// remove paths
lfs3_remove(&lfs3, "coffee/drip/") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/coldbrew//") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/turkish///") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/tubruk////") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/vietnamese/////") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/thai//////") => LFS3_ERR_NOTDIR;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_unmount(&lfs3) => 0;
'''
# notsup tests with trailing dots
[cases.test_paths_notsup_trailing_dots]
in = 'lfs3.c'
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
// create paths with unknown file types
const char *path;
lfs3_mdir_t mdir;
lfs3_did_t did;
path = "coffee/drip";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/coldbrew";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/turkish";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/tubruk";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/vietnamese";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/thai";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "coffee/drip/./././././.", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/coldbrew/././././.", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/turkish/./././.", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/tubruk/././.", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/vietnamese/./.", &info) => LFS3_ERR_NOTDIR;
lfs3_stat(&lfs3, "coffee/thai/.", &info) => LFS3_ERR_NOTDIR;
// file open paths, only works on files!
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip/.",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew/./.",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish/././.",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk/./././.",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/././././.",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai/./././././.",
LFS3_O_RDONLY) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/drip/.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew/./.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish/././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk/./././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/././././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai/./././././.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/drip/.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew/./.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish/././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/tubruk/./././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/././././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
lfs3_file_open(&lfs3, &file, "coffee/thai/./././././.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NOTDIR;
// dir open paths, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/drip/.") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/coldbrew/./.") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/turkish/././.") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/tubruk/./././.") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/vietnamese/././././.") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/thai/./././././.") => LFS3_ERR_NOTDIR;
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
// bad source
lfs3_rename(&lfs3,
"coffee/drip/./././././.",
"espresso/espresso") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/coldbrew/././././.",
"espresso/americano") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/turkish/./././.",
"espresso/macchiato") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/tubruk/././.",
"espresso/latte") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/vietnamese/./.",
"espresso/cappuccino") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/thai/.",
"espresso/mocha") => LFS3_ERR_NOTDIR;
// bad destination
lfs3_rename(&lfs3,
"coffee/drip",
"espresso/espresso/.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/coldbrew",
"espresso/americano/./.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/turkish",
"espresso/macchiato/././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/tubruk",
"espresso/latte/./././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/vietnamese",
"espresso/cappuccino/././././.") => LFS3_ERR_NOENT;
lfs3_rename(&lfs3,
"coffee/thai",
"espresso/mocha/./././././.") => LFS3_ERR_NOENT;
// bad source and bad destination
lfs3_rename(&lfs3,
"coffee/drip/./././././.",
"espresso/espresso/.") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/coldbrew/././././.",
"espresso/americano/./.") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/turkish/./././.",
"espresso/macchiato/././.") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/tubruk/././.",
"espresso/latte/./././.") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/vietnamese/./.",
"espresso/cappuccino/././././.") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/thai/.",
"espresso/mocha/./././././.") => LFS3_ERR_NOTDIR;
// here's a weird one, what happens if our rename is also a noop?
lfs3_rename(&lfs3,
"coffee/drip/./././././.",
"coffee/drip/./././././.") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/coldbrew/././././.",
"coffee/coldbrew/././././.") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/turkish/./././.",
"coffee/turkish/./././.") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/tubruk/././.",
"coffee/tubruk/././.") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/vietnamese/./.",
"coffee/vietnamese/./.") => LFS3_ERR_NOTDIR;
lfs3_rename(&lfs3,
"coffee/thai/.",
"coffee/thai/.") => LFS3_ERR_NOTDIR;
// remove paths
lfs3_remove(&lfs3, "coffee/drip/.") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/coldbrew/./.") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/turkish/././.") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/tubruk/./././.") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/vietnamese/././././.") => LFS3_ERR_NOTDIR;
lfs3_remove(&lfs3, "coffee/thai/./././././.") => LFS3_ERR_NOTDIR;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_unmount(&lfs3) => 0;
'''
# notsup tests with trailing dotdots
[cases.test_paths_notsup_trailing_dotdots]
in = 'lfs3.c'
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
// create paths with unknown file types
const char *path;
lfs3_mdir_t mdir;
lfs3_did_t did;
path = "coffee/drip";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/coldbrew";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/turkish";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/tubruk";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/vietnamese";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
path = "coffee/thai";
lfs3_mtree_pathlookup(&lfs3, &path,
&mdir, &did) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &mdir, LFS3_RATTRS(
LFS3_RATTR_CAT(
LFS3_TAG_NAME + 0x13, +1,
lfs3_data_fromleb128(did, (uint8_t[LFS3_LEB128_DSIZE]){0}),
LFS3_DATA_BUF(path, lfs3_path_namelen(path))))) => 0;
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "coffee/drip/../../../../../..", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "coffee/coldbrew/../../../../..", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "coffee/turkish/../../../..", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "coffee/tubruk/../../..", &info) => LFS3_ERR_INVAL;
lfs3_stat(&lfs3, "coffee/vietnamese/../..", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "coffee/thai/..", &info) => 0;
assert(strcmp(info.name, "coffee") == 0);
assert(info.type == LFS3_TYPE_DIR);
// file open paths, only works on files!
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip/..",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew/../..",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/turkish/../../..",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/tubruk/../../../..",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/vietnamese/../../../../..",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "coffee/thai/../../../../../..",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
// dir open paths, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/drip/..") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/coldbrew/../..") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/turkish/../../..") => LFS3_ERR_INVAL;
lfs3_dir_open(&lfs3, &dir, "coffee/tubruk/../../../..") => LFS3_ERR_INVAL;
lfs3_dir_open(&lfs3, &dir, "coffee/vietnamese/../../../../..") => LFS3_ERR_INVAL;
lfs3_dir_open(&lfs3, &dir, "coffee/thai/../../../../../..") => LFS3_ERR_INVAL;
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
// bad source
lfs3_rename(&lfs3,
"coffee/drip/../../../../../..",
"espresso/espresso") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/coldbrew/../../../../..",
"espresso/americano") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/turkish/../../../..",
"espresso/macchiato") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/tubruk/../../..",
"espresso/latte") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/vietnamese/../..",
"espresso/cappuccino") => LFS3_ERR_BUSY;
// this one works
lfs3_rename(&lfs3,
"coffee/thai/..",
"espresso/mocha") => 0;
lfs3_rename(&lfs3,
"espresso/mocha",
"coffee") => 0;
// bad destination
lfs3_rename(&lfs3,
"coffee/drip",
"espresso/espresso/..") => LFS3_ERR_ISDIR;
lfs3_rename(&lfs3,
"coffee/coldbrew",
"espresso/americano/../..") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3,
"coffee/turkish",
"espresso/macchiato/../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/tubruk",
"espresso/latte/../../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/vietnamese",
"espresso/cappuccino/../../../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/thai",
"espresso/mocha/../../../../../..") => LFS3_ERR_INVAL;
// bad source and bad destination
lfs3_rename(&lfs3,
"coffee/drip/../../../../../..",
"espresso/espresso/..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/coldbrew/../../../../..",
"espresso/americano/../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/turkish/../../../..",
"espresso/macchiato/../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/tubruk/../../..",
"espresso/latte/../../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/vietnamese/../..",
"espresso/cappuccino/../../../../..") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3,
"coffee/thai/..",
"espresso/mocha/../../../../../..") => LFS3_ERR_INVAL;
// here's a weird one, what happens if our rename is also a noop?
lfs3_rename(&lfs3,
"coffee/drip/../../../../../..",
"coffee/drip/../../../../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/coldbrew/../../../../..",
"coffee/coldbrew/../../../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/turkish/../../../..",
"coffee/turkish/../../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/tubruk/../../..",
"coffee/tubruk/../../..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3,
"coffee/vietnamese/../..",
"coffee/vietnamese/../..") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3,
"coffee/thai/..",
"coffee/thai/..") => 0;
// remove paths
lfs3_remove(&lfs3, "coffee/drip/..") => LFS3_ERR_NOTEMPTY;
lfs3_remove(&lfs3, "coffee/coldbrew/../..") => LFS3_ERR_BUSY;
lfs3_remove(&lfs3, "coffee/turkish/../../..") => LFS3_ERR_INVAL;
lfs3_remove(&lfs3, "coffee/tubruk/../../../..") => LFS3_ERR_INVAL;
lfs3_remove(&lfs3, "coffee/vietnamese/../../../../..") => LFS3_ERR_INVAL;
lfs3_remove(&lfs3, "coffee/thai/../../../../../..") => LFS3_ERR_INVAL;
// stat paths
lfs3_stat(&lfs3, "espresso/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "espresso/mocha", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/turkish", &info) => 0;
assert(strcmp(info.name, "turkish") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/tubruk", &info) => 0;
assert(strcmp(info.name, "tubruk") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/vietnamese", &info) => 0;
assert(strcmp(info.name, "vietnamese") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_stat(&lfs3, "coffee/thai", &info) => 0;
assert(strcmp(info.name, "thai") == 0);
assert(info.type == LFS3_TYPE_UNKNOWN);
lfs3_unmount(&lfs3) => 0;
'''
# test an empty path, this should error
[cases.test_paths_empty]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
struct lfs3_info info;
// create empty, this should error
if (DIR) {
lfs3_mkdir(&lfs3, "") => LFS3_ERR_INVAL;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_INVAL;
}
// stat empty
lfs3_stat(&lfs3, "", &info) => LFS3_ERR_INVAL;
// file open empty, only works on files!
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "",
LFS3_O_RDONLY) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_INVAL;
lfs3_file_open(&lfs3, &file, "",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_INVAL;
// dir open empty, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "") => LFS3_ERR_INVAL;
// rename empty, this should error
lfs3_rename(&lfs3, "", "coffee") => LFS3_ERR_INVAL;
lfs3_mkdir(&lfs3, "coffee") => 0;
lfs3_rename(&lfs3, "coffee", "") => LFS3_ERR_INVAL;
lfs3_remove(&lfs3, "coffee") => 0;
lfs3_rename(&lfs3, "", "") => LFS3_ERR_INVAL;
// stat empty
lfs3_stat(&lfs3, "", &info) => LFS3_ERR_INVAL;
// remove empty, this should error
lfs3_remove(&lfs3, "") => LFS3_ERR_INVAL;
// stat empty
lfs3_stat(&lfs3, "", &info) => LFS3_ERR_INVAL;
lfs3_unmount(&lfs3) => 0;
'''
# root operations
#
# POSIX deviations:
#
# - Root modifications return EINVAL instead of EBUSY:
# - littlefs: remove("/") => EINVAL
# - POSIX: remove("/") => EBUSY
# Reason: This would be the only use of EBUSY in the system.
#
[cases.test_paths_root]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
struct lfs3_info info;
// create root, this should error
if (DIR) {
lfs3_mkdir(&lfs3, "/") => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
}
// stat root
lfs3_stat(&lfs3, "/", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
// file open root, only works on files!
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
// dir open root, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
// rename root, this should error
lfs3_rename(&lfs3, "/", "coffee") => LFS3_ERR_BUSY;
lfs3_mkdir(&lfs3, "coffee") => 0;
lfs3_rename(&lfs3, "coffee", "/") => LFS3_ERR_BUSY;
lfs3_remove(&lfs3, "coffee") => 0;
lfs3_rename(&lfs3, "/", "/") => LFS3_ERR_BUSY;
// stat root
lfs3_stat(&lfs3, "/", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
// remove root, this should error
lfs3_remove(&lfs3, "/") => LFS3_ERR_BUSY;
// stat root
lfs3_stat(&lfs3, "/", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_unmount(&lfs3) => 0;
'''
# other root representations
[cases.test_paths_root_aliases]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
struct lfs3_info info;
// create root, this should error
if (DIR) {
lfs3_mkdir(&lfs3, "/") => LFS3_ERR_EXIST;
lfs3_mkdir(&lfs3, ".") => LFS3_ERR_EXIST;
lfs3_mkdir(&lfs3, "./") => LFS3_ERR_EXIST;
lfs3_mkdir(&lfs3, "/.") => LFS3_ERR_EXIST;
lfs3_mkdir(&lfs3, "//") => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, ".",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "./",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "//",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
}
// stat root
lfs3_stat(&lfs3, "/", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, ".", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "./", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "/.", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "//", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
// file open root, only works on files!
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "/",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, ".",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "./",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/.",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "//",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, ".",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "./",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/.",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "//",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "/",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, ".",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "./",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "/.",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "//",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
// dir open root, only works on dirs!
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "/") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, ".") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "./") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "/.") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "//") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
// rename root, this should error
lfs3_rename(&lfs3, "/", "coffee") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3, ".", "coffee") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3, "./", "coffee") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3, "/.", "coffee") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3, "//", "coffee") => LFS3_ERR_BUSY;
lfs3_mkdir(&lfs3, "coffee") => 0;
lfs3_rename(&lfs3, "coffee", "/") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3, "coffee", ".") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3, "coffee", "./") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3, "coffee", "/.") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3, "coffee", "//") => LFS3_ERR_BUSY;
lfs3_remove(&lfs3, "coffee") => 0;
lfs3_rename(&lfs3, "/", "/") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3, ".", ".") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3, "..", "..") => LFS3_ERR_INVAL;
lfs3_rename(&lfs3, "./", "./") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3, "/.", "/.") => LFS3_ERR_BUSY;
lfs3_rename(&lfs3, "//", "//") => LFS3_ERR_BUSY;
// stat root
lfs3_stat(&lfs3, "/", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, ".", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "./", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "/.", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "//", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
// remove root, this should error
lfs3_remove(&lfs3, "/") => LFS3_ERR_BUSY;
lfs3_remove(&lfs3, ".") => LFS3_ERR_BUSY;
lfs3_remove(&lfs3, "./") => LFS3_ERR_BUSY;
lfs3_remove(&lfs3, "/.") => LFS3_ERR_BUSY;
lfs3_remove(&lfs3, "//") => LFS3_ERR_BUSY;
// stat root
lfs3_stat(&lfs3, "/", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, ".", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "./", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "/.", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_stat(&lfs3, "//", &info) => 0;
assert(strcmp(info.name, "/") == 0);
assert(info.type == LFS3_TYPE_DIR);
lfs3_unmount(&lfs3) => 0;
'''
# superblock magic shouldn't appear as a file
[cases.test_paths_magic_noent]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// stat littlefs, which shouldn't exist
struct lfs3_info info;
lfs3_stat(&lfs3, "littlefs", &info) => LFS3_ERR_NOENT;
// file open littlefs, which shouldn't exist
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "littlefs",
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
// dir open littlefs, which shouldn't exist
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "littlefs") => LFS3_ERR_NOENT;
// rename littlefs, which shouldn't exist
lfs3_rename(&lfs3, "littlefs", "coffee") => LFS3_ERR_NOENT;
// remove littlefs, which shouldn't exist
lfs3_remove(&lfs3, "littlefs") => LFS3_ERR_NOENT;
// stat littlefs, which shouldn't exist
lfs3_stat(&lfs3, "coffee", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "littlefs", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# superblock magic shouldn't conflict with files, that would be silly
[cases.test_paths_magic_conflict]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create littlefs
if (DIR) {
lfs3_mkdir(&lfs3, "littlefs") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "littlefs",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat littlefs
struct lfs3_info info;
lfs3_stat(&lfs3, "littlefs", &info) => 0;
assert(strcmp(info.name, "littlefs") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open littlefs, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "littlefs",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "littlefs",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "littlefs",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "littlefs",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "littlefs",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "littlefs",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open littlefs, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "littlefs") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "littlefs") => LFS3_ERR_NOTDIR;
}
// rename littlefs
lfs3_rename(&lfs3, "littlefs", "coffee") => 0;
lfs3_rename(&lfs3, "coffee", "littlefs") => 0;
// stat littlefs
lfs3_stat(&lfs3, "littlefs", &info) => 0;
assert(strcmp(info.name, "littlefs") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee", &info) => LFS3_ERR_NOENT;
// remove littlefs
lfs3_remove(&lfs3, "littlefs") => 0;
// stat littlefs
lfs3_stat(&lfs3, "littlefs", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# test name too long
[cases.test_paths_nametoolong]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
char a_name[512];
memset(a_name, 'a', LFS3_NAME_MAX+1);
a_name[LFS3_NAME_MAX+1] = '\0';
// create names that are too long, should error
char path[1024];
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
sprintf(path, "coffee/%s", a_name);
lfs3_mkdir(&lfs3, path) => LFS3_ERR_NAMETOOLONG;
} else {
lfs3_file_t file;
sprintf(path, "coffee/%s", a_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_NAMETOOLONG;
}
// stat paths
struct lfs3_info info;
sprintf(path, "coffee/%s", a_name);
lfs3_stat(&lfs3, path, &info) => LFS3_ERR_NOENT;
// file open paths, only works on files!
lfs3_file_t file;
sprintf(path, "coffee/%s", a_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_RDONLY) => LFS3_ERR_NOENT;
// dir open paths, only works on dirs!
lfs3_dir_t dir;
sprintf(path, "coffee/%s", a_name);
lfs3_dir_open(&lfs3, &dir, path) => LFS3_ERR_NOENT;
// rename paths
lfs3_mkdir(&lfs3, "espresso") => 0;
sprintf(path, "coffee/%s", a_name);
lfs3_rename(&lfs3, path, "espresso/espresso") => LFS3_ERR_NOENT;
// renaming with too long a destination is tricky!
if (DIR) {
lfs3_mkdir(&lfs3, "coffee/drip") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/drip",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
sprintf(path, "espresso/%s", a_name);
lfs3_rename(&lfs3, "coffee/drip", path) => LFS3_ERR_NAMETOOLONG;
// stat paths
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
sprintf(path, "espresso/%s", a_name);
lfs3_stat(&lfs3, path, &info) => LFS3_ERR_NOENT;
// remove paths
sprintf(path, "espresso/%s", a_name);
lfs3_remove(&lfs3, path) => LFS3_ERR_NOENT;
// stat paths
lfs3_stat(&lfs3, "coffee/drip", &info) => 0;
assert(strcmp(info.name, "drip") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
sprintf(path, "espresso/%s", a_name);
lfs3_stat(&lfs3, path, &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# test name really long but not too long
[cases.test_paths_namejustlongenough]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
char a_name[512];
memset(a_name, 'a', LFS3_NAME_MAX);
a_name[LFS3_NAME_MAX] = '\0';
char b_name[512];
memset(b_name, 'b', LFS3_NAME_MAX);
b_name[LFS3_NAME_MAX] = '\0';
char c_name[512];
memset(c_name, 'c', LFS3_NAME_MAX);
c_name[LFS3_NAME_MAX] = '\0';
char d_name[512];
memset(d_name, 'd', LFS3_NAME_MAX);
d_name[LFS3_NAME_MAX] = '\0';
char e_name[512];
memset(e_name, 'e', LFS3_NAME_MAX);
e_name[LFS3_NAME_MAX] = '\0';
char f_name[512];
memset(f_name, 'f', LFS3_NAME_MAX);
f_name[LFS3_NAME_MAX] = '\0';
char g_name[512];
memset(g_name, 'g', LFS3_NAME_MAX);
g_name[LFS3_NAME_MAX] = '\0';
char h_name[512];
memset(h_name, 'h', LFS3_NAME_MAX);
h_name[LFS3_NAME_MAX] = '\0';
char i_name[512];
memset(i_name, 'i', LFS3_NAME_MAX);
i_name[LFS3_NAME_MAX] = '\0';
char j_name[512];
memset(j_name, 'j', LFS3_NAME_MAX);
j_name[LFS3_NAME_MAX] = '\0';
char k_name[512];
memset(k_name, 'k', LFS3_NAME_MAX);
k_name[LFS3_NAME_MAX] = '\0';
char l_name[512];
memset(l_name, 'l', LFS3_NAME_MAX);
l_name[LFS3_NAME_MAX] = '\0';
// create names that aren't too long
lfs3_mkdir(&lfs3, c_name) => 0;
char path[1024];
if (DIR) {
sprintf(path, "%s/%s", c_name, a_name);
lfs3_mkdir(&lfs3, path) => 0;
sprintf(path, "%s/%s", c_name, b_name);
lfs3_mkdir(&lfs3, path) => 0;
sprintf(path, "%s/%s", c_name, c_name);
lfs3_mkdir(&lfs3, path) => 0;
sprintf(path, "%s/%s", c_name, d_name);
lfs3_mkdir(&lfs3, path) => 0;
sprintf(path, "%s/%s", c_name, e_name);
lfs3_mkdir(&lfs3, path) => 0;
sprintf(path, "%s/%s", c_name, f_name);
lfs3_mkdir(&lfs3, path) => 0;
} else {
lfs3_file_t file;
sprintf(path, "%s/%s", c_name, a_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, b_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, c_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, d_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, e_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, f_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
sprintf(path, "%s/%s", c_name, a_name);
lfs3_stat(&lfs3, path, &info) => 0;
assert(strcmp(info.name, a_name) == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
sprintf(path, "%s/%s", c_name, b_name);
lfs3_stat(&lfs3, path, &info) => 0;
assert(strcmp(info.name, b_name) == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
sprintf(path, "%s/%s", c_name, c_name);
lfs3_stat(&lfs3, path, &info) => 0;
assert(strcmp(info.name, c_name) == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
sprintf(path, "%s/%s", c_name, d_name);
lfs3_stat(&lfs3, path, &info) => 0;
assert(strcmp(info.name, d_name) == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
sprintf(path, "%s/%s", c_name, e_name);
lfs3_stat(&lfs3, path, &info) => 0;
assert(strcmp(info.name, e_name) == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
sprintf(path, "%s/%s", c_name, f_name);
lfs3_stat(&lfs3, path, &info) => 0;
assert(strcmp(info.name, f_name) == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
sprintf(path, "%s/%s", c_name, a_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
sprintf(path, "%s/%s", c_name, b_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
sprintf(path, "%s/%s", c_name, c_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
sprintf(path, "%s/%s", c_name, d_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
sprintf(path, "%s/%s", c_name, e_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
sprintf(path, "%s/%s", c_name, f_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
sprintf(path, "%s/%s", c_name, a_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
sprintf(path, "%s/%s", c_name, b_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
sprintf(path, "%s/%s", c_name, c_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
sprintf(path, "%s/%s", c_name, d_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
sprintf(path, "%s/%s", c_name, e_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
sprintf(path, "%s/%s", c_name, f_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
sprintf(path, "%s/%s", c_name, a_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
sprintf(path, "%s/%s", c_name, b_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
sprintf(path, "%s/%s", c_name, c_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
sprintf(path, "%s/%s", c_name, d_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
sprintf(path, "%s/%s", c_name, e_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
sprintf(path, "%s/%s", c_name, f_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
sprintf(path, "%s/%s", c_name, a_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, b_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, c_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, d_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, e_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, f_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, a_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, b_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, c_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, d_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, e_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, f_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
sprintf(path, "%s/%s", c_name, a_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
sprintf(path, "%s/%s", c_name, b_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
sprintf(path, "%s/%s", c_name, c_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
sprintf(path, "%s/%s", c_name, d_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
sprintf(path, "%s/%s", c_name, e_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
sprintf(path, "%s/%s", c_name, f_name);
lfs3_file_open(&lfs3, &file, path,
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
sprintf(path, "%s/%s", c_name, a_name);
lfs3_dir_open(&lfs3, &dir, path) => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
sprintf(path, "%s/%s", c_name, b_name);
lfs3_dir_open(&lfs3, &dir, path) => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
sprintf(path, "%s/%s", c_name, c_name);
lfs3_dir_open(&lfs3, &dir, path) => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
sprintf(path, "%s/%s", c_name, d_name);
lfs3_dir_open(&lfs3, &dir, path) => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
sprintf(path, "%s/%s", c_name, e_name);
lfs3_dir_open(&lfs3, &dir, path) => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
sprintf(path, "%s/%s", c_name, f_name);
lfs3_dir_open(&lfs3, &dir, path) => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
sprintf(path, "%s/%s", c_name, a_name);
lfs3_dir_open(&lfs3, &dir, path) => LFS3_ERR_NOTDIR;
sprintf(path, "%s/%s", c_name, b_name);
lfs3_dir_open(&lfs3, &dir, path) => LFS3_ERR_NOTDIR;
sprintf(path, "%s/%s", c_name, c_name);
lfs3_dir_open(&lfs3, &dir, path) => LFS3_ERR_NOTDIR;
sprintf(path, "%s/%s", c_name, d_name);
lfs3_dir_open(&lfs3, &dir, path) => LFS3_ERR_NOTDIR;
sprintf(path, "%s/%s", c_name, e_name);
lfs3_dir_open(&lfs3, &dir, path) => LFS3_ERR_NOTDIR;
sprintf(path, "%s/%s", c_name, f_name);
lfs3_dir_open(&lfs3, &dir, path) => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, e_name) => 0;
char path_[1024];
sprintf(path, "%s/%s", c_name, a_name);
sprintf(path_, "%s/%s", e_name, g_name);
lfs3_rename(&lfs3, path, path_) => 0;
sprintf(path, "%s/%s", c_name, b_name);
sprintf(path_, "%s/%s", e_name, h_name);
lfs3_rename(&lfs3, path, path_) => 0;
sprintf(path, "%s/%s", c_name, c_name);
sprintf(path_, "%s/%s", e_name, i_name);
lfs3_rename(&lfs3, path, path_) => 0;
sprintf(path, "%s/%s", c_name, d_name);
sprintf(path_, "%s/%s", e_name, j_name);
lfs3_rename(&lfs3, path, path_) => 0;
sprintf(path, "%s/%s", c_name, e_name);
sprintf(path_, "%s/%s", e_name, k_name);
lfs3_rename(&lfs3, path, path_) => 0;
sprintf(path, "%s/%s", c_name, f_name);
sprintf(path_, "%s/%s", e_name, l_name);
lfs3_rename(&lfs3, path, path_) => 0;
// stat paths
sprintf(path, "%s/%s", e_name, g_name);
lfs3_stat(&lfs3, path, &info) => 0;
assert(strcmp(info.name, g_name) == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
sprintf(path, "%s/%s", e_name, h_name);
lfs3_stat(&lfs3, path, &info) => 0;
assert(strcmp(info.name, h_name) == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
sprintf(path, "%s/%s", e_name, i_name);
lfs3_stat(&lfs3, path, &info) => 0;
assert(strcmp(info.name, i_name) == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
sprintf(path, "%s/%s", e_name, j_name);
lfs3_stat(&lfs3, path, &info) => 0;
assert(strcmp(info.name, j_name) == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
sprintf(path, "%s/%s", e_name, k_name);
lfs3_stat(&lfs3, path, &info) => 0;
assert(strcmp(info.name, k_name) == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
sprintf(path, "%s/%s", e_name, l_name);
lfs3_stat(&lfs3, path, &info) => 0;
assert(strcmp(info.name, l_name) == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
sprintf(path, "%s/%s", c_name, a_name);
lfs3_stat(&lfs3, path, &info) => LFS3_ERR_NOENT;
sprintf(path, "%s/%s", c_name, b_name);
lfs3_stat(&lfs3, path, &info) => LFS3_ERR_NOENT;
sprintf(path, "%s/%s", c_name, c_name);
lfs3_stat(&lfs3, path, &info) => LFS3_ERR_NOENT;
sprintf(path, "%s/%s", c_name, d_name);
lfs3_stat(&lfs3, path, &info) => LFS3_ERR_NOENT;
sprintf(path, "%s/%s", c_name, e_name);
lfs3_stat(&lfs3, path, &info) => LFS3_ERR_NOENT;
sprintf(path, "%s/%s", c_name, f_name);
lfs3_stat(&lfs3, path, &info) => LFS3_ERR_NOENT;
// remove paths
sprintf(path, "%s/%s", e_name, g_name);
lfs3_remove(&lfs3, path) => 0;
sprintf(path, "%s/%s", e_name, h_name);
lfs3_remove(&lfs3, path) => 0;
sprintf(path, "%s/%s", e_name, i_name);
lfs3_remove(&lfs3, path) => 0;
sprintf(path, "%s/%s", e_name, j_name);
lfs3_remove(&lfs3, path) => 0;
sprintf(path, "%s/%s", e_name, k_name);
lfs3_remove(&lfs3, path) => 0;
sprintf(path, "%s/%s", e_name, l_name);
lfs3_remove(&lfs3, path) => 0;
// stat paths
sprintf(path, "%s/%s", e_name, g_name);
lfs3_stat(&lfs3, path, &info) => LFS3_ERR_NOENT;
sprintf(path, "%s/%s", e_name, h_name);
lfs3_stat(&lfs3, path, &info) => LFS3_ERR_NOENT;
sprintf(path, "%s/%s", e_name, i_name);
lfs3_stat(&lfs3, path, &info) => LFS3_ERR_NOENT;
sprintf(path, "%s/%s", e_name, j_name);
lfs3_stat(&lfs3, path, &info) => LFS3_ERR_NOENT;
sprintf(path, "%s/%s", e_name, k_name);
lfs3_stat(&lfs3, path, &info) => LFS3_ERR_NOENT;
sprintf(path, "%s/%s", e_name, l_name);
lfs3_stat(&lfs3, path, &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# a quick utf8 test, utf8 is easy to support
[cases.test_paths_utf8]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "coffee") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "coffee/dripcoffee") => 0;
lfs3_mkdir(&lfs3, "coffee/coldbrew") => 0;
lfs3_mkdir(&lfs3, "coffee/türkkahvesi") => 0;
lfs3_mkdir(&lfs3, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") => 0;
lfs3_mkdir(&lfs3, "coffee/càphêđá") => 0;
lfs3_mkdir(&lfs3, "coffee/โอเลี้ยง") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/dripcoffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/türkkahvesi",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/càphêđá",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/โอเลี้ยง",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "coffee/dripcoffee", &info) => 0;
assert(strcmp(info.name, "dripcoffee") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => 0;
assert(strcmp(info.name, "coldbrew") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/türkkahvesi", &info) => 0;
assert(strcmp(info.name, "türkkahvesi") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀", &info) => 0;
assert(strcmp(info.name, "ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/càphêđá", &info) => 0;
assert(strcmp(info.name, "càphêđá") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/โอเลี้ยง", &info) => 0;
assert(strcmp(info.name, "โอเลี้ยง") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/dripcoffee",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/türkkahvesi",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/càphêđá",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/โอเลี้ยง",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/dripcoffee",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/türkkahvesi",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/càphêđá",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/โอเลี้ยง",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "coffee/dripcoffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/türkkahvesi",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/càphêđá",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/โอเลี้ยง",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "coffee/dripcoffee",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/türkkahvesi",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/càphêđá",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/โอเลี้ยง",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/dripcoffee",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/türkkahvesi",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/càphêđá",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/โอเลี้ยง",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "coffee/dripcoffee",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/coldbrew",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/türkkahvesi",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/càphêđá",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "coffee/โอเลี้ยง",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/dripcoffee") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/coldbrew") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/türkkahvesi") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/càphêđá") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "coffee/โอเลี้ยง") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "coffee/dripcoffee") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/coldbrew") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/türkkahvesi") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/càphêđá") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "coffee/โอเลี้ยง") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "caffè") => 0;
lfs3_rename(&lfs3,
"coffee/dripcoffee",
"caffè/espresso") => 0;
lfs3_rename(&lfs3,
"coffee/coldbrew",
"caffè/americano") => 0;
lfs3_rename(&lfs3,
"coffee/türkkahvesi",
"caffè/macchiato") => 0;
lfs3_rename(&lfs3,
"coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀",
"caffè/latte") => 0;
lfs3_rename(&lfs3,
"coffee/càphêđá",
"caffè/cappuccino") => 0;
lfs3_rename(&lfs3,
"coffee/โอเลี้ยง",
"caffè/mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "caffè/espresso", &info) => 0;
assert(strcmp(info.name, "espresso") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "caffè/americano", &info) => 0;
assert(strcmp(info.name, "americano") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "caffè/macchiato", &info) => 0;
assert(strcmp(info.name, "macchiato") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "caffè/latte", &info) => 0;
assert(strcmp(info.name, "latte") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "caffè/cappuccino", &info) => 0;
assert(strcmp(info.name, "cappuccino") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "caffè/mocha", &info) => 0;
assert(strcmp(info.name, "mocha") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "coffee/dripcoffee", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/coldbrew", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/türkkahvesi", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/ꦏꦺꦴꦥꦶꦠꦸꦧꦿꦸꦏ꧀", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/càphêđá", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "coffee/โอเลี้ยง", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "caffè/espresso") => 0;
lfs3_remove(&lfs3, "caffè/americano") => 0;
lfs3_remove(&lfs3, "caffè/macchiato") => 0;
lfs3_remove(&lfs3, "caffè/latte") => 0;
lfs3_remove(&lfs3, "caffè/cappuccino") => 0;
lfs3_remove(&lfs3, "caffè/mocha") => 0;
// stat paths
lfs3_stat(&lfs3, "caffè/espresso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "caffè/americano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "caffè/macchiato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "caffè/latte", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "caffè/cappuccino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "caffè/mocha", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# more utf8 tests
[cases.test_paths_utf8_ipa]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "ˈkɔ.fi") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "ˈkɔ.fi/dɹɪpˈkɔ.fi") => 0;
lfs3_mkdir(&lfs3, "ˈkɔ.fi/koʊldbɹuː") => 0;
lfs3_mkdir(&lfs3, "ˈkɔ.fi/tyɾckɑhvɛˈsi") => 0;
lfs3_mkdir(&lfs3, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚") => 0;
lfs3_mkdir(&lfs3, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥") => 0;
lfs3_mkdir(&lfs3, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/koʊldbɹuː",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "ˈkɔ.fi/dɹɪpˈkɔ.fi", &info) => 0;
assert(strcmp(info.name, "dɹɪpˈkɔ.fi") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "ˈkɔ.fi/koʊldbɹuː", &info) => 0;
assert(strcmp(info.name, "koʊldbɹuː") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "ˈkɔ.fi/tyɾckɑhvɛˈsi", &info) => 0;
assert(strcmp(info.name, "tyɾckɑhvɛˈsi") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚", &info) => 0;
assert(strcmp(info.name, "ˈko.piˈt̪up̚.rʊk̚") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥", &info) => 0;
assert(strcmp(info.name, "kaː˨˩fe˧˧ɗaː˧˥") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥", &info) => 0;
assert(strcmp(info.name, "ʔoː˧.lia̯ŋ˦˥") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/koʊldbɹuː",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/koʊldbɹuː",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/koʊldbɹuː",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/koʊldbɹuː",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/koʊldbɹuː",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/dɹɪpˈkɔ.fi",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/koʊldbɹuː",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/tyɾckɑhvɛˈsi",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "ˈkɔ.fi/dɹɪpˈkɔ.fi") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "ˈkɔ.fi/koʊldbɹuː") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "ˈkɔ.fi/tyɾckɑhvɛˈsi") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "ˈkɔ.fi/dɹɪpˈkɔ.fi") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "ˈkɔ.fi/koʊldbɹuː") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "ˈkɔ.fi/tyɾckɑhvɛˈsi") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "kafˈfɛ") => 0;
lfs3_rename(&lfs3,
"ˈkɔ.fi/dɹɪpˈkɔ.fi",
"kafˈfɛ/eˈsprɛsso") => 0;
lfs3_rename(&lfs3,
"ˈkɔ.fi/koʊldbɹuː",
"kafˈfɛ/ameriˈkano") => 0;
lfs3_rename(&lfs3,
"ˈkɔ.fi/tyɾckɑhvɛˈsi",
"kafˈfɛ/makˈkjato") => 0;
lfs3_rename(&lfs3,
"ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚",
"kafˈfɛ/ˈlat.te") => 0;
lfs3_rename(&lfs3,
"ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥",
"kafˈfɛ/kapputˈt͡ʃino") => 0;
lfs3_rename(&lfs3,
"ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥",
"kafˈfɛ/ˈmoʊkə") => 0;
// stat paths
lfs3_stat(&lfs3, "kafˈfɛ/eˈsprɛsso", &info) => 0;
assert(strcmp(info.name, "eˈsprɛsso") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "kafˈfɛ/ameriˈkano", &info) => 0;
assert(strcmp(info.name, "ameriˈkano") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "kafˈfɛ/makˈkjato", &info) => 0;
assert(strcmp(info.name, "makˈkjato") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "kafˈfɛ/ˈlat.te", &info) => 0;
assert(strcmp(info.name, "ˈlat.te") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "kafˈfɛ/kapputˈt͡ʃino", &info) => 0;
assert(strcmp(info.name, "kapputˈt͡ʃino") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "kafˈfɛ/ˈmoʊkə", &info) => 0;
assert(strcmp(info.name, "ˈmoʊkə") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "ˈkɔ.fi/dɹɪpˈkɔ.fi", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "ˈkɔ.fi/koʊldbɹuː", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "ˈkɔ.fi/tyɾckɑhvɛˈsi", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "ˈkɔ.fi/ˈko.piˈt̪up̚.rʊk̚", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "ˈkɔ.fi/kaː˨˩fe˧˧ɗaː˧˥", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "ˈkɔ.fi/ʔoː˧.lia̯ŋ˦˥", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "kafˈfɛ/eˈsprɛsso") => 0;
lfs3_remove(&lfs3, "kafˈfɛ/ameriˈkano") => 0;
lfs3_remove(&lfs3, "kafˈfɛ/makˈkjato") => 0;
lfs3_remove(&lfs3, "kafˈfɛ/ˈlat.te") => 0;
lfs3_remove(&lfs3, "kafˈfɛ/kapputˈt͡ʃino") => 0;
lfs3_remove(&lfs3, "kafˈfɛ/ˈmoʊkə") => 0;
// stat paths
lfs3_stat(&lfs3, "kafˈfɛ/eˈsprɛsso", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "kafˈfɛ/ameriˈkano", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "kafˈfɛ/makˈkjato", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "kafˈfɛ/ˈlat.te", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "kafˈfɛ/kapputˈt͡ʃino", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "kafˈfɛ/ˈmoʊkə", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# test spaces have no problems
[cases.test_paths_spaces]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "c o f f e e") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "c o f f e e/d r i p") => 0;
lfs3_mkdir(&lfs3, "c o f f e e/c o l d b r e w") => 0;
lfs3_mkdir(&lfs3, "c o f f e e/t u r k i s h") => 0;
lfs3_mkdir(&lfs3, "c o f f e e/t u b r u k") => 0;
lfs3_mkdir(&lfs3, "c o f f e e/v i e t n a m e s e") => 0;
lfs3_mkdir(&lfs3, "c o f f e e/t h a i") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "c o f f e e/d r i p",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/c o l d b r e w",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/t u r k i s h",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/t u b r u k",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/v i e t n a m e s e",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/t h a i",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "c o f f e e/d r i p", &info) => 0;
assert(strcmp(info.name, "d r i p") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "c o f f e e/c o l d b r e w", &info) => 0;
assert(strcmp(info.name, "c o l d b r e w") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "c o f f e e/t u r k i s h", &info) => 0;
assert(strcmp(info.name, "t u r k i s h") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "c o f f e e/t u b r u k", &info) => 0;
assert(strcmp(info.name, "t u b r u k") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "c o f f e e/v i e t n a m e s e", &info) => 0;
assert(strcmp(info.name, "v i e t n a m e s e") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "c o f f e e/t h a i", &info) => 0;
assert(strcmp(info.name, "t h a i") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "c o f f e e/d r i p",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "c o f f e e/c o l d b r e w",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "c o f f e e/t u r k i s h",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "c o f f e e/t u b r u k",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "c o f f e e/v i e t n a m e s e",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "c o f f e e/t h a i",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "c o f f e e/d r i p",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "c o f f e e/c o l d b r e w",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "c o f f e e/t u r k i s h",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "c o f f e e/t u b r u k",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "c o f f e e/v i e t n a m e s e",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "c o f f e e/t h a i",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "c o f f e e/d r i p",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "c o f f e e/c o l d b r e w",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "c o f f e e/t u r k i s h",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "c o f f e e/t u b r u k",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "c o f f e e/v i e t n a m e s e",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "c o f f e e/t h a i",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "c o f f e e/d r i p",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/c o l d b r e w",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/t u r k i s h",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/t u b r u k",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/v i e t n a m e s e",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/t h a i",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/d r i p",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/c o l d b r e w",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/t u r k i s h",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/t u b r u k",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/v i e t n a m e s e",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/t h a i",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "c o f f e e/d r i p",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "c o f f e e/c o l d b r e w",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "c o f f e e/t u r k i s h",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "c o f f e e/t u b r u k",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "c o f f e e/v i e t n a m e s e",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "c o f f e e/t h a i",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "c o f f e e/d r i p") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "c o f f e e/c o l d b r e w") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "c o f f e e/t u r k i s h") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "c o f f e e/t u b r u k") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "c o f f e e/v i e t n a m e s e") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "c o f f e e/t h a i") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "c o f f e e/d r i p") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "c o f f e e/c o l d b r e w") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "c o f f e e/t u r k i s h") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "c o f f e e/t u b r u k") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "c o f f e e/v i e t n a m e s e") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "c o f f e e/t h a i") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "e s p r e s s o") => 0;
lfs3_rename(&lfs3,
"c o f f e e/d r i p",
"e s p r e s s o/e s p r e s s o") => 0;
lfs3_rename(&lfs3,
"c o f f e e/c o l d b r e w",
"e s p r e s s o/a m e r i c a n o") => 0;
lfs3_rename(&lfs3,
"c o f f e e/t u r k i s h",
"e s p r e s s o/m a c c h i a t o") => 0;
lfs3_rename(&lfs3,
"c o f f e e/t u b r u k",
"e s p r e s s o/l a t t e") => 0;
lfs3_rename(&lfs3,
"c o f f e e/v i e t n a m e s e",
"e s p r e s s o/c a p p u c c i n o") => 0;
lfs3_rename(&lfs3,
"c o f f e e/t h a i",
"e s p r e s s o/m o c h a") => 0;
// stat paths
lfs3_stat(&lfs3, "e s p r e s s o/e s p r e s s o", &info) => 0;
assert(strcmp(info.name, "e s p r e s s o") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "e s p r e s s o/a m e r i c a n o", &info) => 0;
assert(strcmp(info.name, "a m e r i c a n o") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "e s p r e s s o/m a c c h i a t o", &info) => 0;
assert(strcmp(info.name, "m a c c h i a t o") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "e s p r e s s o/l a t t e", &info) => 0;
assert(strcmp(info.name, "l a t t e") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "e s p r e s s o/c a p p u c c i n o", &info) => 0;
assert(strcmp(info.name, "c a p p u c c i n o") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "e s p r e s s o/m o c h a", &info) => 0;
assert(strcmp(info.name, "m o c h a") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "c o f f e e/d r i p", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "c o f f e e/c o l d b r e w", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "c o f f e e/t u r k i s h", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "c o f f e e/t u b r u k", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "c o f f e e/v i e t n a m e s e", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "c o f f e e/t h a i", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "e s p r e s s o/e s p r e s s o") => 0;
lfs3_remove(&lfs3, "e s p r e s s o/a m e r i c a n o") => 0;
lfs3_remove(&lfs3, "e s p r e s s o/m a c c h i a t o") => 0;
lfs3_remove(&lfs3, "e s p r e s s o/l a t t e") => 0;
lfs3_remove(&lfs3, "e s p r e s s o/c a p p u c c i n o") => 0;
lfs3_remove(&lfs3, "e s p r e s s o/m o c h a") => 0;
// stat paths
lfs3_stat(&lfs3, "e s p r e s s o/e s p r e s s o", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "e s p r e s s o/a m e r i c a n o", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "e s p r e s s o/m a c c h i a t o", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "e s p r e s s o/l a t t e", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "e s p r e s s o/c a p p u c c i n o", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "e s p r e s s o/m o c h a", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# test with only spaces
#
# please don't do this
[cases.test_paths_oopsallspaces]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, " ") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, " / ") => 0;
lfs3_mkdir(&lfs3, " / ") => 0;
lfs3_mkdir(&lfs3, " / ") => 0;
lfs3_mkdir(&lfs3, " / ") => 0;
lfs3_mkdir(&lfs3, " / ") => 0;
lfs3_mkdir(&lfs3, " / ") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, " / ", &info) => 0;
assert(strcmp(info.name, " ") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, " / ", &info) => 0;
assert(strcmp(info.name, " ") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, " / ", &info) => 0;
assert(strcmp(info.name, " ") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, " / ", &info) => 0;
assert(strcmp(info.name, " ") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, " / ", &info) => 0;
assert(strcmp(info.name, " ") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, " / ", &info) => 0;
assert(strcmp(info.name, " ") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, " / ",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, " / ") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, " / ") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, " / ") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, " / ") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, " / ") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, " / ") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, " / ") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, " / ") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, " / ") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, " / ") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, " / ") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, " / ") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, " ") => 0;
lfs3_rename(&lfs3,
" / ",
" / ") => 0;
lfs3_rename(&lfs3,
" / ",
" / ") => 0;
lfs3_rename(&lfs3,
" / ",
" / ") => 0;
lfs3_rename(&lfs3,
" / ",
" / ") => 0;
lfs3_rename(&lfs3,
" / ",
" / ") => 0;
lfs3_rename(&lfs3,
" / ",
" / ") => 0;
// stat paths
lfs3_stat(&lfs3, " / ", &info) => 0;
assert(strcmp(info.name, " ") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, " / ", &info) => 0;
assert(strcmp(info.name, " ") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, " / ", &info) => 0;
assert(strcmp(info.name, " ") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, " / ", &info) => 0;
assert(strcmp(info.name, " ") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, " / ", &info) => 0;
assert(strcmp(info.name, " ") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, " / ", &info) => 0;
assert(strcmp(info.name, " ") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, " / ", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, " / ", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, " / ", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, " / ", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, " / ", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, " / ", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, " / ") => 0;
lfs3_remove(&lfs3, " / ") => 0;
lfs3_remove(&lfs3, " / ") => 0;
lfs3_remove(&lfs3, " / ") => 0;
lfs3_remove(&lfs3, " / ") => 0;
lfs3_remove(&lfs3, " / ") => 0;
// stat paths
lfs3_stat(&lfs3, " / ", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, " / ", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, " / ", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, " / ", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, " / ", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, " / ", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# test with only ascii control characters
#
# littlefs only cares about "./" and NULL
[cases.test_paths_nonprintable]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "\x0c") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "\x0c/\x01") => 0;
lfs3_mkdir(&lfs3, "\x0c/\x02") => 0;
lfs3_mkdir(&lfs3, "\x0c/\x03") => 0;
lfs3_mkdir(&lfs3, "\x0c/\x04") => 0;
lfs3_mkdir(&lfs3, "\x0c/\x05") => 0;
lfs3_mkdir(&lfs3, "\x0c/\x06") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "\x0c/\x01",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x02",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x03",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x04",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x05",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x06",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "\x0c/\x01", &info) => 0;
assert(strcmp(info.name, "\x01") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x0c/\x02", &info) => 0;
assert(strcmp(info.name, "\x02") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x0c/\x03", &info) => 0;
assert(strcmp(info.name, "\x03") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x0c/\x04", &info) => 0;
assert(strcmp(info.name, "\x04") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x0c/\x05", &info) => 0;
assert(strcmp(info.name, "\x05") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x0c/\x06", &info) => 0;
assert(strcmp(info.name, "\x06") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "\x0c/\x01",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x0c/\x02",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x0c/\x03",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x0c/\x04",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x0c/\x05",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x0c/\x06",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x0c/\x01",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x0c/\x02",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x0c/\x03",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x0c/\x04",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x0c/\x05",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x0c/\x06",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x0c/\x01",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x0c/\x02",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x0c/\x03",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x0c/\x04",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x0c/\x05",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x0c/\x06",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "\x0c/\x01",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x02",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x03",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x04",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x05",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x06",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x01",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x02",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x03",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x04",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x05",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x06",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x0c/\x01",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x0c/\x02",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x0c/\x03",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x0c/\x04",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x0c/\x05",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x0c/\x06",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "\x0c/\x01") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\x0c/\x02") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\x0c/\x03") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\x0c/\x04") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\x0c/\x05") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\x0c/\x06") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "\x0c/\x01") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\x0c/\x02") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\x0c/\x03") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\x0c/\x04") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\x0c/\x05") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\x0c/\x06") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "\x0e") => 0;
lfs3_rename(&lfs3,
"\x0c/\x01",
"\x0e/\x1a") => 0;
lfs3_rename(&lfs3,
"\x0c/\x02",
"\x0e/\x1b") => 0;
lfs3_rename(&lfs3,
"\x0c/\x03",
"\x0e/\x1c") => 0;
lfs3_rename(&lfs3,
"\x0c/\x04",
"\x0e/\x1d") => 0;
lfs3_rename(&lfs3,
"\x0c/\x05",
"\x0e/\x1e") => 0;
lfs3_rename(&lfs3,
"\x0c/\x06",
"\x0e/\x1f") => 0;
// stat paths
lfs3_stat(&lfs3, "\x0e/\x1a", &info) => 0;
assert(strcmp(info.name, "\x1a") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x0e/\x1b", &info) => 0;
assert(strcmp(info.name, "\x1b") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x0e/\x1c", &info) => 0;
assert(strcmp(info.name, "\x1c") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x0e/\x1d", &info) => 0;
assert(strcmp(info.name, "\x1d") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x0e/\x1e", &info) => 0;
assert(strcmp(info.name, "\x1e") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x0e/\x1f", &info) => 0;
assert(strcmp(info.name, "\x1f") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x0c/\x01", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x0c/\x02", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x0c/\x03", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x0c/\x04", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x0c/\x05", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x0c/\x06", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "\x0e/\x1a") => 0;
lfs3_remove(&lfs3, "\x0e/\x1b") => 0;
lfs3_remove(&lfs3, "\x0e/\x1c") => 0;
lfs3_remove(&lfs3, "\x0e/\x1d") => 0;
lfs3_remove(&lfs3, "\x0e/\x1e") => 0;
lfs3_remove(&lfs3, "\x0e/\x1f") => 0;
// stat paths
lfs3_stat(&lfs3, "\x0e/\x1a", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x0e/\x1b", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x0e/\x1c", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x0e/\x1d", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x0e/\x1e", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x0e/\x1f", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# test with only ascii DELs
#
# I don't know why you'd do this
[cases.test_paths_oopsalldels]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "\x7f") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "\x7f/\x7f") => 0;
lfs3_mkdir(&lfs3, "\x7f/\x7f\x7f") => 0;
lfs3_mkdir(&lfs3, "\x7f/\x7f\x7f\x7f") => 0;
lfs3_mkdir(&lfs3, "\x7f/\x7f\x7f\x7f\x7f") => 0;
lfs3_mkdir(&lfs3, "\x7f/\x7f\x7f\x7f\x7f\x7f") => 0;
lfs3_mkdir(&lfs3, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "\x7f/\x7f", &info) => 0;
assert(strcmp(info.name, "\x7f") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x7f/\x7f\x7f", &info) => 0;
assert(strcmp(info.name, "\x7f\x7f") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x7f/\x7f\x7f\x7f", &info) => 0;
assert(strcmp(info.name, "\x7f\x7f\x7f") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x7f/\x7f\x7f\x7f\x7f", &info) => 0;
assert(strcmp(info.name, "\x7f\x7f\x7f\x7f") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x7f/\x7f\x7f\x7f\x7f\x7f", &info) => 0;
assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "\x7f/\x7f") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\x7f/\x7f\x7f") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\x7f/\x7f\x7f\x7f") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\x7f/\x7f\x7f\x7f\x7f") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "\x7f/\x7f") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\x7f/\x7f\x7f") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\x7f/\x7f\x7f\x7f") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\x7f/\x7f\x7f\x7f\x7f") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "\x7f\x7f") => 0;
lfs3_rename(&lfs3,
"\x7f/\x7f",
"\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
lfs3_rename(&lfs3,
"\x7f/\x7f\x7f",
"\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
lfs3_rename(&lfs3,
"\x7f/\x7f\x7f\x7f",
"\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
lfs3_rename(&lfs3,
"\x7f/\x7f\x7f\x7f\x7f",
"\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
lfs3_rename(&lfs3,
"\x7f/\x7f\x7f\x7f\x7f\x7f",
"\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
lfs3_rename(&lfs3,
"\x7f/\x7f\x7f\x7f\x7f\x7f\x7f",
"\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
// stat paths
lfs3_stat(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => 0;
assert(strcmp(info.name, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\x7f/\x7f", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x7f/\x7f\x7f", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x7f/\x7f\x7f\x7f", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x7f/\x7f\x7f\x7f\x7f", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x7f/\x7f\x7f\x7f\x7f\x7f", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
lfs3_remove(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
lfs3_remove(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
lfs3_remove(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
lfs3_remove(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
lfs3_remove(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f") => 0;
// stat paths
lfs3_stat(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\x7f\x7f/\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# test with invalid utf8 sequences
#
# Don't do this! These filenames are not utf8 and will probably break
# external tools.
#
[cases.test_paths_nonutf8]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "\xc0") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "\xc0/\xa0") => 0;
lfs3_mkdir(&lfs3, "\xc0/\xb0") => 0;
lfs3_mkdir(&lfs3, "\xc0/\xc0") => 0;
lfs3_mkdir(&lfs3, "\xc0/\xd0") => 0;
lfs3_mkdir(&lfs3, "\xc0/\xe0") => 0;
lfs3_mkdir(&lfs3, "\xc0/\xf0") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "\xc0/\xa0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xb0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xc0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xd0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xe0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xf0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "\xc0/\xa0", &info) => 0;
assert(strcmp(info.name, "\xa0") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xc0/\xb0", &info) => 0;
assert(strcmp(info.name, "\xb0") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xc0/\xc0", &info) => 0;
assert(strcmp(info.name, "\xc0") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xc0/\xd0", &info) => 0;
assert(strcmp(info.name, "\xd0") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xc0/\xe0", &info) => 0;
assert(strcmp(info.name, "\xe0") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xc0/\xf0", &info) => 0;
assert(strcmp(info.name, "\xf0") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "\xc0/\xa0",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xc0/\xb0",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xc0/\xc0",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xc0/\xd0",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xc0/\xe0",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xc0/\xf0",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xc0/\xa0",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xc0/\xb0",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xc0/\xc0",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xc0/\xd0",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xc0/\xe0",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xc0/\xf0",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xc0/\xa0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xc0/\xb0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xc0/\xc0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xc0/\xd0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xc0/\xe0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xc0/\xf0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "\xc0/\xa0",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xb0",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xc0",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xd0",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xe0",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xf0",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xa0",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xb0",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xc0",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xd0",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xe0",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xf0",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xc0/\xa0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xc0/\xb0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xc0/\xc0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xc0/\xd0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xc0/\xe0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xc0/\xf0",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "\xc0/\xa0") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\xc0/\xb0") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\xc0/\xc0") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\xc0/\xd0") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\xc0/\xe0") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\xc0/\xf0") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "\xc0/\xa0") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\xc0/\xb0") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\xc0/\xc0") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\xc0/\xd0") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\xc0/\xe0") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\xc0/\xf0") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "\xe0") => 0;
lfs3_rename(&lfs3,
"\xc0/\xa0",
"\xe0/\xaf") => 0;
lfs3_rename(&lfs3,
"\xc0/\xb0",
"\xe0/\xbf") => 0;
lfs3_rename(&lfs3,
"\xc0/\xc0",
"\xe0/\xcf") => 0;
lfs3_rename(&lfs3,
"\xc0/\xd0",
"\xe0/\xdf") => 0;
lfs3_rename(&lfs3,
"\xc0/\xe0",
"\xe0/\xef") => 0;
lfs3_rename(&lfs3,
"\xc0/\xf0",
"\xe0/\xff") => 0;
// stat paths
lfs3_stat(&lfs3, "\xe0/\xaf", &info) => 0;
assert(strcmp(info.name, "\xaf") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xe0/\xbf", &info) => 0;
assert(strcmp(info.name, "\xbf") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xe0/\xcf", &info) => 0;
assert(strcmp(info.name, "\xcf") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xe0/\xdf", &info) => 0;
assert(strcmp(info.name, "\xdf") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xe0/\xef", &info) => 0;
assert(strcmp(info.name, "\xef") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xe0/\xff", &info) => 0;
assert(strcmp(info.name, "\xff") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xc0/\xa0", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xc0/\xb0", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xc0/\xc0", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xc0/\xd0", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xc0/\xe0", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xc0/\xf0", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "\xe0/\xaf") => 0;
lfs3_remove(&lfs3, "\xe0/\xbf") => 0;
lfs3_remove(&lfs3, "\xe0/\xcf") => 0;
lfs3_remove(&lfs3, "\xe0/\xdf") => 0;
lfs3_remove(&lfs3, "\xe0/\xef") => 0;
lfs3_remove(&lfs3, "\xe0/\xff") => 0;
// stat paths
lfs3_stat(&lfs3, "\xe0/\xaf", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xe0/\xbf", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xe0/\xcf", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xe0/\xdf", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xe0/\xef", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xe0/\xff", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''
# test with only "\xff" characters
#
# Don't do this! These filenames are not utf8 and will probably break
# external tools.
#
[cases.test_paths_oopsallffs]
defines.DIR = [false, true]
code = '''
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, CFG) => 0;
lfs3_mount(&lfs3, LFS3_F_RDWR, CFG) => 0;
// create paths
lfs3_mkdir(&lfs3, "\xff") => 0;
if (DIR) {
lfs3_mkdir(&lfs3, "\xff/\xff") => 0;
lfs3_mkdir(&lfs3, "\xff/\xff\xff") => 0;
lfs3_mkdir(&lfs3, "\xff/\xff\xff\xff") => 0;
lfs3_mkdir(&lfs3, "\xff/\xff\xff\xff\xff") => 0;
lfs3_mkdir(&lfs3, "\xff/\xff\xff\xff\xff\xff") => 0;
lfs3_mkdir(&lfs3, "\xff/\xff\xff\xff\xff\xff\xff") => 0;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "\xff/\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
}
// stat paths
struct lfs3_info info;
lfs3_stat(&lfs3, "\xff/\xff", &info) => 0;
assert(strcmp(info.name, "\xff") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xff/\xff\xff", &info) => 0;
assert(strcmp(info.name, "\xff\xff") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xff/\xff\xff\xff", &info) => 0;
assert(strcmp(info.name, "\xff\xff\xff") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xff/\xff\xff\xff\xff", &info) => 0;
assert(strcmp(info.name, "\xff\xff\xff\xff") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xff/\xff\xff\xff\xff\xff", &info) => 0;
assert(strcmp(info.name, "\xff\xff\xff\xff\xff") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xff/\xff\xff\xff\xff\xff\xff", &info) => 0;
assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
// file open paths, only works on files!
if (DIR) {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "\xff/\xff",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff\xff",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff\xff\xff",
LFS3_O_RDONLY) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xff/\xff",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT) => LFS3_ERR_ISDIR;
lfs3_file_open(&lfs3, &file, "\xff/\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
} else {
lfs3_file_t file;
lfs3_file_open(&lfs3, &file, "\xff/\xff",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff\xff",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff\xff\xff",
LFS3_O_RDONLY) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT) => 0;
lfs3_file_close(&lfs3, &file) => 0;
lfs3_file_open(&lfs3, &file, "\xff/\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
lfs3_file_open(&lfs3, &file, "\xff/\xff\xff\xff\xff\xff\xff",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => LFS3_ERR_EXIST;
}
// dir open paths, only works on dirs!
if (DIR) {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "\xff/\xff") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\xff/\xff\xff") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\xff/\xff\xff\xff") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\xff/\xff\xff\xff\xff") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\xff/\xff\xff\xff\xff\xff") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
lfs3_dir_open(&lfs3, &dir, "\xff/\xff\xff\xff\xff\xff\xff") => 0;
lfs3_dir_close(&lfs3, &dir) => 0;
} else {
lfs3_dir_t dir;
lfs3_dir_open(&lfs3, &dir, "\xff/\xff") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\xff/\xff\xff") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\xff/\xff\xff\xff") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\xff/\xff\xff\xff\xff") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\xff/\xff\xff\xff\xff\xff") => LFS3_ERR_NOTDIR;
lfs3_dir_open(&lfs3, &dir, "\xff/\xff\xff\xff\xff\xff\xff") => LFS3_ERR_NOTDIR;
}
// rename paths
lfs3_mkdir(&lfs3, "\xff\xff") => 0;
lfs3_rename(&lfs3,
"\xff/\xff",
"\xff\xff/\xff\xff\xff\xff\xff\xff") => 0;
lfs3_rename(&lfs3,
"\xff/\xff\xff",
"\xff\xff/\xff\xff\xff\xff\xff\xff\xff") => 0;
lfs3_rename(&lfs3,
"\xff/\xff\xff\xff",
"\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
lfs3_rename(&lfs3,
"\xff/\xff\xff\xff\xff",
"\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
lfs3_rename(&lfs3,
"\xff/\xff\xff\xff\xff\xff",
"\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
lfs3_rename(&lfs3,
"\xff/\xff\xff\xff\xff\xff\xff",
"\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
// stat paths
lfs3_stat(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff", &info) => 0;
assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => 0;
assert(strcmp(info.name, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") == 0);
assert(info.type == ((DIR) ? LFS3_TYPE_DIR : LFS3_TYPE_REG));
lfs3_stat(&lfs3, "\xff/\xff", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xff/\xff\xff", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xff/\xff\xff\xff", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xff/\xff\xff\xff\xff", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xff/\xff\xff\xff\xff\xff", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xff/\xff\xff\xff\xff\xff\xff", &info) => LFS3_ERR_NOENT;
// remove paths
lfs3_remove(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff") => 0;
lfs3_remove(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff") => 0;
lfs3_remove(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
lfs3_remove(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
lfs3_remove(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
lfs3_remove(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") => 0;
// stat paths
lfs3_stat(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS3_ERR_NOENT;
lfs3_stat(&lfs3, "\xff\xff/\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &info) => LFS3_ERR_NOENT;
lfs3_unmount(&lfs3) => 0;
'''