1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
13 "golang.org/x/sys/unix"
16 func TestMmap(t *testing.T) {
17 b, err := unix.Mmap(-1, 0, unix.Getpagesize(), unix.PROT_NONE, unix.MAP_ANON|unix.MAP_PRIVATE)
19 t.Fatalf("Mmap: %v", err)
21 if err := unix.Mprotect(b, unix.PROT_READ|unix.PROT_WRITE); err != nil {
22 t.Fatalf("Mprotect: %v", err)
27 if runtime.GOOS == "aix" {
28 t.Skip("msync returns invalid argument for AIX, skipping msync test")
30 if err := unix.Msync(b, unix.MS_SYNC); err != nil {
31 t.Fatalf("Msync: %v", err)
35 if err := unix.Madvise(b, unix.MADV_DONTNEED); err != nil {
36 t.Fatalf("Madvise: %v", err)
38 if err := unix.Munmap(b); err != nil {
39 t.Fatalf("Munmap: %v", err)