github.com/m10x/go/src@v0.0.0-20220112094212-ba61592315da/syscall/mmap_unix_test.go (about)

     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.
     4  
     5  //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd
     6  
     7  package syscall_test
     8  
     9  import (
    10  	"syscall"
    11  	"testing"
    12  )
    13  
    14  func TestMmap(t *testing.T) {
    15  	b, err := syscall.Mmap(-1, 0, syscall.Getpagesize(), syscall.PROT_NONE, syscall.MAP_ANON|syscall.MAP_PRIVATE)
    16  	if err != nil {
    17  		t.Fatalf("Mmap: %v", err)
    18  	}
    19  	if err := syscall.Munmap(b); err != nil {
    20  		t.Fatalf("Munmap: %v", err)
    21  	}
    22  }