This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
The test case fails to truncate the file when a file is intended to be
opened in w+ mode. Add O_TRUNC to fix this. The test still succeeds
with this change.
OK to commit?
Siddhesh
* libio/tst-ftell-active-handler.c (do_ftruncate_test): Add
O_TRUNC flag for w+ mode.
(do_rewind_test): Likewise.
(do_ftell_test): Likewise.
(do_write_test): Likewise.
---
libio/tst-ftell-active-handler.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libio/tst-ftell-active-handler.c b/libio/tst-ftell-active-handler.c
index 9f23c55..5922bb5 100644
--- a/libio/tst-ftell-active-handler.c
+++ b/libio/tst-ftell-active-handler.c
@@ -105,7 +105,7 @@ do_ftruncate_test (const char *filename)
} test_modes[] = {
{"r+", O_RDWR},
{"w", O_WRONLY},
- {"w+", O_RDWR},
+ {"w+", O_RDWR | O_TRUNC},
{"a", O_WRONLY},
{"a+", O_RDWR}
};
@@ -190,7 +190,7 @@ do_rewind_test (const char *filename)
size_t new_off;
} test_modes[] = {
{"w", O_WRONLY, 0, data_len},
- {"w+", O_RDWR, 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
@@ -295,7 +295,7 @@ do_ftell_test (const char *filename)
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_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
@@ -376,7 +376,7 @@ do_write_test (const char *filename)
int fd_mode;
} test_modes[] = {
{"w", O_WRONLY},
- {"w+", O_RDWR},
+ {"w+", O_RDWR | O_TRUNC},
{"r+", O_RDWR}
};
--
1.9.3
Attachment:
pgpYiqCJcmRub.pgp
Description: PGP signature
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |