diff options
author | Christopher Haster <chaster@utexas.edu> | 2017-04-29 20:41:53 +0300 |
---|---|---|
committer | Christopher Haster <chaster@utexas.edu> | 2017-05-08 08:37:58 +0300 |
commit | a30142e0e17d0acf5fbb7605e40954bbf02e94bb (patch) | |
tree | 80af7075fd428670cdae52e7672192d402b82fa0 /tests | |
parent | 210b487325d885c1726653294fe99ff6b9aa638f (diff) |
Fixed allocation bugs near the end of storage
Also added better testing specifically for these corner cases
around the end of storage
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test_alloc.sh | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/test_alloc.sh b/tests/test_alloc.sh index e3e4fe0..630be2a 100755 --- a/tests/test_alloc.sh +++ b/tests/test_alloc.sh @@ -193,5 +193,69 @@ tests/test.py << TEST lfs_unmount(&lfs) => 0; TEST +echo "--- Dir exhaustion test ---" +tests/test.py << TEST + lfs_mount(&lfs, &cfg) => 0; + lfs_stat(&lfs, "exhaustion", &info) => 0; + lfs_size_t fullsize = info.size; + lfs_remove(&lfs, "exhaustion") => 0; + + lfs_file_open(&lfs, &file[0], "exhaustion", LFS_O_WRONLY | LFS_O_CREAT); + size = strlen("blahblahblahblah"); + memcpy(buffer, "blahblahblahblah", size); + for (lfs_size_t i = 0; i < fullsize - 2*512; i += size) { + lfs_file_write(&lfs, &file[0], buffer, size) => size; + } + lfs_file_close(&lfs, &file[0]) => 0; + + lfs_mkdir(&lfs, "exhaustiondir") => 0; + lfs_remove(&lfs, "exhaustiondir") => 0; + + lfs_file_open(&lfs, &file[0], "exhaustion", LFS_O_WRONLY | LFS_O_APPEND); + size = strlen("blahblahblahblah"); + memcpy(buffer, "blahblahblahblah", size); + lfs_file_write(&lfs, &file[0], buffer, size) => size; + lfs_file_close(&lfs, &file[0]) => 0; + + lfs_mkdir(&lfs, "exhaustiondir") => LFS_ERR_NOSPC; + lfs_unmount(&lfs) => 0; +TEST + +echo "--- Chained dir exhaustion test ---" +tests/test.py << TEST + lfs_mount(&lfs, &cfg) => 0; + lfs_stat(&lfs, "exhaustion", &info) => 0; + lfs_size_t fullsize = info.size; + + lfs_remove(&lfs, "exhaustion") => 0; + lfs_file_open(&lfs, &file[0], "exhaustion", LFS_O_WRONLY | LFS_O_CREAT); + size = strlen("blahblahblahblah"); + memcpy(buffer, "blahblahblahblah", size); + for (lfs_size_t i = 0; i < fullsize - 19*512; i += size) { + lfs_file_write(&lfs, &file[0], buffer, size) => size; + } + lfs_file_close(&lfs, &file[0]) => 0; + + for (int i = 0; i < 9; i++) { + sprintf((char*)buffer, "dirwithanexhaustivelylongnameforpadding%d", i); + lfs_mkdir(&lfs, (char*)buffer) => 0; + } + + lfs_mkdir(&lfs, "exhaustiondir") => LFS_ERR_NOSPC; + + lfs_remove(&lfs, "exhaustion") => 0; + lfs_file_open(&lfs, &file[0], "exhaustion", LFS_O_WRONLY | LFS_O_CREAT); + size = strlen("blahblahblahblah"); + memcpy(buffer, "blahblahblahblah", size); + for (lfs_size_t i = 0; i < fullsize - 20*512; i += size) { + lfs_file_write(&lfs, &file[0], buffer, size) => size; + } + lfs_file_close(&lfs, &file[0]) => 0; + + lfs_mkdir(&lfs, "exhaustiondir") => 0; + lfs_mkdir(&lfs, "exhaustiondir2") => LFS_ERR_NOSPC; +TEST + + echo "--- Results ---" tests/stats.py |