diff options
author | Christopher Haster <chaster@utexas.edu> | 2017-04-24 07:39:50 +0300 |
---|---|---|
committer | Christopher Haster <chaster@utexas.edu> | 2017-04-24 07:39:50 +0300 |
commit | 0406442253dcb6b813e6ff9a1659bd418fd0fe96 (patch) | |
tree | d9a0d5203f2ef33d8e936b46e27364c619a3f370 /tests | |
parent | 287b54876ed18524b3441d141c4f094ff6ff92d0 (diff) |
Fixed non-standard behaviour of rdwr streams
Originally had two seperate positions for reading/writing,
but this is inconsistent with the the posix standard, which
has a single position for reading and writing.
Also added proper handling of when the file is dirty, just
added an internal flag for this state.
Also moved the entry out of the file struct, and rearranged
some members to clean things up.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test_files.sh | 6 | ||||
-rwxr-xr-x | tests/test_seek.sh | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/tests/test_files.sh b/tests/test_files.sh index dbdd923..6086107 100755 --- a/tests/test_files.sh +++ b/tests/test_files.sh @@ -14,10 +14,14 @@ TEST echo "--- Simple file test ---" tests/test.py << TEST lfs_mount(&lfs, &cfg) => 0; - lfs_file_open(&lfs, &file[0], "hello", LFS_O_RDWR | LFS_O_CREAT | LFS_O_APPEND) => 0; + lfs_file_open(&lfs, &file[0], "hello", LFS_O_WRONLY | LFS_O_CREAT) => 0; size = strlen("Hello World!\n"); memcpy(wbuffer, "Hello World!\n", size); lfs_file_write(&lfs, &file[0], wbuffer, size) => size; + lfs_file_close(&lfs, &file[0]) => 0; + + lfs_file_open(&lfs, &file[0], "hello", LFS_O_RDONLY) => 0; + size = strlen("Hello World!\n"); lfs_file_read(&lfs, &file[0], rbuffer, size) => size; memcmp(rbuffer, wbuffer, size) => 0; lfs_file_close(&lfs, &file[0]) => 0; diff --git a/tests/test_seek.sh b/tests/test_seek.sh index b385e8b..8c00938 100755 --- a/tests/test_seek.sh +++ b/tests/test_seek.sh @@ -211,7 +211,7 @@ tests/test.py << TEST lfs_file_seek(&lfs, &file[0], pos, LFS_SEEK_SET) => pos; lfs_file_write(&lfs, &file[0], buffer, size) => size; - lfs_file_seek(&lfs, &file[0], pos, LFS_SEEK_SET) => pos; + lfs_file_seek(&lfs, &file[0], pos, LFS_SEEK_SET) => pos+size; lfs_file_read(&lfs, &file[0], buffer, size) => size; memcmp(buffer, "doggodogdog", size) => 0; @@ -254,7 +254,7 @@ tests/test.py << TEST lfs_file_seek(&lfs, &file[0], pos, LFS_SEEK_SET) => pos; lfs_file_write(&lfs, &file[0], buffer, size) => size; - lfs_file_seek(&lfs, &file[0], pos, LFS_SEEK_SET) => pos; + lfs_file_seek(&lfs, &file[0], pos, LFS_SEEK_SET) => pos+size; lfs_file_read(&lfs, &file[0], buffer, size) => size; memcmp(buffer, "doggodogdog", size) => 0; |