From 32da7d50151a7a6606c22039b68760e4d4763224 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Tue, 24 Mar 2015 13:49:44 +1100 Subject: [PATCH] FsyncErrorTest.Msync --- samples/flushfs/flush_fs_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/samples/flushfs/flush_fs_test.go b/samples/flushfs/flush_fs_test.go index 6e73a93..927e693 100644 --- a/samples/flushfs/flush_fs_test.go +++ b/samples/flushfs/flush_fs_test.go @@ -914,3 +914,32 @@ func (t *FsyncErrorTest) Fdatasync() { ExpectThat(err, Error(HasSubstr("no such file"))) } + +func (t *FsyncErrorTest) Msync() { + var err error + + // On OS X, msync does not cause SyncFile. + if isDarwin { + return + } + + // Open the file. + t.f1, err = os.OpenFile(path.Join(t.Dir, "foo"), os.O_RDWR, 0) + AssertEq(nil, err) + + // mmap the file. + data, err := syscall.Mmap( + int(t.f1.Fd()), 0, 4, + syscall.PROT_READ|syscall.PROT_WRITE, + syscall.MAP_SHARED) + + AssertEq(nil, err) + + // msync the mapping. + err = msync(data) + ExpectThat(err, Error(HasSubstr("no such file"))) + + // Unmap. + err = syscall.Munmap(data) + AssertEq(nil, err) +}