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 darwin dragonfly freebsd linux netbsd openbsd solaris
12 "golang.org/x/sys/unix"
15 func TestMmap(t *testing.T) {
16 b, err := unix.Mmap(-1, 0, unix.Getpagesize(), unix.PROT_NONE, unix.MAP_ANON|unix.MAP_PRIVATE)
18 t.Fatalf("Mmap: %v", err)
20 if err := unix.Mprotect(b, unix.PROT_WRITE); err != nil {
21 t.Fatalf("Mprotect: %v", err)
26 if err := unix.Msync(b, unix.MS_SYNC); err != nil {
27 t.Fatalf("Msync: %v", err)
29 if err := unix.Madvise(b, unix.MADV_DONTNEED); err != nil {
30 t.Fatalf("Madvise: %v", err)
32 if err := unix.Munmap(b); err != nil {
33 t.Fatalf("Munmap: %v", err)