diff options
author | Siddhesh Poyarekar <siddhesh@redhat.com> | 2014-12-04 08:11:07 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@redhat.com> | 2014-12-04 08:11:07 +0530 |
commit | 61b4f792e03facb456036b3f631d58d4f53b8075 (patch) | |
tree | 9c7a8b641caf405210cafb8ad1d9837b45add0ed /libio/tst-ftell-active-handler.c | |
parent | be349d7042de84c3c5157a5c1fbcad580aed33e1 (diff) | |
download | glibc-61b4f792e03facb456036b3f631d58d4f53b8075.tar glibc-61b4f792e03facb456036b3f631d58d4f53b8075.tar.gz glibc-61b4f792e03facb456036b3f631d58d4f53b8075.tar.bz2 glibc-61b4f792e03facb456036b3f631d58d4f53b8075.zip |
tst-ftell-active-handler: Open file with O_TRUNC for w modes
The test case fails to truncate the file when a file is intended to be
opened in w or w+ mode. Add O_TRUNC to fix this. The test still
succeeds with this change.
Diffstat (limited to 'libio/tst-ftell-active-handler.c')
-rw-r--r-- | libio/tst-ftell-active-handler.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/libio/tst-ftell-active-handler.c b/libio/tst-ftell-active-handler.c index 9f23c55072..72066b467e 100644 --- a/libio/tst-ftell-active-handler.c +++ b/libio/tst-ftell-active-handler.c @@ -104,8 +104,8 @@ do_ftruncate_test (const char *filename) int fd_mode; } test_modes[] = { {"r+", O_RDWR}, - {"w", O_WRONLY}, - {"w+", O_RDWR}, + {"w", O_WRONLY | O_TRUNC}, + {"w+", O_RDWR | O_TRUNC}, {"a", O_WRONLY}, {"a+", O_RDWR} }; @@ -189,8 +189,8 @@ do_rewind_test (const char *filename) size_t old_off; size_t new_off; } test_modes[] = { - {"w", O_WRONLY, 0, data_len}, - {"w+", O_RDWR, 0, data_len}, + {"w", O_WRONLY | O_TRUNC, 0, data_len}, + {"w+", O_RDWR | O_TRUNC, 0, data_len}, {"r+", O_RDWR, 0, data_len}, /* The new offsets for 'a' and 'a+' modes have to factor in the previous writes since they always append to the end of the @@ -294,8 +294,8 @@ do_ftell_test (const char *filename) /* In w, w+ and r+ modes, the file position should be at the beginning of the file. After the write, the offset should be updated to data_len. */ - {"w", O_WRONLY, 0, data_len}, - {"w+", O_RDWR, 0, data_len}, + {"w", O_WRONLY | O_TRUNC, 0, data_len}, + {"w+", O_RDWR | O_TRUNC, 0, data_len}, {"r+", O_RDWR, 0, data_len}, /* For the 'a' mode, the initial file position should be the current end of file. After the write, the offset has data_len @@ -375,8 +375,8 @@ do_write_test (const char *filename) const char *mode; int fd_mode; } test_modes[] = { - {"w", O_WRONLY}, - {"w+", O_RDWR}, + {"w", O_WRONLY | O_TRUNC}, + {"w+", O_RDWR | O_TRUNC}, {"r+", O_RDWR} }; |