mirror of
https://github.com/eledio-devices/thirdparty-littlefs.git
synced 2025-11-01 00:38:29 +01:00
Added support for custom attributes 2
This commit is contained in:
@@ -140,12 +140,10 @@ TEST
|
||||
echo "--- Set/get file attribute ---"
|
||||
tests/test.py << TEST
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
struct lfs_file_config cfg1 = {
|
||||
.attrs =
|
||||
&(struct lfs_attr){'A', buffer, 4,
|
||||
&(struct lfs_attr){'B', buffer+4, 6,
|
||||
&(struct lfs_attr){'C', buffer+10, 5}}}
|
||||
};
|
||||
struct lfs_attr a1 = {'A', buffer, 4};
|
||||
struct lfs_attr b1 = {'B', buffer+4, 6, &a1};
|
||||
struct lfs_attr c1 = {'C', buffer+10, 5, &b1};
|
||||
struct lfs_file_config cfg1 = {.attrs = &c1};
|
||||
|
||||
lfs_file_opencfg(&lfs, &file[0], "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
|
||||
memcpy(buffer, "aaaa", 4);
|
||||
@@ -159,55 +157,53 @@ tests/test.py << TEST
|
||||
memcmp(buffer+4, "bbbbbb", 6) => 0;
|
||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
||||
|
||||
cfg1.attrs->next->size = 0;
|
||||
b1.size = 0;
|
||||
lfs_file_opencfg(&lfs, &file[0], "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
|
||||
lfs_file_close(&lfs, &file[0]) => 0;
|
||||
memset(buffer, 0, 15);
|
||||
cfg1.attrs->next->size = 6;
|
||||
b1.size = 6;
|
||||
lfs_file_opencfg(&lfs, &file[0], "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
|
||||
lfs_file_close(&lfs, &file[0]) => 0;
|
||||
memcmp(buffer, "aaaa", 4) => 0;
|
||||
memcmp(buffer+4, "\0\0\0\0\0\0", 6) => 0;
|
||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
||||
|
||||
cfg1.attrs->next->size = 6;
|
||||
b1.size = 6;
|
||||
lfs_file_opencfg(&lfs, &file[0], "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
|
||||
memcpy(buffer+4, "dddddd", 6);
|
||||
lfs_file_close(&lfs, &file[0]) => 0;
|
||||
memset(buffer, 0, 15);
|
||||
cfg1.attrs->next->size = 6;
|
||||
b1.size = 6;
|
||||
lfs_file_opencfg(&lfs, &file[0], "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
|
||||
lfs_file_close(&lfs, &file[0]) => 0;
|
||||
memcmp(buffer, "aaaa", 4) => 0;
|
||||
memcmp(buffer+4, "dddddd", 6) => 0;
|
||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
||||
|
||||
cfg1.attrs->next->size = 3;
|
||||
b1.size = 3;
|
||||
lfs_file_opencfg(&lfs, &file[0], "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
|
||||
memcpy(buffer+4, "eee", 3);
|
||||
lfs_file_close(&lfs, &file[0]) => 0;
|
||||
memset(buffer, 0, 15);
|
||||
cfg1.attrs->next->size = 6;
|
||||
b1.size = 6;
|
||||
lfs_file_opencfg(&lfs, &file[0], "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
|
||||
lfs_file_close(&lfs, &file[0]) => 0;
|
||||
memcmp(buffer, "aaaa", 4) => 0;
|
||||
memcmp(buffer+4, "eee\0\0\0", 6) => 0;
|
||||
memcmp(buffer+10, "ccccc", 5) => 0;
|
||||
|
||||
cfg1.attrs->size = LFS_ATTR_MAX+1;
|
||||
a1.size = LFS_ATTR_MAX+1;
|
||||
lfs_file_opencfg(&lfs, &file[0], "hello/hello", LFS_O_WRONLY, &cfg1)
|
||||
=> LFS_ERR_NOSPC;
|
||||
|
||||
struct lfs_file_config cfg2 = {
|
||||
.attrs =
|
||||
&(struct lfs_attr){'A', buffer, 4,
|
||||
&(struct lfs_attr){'B', buffer+4, 9,
|
||||
&(struct lfs_attr){'C', buffer+13, 5}}}
|
||||
};
|
||||
struct lfs_attr a2 = {'A', buffer, 4};
|
||||
struct lfs_attr b2 = {'B', buffer+4, 9, &a2};
|
||||
struct lfs_attr c2 = {'C', buffer+13, 5, &b2};
|
||||
struct lfs_file_config cfg2 = {.attrs = &c2};
|
||||
lfs_file_opencfg(&lfs, &file[0], "hello/hello", LFS_O_RDWR, &cfg2) => 0;
|
||||
memcpy(buffer+4, "fffffffff", 9);
|
||||
lfs_file_close(&lfs, &file[0]) => 0;
|
||||
cfg1.attrs->size = 4;
|
||||
a1.size = 4;
|
||||
lfs_file_opencfg(&lfs, &file[0], "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
|
||||
lfs_file_close(&lfs, &file[0]) => 0;
|
||||
|
||||
@@ -215,12 +211,10 @@ tests/test.py << TEST
|
||||
TEST
|
||||
tests/test.py << TEST
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
struct lfs_file_config cfg2 = {
|
||||
.attrs =
|
||||
&(struct lfs_attr){'A', buffer, 4,
|
||||
&(struct lfs_attr){'B', buffer+4, 9,
|
||||
&(struct lfs_attr){'C', buffer+13, 5}}}
|
||||
};
|
||||
struct lfs_attr a2 = {'A', buffer, 4};
|
||||
struct lfs_attr b2 = {'B', buffer+4, 9, &a2};
|
||||
struct lfs_attr c2 = {'C', buffer+13, 5, &b2};
|
||||
struct lfs_file_config cfg2 = {.attrs = &c2};
|
||||
|
||||
lfs_file_opencfg(&lfs, &file[0], "hello/hello", LFS_O_RDONLY, &cfg2) => 0;
|
||||
lfs_file_close(&lfs, &file[0]) => 0;
|
||||
@@ -238,12 +232,10 @@ TEST
|
||||
echo "--- Deferred file attributes ---"
|
||||
tests/test.py << TEST
|
||||
lfs_mount(&lfs, &cfg) => 0;
|
||||
struct lfs_file_config cfg1 = {
|
||||
.attrs =
|
||||
&(struct lfs_attr){'B', "gggg", 4,
|
||||
&(struct lfs_attr){'C', "", 0,
|
||||
&(struct lfs_attr){'D', "hhhh", 4}}}
|
||||
};
|
||||
struct lfs_attr a1 = {'B', "gggg", 4};
|
||||
struct lfs_attr b1 = {'C', "", 0, &a1};
|
||||
struct lfs_attr c1 = {'D', "hhhh", 4, &b1};
|
||||
struct lfs_file_config cfg1 = {.attrs = &c1};
|
||||
|
||||
lfs_file_opencfg(&lfs, &file[0], "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user