diff options
author | Christopher Haster <chaster@utexas.edu> | 2017-11-22 05:53:15 +0300 |
---|---|---|
committer | Christopher Haster <chaster@utexas.edu> | 2017-11-22 23:49:43 +0300 |
commit | bf78b09d370d4ae2eb1b59671053b065e9f9c550 (patch) | |
tree | b9b16cf06447f5449cc5cd6d72a3a76996d5bc94 /tests | |
parent | e169d06c574d9c3aefd8b7cd1c407c4726c008f3 (diff) |
Added directory list for synchronizing in flight directories
As it was, if a user operated on a directory while at the same
time iterating over the directory, the directory objects could
fall out of sync. In the best case, files may be skipped while
removing everything in a file, in the worst case, a very poorly
timed directory relocate could be missed.
Simple fix is to add the same directory tracking that is currently
in use for files, at a small code+complexity cost.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test_dirs.sh | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/tests/test_dirs.sh b/tests/test_dirs.sh index 8b69e7e..4318890 100755 --- a/tests/test_dirs.sh +++ b/tests/test_dirs.sh @@ -282,6 +282,49 @@ tests/test.py << TEST lfs_unmount(&lfs) => 0; TEST +echo "--- Recursive remove ---" +tests/test.py << TEST + lfs_mount(&lfs, &cfg) => 0; + lfs_remove(&lfs, "coldpotato") => LFS_ERR_INVAL; + + lfs_dir_open(&lfs, &dir[0], "coldpotato") => 0; + lfs_dir_read(&lfs, &dir[0], &info) => 1; + lfs_dir_read(&lfs, &dir[0], &info) => 1; + + while (true) { + int err = lfs_dir_read(&lfs, &dir[0], &info); + err >= 0 => 1; + if (err == 0) { + break; + } + + strcpy((char*)buffer, "coldpotato/"); + strcat((char*)buffer, info.name); + lfs_remove(&lfs, (char*)buffer) => 0; + } + + lfs_remove(&lfs, "coldpotato") => 0; +TEST +tests/test.py << TEST + lfs_mount(&lfs, &cfg) => 0; + lfs_dir_open(&lfs, &dir[0], "/") => 0; + lfs_dir_read(&lfs, &dir[0], &info) => 1; + strcmp(info.name, ".") => 0; + info.type => LFS_TYPE_DIR; + lfs_dir_read(&lfs, &dir[0], &info) => 1; + strcmp(info.name, "..") => 0; + info.type => LFS_TYPE_DIR; + lfs_dir_read(&lfs, &dir[0], &info) => 1; + strcmp(info.name, "burito") => 0; + info.type => LFS_TYPE_REG; + lfs_dir_read(&lfs, &dir[0], &info) => 1; + strcmp(info.name, "cactus") => 0; + info.type => LFS_TYPE_DIR; + lfs_dir_read(&lfs, &dir[0], &info) => 0; + lfs_dir_close(&lfs, &dir[0]) => 0; + lfs_unmount(&lfs) => 0; +TEST + echo "--- Multi-block remove ---" tests/test.py << TEST lfs_mount(&lfs, &cfg) => 0; @@ -307,9 +350,6 @@ tests/test.py << TEST lfs_dir_read(&lfs, &dir[0], &info) => 1; strcmp(info.name, "burito") => 0; info.type => LFS_TYPE_REG; - lfs_dir_read(&lfs, &dir[0], &info) => 1; - strcmp(info.name, "coldpotato") => 0; - info.type => LFS_TYPE_DIR; lfs_dir_read(&lfs, &dir[0], &info) => 0; lfs_dir_close(&lfs, &dir[0]) => 0; lfs_unmount(&lfs) => 0; |