Updated pwrite tests for Linux.

geesefs-0-30-9
Aaron Jacobs 2015-03-16 14:02:54 +11:00
parent bf21976965
commit d6218a3538
2 changed files with 20 additions and 2 deletions

View File

@ -943,9 +943,18 @@ func (t *MemFSTest) AppendMode() {
// Read back the contents of the file, which should be correct even though we
// seeked to a silly place before writing the world part.
//
// Linux's support for pwrite is buggy; the pwrite(2) man page says this:
//
// POSIX requires that opening a file with the O_APPEND flag should have
// no affect on the location at which pwrite() writes data. However, on
// Linux, if a file is opened with O_APPEND, pwrite() appends data to
// the end of the file, regardless of the value of offset.
//
// So we allow either the POSIX result or the Linux result.
n, err = f.ReadAt(buf, 0)
AssertEq(io.EOF, err)
ExpectEq("Hello, world!", string(buf[:n]))
ExpectThat(string(buf[:n]), AnyOf("Hello, world!", "Jello, world!H"))
}
func (t *MemFSTest) ReadsPastEndOfFile() {

View File

@ -260,9 +260,18 @@ func (t *PosixTest) AppendMode() {
// Read back the contents of the file, which should be correct even though we
// seeked to a silly place before writing the world part.
//
// Linux's support for pwrite is buggy; the pwrite(2) man page says this:
//
// POSIX requires that opening a file with the O_APPEND flag should have
// no affect on the location at which pwrite() writes data. However, on
// Linux, if a file is opened with O_APPEND, pwrite() appends data to
// the end of the file, regardless of the value of offset.
//
// So we allow either the POSIX result or the Linux result.
n, err = f.ReadAt(buf, 0)
AssertEq(io.EOF, err)
ExpectEq("Hello, world!", string(buf[:n]))
ExpectThat(string(buf[:n]), AnyOf("Hello, world!", "Jello, world!H"))
}
func (t *PosixTest) ReadsPastEndOfFile() {