diff options
author | Christopher Haster <chaster@utexas.edu> | 2017-03-26 02:11:45 +0300 |
---|---|---|
committer | Christopher Haster <chaster@utexas.edu> | 2017-03-26 03:23:30 +0300 |
commit | a711675607496eb6271c22de9239f334639980e3 (patch) | |
tree | 31d841affb695dbf46b82f46dae8225b87c8c23e /tests/test_dirs.sh | |
parent | afa4ad82544048581913e0a273745acb3886dc84 (diff) |
Added dir tests, test fixes, config
Diffstat (limited to 'tests/test_dirs.sh')
-rwxr-xr-x | tests/test_dirs.sh | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/test_dirs.sh b/tests/test_dirs.sh new file mode 100755 index 0000000..00304b3 --- /dev/null +++ b/tests/test_dirs.sh @@ -0,0 +1,59 @@ +#!/bin/bash +set -eu + +echo "=== Directory tests ===" +rm -rf blocks + +echo "--- Root directory ---" +tests/test.py << TEST + lfs_format(&lfs, &config) => 0; + + lfs_dir_open(&lfs, &dir[0], "/") => 0; + lfs_dir_close(&lfs, &dir[0]) => 0; +TEST + +echo "--- Directory creation ---" +tests/test.py << TEST + lfs_mount(&lfs, &config) => 0; + lfs_mkdir(&lfs, "potato") => 0; + lfs_unmount(&lfs) => 0; +TEST + +echo "--- File creation ---" +tests/test.py << TEST + lfs_mount(&lfs, &config) => 0; + lfs_file_open(&lfs, &file[0], "burito", LFS_O_CREAT | LFS_O_WRONLY) => 0; + lfs_file_close(&lfs, &file[0]) => 0; + lfs_unmount(&lfs) => 0; +TEST + +echo "--- Directory iteration ---" +tests/test.py << TEST + lfs_mount(&lfs, &config) => 0; + lfs_dir_open(&lfs, &dir[0], "/") => 0; + lfs_dir_read(&lfs, &dir[0], &info) => 1; + strcmp(info.name, ".") => 0; + lfs_dir_read(&lfs, &dir[0], &info) => 1; + strcmp(info.name, "..") => 0; + lfs_dir_read(&lfs, &dir[0], &info) => 1; + strcmp(info.name, "potato") => 0; + lfs_dir_read(&lfs, &dir[0], &info) => 1; + strcmp(info.name, "burito") => 0; + lfs_dir_read(&lfs, &dir[0], &info) => 0; + lfs_dir_close(&lfs, &dir[0]) => 0; + lfs_unmount(&lfs) => 0; +TEST + +echo "--- Directory failures ---" +tests/test.py << TEST + lfs_mount(&lfs, &config) => 0; + lfs_mkdir(&lfs, "potato") => LFS_ERROR_EXISTS; + lfs_dir_open(&lfs, &dir[0], "tomato") => LFS_ERROR_NO_ENTRY; + lfs_dir_open(&lfs, &dir[0], "burito") => LFS_ERROR_NOT_DIR; + lfs_file_open(&lfs, &file[0], "tomato", LFS_O_RDONLY) => LFS_ERROR_NO_ENTRY; + lfs_file_open(&lfs, &file[0], "potato", LFS_O_RDONLY) => LFS_ERROR_IS_DIR; + lfs_unmount(&lfs) => 0; +TEST + +echo "--- Results ---" +tests/stats.py |