119ea8026Sopenharmony_ci[cases.test_attrs_get_set]
219ea8026Sopenharmony_cicode = '''
319ea8026Sopenharmony_ci    lfs_t lfs;
419ea8026Sopenharmony_ci    lfs_format(&lfs, cfg) => 0;
519ea8026Sopenharmony_ci    lfs_mount(&lfs, cfg) => 0;
619ea8026Sopenharmony_ci    lfs_mkdir(&lfs, "hello") => 0;
719ea8026Sopenharmony_ci    lfs_file_t file;
819ea8026Sopenharmony_ci    lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
919ea8026Sopenharmony_ci    lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
1019ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file);
1119ea8026Sopenharmony_ci    lfs_unmount(&lfs) => 0;
1219ea8026Sopenharmony_ci
1319ea8026Sopenharmony_ci    lfs_mount(&lfs, cfg) => 0;
1419ea8026Sopenharmony_ci    uint8_t buffer[1024];
1519ea8026Sopenharmony_ci    memset(buffer, 0, sizeof(buffer));
1619ea8026Sopenharmony_ci    lfs_setattr(&lfs, "hello", 'A', "aaaa",   4) => 0;
1719ea8026Sopenharmony_ci    lfs_setattr(&lfs, "hello", 'B', "bbbbbb", 6) => 0;
1819ea8026Sopenharmony_ci    lfs_setattr(&lfs, "hello", 'C', "ccccc",  5) => 0;
1919ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'A', buffer,    4) => 4;
2019ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'B', buffer+4,  6) => 6;
2119ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
2219ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",   4) => 0;
2319ea8026Sopenharmony_ci    memcmp(buffer+4,  "bbbbbb", 6) => 0;
2419ea8026Sopenharmony_ci    memcmp(buffer+10, "ccccc",  5) => 0;
2519ea8026Sopenharmony_ci
2619ea8026Sopenharmony_ci    lfs_setattr(&lfs, "hello", 'B', "", 0) => 0;
2719ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'A', buffer,    4) => 4;
2819ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'B', buffer+4,  6) => 0;
2919ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
3019ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",         4) => 0;
3119ea8026Sopenharmony_ci    memcmp(buffer+4,  "\0\0\0\0\0\0", 6) => 0;
3219ea8026Sopenharmony_ci    memcmp(buffer+10, "ccccc",        5) => 0;
3319ea8026Sopenharmony_ci
3419ea8026Sopenharmony_ci    lfs_removeattr(&lfs, "hello", 'B') => 0;
3519ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'A', buffer,    4) => 4;
3619ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'B', buffer+4,  6) => LFS_ERR_NOATTR;
3719ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
3819ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",         4) => 0;
3919ea8026Sopenharmony_ci    memcmp(buffer+4,  "\0\0\0\0\0\0", 6) => 0;
4019ea8026Sopenharmony_ci    memcmp(buffer+10, "ccccc",        5) => 0;
4119ea8026Sopenharmony_ci
4219ea8026Sopenharmony_ci    lfs_setattr(&lfs, "hello", 'B', "dddddd", 6) => 0;
4319ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'A', buffer,    4) => 4;
4419ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'B', buffer+4,  6) => 6;
4519ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
4619ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",   4) => 0;
4719ea8026Sopenharmony_ci    memcmp(buffer+4,  "dddddd", 6) => 0;
4819ea8026Sopenharmony_ci    memcmp(buffer+10, "ccccc",  5) => 0;
4919ea8026Sopenharmony_ci
5019ea8026Sopenharmony_ci    lfs_setattr(&lfs, "hello", 'B', "eee", 3) => 0;
5119ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'A', buffer,    4) => 4;
5219ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'B', buffer+4,  6) => 3;
5319ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
5419ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",      4) => 0;
5519ea8026Sopenharmony_ci    memcmp(buffer+4,  "eee\0\0\0", 6) => 0;
5619ea8026Sopenharmony_ci    memcmp(buffer+10, "ccccc",     5) => 0;
5719ea8026Sopenharmony_ci
5819ea8026Sopenharmony_ci    lfs_setattr(&lfs, "hello", 'A', buffer, LFS_ATTR_MAX+1) => LFS_ERR_NOSPC;
5919ea8026Sopenharmony_ci    lfs_setattr(&lfs, "hello", 'B', "fffffffff", 9) => 0;
6019ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'A', buffer,    4) => 4;
6119ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'B', buffer+4,  6) => 9;
6219ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'C', buffer+10, 5) => 5;
6319ea8026Sopenharmony_ci
6419ea8026Sopenharmony_ci    lfs_unmount(&lfs) => 0;
6519ea8026Sopenharmony_ci
6619ea8026Sopenharmony_ci    lfs_mount(&lfs, cfg) => 0;
6719ea8026Sopenharmony_ci    memset(buffer, 0, sizeof(buffer));
6819ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'A', buffer,    4) => 4;
6919ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'B', buffer+4,  9) => 9;
7019ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello", 'C', buffer+13, 5) => 5;
7119ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",      4) => 0;
7219ea8026Sopenharmony_ci    memcmp(buffer+4,  "fffffffff", 9) => 0;
7319ea8026Sopenharmony_ci    memcmp(buffer+13, "ccccc",     5) => 0;
7419ea8026Sopenharmony_ci
7519ea8026Sopenharmony_ci    lfs_file_open(&lfs, &file, "hello/hello", LFS_O_RDONLY) => 0;
7619ea8026Sopenharmony_ci    lfs_file_read(&lfs, &file, buffer, sizeof(buffer)) => strlen("hello");
7719ea8026Sopenharmony_ci    memcmp(buffer, "hello", strlen("hello")) => 0;
7819ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file);
7919ea8026Sopenharmony_ci    lfs_unmount(&lfs) => 0;
8019ea8026Sopenharmony_ci'''
8119ea8026Sopenharmony_ci
8219ea8026Sopenharmony_ci[cases.test_attrs_get_set_root]
8319ea8026Sopenharmony_cicode = '''
8419ea8026Sopenharmony_ci    lfs_t lfs;
8519ea8026Sopenharmony_ci    lfs_format(&lfs, cfg) => 0;
8619ea8026Sopenharmony_ci    lfs_mount(&lfs, cfg) => 0;
8719ea8026Sopenharmony_ci    lfs_mkdir(&lfs, "hello") => 0;
8819ea8026Sopenharmony_ci    lfs_file_t file;
8919ea8026Sopenharmony_ci    lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
9019ea8026Sopenharmony_ci    lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
9119ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file);
9219ea8026Sopenharmony_ci    lfs_unmount(&lfs) => 0;
9319ea8026Sopenharmony_ci
9419ea8026Sopenharmony_ci    lfs_mount(&lfs, cfg) => 0;
9519ea8026Sopenharmony_ci    uint8_t buffer[1024];
9619ea8026Sopenharmony_ci    memset(buffer, 0, sizeof(buffer));
9719ea8026Sopenharmony_ci    lfs_setattr(&lfs, "/", 'A', "aaaa",   4) => 0;
9819ea8026Sopenharmony_ci    lfs_setattr(&lfs, "/", 'B', "bbbbbb", 6) => 0;
9919ea8026Sopenharmony_ci    lfs_setattr(&lfs, "/", 'C', "ccccc",  5) => 0;
10019ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'A', buffer,    4) => 4;
10119ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'B', buffer+4,  6) => 6;
10219ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
10319ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",   4) => 0;
10419ea8026Sopenharmony_ci    memcmp(buffer+4,  "bbbbbb", 6) => 0;
10519ea8026Sopenharmony_ci    memcmp(buffer+10, "ccccc",  5) => 0;
10619ea8026Sopenharmony_ci
10719ea8026Sopenharmony_ci    lfs_setattr(&lfs, "/", 'B', "", 0) => 0;
10819ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'A', buffer,    4) => 4;
10919ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'B', buffer+4,  6) => 0;
11019ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
11119ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",         4) => 0;
11219ea8026Sopenharmony_ci    memcmp(buffer+4,  "\0\0\0\0\0\0", 6) => 0;
11319ea8026Sopenharmony_ci    memcmp(buffer+10, "ccccc",        5) => 0;
11419ea8026Sopenharmony_ci
11519ea8026Sopenharmony_ci    lfs_removeattr(&lfs, "/", 'B') => 0;
11619ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'A', buffer,    4) => 4;
11719ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'B', buffer+4,  6) => LFS_ERR_NOATTR;
11819ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
11919ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",         4) => 0;
12019ea8026Sopenharmony_ci    memcmp(buffer+4,  "\0\0\0\0\0\0", 6) => 0;
12119ea8026Sopenharmony_ci    memcmp(buffer+10, "ccccc",        5) => 0;
12219ea8026Sopenharmony_ci
12319ea8026Sopenharmony_ci    lfs_setattr(&lfs, "/", 'B', "dddddd", 6) => 0;
12419ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'A', buffer,    4) => 4;
12519ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'B', buffer+4,  6) => 6;
12619ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
12719ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",   4) => 0;
12819ea8026Sopenharmony_ci    memcmp(buffer+4,  "dddddd", 6) => 0;
12919ea8026Sopenharmony_ci    memcmp(buffer+10, "ccccc",  5) => 0;
13019ea8026Sopenharmony_ci
13119ea8026Sopenharmony_ci    lfs_setattr(&lfs, "/", 'B', "eee", 3) => 0;
13219ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'A', buffer,    4) => 4;
13319ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'B', buffer+4,  6) => 3;
13419ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
13519ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",      4) => 0;
13619ea8026Sopenharmony_ci    memcmp(buffer+4,  "eee\0\0\0", 6) => 0;
13719ea8026Sopenharmony_ci    memcmp(buffer+10, "ccccc",     5) => 0;
13819ea8026Sopenharmony_ci
13919ea8026Sopenharmony_ci    lfs_setattr(&lfs, "/", 'A', buffer, LFS_ATTR_MAX+1) => LFS_ERR_NOSPC;
14019ea8026Sopenharmony_ci    lfs_setattr(&lfs, "/", 'B', "fffffffff", 9) => 0;
14119ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'A', buffer,    4) => 4;
14219ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'B', buffer+4,  6) => 9;
14319ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'C', buffer+10, 5) => 5;
14419ea8026Sopenharmony_ci    lfs_unmount(&lfs) => 0;
14519ea8026Sopenharmony_ci
14619ea8026Sopenharmony_ci    lfs_mount(&lfs, cfg) => 0;
14719ea8026Sopenharmony_ci    memset(buffer, 0, sizeof(buffer));
14819ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'A', buffer,    4) => 4;
14919ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'B', buffer+4,  9) => 9;
15019ea8026Sopenharmony_ci    lfs_getattr(&lfs, "/", 'C', buffer+13, 5) => 5;
15119ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",      4) => 0;
15219ea8026Sopenharmony_ci    memcmp(buffer+4,  "fffffffff", 9) => 0;
15319ea8026Sopenharmony_ci    memcmp(buffer+13, "ccccc",     5) => 0;
15419ea8026Sopenharmony_ci
15519ea8026Sopenharmony_ci    lfs_file_open(&lfs, &file, "hello/hello", LFS_O_RDONLY) => 0;
15619ea8026Sopenharmony_ci    lfs_file_read(&lfs, &file, buffer, sizeof(buffer)) => strlen("hello");
15719ea8026Sopenharmony_ci    memcmp(buffer, "hello", strlen("hello")) => 0;
15819ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file);
15919ea8026Sopenharmony_ci    lfs_unmount(&lfs) => 0;
16019ea8026Sopenharmony_ci'''
16119ea8026Sopenharmony_ci
16219ea8026Sopenharmony_ci[cases.test_attrs_get_set_file]
16319ea8026Sopenharmony_cicode = '''
16419ea8026Sopenharmony_ci    lfs_t lfs;
16519ea8026Sopenharmony_ci    lfs_format(&lfs, cfg) => 0;
16619ea8026Sopenharmony_ci    lfs_mount(&lfs, cfg) => 0;
16719ea8026Sopenharmony_ci    lfs_mkdir(&lfs, "hello") => 0;
16819ea8026Sopenharmony_ci    lfs_file_t file;
16919ea8026Sopenharmony_ci    lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
17019ea8026Sopenharmony_ci    lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
17119ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file);
17219ea8026Sopenharmony_ci    lfs_unmount(&lfs) => 0;
17319ea8026Sopenharmony_ci
17419ea8026Sopenharmony_ci    lfs_mount(&lfs, cfg) => 0;
17519ea8026Sopenharmony_ci    uint8_t buffer[1024];
17619ea8026Sopenharmony_ci    memset(buffer, 0, sizeof(buffer));
17719ea8026Sopenharmony_ci    struct lfs_attr attrs1[] = {
17819ea8026Sopenharmony_ci        {'A', buffer,    4},
17919ea8026Sopenharmony_ci        {'B', buffer+4,  6},
18019ea8026Sopenharmony_ci        {'C', buffer+10, 5},
18119ea8026Sopenharmony_ci    };
18219ea8026Sopenharmony_ci    struct lfs_file_config cfg1 = {.attrs=attrs1, .attr_count=3};
18319ea8026Sopenharmony_ci
18419ea8026Sopenharmony_ci    lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
18519ea8026Sopenharmony_ci    memcpy(buffer,    "aaaa",   4);
18619ea8026Sopenharmony_ci    memcpy(buffer+4,  "bbbbbb", 6);
18719ea8026Sopenharmony_ci    memcpy(buffer+10, "ccccc",  5);
18819ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file) => 0;
18919ea8026Sopenharmony_ci    memset(buffer, 0, 15);
19019ea8026Sopenharmony_ci    lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
19119ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file) => 0;
19219ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",   4) => 0;
19319ea8026Sopenharmony_ci    memcmp(buffer+4,  "bbbbbb", 6) => 0;
19419ea8026Sopenharmony_ci    memcmp(buffer+10, "ccccc",  5) => 0;
19519ea8026Sopenharmony_ci
19619ea8026Sopenharmony_ci    attrs1[1].size = 0;
19719ea8026Sopenharmony_ci    lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
19819ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file) => 0;
19919ea8026Sopenharmony_ci    memset(buffer, 0, 15);
20019ea8026Sopenharmony_ci    attrs1[1].size = 6;
20119ea8026Sopenharmony_ci    lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
20219ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file) => 0;
20319ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",         4) => 0;
20419ea8026Sopenharmony_ci    memcmp(buffer+4,  "\0\0\0\0\0\0", 6) => 0;
20519ea8026Sopenharmony_ci    memcmp(buffer+10, "ccccc",        5) => 0;
20619ea8026Sopenharmony_ci
20719ea8026Sopenharmony_ci    attrs1[1].size = 6;
20819ea8026Sopenharmony_ci    lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
20919ea8026Sopenharmony_ci    memcpy(buffer+4,  "dddddd", 6);
21019ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file) => 0;
21119ea8026Sopenharmony_ci    memset(buffer, 0, 15);
21219ea8026Sopenharmony_ci    attrs1[1].size = 6;
21319ea8026Sopenharmony_ci    lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
21419ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file) => 0;
21519ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",   4) => 0;
21619ea8026Sopenharmony_ci    memcmp(buffer+4,  "dddddd", 6) => 0;
21719ea8026Sopenharmony_ci    memcmp(buffer+10, "ccccc",  5) => 0;
21819ea8026Sopenharmony_ci
21919ea8026Sopenharmony_ci    attrs1[1].size = 3;
22019ea8026Sopenharmony_ci    lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
22119ea8026Sopenharmony_ci    memcpy(buffer+4,  "eee", 3);
22219ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file) => 0;
22319ea8026Sopenharmony_ci    memset(buffer, 0, 15);
22419ea8026Sopenharmony_ci    attrs1[1].size = 6;
22519ea8026Sopenharmony_ci    lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
22619ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file) => 0;
22719ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",      4) => 0;
22819ea8026Sopenharmony_ci    memcmp(buffer+4,  "eee\0\0\0", 6) => 0;
22919ea8026Sopenharmony_ci    memcmp(buffer+10, "ccccc",     5) => 0;
23019ea8026Sopenharmony_ci
23119ea8026Sopenharmony_ci    attrs1[0].size = LFS_ATTR_MAX+1;
23219ea8026Sopenharmony_ci    lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1)
23319ea8026Sopenharmony_ci        => LFS_ERR_NOSPC;
23419ea8026Sopenharmony_ci
23519ea8026Sopenharmony_ci    struct lfs_attr attrs2[] = {
23619ea8026Sopenharmony_ci        {'A', buffer,    4},
23719ea8026Sopenharmony_ci        {'B', buffer+4,  9},
23819ea8026Sopenharmony_ci        {'C', buffer+13, 5},
23919ea8026Sopenharmony_ci    };
24019ea8026Sopenharmony_ci    struct lfs_file_config cfg2 = {.attrs=attrs2, .attr_count=3};
24119ea8026Sopenharmony_ci    lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDWR, &cfg2) => 0;
24219ea8026Sopenharmony_ci    memcpy(buffer+4,  "fffffffff", 9);
24319ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file) => 0;
24419ea8026Sopenharmony_ci    attrs1[0].size = 4;
24519ea8026Sopenharmony_ci    lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg1) => 0;
24619ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file) => 0;
24719ea8026Sopenharmony_ci
24819ea8026Sopenharmony_ci    lfs_unmount(&lfs) => 0;
24919ea8026Sopenharmony_ci
25019ea8026Sopenharmony_ci    lfs_mount(&lfs, cfg) => 0;
25119ea8026Sopenharmony_ci    memset(buffer, 0, sizeof(buffer));
25219ea8026Sopenharmony_ci    struct lfs_attr attrs3[] = {
25319ea8026Sopenharmony_ci        {'A', buffer,    4},
25419ea8026Sopenharmony_ci        {'B', buffer+4,  9},
25519ea8026Sopenharmony_ci        {'C', buffer+13, 5},
25619ea8026Sopenharmony_ci    };
25719ea8026Sopenharmony_ci    struct lfs_file_config cfg3 = {.attrs=attrs3, .attr_count=3};
25819ea8026Sopenharmony_ci
25919ea8026Sopenharmony_ci    lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_RDONLY, &cfg3) => 0;
26019ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file) => 0;
26119ea8026Sopenharmony_ci    memcmp(buffer,    "aaaa",      4) => 0;
26219ea8026Sopenharmony_ci    memcmp(buffer+4,  "fffffffff", 9) => 0;
26319ea8026Sopenharmony_ci    memcmp(buffer+13, "ccccc",     5) => 0;
26419ea8026Sopenharmony_ci
26519ea8026Sopenharmony_ci    lfs_file_open(&lfs, &file, "hello/hello", LFS_O_RDONLY) => 0;
26619ea8026Sopenharmony_ci    lfs_file_read(&lfs, &file, buffer, sizeof(buffer)) => strlen("hello");
26719ea8026Sopenharmony_ci    memcmp(buffer, "hello", strlen("hello")) => 0;
26819ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file);
26919ea8026Sopenharmony_ci    lfs_unmount(&lfs) => 0;
27019ea8026Sopenharmony_ci'''
27119ea8026Sopenharmony_ci
27219ea8026Sopenharmony_ci[cases.test_attrs_deferred_file]
27319ea8026Sopenharmony_cicode = '''
27419ea8026Sopenharmony_ci    lfs_t lfs;
27519ea8026Sopenharmony_ci    lfs_format(&lfs, cfg) => 0;
27619ea8026Sopenharmony_ci    lfs_mount(&lfs, cfg) => 0;
27719ea8026Sopenharmony_ci    lfs_mkdir(&lfs, "hello") => 0;
27819ea8026Sopenharmony_ci    lfs_file_t file;
27919ea8026Sopenharmony_ci    lfs_file_open(&lfs, &file, "hello/hello", LFS_O_WRONLY | LFS_O_CREAT) => 0;
28019ea8026Sopenharmony_ci    lfs_file_write(&lfs, &file, "hello", strlen("hello")) => strlen("hello");
28119ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file);
28219ea8026Sopenharmony_ci    lfs_unmount(&lfs) => 0;
28319ea8026Sopenharmony_ci
28419ea8026Sopenharmony_ci    lfs_mount(&lfs, cfg) => 0;
28519ea8026Sopenharmony_ci    lfs_setattr(&lfs, "hello/hello", 'B', "fffffffff",  9) => 0;
28619ea8026Sopenharmony_ci    lfs_setattr(&lfs, "hello/hello", 'C', "ccccc",      5) => 0;
28719ea8026Sopenharmony_ci
28819ea8026Sopenharmony_ci    uint8_t buffer[1024];
28919ea8026Sopenharmony_ci    memset(buffer, 0, sizeof(buffer));
29019ea8026Sopenharmony_ci    struct lfs_attr attrs1[] = {
29119ea8026Sopenharmony_ci        {'B', "gggg", 4},
29219ea8026Sopenharmony_ci        {'C', "",     0},
29319ea8026Sopenharmony_ci        {'D', "hhhh", 4},
29419ea8026Sopenharmony_ci    };
29519ea8026Sopenharmony_ci    struct lfs_file_config cfg1 = {.attrs=attrs1, .attr_count=3};
29619ea8026Sopenharmony_ci
29719ea8026Sopenharmony_ci    lfs_file_opencfg(&lfs, &file, "hello/hello", LFS_O_WRONLY, &cfg1) => 0;
29819ea8026Sopenharmony_ci
29919ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello/hello", 'B', buffer,    9) => 9;
30019ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello/hello", 'C', buffer+9,  9) => 5;
30119ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello/hello", 'D', buffer+18, 9) => LFS_ERR_NOATTR;
30219ea8026Sopenharmony_ci    memcmp(buffer,    "fffffffff",          9) => 0;
30319ea8026Sopenharmony_ci    memcmp(buffer+9,  "ccccc\0\0\0\0",      9) => 0;
30419ea8026Sopenharmony_ci    memcmp(buffer+18, "\0\0\0\0\0\0\0\0\0", 9) => 0;
30519ea8026Sopenharmony_ci
30619ea8026Sopenharmony_ci    lfs_file_sync(&lfs, &file) => 0;
30719ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello/hello", 'B', buffer,    9) => 4;
30819ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello/hello", 'C', buffer+9,  9) => 0;
30919ea8026Sopenharmony_ci    lfs_getattr(&lfs, "hello/hello", 'D', buffer+18, 9) => 4;
31019ea8026Sopenharmony_ci    memcmp(buffer,    "gggg\0\0\0\0\0",     9) => 0;
31119ea8026Sopenharmony_ci    memcmp(buffer+9,  "\0\0\0\0\0\0\0\0\0", 9) => 0;
31219ea8026Sopenharmony_ci    memcmp(buffer+18, "hhhh\0\0\0\0\0",     9) => 0;
31319ea8026Sopenharmony_ci
31419ea8026Sopenharmony_ci    lfs_file_close(&lfs, &file) => 0;
31519ea8026Sopenharmony_ci    lfs_unmount(&lfs) => 0;
31619ea8026Sopenharmony_ci'''
317