| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- # specific corner cases worth explicitly testing for
- [[case]] # dangling split dir test
- define.ITERATIONS = 20
- define.COUNT = 10
- code = '''
- lfs_format(&lfs, &cfg) => 0;
- // fill up filesystem so only ~16 blocks are left
- lfs_mount(&lfs, &cfg) => 0;
- lfs_file_open(&lfs, &file, "padding", LFS_O_CREAT | LFS_O_WRONLY) => 0;
- memset(buffer, 0, 512);
- while (LFS_BLOCK_COUNT - lfs_fs_size(&lfs) > 16) {
- lfs_file_write(&lfs, &file, buffer, 512) => 512;
- }
- lfs_file_close(&lfs, &file) => 0;
- // make a child dir to use in bounded space
- lfs_mkdir(&lfs, "child") => 0;
- lfs_unmount(&lfs) => 0;
- lfs_mount(&lfs, &cfg) => 0;
- for (int j = 0; j < ITERATIONS; j++) {
- for (int i = 0; i < COUNT; i++) {
- sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
- lfs_file_open(&lfs, &file, path, LFS_O_CREAT | LFS_O_WRONLY) => 0;
- lfs_file_close(&lfs, &file) => 0;
- }
- lfs_dir_open(&lfs, &dir, "child") => 0;
- lfs_dir_read(&lfs, &dir, &info) => 1;
- lfs_dir_read(&lfs, &dir, &info) => 1;
- for (int i = 0; i < COUNT; i++) {
- sprintf(path, "test%03d_loooooooooooooooooong_name", i);
- lfs_dir_read(&lfs, &dir, &info) => 1;
- strcmp(info.name, path) => 0;
- }
- lfs_dir_read(&lfs, &dir, &info) => 0;
- lfs_dir_close(&lfs, &dir) => 0;
- if (j == ITERATIONS-1) {
- break;
- }
- for (int i = 0; i < COUNT; i++) {
- sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
- lfs_remove(&lfs, path) => 0;
- }
- }
- lfs_unmount(&lfs) => 0;
- lfs_mount(&lfs, &cfg) => 0;
- lfs_dir_open(&lfs, &dir, "child") => 0;
- lfs_dir_read(&lfs, &dir, &info) => 1;
- lfs_dir_read(&lfs, &dir, &info) => 1;
- for (int i = 0; i < COUNT; i++) {
- sprintf(path, "test%03d_loooooooooooooooooong_name", i);
- lfs_dir_read(&lfs, &dir, &info) => 1;
- strcmp(info.name, path) => 0;
- }
- lfs_dir_read(&lfs, &dir, &info) => 0;
- lfs_dir_close(&lfs, &dir) => 0;
- for (int i = 0; i < COUNT; i++) {
- sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
- lfs_remove(&lfs, path) => 0;
- }
- lfs_unmount(&lfs) => 0;
- '''
- [[case]] # outdated head test
- define.ITERATIONS = 20
- define.COUNT = 10
- code = '''
- lfs_format(&lfs, &cfg) => 0;
- // fill up filesystem so only ~16 blocks are left
- lfs_mount(&lfs, &cfg) => 0;
- lfs_file_open(&lfs, &file, "padding", LFS_O_CREAT | LFS_O_WRONLY) => 0;
- memset(buffer, 0, 512);
- while (LFS_BLOCK_COUNT - lfs_fs_size(&lfs) > 16) {
- lfs_file_write(&lfs, &file, buffer, 512) => 512;
- }
- lfs_file_close(&lfs, &file) => 0;
- // make a child dir to use in bounded space
- lfs_mkdir(&lfs, "child") => 0;
- lfs_unmount(&lfs) => 0;
- lfs_mount(&lfs, &cfg) => 0;
- for (int j = 0; j < ITERATIONS; j++) {
- for (int i = 0; i < COUNT; i++) {
- sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
- lfs_file_open(&lfs, &file, path, LFS_O_CREAT | LFS_O_WRONLY) => 0;
- lfs_file_close(&lfs, &file) => 0;
- }
- lfs_dir_open(&lfs, &dir, "child") => 0;
- lfs_dir_read(&lfs, &dir, &info) => 1;
- lfs_dir_read(&lfs, &dir, &info) => 1;
- for (int i = 0; i < COUNT; i++) {
- sprintf(path, "test%03d_loooooooooooooooooong_name", i);
- lfs_dir_read(&lfs, &dir, &info) => 1;
- strcmp(info.name, path) => 0;
- info.size => 0;
- sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
- lfs_file_open(&lfs, &file, path, LFS_O_WRONLY) => 0;
- lfs_file_write(&lfs, &file, "hi", 2) => 2;
- lfs_file_close(&lfs, &file) => 0;
- }
- lfs_dir_read(&lfs, &dir, &info) => 0;
- lfs_dir_rewind(&lfs, &dir) => 0;
- lfs_dir_read(&lfs, &dir, &info) => 1;
- lfs_dir_read(&lfs, &dir, &info) => 1;
- for (int i = 0; i < COUNT; i++) {
- sprintf(path, "test%03d_loooooooooooooooooong_name", i);
- lfs_dir_read(&lfs, &dir, &info) => 1;
- strcmp(info.name, path) => 0;
- info.size => 2;
- sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
- lfs_file_open(&lfs, &file, path, LFS_O_WRONLY) => 0;
- lfs_file_write(&lfs, &file, "hi", 2) => 2;
- lfs_file_close(&lfs, &file) => 0;
- }
- lfs_dir_read(&lfs, &dir, &info) => 0;
- lfs_dir_rewind(&lfs, &dir) => 0;
- lfs_dir_read(&lfs, &dir, &info) => 1;
- lfs_dir_read(&lfs, &dir, &info) => 1;
- for (int i = 0; i < COUNT; i++) {
- sprintf(path, "test%03d_loooooooooooooooooong_name", i);
- lfs_dir_read(&lfs, &dir, &info) => 1;
- strcmp(info.name, path) => 0;
- info.size => 2;
- }
- lfs_dir_read(&lfs, &dir, &info) => 0;
- lfs_dir_close(&lfs, &dir) => 0;
- for (int i = 0; i < COUNT; i++) {
- sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
- lfs_remove(&lfs, path) => 0;
- }
- }
- lfs_unmount(&lfs) => 0;
- '''
|